diff options
author | Christian Foellmann <foellmann@foe-services.de> | 2014-07-28 14:13:10 +0400 |
---|---|---|
committer | Christian Foellmann <foellmann@foe-services.de> | 2014-07-28 14:13:10 +0400 |
commit | 276394119dfbe117acd411a3862de597ba35a2ad (patch) | |
tree | 3dc394a15f459d6324e3452e15e9446e47fe3bd0 /libraries/plugin_interface.lib.php | |
parent | c8c2e72886de1b71f5abcaa295075da9666096b5 (diff) |
UPDATE phpmyadmin 4.2.6 multilanguage
Diffstat (limited to 'libraries/plugin_interface.lib.php')
-rw-r--r-- | libraries/plugin_interface.lib.php | 304 |
1 files changed, 159 insertions, 145 deletions
diff --git a/libraries/plugin_interface.lib.php b/libraries/plugin_interface.lib.php index 4166702dc1..619d5ff9d4 100644 --- a/libraries/plugin_interface.lib.php +++ b/libraries/plugin_interface.lib.php @@ -15,7 +15,7 @@ * @param mixed $plugin_param parameter to plugin by which they can * decide whether they can work * - * @return object|null new plugin instance + * @return object new plugin instance */ function PMA_getPlugin( $plugin_type, @@ -34,7 +34,8 @@ function PMA_getPlugin( return new $class_name; } - return null; + // by default, return SQL plugin + return PMA_getPlugin($plugin_type, 'sql', $plugins_dir, $plugin_param); } /** @@ -52,30 +53,37 @@ function PMA_getPlugins($plugin_type, $plugins_dir, $plugin_param) $GLOBALS['plugin_param'] = $plugin_param; /* Scan for plugins */ $plugin_list = array(); - if ($handle = @opendir($plugins_dir)) { - while ($file = @readdir($handle)) { - // In some situations, Mac OS creates a new file for each file - // (for example ._csv.php) so the following regexp - // matches a file which does not start with a dot but ends - // with ".php" - $class_type = mb_strtoupper($plugin_type[0], 'UTF-8') - . mb_strtolower(substr($plugin_type, 1), 'UTF-8'); - if (is_file($plugins_dir . $file) - && preg_match( - '@^' . $class_type . '(.+)\.class\.php$@i', - $file, - $matches - ) - ) { - $GLOBALS['skip_import'] = false; - include_once $plugins_dir . $file; - if (! $GLOBALS['skip_import']) { - $class_name = $class_type . $matches[1]; - $plugin_list [] = new $class_name; + if (!($handle = @opendir($plugins_dir))) { + ksort($plugin_list); + return $plugin_list; + } + + while ($file = @readdir($handle)) { + // In some situations, Mac OS creates a new file for each file + // (for example ._csv.php) so the following regexp + // matches a file which does not start with a dot but ends + // with ".php" + $class_type = mb_strtoupper($plugin_type[0], 'UTF-8') + . mb_strtolower(substr($plugin_type, 1), 'UTF-8'); + if (is_file($plugins_dir . $file) + && preg_match( + '@^' . $class_type . '(.+)\.class\.php$@i', + $file, + $matches + ) + ) { + $GLOBALS['skip_import'] = false; + include_once $plugins_dir . $file; + if (! $GLOBALS['skip_import']) { + $class_name = $class_type . $matches[1]; + $plugin = new $class_name; + if (null !== $plugin->getProperties()) { + $plugin_list[] = $plugin; } } } } + ksort($plugin_list); return $plugin_list; } @@ -132,31 +140,36 @@ function PMA_pluginGetDefault($section, $opt) if (isset($_GET[$opt])) { // If the form is being repopulated using $_GET data, that is priority return htmlspecialchars($_GET[$opt]); - } elseif (isset($GLOBALS['timeout_passed']) + } + + if (isset($GLOBALS['timeout_passed']) && $GLOBALS['timeout_passed'] && isset($_REQUEST[$opt]) ) { return htmlspecialchars($_REQUEST[$opt]); - } elseif (isset($GLOBALS['cfg'][$section][$opt])) { - $matches = array(); - /* Possibly replace localised texts */ - if (preg_match_all( - '/(str[A-Z][A-Za-z0-9]*)/', - $GLOBALS['cfg'][$section][$opt], - $matches - )) { - $val = $GLOBALS['cfg'][$section][$opt]; - foreach ($matches[0] as $match) { - if (isset($GLOBALS[$match])) { - $val = str_replace($match, $GLOBALS[$match], $val); - } - } - return htmlspecialchars($val); - } else { - return htmlspecialchars($GLOBALS['cfg'][$section][$opt]); + } + + if (!isset($GLOBALS['cfg'][$section][$opt])) { + return ''; + } + + $matches = array(); + /* Possibly replace localised texts */ + if (!preg_match_all( + '/(str[A-Z][A-Za-z0-9]*)/', + $GLOBALS['cfg'][$section][$opt], + $matches + )) { + return htmlspecialchars($GLOBALS['cfg'][$section][$opt]); + } + + $val = $GLOBALS['cfg'][$section][$opt]; + foreach ($matches[0] as $match) { + if (isset($GLOBALS[$match])) { + $val = str_replace($match, $GLOBALS[$match], $val); } } - return ''; + return htmlspecialchars($val); } /** @@ -214,7 +227,7 @@ function PMA_pluginGetChoice($section, $name, &$list, $cfgname = null) } else { $ret .= 'false'; } - $ret .= '" />'. "\n"; + $ret .= '" />' . "\n"; } return $ret; @@ -295,116 +308,117 @@ function PMA_pluginGetOneOption( $propertyItem, true ); - } else { - // single property item - switch ($property_class) { - case "BoolPropertyItem": - $ret .= '<li>' . "\n"; - $ret .= '<input type="checkbox" name="' . $plugin_name . '_' - . $propertyItem->getName() . '"' - . ' value="something" id="checkbox_' . $plugin_name . '_' - . $propertyItem->getName() . '"' - . ' ' - . PMA_pluginCheckboxCheck( - $section, - $plugin_name . '_' . $propertyItem->getName() - ); - - if ($propertyItem->getForce() != null) { - // Same code is also few lines lower, update both if needed - $ret .= ' onclick="if (!this.checked && ' - . '(!document.getElementById(\'checkbox_' . $plugin_name - . '_' . $propertyItem->getForce() . '\') ' - . '|| !document.getElementById(\'checkbox_' - . $plugin_name . '_' . $propertyItem->getForce() - . '\').checked)) ' - . 'return false; else return true;"'; - } - $ret .= ' />'; - $ret .= '<label for="checkbox_' . $plugin_name . '_' - . $propertyItem->getName() . '">' - . PMA_getString($propertyItem->getText()) . '</label>'; - break; - case "DocPropertyItem": - echo "DocPropertyItem"; - break; - case "HiddenPropertyItem": - $ret .= '<li><input type="hidden" name="' . $plugin_name . '_' - . $propertyItem->getName() . '"' - . ' value="' . PMA_pluginGetDefault( - $section, - $plugin_name . '_' . $propertyItem->getName() - ) - . '"' . ' /></li>'; - break; - case "MessageOnlyPropertyItem": - $ret .= '<li>' . "\n"; - $ret .= '<p>' . PMA_getString($propertyItem->getText()) . '</p>'; - break; - case "RadioPropertyItem": - $default = PMA_pluginGetDefault( + continue; + } + + // single property item + switch ($property_class) { + case "BoolPropertyItem": + $ret .= '<li>' . "\n"; + $ret .= '<input type="checkbox" name="' . $plugin_name . '_' + . $propertyItem->getName() . '"' + . ' value="something" id="checkbox_' . $plugin_name . '_' + . $propertyItem->getName() . '"' + . ' ' + . PMA_pluginCheckboxCheck( $section, $plugin_name . '_' . $propertyItem->getName() ); - foreach ($propertyItem->getValues() as $key => $val) { - $ret .= '<li><input type="radio" name="' . $plugin_name - . '_' . $propertyItem->getName() . '" value="' . $key - . '" id="radio_' . $plugin_name . '_' - . $propertyItem->getName() . '_' . $key . '"'; - if ($key == $default) { - $ret .= ' checked="checked"'; - } - $ret .= ' />' . '<label for="radio_' . $plugin_name . '_' - . $propertyItem->getName() . '_' . $key . '">' - . PMA_getString($val) . '</label></li>'; - } - break; - case "SelectPropertyItem": - $ret .= '<li>' . "\n"; - $ret .= '<label for="select_' . $plugin_name . '_' - . $propertyItem->getName() . '" class="desc">' - . PMA_getString($propertyItem->getText()) . '</label>'; - $ret .= '<select name="' . $plugin_name . '_' - . $propertyItem->getName() . '"' - . ' id="select_' . $plugin_name . '_' - . $propertyItem->getName() . '">'; - $default = PMA_pluginGetDefault( + + if ($propertyItem->getForce() != null) { + // Same code is also few lines lower, update both if needed + $ret .= ' onclick="if (!this.checked && ' + . '(!document.getElementById(\'checkbox_' . $plugin_name + . '_' . $propertyItem->getForce() . '\') ' + . '|| !document.getElementById(\'checkbox_' + . $plugin_name . '_' . $propertyItem->getForce() + . '\').checked)) ' + . 'return false; else return true;"'; + } + $ret .= ' />'; + $ret .= '<label for="checkbox_' . $plugin_name . '_' + . $propertyItem->getName() . '">' + . PMA_getString($propertyItem->getText()) . '</label>'; + break; + case "DocPropertyItem": + echo "DocPropertyItem"; + break; + case "HiddenPropertyItem": + $ret .= '<li><input type="hidden" name="' . $plugin_name . '_' + . $propertyItem->getName() . '"' + . ' value="' . PMA_pluginGetDefault( $section, $plugin_name . '_' . $propertyItem->getName() - ); - foreach ($propertyItem->getValues() as $key => $val) { - $ret .= '<option value="' . $key . '"'; - if ($key == $default) { - $ret .= ' selected="selected"'; - } - $ret .= '>' . PMA_getString($val) . '</option>'; + ) + . '"' . ' /></li>'; + break; + case "MessageOnlyPropertyItem": + $ret .= '<li>' . "\n"; + $ret .= '<p>' . PMA_getString($propertyItem->getText()) . '</p>'; + break; + case "RadioPropertyItem": + $default = PMA_pluginGetDefault( + $section, + $plugin_name . '_' . $propertyItem->getName() + ); + foreach ($propertyItem->getValues() as $key => $val) { + $ret .= '<li><input type="radio" name="' . $plugin_name + . '_' . $propertyItem->getName() . '" value="' . $key + . '" id="radio_' . $plugin_name . '_' + . $propertyItem->getName() . '_' . $key . '"'; + if ($key == $default) { + $ret .= ' checked="checked"'; + } + $ret .= ' />' . '<label for="radio_' . $plugin_name . '_' + . $propertyItem->getName() . '_' . $key . '">' + . PMA_getString($val) . '</label></li>'; + } + break; + case "SelectPropertyItem": + $ret .= '<li>' . "\n"; + $ret .= '<label for="select_' . $plugin_name . '_' + . $propertyItem->getName() . '" class="desc">' + . PMA_getString($propertyItem->getText()) . '</label>'; + $ret .= '<select name="' . $plugin_name . '_' + . $propertyItem->getName() . '"' + . ' id="select_' . $plugin_name . '_' + . $propertyItem->getName() . '">'; + $default = PMA_pluginGetDefault( + $section, + $plugin_name . '_' . $propertyItem->getName() + ); + foreach ($propertyItem->getValues() as $key => $val) { + $ret .= '<option value="' . $key . '"'; + if ($key == $default) { + $ret .= ' selected="selected"'; } - $ret .= '</select>'; - break; - case "TextPropertyItem": - case "NumberPropertyItem": - $ret .= '<li>' . "\n"; - $ret .= '<label for="text_' . $plugin_name . '_' - . $propertyItem->getName() . '" class="desc">' - . PMA_getString($propertyItem->getText()) . '</label>'; - $ret .= '<input type="text" name="' . $plugin_name . '_' - . $propertyItem->getName() . '"' - . ' value="' . PMA_pluginGetDefault( - $section, - $plugin_name . '_' . $propertyItem->getName() - ) . '"' - . ' id="text_' . $plugin_name . '_' - . $propertyItem->getName() . '"' - . ($propertyItem->getSize() != null - ? ' size="' . $propertyItem->getSize() . '"' - : '') - . ($propertyItem->getLen() != null - ? ' maxlength="' . $propertyItem->getLen() . '"' - : '') - . ' />'; - break; - default:; + $ret .= '>' . PMA_getString($val) . '</option>'; } + $ret .= '</select>'; + break; + case "TextPropertyItem": + case "NumberPropertyItem": + $ret .= '<li>' . "\n"; + $ret .= '<label for="text_' . $plugin_name . '_' + . $propertyItem->getName() . '" class="desc">' + . PMA_getString($propertyItem->getText()) . '</label>'; + $ret .= '<input type="text" name="' . $plugin_name . '_' + . $propertyItem->getName() . '"' + . ' value="' . PMA_pluginGetDefault( + $section, + $plugin_name . '_' . $propertyItem->getName() + ) . '"' + . ' id="text_' . $plugin_name . '_' + . $propertyItem->getName() . '"' + . ($propertyItem->getSize() != null + ? ' size="' . $propertyItem->getSize() . '"' + : '') + . ($propertyItem->getLen() != null + ? ' maxlength="' . $propertyItem->getLen() . '"' + : '') + . ' />'; + break; + default:; } } } |