Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use plugin_lang_get to display repo settings keys, trans bool values #215

Merged
merged 1 commit into from
Jun 14, 2017

Conversation

obmsch
Copy link
Contributor

@obmsch obmsch commented May 3, 2017

Instead of just displaying the raw keys, be user friendly and show the lang
strings as repo_update does. For bool values use trans_bool to get a nice
check mark.

Copy link
Member

@dregad dregad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution.

There are 2 things that I think should be improved:

  1. If a repo's data contains keys that are not recognized, an error message is displayed (this can happen with old repos created before a change in how the plugin stored its data):
    selection_001
    or, if $g_display_errors is set to hide warnings, we get a very narrow line with no data
    image
    I would expect a graceful fall-back to the raw string in this case
  2. While having a descriptive label is a lot better than the raw key, I don't like seeing the "helper text" below, as this is intended as a guide for input. I suggest splitting the strings and only display the helper text in repo_update_page.php

<td><?php echo $t_value ?></td>
<?php } ?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make the code easier to read, I would suggest to use a ternary operator here, i.e.

<td><?php echo is_bool( $t_value ) ? trans_bool( $t_value ) : $t_value ?></td>

@obmsch
Copy link
Contributor Author

obmsch commented Jun 12, 2017

Rebased, and hopefully adressed all your comments.
Local function "plugin_lang_get_defaulted" eventually moves to mantisbt core.
A lot of implications and dependencies, surely beyond the scope of this PR.

@dregad
Copy link
Member

dregad commented Jun 13, 2017

Hello Martin, and thanks for the revised PR.

hopefully adressed all your comments

Actually you missed point 2 in #215 (review), i.e. splitting the language strings between label and help text.

Incidentally, that should remove the need for the explode( '<br', ... operation.

Local function "plugin_lang_get_defaulted" eventually moves to mantisbt core.
A lot of implications and dependencies, surely beyond the scope of this PR.

That makes perfect sense, I'll prepare a MantisBT PR so it becomes part of core in a future version.

In the meanwhile, to keep the code clean I think it would be better to move this function into Source.API.php, and also wrap it around an if function_exists block to facilitate the transition.

@obmsch
Copy link
Contributor Author

obmsch commented Jun 13, 2017

Hello Damien,
moving (and wrapping) "plugin_lang_get_defaulted" to Source.API.php makes sense, will look into that later.
I am not sure what you have in mind on the string splitting issue. Are you asking for something like:
$s_plugin_SourceGithub_master_branch = 'Primary Branches
(comma-separated list or "*" for all branches)';
gets

a) $s_plugin_SourceGithub_master_branch = 'Primary Branches';
$s_plugin_SourceGithub_master_branch_help = '
(comma-separated list or "*" for all branches)';

b) $s_plugin_SourceGithub_master_branch_label = 'Primary Branches';
$s_plugin_SourceGithub_master_branch_help = '
(comma-separated list or "*" for all branches)';

c) $s_plugin_SourceGithub_master_branch_label = 'Primary Branches';
$s_plugin_SourceGithub_master_branch = 'Primary Branches
(comma-separated list or "*" for all branches)';

As repo_manage_page and repo_update_page use the same keys to lookup the lang strings

a) Would require an additional lookup at least in all "$t_vcs->update_repo_form( $t_repo )" variants, for a key(help) which may (intentionally) not exist.
b) In principle the same as a), but the first lookup has to be adjusted too.
c) Despite more effort on the lang maintenance, translations, this would be the easiest way to go for. No side effects, only repo_manage_page affected.
instead of
# Extract the descriptive part of the $t_key lang entry
list( $t_description ) = explode( "<br", plugin_lang_get_defaulted( $t_key, $t_vcs->basename, $t_key ) );
... echo $t_description ...
then simply
... echo plugin_lang_get_defaulted( $t_key . "_label", $t_vcs->basename, $t_key ) ...

Thoughts?

@dregad
Copy link
Member

dregad commented Jun 13, 2017

From a design perspective, I never liked these labels including help text with HTML formatting, so I thought that this would be a good opportunity to get rid of them.

As for implementation, I was actually thinking along the lines of your option a) which I think is cleaner than c); b) does not make sense IMO.

I must admit that this was just an idea, I did not fully consider or analyze the implications on the code base and development effort. That being said, I'm not overly concerned about the extra plugin_lang_get() calls, as this would be a one time change.

Anyway this is diverging from your PR's original scope, so maybe it would be better to track this refactoring separately.

trans bool values

- conditionally add function "plugin_lang_get_defaulted" for
  the lookup in Source.API.php
@obmsch
Copy link
Contributor Author

obmsch commented Jun 14, 2017

One more update to the PR. Made "basename" otional and last param in "plugin_lang_get_defaulted".
More convenient, I guess only a few cases (like repo_manage_page) where current basename differs
from the target basename.

For now help text are shown too (minor issue) and will be tackled, when issue #228 gets fixed.

@dregad
Copy link
Member

dregad commented Jun 14, 2017

One more update to the PR. Made "basename" otional and last param in "plugin_lang_get_defaulted".

Indeed, much better this way, and closer to lang_get_defaulted()'s signature too.

@dregad dregad added this to the 2.1.0 milestone Jun 14, 2017
@dregad dregad merged commit eb25dfb into mantisbt-plugins:master Jun 14, 2017
@obmsch obmsch deleted the ms-si-1 branch June 14, 2017 14:44
@dregad
Copy link
Member

dregad commented Feb 27, 2020

I'll prepare a MantisBT PR so it becomes part of core in a future version.

https://mantisbt.org/bugs/view.php?id=26747

dregad added a commit that referenced this pull request May 13, 2021
Function was introduced in #215 to fix the problem in the plugin, until
the update was implemented in MantisBT core (which happened in 2.24.0).

Fixes #339
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants