diff --git a/db_designer.php b/db_designer.php index d199fdf1a1..ceb4f89ed6 100644 --- a/db_designer.php +++ b/db_designer.php @@ -22,7 +22,6 @@ if (isset($_REQUEST['dialog'])) { } else if ($_REQUEST['dialog'] == 'save_as') { $html = Designer::getHtmlForPageSaveAs($GLOBALS['db']); } else if ($_REQUEST['dialog'] == 'export') { - include_once 'libraries/plugin_interface.lib.php'; $html = Designer::getHtmlForSchemaExport( $GLOBALS['db'], $_REQUEST['selected_page'] ); diff --git a/db_operations.php b/db_operations.php index 63d0123bbf..c13e0d343e 100644 --- a/db_operations.php +++ b/db_operations.php @@ -15,6 +15,7 @@ use PhpMyAdmin\DatabaseInterface; use PhpMyAdmin\Display\CreateTable; use PhpMyAdmin\Message; use PhpMyAdmin\Operations; +use PhpMyAdmin\Plugins; use PhpMyAdmin\Plugins\Export\ExportSql; use PhpMyAdmin\Relation; use PhpMyAdmin\Response; @@ -75,10 +76,9 @@ if (strlen($GLOBALS['db']) > 0 $tables_full = $GLOBALS['dbi']->getTablesFull($GLOBALS['db']); - include_once "libraries/plugin_interface.lib.php"; // remove all foreign key constraints, otherwise we can get errors /* @var $export_sql_plugin ExportSql */ - $export_sql_plugin = PMA_getPlugin( + $export_sql_plugin = Plugins::getPlugin( "export", "sql", 'libraries/classes/Plugins/Export/', diff --git a/export.php b/export.php index 88b481989b..1c2fb68f84 100644 --- a/export.php +++ b/export.php @@ -9,6 +9,7 @@ use PhpMyAdmin\Core; use PhpMyAdmin\Encoding; use PhpMyAdmin\Export; +use PhpMyAdmin\Plugins; use PhpMyAdmin\Plugins\ExportPlugin; use PhpMyAdmin\Relation; use PhpMyAdmin\Sanitize; @@ -26,7 +27,6 @@ if (isset($_POST['output_format']) && $_POST['output_format'] == 'sendit') { define('PMA_BYPASS_GET_INSTANCE', 1); } include_once 'libraries/common.inc.php'; -include_once 'libraries/plugin_interface.lib.php'; //check if it's the GET request to check export time out if (isset($_GET['check_time_out'])) { @@ -181,7 +181,7 @@ $what = Core::securePath($_POST['what']); // export class instance, not array of properties, as before /* @var $export_plugin ExportPlugin */ -$export_plugin = PMA_getPlugin( +$export_plugin = Plugins::getPlugin( "export", $what, 'libraries/classes/Plugins/Export/', diff --git a/import.php b/import.php index 3e462d983d..1e00db8e1b 100644 --- a/import.php +++ b/import.php @@ -12,6 +12,7 @@ use PhpMyAdmin\Encoding; use PhpMyAdmin\File; use PhpMyAdmin\Import; use PhpMyAdmin\ParseAnalyze; +use PhpMyAdmin\Plugins; use PhpMyAdmin\Plugins\ImportPlugin; use PhpMyAdmin\Response; use PhpMyAdmin\Sql; @@ -515,10 +516,8 @@ if (! $error && isset($_POST['skip'])) { $sql_data = array('valid_sql' => array(), 'valid_queries' => 0); if (! $error) { - // Check for file existence - include_once "libraries/plugin_interface.lib.php"; /* @var $import_plugin ImportPlugin */ - $import_plugin = PMA_getPlugin( + $import_plugin = Plugins::getPlugin( "import", $format, 'libraries/classes/Plugins/Import/', diff --git a/libraries/classes/Database/Designer.php b/libraries/classes/Database/Designer.php index e290c95d56..763ae5ae3c 100644 --- a/libraries/classes/Database/Designer.php +++ b/libraries/classes/Database/Designer.php @@ -9,6 +9,7 @@ namespace PhpMyAdmin\Database; use PhpMyAdmin\DatabaseInterface; use PhpMyAdmin\Message; +use PhpMyAdmin\Plugins; use PhpMyAdmin\Plugins\SchemaPlugin; use PhpMyAdmin\Relation; use PhpMyAdmin\Template; @@ -114,7 +115,7 @@ class Designer { /* Scan for schema plugins */ /* @var $export_list SchemaPlugin[] */ - $export_list = PMA_getPlugins( + $export_list = Plugins::getPlugins( "schema", 'libraries/classes/Plugins/Schema/', null diff --git a/libraries/classes/Display/Export.php b/libraries/classes/Display/Export.php index 48414bb696..6bef98947b 100644 --- a/libraries/classes/Display/Export.php +++ b/libraries/classes/Display/Export.php @@ -10,6 +10,7 @@ namespace PhpMyAdmin\Display; use PhpMyAdmin\Core; use PhpMyAdmin\Encoding; use PhpMyAdmin\Message; +use PhpMyAdmin\Plugins; use PhpMyAdmin\Plugins\ExportPlugin; use PhpMyAdmin\Relation; use PhpMyAdmin\Response; @@ -371,7 +372,7 @@ class Export { $html = '
'; $html .= '

' . __('Format:') . '

'; - $html .= PMA_pluginGetChoice('Export', 'what', $export_list, 'format'); + $html .= Plugins::getChoice('Export', 'what', $export_list, 'format'); $html .= '
'; return $html; } @@ -393,7 +394,7 @@ class Export . 'and ignore the options for other formats.' ); $html .= '

'; - $html .= PMA_pluginGetOptions('Export', $export_list); + $html .= Plugins::getOptions('Export', $export_list); $html .= ''; if (Encoding::canConvertKanji()) { @@ -1002,11 +1003,9 @@ class Export $GLOBALS['single_table'] = $_REQUEST['single_table']; } - include_once './libraries/plugin_interface.lib.php'; - /* Scan for plugins */ /* @var $export_list ExportPlugin[] */ - $export_list = PMA_getPlugins( + $export_list = Plugins::getPlugins( "export", 'libraries/classes/Plugins/Export/', array( diff --git a/libraries/classes/Display/Import.php b/libraries/classes/Display/Import.php index 17afb49e53..3fcbf21890 100644 --- a/libraries/classes/Display/Import.php +++ b/libraries/classes/Display/Import.php @@ -12,6 +12,7 @@ use PhpMyAdmin\Core; use PhpMyAdmin\Display\ImportAjax; use PhpMyAdmin\Encoding; use PhpMyAdmin\Message; +use PhpMyAdmin\Plugins; use PhpMyAdmin\Plugins\ImportPlugin; use PhpMyAdmin\Sanitize; use PhpMyAdmin\Url; @@ -308,7 +309,7 @@ class Import $html .= '
'; $html .= ' '; + . Plugins::checkboxCheck('Import', 'allow_interrupt') . '/>'; $html .= ' '; $html .= ' '; $html .= '
'; @@ -334,7 +335,7 @@ class Import // do not show the Skip dialog to avoid the risk of someone // entering a value here that would interfere with "skip" $html .= ' '; } @@ -371,7 +372,7 @@ class Import { $html = '
'; $html .= '

' . __('Format:') . '

'; - $html .= PMA_pluginGetChoice('Import', 'format', $import_list); + $html .= Plugins::getChoice('Import', 'format', $import_list); $html .= '
'; $html .= '
'; @@ -380,7 +381,7 @@ class Import $html .= '

' . 'Scroll down to fill in the options for the selected format ' . 'and ignore the options for other formats.

'; - $html .= PMA_pluginGetOptions('Import', $import_list); + $html .= Plugins::getOptions('Import', $import_list); $html .= ' '; $html .= '
'; @@ -650,7 +651,6 @@ class Import public static function getImportDisplay($import_type, $db, $table, $max_upload_size) { global $SESSION_KEY; - include_once './libraries/plugin_interface.lib.php'; list( $SESSION_KEY, @@ -659,7 +659,7 @@ class Import /* Scan for plugins */ /* @var $import_list ImportPlugin[] */ - $import_list = PMA_getPlugins( + $import_list = Plugins::getPlugins( "import", 'libraries/classes/Plugins/Import/', $import_type diff --git a/libraries/classes/File.php b/libraries/classes/File.php index a7ca8a195d..9624a09317 100644 --- a/libraries/classes/File.php +++ b/libraries/classes/File.php @@ -547,18 +547,6 @@ class File return false; } - /** - * @todo - * get registered plugins for file compression - - foreach (PMA_getPlugins($type = 'compression') as $plugin) { - if ($plugin['classname']::canHandle($this->getName())) { - $this->setCompressionPlugin($plugin); - break; - } - } - */ - $this->_compression = Util::getCompressionMimeType($file); return $this->_compression; } diff --git a/libraries/classes/Plugins.php b/libraries/classes/Plugins.php new file mode 100644 index 0000000000..a9569ecd61 --- /dev/null +++ b/libraries/classes/Plugins.php @@ -0,0 +1,584 @@ +getProperties()) { + $plugin_list[] = $plugin; + } + } + } + } + + usort($plugin_list, function($cmp_name_1, $cmp_name_2) { + return strcasecmp( + $cmp_name_1->getProperties()->getText(), + $cmp_name_2->getProperties()->getText() + ); + }); + return $plugin_list; + } + + /** + * Returns locale string for $name or $name if no locale is found + * + * @param string $name for local string + * + * @return string locale string for $name + */ + public static function getString($name) + { + return isset($GLOBALS[$name]) ? $GLOBALS[$name] : $name; + } + + /** + * Returns html input tag option 'checked' if plugin $opt + * should be set by config or request + * + * @param string $section name of config section in + * $GLOBALS['cfg'][$section] for plugin + * @param string $opt name of option + * + * @return string html input tag option 'checked' + */ + public static function checkboxCheck($section, $opt) + { + // If the form is being repopulated using $_GET data, that is priority + if (isset($_GET[$opt]) + || ! isset($_GET['repopulate']) + && ((! empty($GLOBALS['timeout_passed']) && isset($_REQUEST[$opt])) + || ! empty($GLOBALS['cfg'][$section][$opt])) + ) { + return ' checked="checked"'; + } + return ''; + } + + /** + * Returns default value for option $opt + * + * @param string $section name of config section in + * $GLOBALS['cfg'][$section] for plugin + * @param string $opt name of option + * + * @return string default value for option $opt + */ + public static function getDefault($section, $opt) + { + if (isset($_GET[$opt])) { + // If the form is being repopulated using $_GET data, that is priority + return htmlspecialchars($_GET[$opt]); + } + + if (isset($GLOBALS['timeout_passed']) + && $GLOBALS['timeout_passed'] + && isset($_REQUEST[$opt]) + ) { + return htmlspecialchars($_REQUEST[$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 htmlspecialchars($val); + } + + /** + * Returns html select form element for plugin choice + * and hidden fields denoting whether each plugin must be exported as a file + * + * @param string $section name of config section in + * $GLOBALS['cfg'][$section] for plugin + * @param string $name name of select element + * @param array &$list array with plugin instances + * @param string $cfgname name of config value, if none same as $name + * + * @return string html select tag + */ + public static function getChoice($section, $name, &$list, $cfgname = null) + { + if (! isset($cfgname)) { + $cfgname = $name; + } + $ret = '' . "\n"; + } + $ret .= '' . "\n" . $hidden; + + return $ret; + } + + /** + * Returns single option in a list element + * + * @param string $section name of config section in $GLOBALS['cfg'][$section] for plugin + * @param string $plugin_name unique plugin name + * @param array|\PhpMyAdmin\Properties\PropertyItem &$propertyGroup options property main group instance + * @param boolean $is_subgroup if this group is a subgroup + * + * @return string table row with option + */ + public static function getOneOption( + $section, + $plugin_name, + &$propertyGroup, + $is_subgroup = false + ) { + $ret = "\n"; + + if (! $is_subgroup) { + // for subgroup headers + if (mb_strpos(get_class($propertyGroup), "PropertyItem")) { + $properties = array($propertyGroup); + } else { + // for main groups + $ret .= '
'; + + if (method_exists($propertyGroup, 'getText')) { + $text = $propertyGroup->getText(); + } + + if ($text != null) { + $ret .= '

' . self::getString($text) . '

'; + } + $ret .= ''; + } else { + // end main group + if (! empty($not_subgroup_header)) { + $ret .= '
'; + } + } + + if (method_exists($propertyGroup, "getDoc")) { + $doc = $propertyGroup->getDoc(); + if ($doc != null) { + if (count($doc) == 3) { + $ret .= PhpMyAdmin\Util::showMySQLDocu( + $doc[1], + false, + $doc[2] + ); + } elseif (count($doc) == 1) { + $ret .= PhpMyAdmin\Util::showDocu('faq', $doc[0]); + } else { + $ret .= PhpMyAdmin\Util::showMySQLDocu( + $doc[1] + ); + } + } + } + + // Close the list element after $doc link is displayed + if (isset($property_class)) { + if ($property_class == 'PhpMyAdmin\Properties\Options\Items\BoolPropertyItem' + || $property_class == 'PhpMyAdmin\Properties\Options\Items\MessageOnlyPropertyItem' + || $property_class == 'PhpMyAdmin\Properties\Options\Items\SelectPropertyItem' + || $property_class == 'PhpMyAdmin\Properties\Options\Items\TextPropertyItem' + ) { + $ret .= ''; + } + } + $ret .= "\n"; + return $ret; + } + + /** + * Get HTML for properties items + * + * @param string $section name of config section in + * $GLOBALS['cfg'][$section] for plugin + * @param string $plugin_name unique plugin name + * @param OptionsPropertyItem $propertyItem Property item + * + * @return string + */ + public static function getHtmlForProperty( + $section, $plugin_name, $propertyItem + ) { + $ret = null; + $property_class = get_class($propertyItem); + switch ($property_class) { + case 'PhpMyAdmin\Properties\Options\Items\BoolPropertyItem': + $ret .= '
  • ' . "\n"; + $ret .= '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 .= ''; + break; + case 'PhpMyAdmin\Properties\Options\Items\DocPropertyItem': + echo 'PhpMyAdmin\Properties\Options\Items\DocPropertyItem'; + break; + case 'PhpMyAdmin\Properties\Options\Items\HiddenPropertyItem': + $ret .= '
  • '; + break; + case 'PhpMyAdmin\Properties\Options\Items\MessageOnlyPropertyItem': + $ret .= '
  • ' . "\n"; + $ret .= '

    ' . self::getString($propertyItem->getText()) . '

    '; + break; + case 'PhpMyAdmin\Properties\Options\Items\RadioPropertyItem': + $default = self::getDefault( + $section, + $plugin_name . '_' . $propertyItem->getName() + ); + foreach ($propertyItem->getValues() as $key => $val) { + $ret .= '
  • ' + . self::getString($val) . '
  • '; + } + break; + case 'PhpMyAdmin\Properties\Options\Items\SelectPropertyItem': + $ret .= '
  • ' . "\n"; + $ret .= ''; + $ret .= ''; + break; + case 'PhpMyAdmin\Properties\Options\Items\TextPropertyItem': + case 'PhpMyAdmin\Properties\Options\Items\NumberPropertyItem': + $ret .= '
  • ' . "\n"; + $ret .= ''; + $ret .= 'getSize() != null + ? ' size="' . $propertyItem->getSize() . '"' + : '') + . ($propertyItem->getLen() != null + ? ' maxlength="' . $propertyItem->getLen() . '"' + : '') + . ' />'; + break; + default: + break; + } + return $ret; + } + + /** + * Returns html div with editable options for plugin + * + * @param string $section name of config section in $GLOBALS['cfg'][$section] + * @param array &$list array with plugin instances + * + * @return string html fieldset with plugin options + */ + public static function getOptions($section, &$list) + { + $ret = ''; + // Options for plugins that support them + foreach ($list as $plugin) { + $properties = $plugin->getProperties(); + if ($properties != null) { + $text = $properties->getText(); + $options = $properties->getOptions(); + } + + $elem = explode('\\', get_class($plugin)); + $plugin_name = array_pop($elem); + unset($elem); + $plugin_name = mb_strtolower( + mb_substr( + $plugin_name, + mb_strlen($section) + ) + ); + + $ret .= '
    '; + $ret .= '

    ' . self::getString($text) . '

    '; + + $no_options = true; + if (! is_null($options) && count($options) > 0) { + foreach ($options->getProperties() + as $propertyMainGroup + ) { + // check for hidden properties + $no_options = true; + foreach ($propertyMainGroup->getProperties() as $propertyItem) { + if (strcmp('PhpMyAdmin\Properties\Options\Items\HiddenPropertyItem', get_class($propertyItem))) { + $no_options = false; + break; + } + } + + $ret .= self::getOneOption( + $section, + $plugin_name, + $propertyMainGroup + ); + } + } + + if ($no_options) { + $ret .= '

    ' . __('This format has no options') . '

    '; + } + $ret .= '
    '; + } + return $ret; + } +} diff --git a/libraries/classes/Plugins/Schema/Svg/SvgRelationSchema.php b/libraries/classes/Plugins/Schema/Svg/SvgRelationSchema.php index 5d5231125b..c6918724c7 100644 --- a/libraries/classes/Plugins/Schema/Svg/SvgRelationSchema.php +++ b/libraries/classes/Plugins/Schema/Svg/SvgRelationSchema.php @@ -34,7 +34,7 @@ use PhpMyAdmin\Relation; class SvgRelationSchema extends ExportRelationSchema { /** - * @var \PhpMyAdmin\Plugins\Schema\Dia\TableStatsDia[]|TableStatsEps[]|TableStatsPdf[]|TableStatsSvg[] + * @var PhpMyAdmin\Plugins\Schema\Dia\TableStatsDia[]|TableStatsEps[]|TableStatsPdf[]|TableStatsSvg[] */ private $_tables = array(); /** @var RelationStatsDia[] Relations */ diff --git a/libraries/classes/Table.php b/libraries/classes/Table.php index 44d442dddc..ad79f2e193 100644 --- a/libraries/classes/Table.php +++ b/libraries/classes/Table.php @@ -10,6 +10,7 @@ namespace PhpMyAdmin; use PhpMyAdmin\DatabaseInterface; use PhpMyAdmin\Index; use PhpMyAdmin\Message; +use PhpMyAdmin\Plugins; use PhpMyAdmin\Plugins\Export\ExportSql; use PhpMyAdmin\Relation; use PhpMyAdmin\SqlParser\Components\Expression; @@ -908,15 +909,12 @@ class Table // No table is created when this is a data-only operation. if ($what != 'dataonly') { - - include_once "libraries/plugin_interface.lib.php"; - /** * Instance used for exporting the current structure of the table. * - * @var \PhpMyAdmin\Plugins\Export\ExportSql + * @var PhpMyAdmin\Plugins\Export\ExportSql */ - $export_sql_plugin = PMA_getPlugin( + $export_sql_plugin = Plugins::getPlugin( "export", "sql", 'libraries/classes/Plugins/Export/', diff --git a/libraries/classes/Tracker.php b/libraries/classes/Tracker.php index ac9c999f79..fa9e8cdf89 100644 --- a/libraries/classes/Tracker.php +++ b/libraries/classes/Tracker.php @@ -7,6 +7,7 @@ */ namespace PhpMyAdmin; +use PhpMyAdmin\Plugins; use PhpMyAdmin\Plugins\Export\ExportSql; use PhpMyAdmin\Relation; use PhpMyAdmin\SqlParser\Parser; @@ -192,9 +193,8 @@ class Tracker } // get Export SQL instance - include_once "libraries/plugin_interface.lib.php"; - /* @var $export_sql_plugin \PhpMyAdmin\Plugins\Export\ExportSql */ - $export_sql_plugin = PMA_getPlugin( + /* @var $export_sql_plugin PhpMyAdmin\Plugins\Export\ExportSql */ + $export_sql_plugin = Plugins::getPlugin( "export", "sql", 'libraries/classes/Plugins/Export/', diff --git a/libraries/plugin_interface.lib.php b/libraries/plugin_interface.lib.php deleted file mode 100644 index add6671665..0000000000 --- a/libraries/plugin_interface.lib.php +++ /dev/null @@ -1,583 +0,0 @@ -getProperties()) { - $plugin_list[] = $plugin; - } - } - } - } - - usort($plugin_list, function($cmp_name_1, $cmp_name_2) { - return strcasecmp( - $cmp_name_1->getProperties()->getText(), - $cmp_name_2->getProperties()->getText() - ); - }); - return $plugin_list; -} - -/** - * Returns locale string for $name or $name if no locale is found - * - * @param string $name for local string - * - * @return string locale string for $name - */ -function PMA_getString($name) -{ - return isset($GLOBALS[$name]) ? $GLOBALS[$name] : $name; -} - -/** - * Returns html input tag option 'checked' if plugin $opt - * should be set by config or request - * - * @param string $section name of config section in - * $GLOBALS['cfg'][$section] for plugin - * @param string $opt name of option - * - * @return string html input tag option 'checked' - */ -function PMA_pluginCheckboxCheck($section, $opt) -{ - // If the form is being repopulated using $_GET data, that is priority - if (isset($_GET[$opt]) - || ! isset($_GET['repopulate']) - && ((! empty($GLOBALS['timeout_passed']) && isset($_REQUEST[$opt])) - || ! empty($GLOBALS['cfg'][$section][$opt])) - ) { - return ' checked="checked"'; - } - return ''; -} - -/** - * Returns default value for option $opt - * - * @param string $section name of config section in - * $GLOBALS['cfg'][$section] for plugin - * @param string $opt name of option - * - * @return string default value for option $opt - */ -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]); - } - - if (isset($GLOBALS['timeout_passed']) - && $GLOBALS['timeout_passed'] - && isset($_REQUEST[$opt]) - ) { - return htmlspecialchars($_REQUEST[$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 htmlspecialchars($val); -} - -/** - * Returns html select form element for plugin choice - * and hidden fields denoting whether each plugin must be exported as a file - * - * @param string $section name of config section in - * $GLOBALS['cfg'][$section] for plugin - * @param string $name name of select element - * @param array &$list array with plugin instances - * @param string $cfgname name of config value, if none same as $name - * - * @return string html select tag - */ -function PMA_pluginGetChoice($section, $name, &$list, $cfgname = null) -{ - if (! isset($cfgname)) { - $cfgname = $name; - } - $ret = '' . "\n"; - } - $ret .= '' . "\n" . $hidden; - - return $ret; -} - -/** - * Returns single option in a list element - * - * @param string $section name of config section in $GLOBALS['cfg'][$section] for plugin - * config - * section in - * $GLOBALS['cfg'][$section] - * for plugin - * @param string $plugin_name unique plugin name - * name - * @param array|\PhpMyAdmin\Properties\PropertyItem &$propertyGroup options - * property main - * group - * instance - * @param boolean $is_subgroup if this group is a subgroup - * is a subgroup - * - * @return string table row with option - */ -function PMA_pluginGetOneOption( - $section, - $plugin_name, - &$propertyGroup, - $is_subgroup = false -) { - $ret = "\n"; - - if (! $is_subgroup) { - // for subgroup headers - if (mb_strpos(get_class($propertyGroup), "PropertyItem")) { - $properties = array($propertyGroup); - } else { - // for main groups - $ret .= '
    '; - - if (method_exists($propertyGroup, 'getText')) { - $text = $propertyGroup->getText(); - } - - if ($text != null) { - $ret .= '

    ' . PMA_getString($text) . '

    '; - } - $ret .= '
  • '; - } else { - // end main group - if (! empty($not_subgroup_header)) { - $ret .= ''; - } - } - - if (method_exists($propertyGroup, "getDoc")) { - $doc = $propertyGroup->getDoc(); - if ($doc != null) { - if (count($doc) == 3) { - $ret .= PhpMyAdmin\Util::showMySQLDocu( - $doc[1], - false, - $doc[2] - ); - } elseif (count($doc) == 1) { - $ret .= PhpMyAdmin\Util::showDocu('faq', $doc[0]); - } else { - $ret .= PhpMyAdmin\Util::showMySQLDocu( - $doc[1] - ); - } - } - } - - // Close the list element after $doc link is displayed - if (isset($property_class)) { - if ($property_class == 'PhpMyAdmin\Properties\Options\Items\BoolPropertyItem' - || $property_class == 'PhpMyAdmin\Properties\Options\Items\MessageOnlyPropertyItem' - || $property_class == 'PhpMyAdmin\Properties\Options\Items\SelectPropertyItem' - || $property_class == 'PhpMyAdmin\Properties\Options\Items\TextPropertyItem' - ) { - $ret .= ''; - } - } - $ret .= "\n"; - return $ret; -} - -/** - * Get HTML for properties items - * - * @param string $section name of config section in - * $GLOBALS['cfg'][$section] for plugin - * @param string $plugin_name unique plugin name - * @param OptionsPropertyItem $propertyItem Property item - * - * @return string - */ -function PMA_getHtmlForProperty( - $section, $plugin_name, $propertyItem -) { - $ret = null; - $property_class = get_class($propertyItem); - switch ($property_class) { - case 'PhpMyAdmin\Properties\Options\Items\BoolPropertyItem': - $ret .= '
  • ' . "\n"; - $ret .= '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 .= ''; - break; - case 'PhpMyAdmin\Properties\Options\Items\DocPropertyItem': - echo 'PhpMyAdmin\Properties\Options\Items\DocPropertyItem'; - break; - case 'PhpMyAdmin\Properties\Options\Items\HiddenPropertyItem': - $ret .= '
  • '; - break; - case 'PhpMyAdmin\Properties\Options\Items\MessageOnlyPropertyItem': - $ret .= '
  • ' . "\n"; - $ret .= '

    ' . PMA_getString($propertyItem->getText()) . '

    '; - break; - case 'PhpMyAdmin\Properties\Options\Items\RadioPropertyItem': - $default = PMA_pluginGetDefault( - $section, - $plugin_name . '_' . $propertyItem->getName() - ); - foreach ($propertyItem->getValues() as $key => $val) { - $ret .= '
  • ' - . PMA_getString($val) . '
  • '; - } - break; - case 'PhpMyAdmin\Properties\Options\Items\SelectPropertyItem': - $ret .= '
  • ' . "\n"; - $ret .= ''; - $ret .= ''; - break; - case 'PhpMyAdmin\Properties\Options\Items\TextPropertyItem': - case 'PhpMyAdmin\Properties\Options\Items\NumberPropertyItem': - $ret .= '
  • ' . "\n"; - $ret .= ''; - $ret .= 'getSize() != null - ? ' size="' . $propertyItem->getSize() . '"' - : '') - . ($propertyItem->getLen() != null - ? ' maxlength="' . $propertyItem->getLen() . '"' - : '') - . ' />'; - break; - default: - break; - } - return $ret; -} - -/** - * Returns html div with editable options for plugin - * - * @param string $section name of config section in $GLOBALS['cfg'][$section] - * @param array &$list array with plugin instances - * - * @return string html fieldset with plugin options - */ -function PMA_pluginGetOptions($section, &$list) -{ - $ret = ''; - // Options for plugins that support them - foreach ($list as $plugin) { - $properties = $plugin->getProperties(); - if ($properties != null) { - $text = $properties->getText(); - $options = $properties->getOptions(); - } - - $elem = explode('\\', get_class($plugin)); - $plugin_name = array_pop($elem); - unset($elem); - $plugin_name = mb_strtolower( - mb_substr( - $plugin_name, - mb_strlen($section) - ) - ); - - $ret .= '
    '; - $ret .= '

    ' . PMA_getString($text) . '

    '; - - $no_options = true; - if (! is_null($options) && count($options) > 0) { - foreach ($options->getProperties() - as $propertyMainGroup - ) { - // check for hidden properties - $no_options = true; - foreach ($propertyMainGroup->getProperties() as $propertyItem) { - if (strcmp('PhpMyAdmin\Properties\Options\Items\HiddenPropertyItem', get_class($propertyItem))) { - $no_options = false; - break; - } - } - - $ret .= PMA_pluginGetOneOption( - $section, - $plugin_name, - $propertyMainGroup - ); - } - } - - if ($no_options) { - $ret .= '

    ' . __('This format has no options') . '

    '; - } - $ret .= '
    '; - } - return $ret; -} diff --git a/schema_export.php b/schema_export.php index 040768dd2b..936cc0c263 100644 --- a/schema_export.php +++ b/schema_export.php @@ -7,6 +7,7 @@ */ use PhpMyAdmin\Core; +use PhpMyAdmin\Plugins; use PhpMyAdmin\Plugins\SchemaPlugin; use PhpMyAdmin\Relation; @@ -22,7 +23,6 @@ require_once 'libraries/common.inc.php'; $cfgRelation = Relation::getRelationsParam(); require_once 'libraries/pmd_common.php'; -require_once 'libraries/plugin_interface.lib.php'; if (! isset($_REQUEST['export_type'])) { PhpMyAdmin\Util::checkParameters(array('export_type')); @@ -56,7 +56,7 @@ function PMA_processExportSchema($export_type) // get the specific plugin /* @var $export_plugin SchemaPlugin */ - $export_plugin = PMA_getPlugin( + $export_plugin = Plugins::getPlugin( "schema", $export_type, 'libraries/classes/Plugins/Schema/' diff --git a/templates/database/designer/schema_export.phtml b/templates/database/designer/schema_export.phtml index 6364edc452..ec0dcf66ee 100644 --- a/templates/database/designer/schema_export.phtml +++ b/templates/database/designer/schema_export.phtml @@ -2,10 +2,10 @@

    - - +
    diff --git a/test/classes/Database/DesignerTest.php b/test/classes/Database/DesignerTest.php index eab496922b..c3039e69c7 100644 --- a/test/classes/Database/DesignerTest.php +++ b/test/classes/Database/DesignerTest.php @@ -9,11 +9,6 @@ namespace PhpMyAdmin\Tests\Database; use PhpMyAdmin\Database\Designer; use PhpMyAdmin\DatabaseInterface; -/* - * Include to test. - */ -require_once 'libraries/plugin_interface.lib.php'; - /** * Tests for PhpMyAdmin\Database\Designer * diff --git a/test/classes/Display/ExportTest.php b/test/classes/Display/ExportTest.php index b737e4e5e9..5ca4ae8b41 100644 --- a/test/classes/Display/ExportTest.php +++ b/test/classes/Display/ExportTest.php @@ -9,12 +9,11 @@ namespace PhpMyAdmin\Tests\Display; use PhpMyAdmin\Core; use PhpMyAdmin\Display\Export; +use PhpMyAdmin\Plugins; use PhpMyAdmin\Theme; use PhpMyAdmin\Url; use PhpMyAdmin\Util; -require_once 'libraries/plugin_interface.lib.php'; - /** * class PhpMyAdmin\Tests\Display\ExportTest * @@ -148,7 +147,7 @@ class ExportTest extends \PHPUnit_Framework_TestCase $GLOBALS['dbi'] = $dbi; /* Scan for plugins */ - $export_list = PMA_getPlugins( + $export_list = Plugins::getPlugins( "export", 'libraries/classes/Plugins/Export/', array(