Update nodes load.
Fix template call. Remove useless 'use'. Fix node load. Fix merge. Attempt to fix transformation unit test. Signed-off-by: Hugues Peccatte <hugues.peccatte@gmail.com>
This commit is contained in:
parent
914cdaa984
commit
37bf6f2093
@ -5,7 +5,6 @@
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
use PMA\libraries\PMA_String;
|
||||
use PMA\libraries\RecentFavoriteTable;
|
||||
|
||||
/**
|
||||
|
||||
@ -144,7 +144,7 @@ class NavigationTree
|
||||
$this->_searchClause2 = $_REQUEST['searchClause2'];
|
||||
}
|
||||
// Initialise the tree by creating a root node
|
||||
$node = NodeFactory::getInstance('PMA\\libraries\\navigation\\nodes\\NodeDatabaseContainer', 'root');
|
||||
$node = NodeFactory::getInstance('NodeDatabaseContainer', 'root');
|
||||
$this->_tree = $node;
|
||||
if ($GLOBALS['cfg']['NavigationTreeEnableGrouping']
|
||||
&& $GLOBALS['cfg']['ShowDatabasesNavigationAsTree']
|
||||
@ -282,7 +282,7 @@ class NavigationTree
|
||||
);
|
||||
$hiddenCounts = $this->_tree->getNavigationHidingData();
|
||||
foreach ($data as $db) {
|
||||
$node = NodeFactory::getInstance('PMA\\libraries\\navigation\\nodes\\NodeDatabase', $db);
|
||||
$node = NodeFactory::getInstance('NodeDatabase', $db);
|
||||
if (isset($hiddenCounts[$db])) {
|
||||
$node->setHiddenCount($hiddenCounts[$db]);
|
||||
}
|
||||
@ -804,8 +804,10 @@ class NavigationTree
|
||||
continue;
|
||||
}
|
||||
$class = get_class($child);
|
||||
$className = substr($class, strrpos($class, '\\') + 1);
|
||||
unset($class);
|
||||
$new_child = NodeFactory::getInstance(
|
||||
$class,
|
||||
$className,
|
||||
/*overload*/
|
||||
mb_substr(
|
||||
$child->name,
|
||||
|
||||
@ -17,6 +17,7 @@ use PMA\Psr4Autoloader;
|
||||
*/
|
||||
class NodeFactory
|
||||
{
|
||||
protected static $_namespace = 'PMA\\libraries\\navigation\\nodes\\%s';
|
||||
/**
|
||||
* Sanitizes the name of a Node class
|
||||
*
|
||||
@ -26,7 +27,7 @@ class NodeFactory
|
||||
*/
|
||||
private static function _sanitizeClass($class)
|
||||
{
|
||||
if (!preg_match('@^PMA\\\\libraries\\\\navigation\\\\nodes\\\\Node\w*$@', $class)) {
|
||||
if (!preg_match('@^Node\w*$@', $class)) {
|
||||
$class = 'Node';
|
||||
trigger_error(
|
||||
sprintf(
|
||||
@ -52,8 +53,11 @@ class NodeFactory
|
||||
*/
|
||||
private static function _checkClass($class)
|
||||
{
|
||||
if (!class_exists($class) && !Psr4Autoloader::getInstance()->loadClass($class)) {
|
||||
$class = 'Node';
|
||||
$class = sprintf(self::$_namespace, $class);
|
||||
if (!class_exists($class)
|
||||
&& !Psr4Autoloader::getInstance()->loadClass($class)
|
||||
) {
|
||||
$class = sprintf(self::$_namespace, 'Node');
|
||||
trigger_error(
|
||||
sprintf(
|
||||
__('Could not load class "%1$s"'),
|
||||
@ -78,7 +82,7 @@ class NodeFactory
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getInstance(
|
||||
$class = 'PMA\\libraries\\navigation\\nodes\\Node',
|
||||
$class = 'Node',
|
||||
$name = 'default',
|
||||
$type = Node::OBJECT,
|
||||
$is_group = false
|
||||
|
||||
@ -32,7 +32,7 @@ class NodeDatabaseContainer extends Node
|
||||
&& $GLOBALS['cfg']['ShowCreateDb'] !== false
|
||||
) {
|
||||
$new = NodeFactory::getInstance(
|
||||
'PMA\\libraries\\navigation\\nodes\\Node',
|
||||
'Node',
|
||||
_pgettext('Create new database', 'New')
|
||||
);
|
||||
$new->isNew = true;
|
||||
|
||||
@ -3333,7 +3333,7 @@ function PMA_getHtmlForAllTableSpecificRights(
|
||||
$data['routines'] = $routines;
|
||||
}
|
||||
|
||||
$html_output = PMA\Template::get('privileges/privileges_summary')
|
||||
$html_output = Template::get('privileges/privileges_summary')
|
||||
->render($data);
|
||||
|
||||
return $html_output;
|
||||
|
||||
@ -169,9 +169,9 @@ function PMA_getTransformationClassName($filename)
|
||||
function PMA_getTransformationDescription($file)
|
||||
{
|
||||
/* @var $class_name TransformationsInterface */
|
||||
$class_name = PMA_getTransformationClassName('libraries/plugins/transformations/' . $file);
|
||||
$class_name = PMA_getTransformationClassName($file);
|
||||
// include and instantiate the class
|
||||
include_once 'libraries/plugins/transformations/' . $file;
|
||||
include_once $file;
|
||||
return $class_name::getInfo();
|
||||
}
|
||||
|
||||
@ -187,7 +187,7 @@ function PMA_getTransformationName($file)
|
||||
/* @var $class_name TransformationsInterface */
|
||||
$class_name = PMA_getTransformationClassName($file);
|
||||
// include and instantiate the class
|
||||
include_once 'libraries/plugins/transformations/' . $file;
|
||||
include_once $file;
|
||||
return $class_name::getName();
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
<?php use PMA\libraries\Util; ?>
|
||||
<label for="text_dbname"><?php echo __('Add privileges on the following database(s):'); ?></label>
|
||||
|
||||
<?php if (! empty($databases)) : ?>
|
||||
<select name="pred_dbname[]" multiple="multiple">
|
||||
<?php foreach ($databases as $database) : ?>
|
||||
<?php $escapedDatabase = PMA_Util::escapeMysqlWildcards($database); ?>
|
||||
<?php $escapedDatabase = Util::escapeMysqlWildcards($database); ?>
|
||||
<option value="<?php echo htmlspecialchars($escapedDatabase); ?>">
|
||||
<?php echo htmlspecialchars($database); ?>
|
||||
</option>
|
||||
@ -12,4 +13,4 @@
|
||||
<?php endif; ?>
|
||||
|
||||
<input type="text" id="text_dbname" name="dbname" />
|
||||
<?php echo PMA_Util::showHint(__('Wildcards % and _ should be escaped with a \ to use them literally.'))?>
|
||||
<?php echo Util::showHint(__('Wildcards % and _ should be escaped with a \ to use them literally.'))?>
|
||||
@ -1,3 +1,4 @@
|
||||
<?php use PMA\libraries\Template; ?>
|
||||
<form class="submenu-item" action="server_privileges.php" id="<?php echo $formId; ?>" method="post">
|
||||
<?php echo PMA_URL_getHiddenInputs(); ?>
|
||||
<input type="hidden" name="username" value="<?php echo htmlspecialchars($userName); ?>" />
|
||||
@ -32,7 +33,7 @@
|
||||
<?php else : ?>
|
||||
<?php $odd = true; ?>
|
||||
<?php foreach ($privileges as $privilege) : ?>
|
||||
<?php echo PMA\Template::get('privileges/privileges_summary_row')
|
||||
<?php echo Template::get('privileges/privileges_summary_row')
|
||||
->render(
|
||||
array_merge(
|
||||
$privilege,
|
||||
@ -49,13 +50,13 @@
|
||||
</table>
|
||||
|
||||
<?php if ($type == 'database') : ?>
|
||||
<?php echo PMA\Template::get('privileges/add_privileges_database')
|
||||
<?php echo Template::get('privileges/add_privileges_database')
|
||||
->render(array('databases' => $databases)); ?>
|
||||
<?php elseif ($type == 'table') : ?>
|
||||
<?php echo PMA\Template::get('privileges/add_privileges_table')
|
||||
<?php echo Template::get('privileges/add_privileges_table')
|
||||
->render(array('database' => $database, 'tables' => $tables)); ?>
|
||||
<?php else: // routine ?>
|
||||
<?php echo PMA\Template::get('privileges/add_privileges_routine')
|
||||
<?php echo Template::get('privileges/add_privileges_routine')
|
||||
->render(array('database' => $database, 'routines' => $routines)); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ class NodeFactory_Test extends PHPUnit_Framework_TestCase
|
||||
public function testDefaultContainer()
|
||||
{
|
||||
$node = NodeFactory::getInstance(
|
||||
'PMA\\libraries\\navigation\\nodes\\Node',
|
||||
'Node',
|
||||
'default',
|
||||
Node::CONTAINER
|
||||
);
|
||||
@ -71,7 +71,7 @@ class NodeFactory_Test extends PHPUnit_Framework_TestCase
|
||||
public function testGroupContainer()
|
||||
{
|
||||
$node = NodeFactory::getInstance(
|
||||
'PMA\\libraries\\navigation\\nodes\\Node',
|
||||
'Node',
|
||||
'default',
|
||||
Node::CONTAINER,
|
||||
true
|
||||
@ -89,7 +89,7 @@ class NodeFactory_Test extends PHPUnit_Framework_TestCase
|
||||
public function testFileError()
|
||||
{
|
||||
$this->setExpectedException('PHPUnit_Framework_Error');
|
||||
NodeFactory::getInstance('PMA\\libraries\\navigation\\nodes\\NodeDoesNotExist');
|
||||
NodeFactory::getInstance('NodeDoesNotExist');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -100,6 +100,6 @@ class NodeFactory_Test extends PHPUnit_Framework_TestCase
|
||||
public function testClassNameError()
|
||||
{
|
||||
$this->setExpectedException('PHPUnit_Framework_Error');
|
||||
NodeFactory::getInstance('PMA\\libraries\\navigation\\nodes\\Invalid');
|
||||
NodeFactory::getInstance('Invalid');
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,25 +122,25 @@ class PMA_Transformation_Test extends PHPUnit_Framework_TestCase
|
||||
18 => 'Text/Plain: Substring',
|
||||
),
|
||||
'transformation_file' => array (
|
||||
0 => 'output/Application_Octetstream_Download.php',
|
||||
1 => 'output/Application_Octetstream_Hex.php',
|
||||
2 => 'output/Image_JPEG_Inline.php',
|
||||
3 => 'output/Image_JPEG_Link.php',
|
||||
4 => 'output/Image_PNG_Inline.php',
|
||||
5 => 'output/Text_Octetstream_Sql.php',
|
||||
6 => 'output/Text_Plain_Binarytoip.php',
|
||||
7 => 'output/Text_Plain_Bool2Text.php',
|
||||
8 => 'output/Text_Plain_Dateformat.php',
|
||||
9 => 'output/Text_Plain_External.php',
|
||||
10 => 'output/Text_Plain_Formatted.php',
|
||||
11 => 'output/Text_Plain_Imagelink.php',
|
||||
12 => 'output/Text_Plain_Json.php',
|
||||
13 => 'output/Text_Plain_Sql.php',
|
||||
14 => 'output/Text_Plain_Xml.php',
|
||||
15 => 'Text_Plain_Link.php',
|
||||
16 => 'Text_Plain_Longtoipv4.php',
|
||||
17 => 'Text_Plain_PreApPend.php',
|
||||
18 => 'Text_Plain_Substring.php',
|
||||
0 => 'libraries/plugins/transformations/output/Application_Octetstream_Download.php',
|
||||
1 => 'libraries/plugins/transformations/output/Application_Octetstream_Hex.php',
|
||||
2 => 'libraries/plugins/transformations/output/Image_JPEG_Inline.php',
|
||||
3 => 'libraries/plugins/transformations/output/Image_JPEG_Link.php',
|
||||
4 => 'libraries/plugins/transformations/output/Image_PNG_Inline.php',
|
||||
5 => 'libraries/plugins/transformations/output/Text_Octetstream_Sql.php',
|
||||
6 => 'libraries/plugins/transformations/output/Text_Plain_Binarytoip.php',
|
||||
7 => 'libraries/plugins/transformations/output/Text_Plain_Bool2Text.php',
|
||||
8 => 'libraries/plugins/transformations/output/Text_Plain_Dateformat.php',
|
||||
9 => 'libraries/plugins/transformations/output/Text_Plain_External.php',
|
||||
10 => 'libraries/plugins/transformations/output/Text_Plain_Formatted.php',
|
||||
11 => 'libraries/plugins/transformations/output/Text_Plain_Imagelink.php',
|
||||
12 => 'libraries/plugins/transformations/output/Text_Plain_Json.php',
|
||||
13 => 'libraries/plugins/transformations/output/Text_Plain_Sql.php',
|
||||
14 => 'libraries/plugins/transformations/output/Text_Plain_Xml.php',
|
||||
15 => 'libraries/plugins/transformations/Text_Plain_Link.php',
|
||||
16 => 'libraries/plugins/transformations/Text_Plain_Longtoipv4.php',
|
||||
17 => 'libraries/plugins/transformations/Text_Plain_PreApPend.php',
|
||||
18 => 'libraries/plugins/transformations/Text_Plain_Substring.php',
|
||||
),
|
||||
'input_transformation' => array(
|
||||
'Image/JPEG: Upload',
|
||||
@ -156,17 +156,17 @@ class PMA_Transformation_Test extends PHPUnit_Framework_TestCase
|
||||
'Text/Plain: Substring',
|
||||
),
|
||||
'input_transformation_file' => array(
|
||||
'input/Image_JPEG_Upload.php',
|
||||
'input/Text_Plain_FileUpload.php',
|
||||
'input/Text_Plain_Iptobinary.php',
|
||||
'input/Text_Plain_JsonEditor.php',
|
||||
'input/Text_Plain_RegexValidation.php',
|
||||
'input/Text_Plain_SqlEditor.php',
|
||||
'input/Text_Plain_XmlEditor.php',
|
||||
'Text_Plain_Link.php',
|
||||
'Text_Plain_Longtoipv4.php',
|
||||
'Text_Plain_PreApPend.php',
|
||||
'Text_Plain_Substring.php',
|
||||
'libraries/plugins/transformations/input/Image_JPEG_Upload.php',
|
||||
'libraries/plugins/transformations/input/Text_Plain_FileUpload.php',
|
||||
'libraries/plugins/transformations/input/Text_Plain_Iptobinary.php',
|
||||
'libraries/plugins/transformations/input/Text_Plain_JsonEditor.php',
|
||||
'libraries/plugins/transformations/input/Text_Plain_RegexValidation.php',
|
||||
'libraries/plugins/transformations/input/Text_Plain_SqlEditor.php',
|
||||
'libraries/plugins/transformations/input/Text_Plain_XmlEditor.php',
|
||||
'libraries/plugins/transformations/Text_Plain_Link.php',
|
||||
'libraries/plugins/transformations/Text_Plain_Longtoipv4.php',
|
||||
'libraries/plugins/transformations/Text_Plain_PreApPend.php',
|
||||
'libraries/plugins/transformations/Text_Plain_Substring.php',
|
||||
),
|
||||
),
|
||||
PMA_getAvailableMIMEtypes()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user