Skip to content

Commit eb25dfb

Browse files
committed
Use "plugin_lang_get_defaulted" to display repo settings keys,
trans bool values - conditionally add function "plugin_lang_get_defaulted" for the lookup in Source.API.php
1 parent e922af8 commit eb25dfb

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

Source/Source.API.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,33 @@
1010
* @author John Reese
1111
*/
1212

13+
if (!function_exists('plugin_lang_get_defaulted')) {
14+
/**
15+
* Get a language string for the plugin.
16+
* - If found, return the appropriate string.
17+
* - If not found, no default supplied, return the supplied string as is.
18+
* - If not found, default supplied, return default.
19+
* Automatically prepends plugin_<basename> to the string requested.
20+
* @param string $p_name Language string name.
21+
* @param string $p_default The default value to return.
22+
* @param string $p_basename Plugin basename.
23+
* @return string Language string
24+
*/
25+
function plugin_lang_get_defaulted( $p_name, $p_default = null, $p_basename = null ) {
26+
if( !is_null( $p_basename ) ) {
27+
plugin_push_current( $p_basename );
28+
}
29+
$t_basename = plugin_get_current();
30+
$t_name = 'plugin_' . $t_basename . '_' . $p_name;
31+
$t_string = lang_get_defaulted( $t_name, $p_default );
32+
33+
if( !is_null( $p_basename ) ) {
34+
plugin_pop_current();
35+
}
36+
return $t_string;
37+
}
38+
}
39+
1340
# branch mapping strategies
1441
define( 'SOURCE_EXPLICIT', 1 );
1542
define( 'SOURCE_NEAR', 2 );

Source/pages/repo_manage_page.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
$f_repo_id = gpc_get_int( 'id' );
99

1010
$t_repo = SourceRepo::load( $f_repo_id );
11+
$t_vcs = SourceVCS::repo( $t_repo );
1112
$t_type = SourceType($t_repo->type);
1213

1314
$t_mappings = $t_repo->load_mappings();
@@ -74,6 +75,7 @@ function convert_to_key_value( $p_array ) {
7475
return $t_result;
7576
}
7677

78+
7779
layout_page_header( plugin_lang_get( 'title' ) );
7880
layout_page_begin();
7981
?>
@@ -121,8 +123,8 @@ function convert_to_key_value( $p_array ) {
121123
foreach( $t_formatted_array as $t_key => $t_value ) {
122124
?>
123125
<tr>
124-
<td class="category"><?php echo $t_key ?></td>
125-
<td><?php echo $t_value ?></td>
126+
<td class="category"><?php echo plugin_lang_get_defaulted( $t_key, $t_key, $t_vcs->basename ) ?></td>
127+
<td><?php echo is_bool( $t_value ) ? trans_bool( $t_value ) : $t_value ?></td>
126128
</tr>
127129
<?php } ?>
128130
</table>

0 commit comments

Comments
 (0)