Merge pull request #799 from Tithugues/nestedLevels

Nested levels
This commit is contained in:
Hugues Peccatte 2013-12-21 13:36:22 -08:00
commit a1091bee51
8 changed files with 651 additions and 578 deletions

View File

@ -642,37 +642,41 @@ class FormDisplay
}
// save forms
if ($allow_partial_save || empty($this->_errors)) {
foreach ($to_save as $work_path => $path) {
// TrustedProxies requires changes before saving
if ($path == 'TrustedProxies') {
$proxies = array();
$i = 0;
foreach ($values[$path] as $value) {
$matches = array();
$match = preg_match(
"/^(.+):(?:[ ]?)(\\w+)$/", $value, $matches
);
if ($match) {
// correct 'IP: HTTP header' pair
$ip = trim($matches[1]);
$proxies[$ip] = trim($matches[2]);
} else {
// save also incorrect values
$proxies["-$i"] = $value;
$i++;
}
if (!$allow_partial_save && !empty($this->_errors)) {
// don't look for non-critical errors
$this->_validate();
return $result;
}
foreach ($to_save as $work_path => $path) {
// TrustedProxies requires changes before saving
if ($path == 'TrustedProxies') {
$proxies = array();
$i = 0;
foreach ($values[$path] as $value) {
$matches = array();
$match = preg_match(
"/^(.+):(?:[ ]?)(\\w+)$/", $value, $matches
);
if ($match) {
// correct 'IP: HTTP header' pair
$ip = trim($matches[1]);
$proxies[$ip] = trim($matches[2]);
} else {
// save also incorrect values
$proxies["-$i"] = $value;
$i++;
}
$values[$path] = $proxies;
}
$this->_configFile->set($work_path, $values[$path], $path);
}
if ($is_setup_script) {
$this->_configFile->set(
'UserprefsDisallow',
array_keys($this->_userprefsDisallow)
);
$values[$path] = $proxies;
}
$this->_configFile->set($work_path, $values[$path], $path);
}
if ($is_setup_script) {
$this->_configFile->set(
'UserprefsDisallow',
array_keys($this->_userprefsDisallow)
);
}
// don't look for non-critical errors

View File

@ -409,20 +409,23 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
// Classify inner rings to their respective outer rings.
foreach ($row_data['parts'] as $j => $ring1) {
if (! $ring1['isOuter']) {
foreach ($row_data['parts'] as $k => $ring2) {
if ($ring2['isOuter']) {
// If the pointOnSurface of the inner ring
// is also inside the outer ring
if (PMA_GIS_Polygon::isPointInsidePolygon(
$ring1['pointOnSurface'], $ring2['points']
)) {
if (! isset($ring2['inner'])) {
$row_data['parts'][$k]['inner'] = array();
}
$row_data['parts'][$k]['inner'][] = $j;
}
if ($ring1['isOuter']) {
continue;
}
foreach ($row_data['parts'] as $k => $ring2) {
if (!$ring2['isOuter']) {
continue;
}
// If the pointOnSurface of the inner ring
// is also inside the outer ring
if (PMA_GIS_Polygon::isPointInsidePolygon(
$ring1['pointOnSurface'], $ring2['points']
)) {
if (! isset($ring2['inner'])) {
$row_data['parts'][$k]['inner'] = array();
}
$row_data['parts'][$k]['inner'][] = $j;
}
}
}
@ -430,30 +433,32 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
$wkt = 'MULTIPOLYGON(';
// for each polygon
foreach ($row_data['parts'] as $ring) {
if ($ring['isOuter']) {
$wkt .= '('; // start of polygon
$wkt .= '('; // start of outer ring
foreach ($ring['points'] as $point) {
$wkt .= $point['x'] . ' ' . $point['y'] . ',';
}
$wkt = substr($wkt, 0, strlen($wkt) - 1);
$wkt .= ')'; // end of outer ring
// inner rings if any
if (isset($ring['inner'])) {
foreach ($ring['inner'] as $j) {
$wkt .= ',('; // start of inner ring
foreach ($row_data['parts'][$j]['points'] as $innerPoint) {
$wkt .= $innerPoint['x'] . ' ' . $innerPoint['y'] . ',';
}
$wkt = substr($wkt, 0, strlen($wkt) - 1);
$wkt .= ')'; // end of inner ring
}
}
$wkt .= '),'; // end of polygon
if (!$ring['isOuter']) {
continue;
}
$wkt .= '('; // start of polygon
$wkt .= '('; // start of outer ring
foreach ($ring['points'] as $point) {
$wkt .= $point['x'] . ' ' . $point['y'] . ',';
}
$wkt = substr($wkt, 0, strlen($wkt) - 1);
$wkt .= ')'; // end of outer ring
// inner rings if any
if (isset($ring['inner'])) {
foreach ($ring['inner'] as $j) {
$wkt .= ',('; // start of inner ring
foreach ($row_data['parts'][$j]['points'] as $innerPoint) {
$wkt .= $innerPoint['x'] . ' ' . $innerPoint['y'] . ',';
}
$wkt = substr($wkt, 0, strlen($wkt) - 1);
$wkt .= ')'; // end of inner ring
}
}
$wkt .= '),'; // end of polygon
}
$wkt = substr($wkt, 0, strlen($wkt) - 1);

View File

@ -91,179 +91,205 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false,
$skip_queries, $executed_queries, $max_sql_len, $read_multiply,
$cfg, $sql_query_disabled, $db, $run_query, $is_superuser;
$read_multiply = 1;
if (isset($import_run_buffer)) {
// Should we skip something?
if ($skip_queries > 0) {
$skip_queries--;
if (!isset($import_run_buffer)) {
// Do we have something to push into buffer?
$import_run_buffer = PMA_importRunQuery_post(
$import_run_buffer, $sql, $full
);
return;
}
// Should we skip something?
if ($skip_queries > 0) {
$skip_queries--;
// Do we have something to push into buffer?
$import_run_buffer = PMA_importRunQuery_post(
$import_run_buffer, $sql, $full
);
return;
}
if (! empty($import_run_buffer['sql'])
&& trim($import_run_buffer['sql']) != ''
) {
// USE query changes the database, son need to track
// while running multiple queries
$is_use_query
= (stripos($import_run_buffer['sql'], "use ") !== false)
? true
: false;
$max_sql_len = max($max_sql_len, strlen($import_run_buffer['sql']));
if (! $sql_query_disabled) {
$sql_query .= $import_run_buffer['full'];
}
$pattern = '@^[[:space:]]*DROP[[:space:]]+(IF EXISTS[[:space:]]+)?'
. 'DATABASE @i';
if (! $cfg['AllowUserDropDatabase']
&& ! $is_superuser
&& preg_match($pattern, $import_run_buffer['sql'])
) {
$GLOBALS['message'] = PMA_Message::error(
__('"DROP DATABASE" statements are disabled.')
);
$error = true;
} else {
if (! empty($import_run_buffer['sql'])
&& trim($import_run_buffer['sql']) != ''
$executed_queries++;
$pattern = '/^[\s]*(SELECT|SHOW|HANDLER)/i';
if ($run_query
&& $GLOBALS['finished']
&& empty($sql)
&& ! $error
&& ((! empty($import_run_buffer['sql'])
&& preg_match($pattern, $import_run_buffer['sql']))
|| ($executed_queries == 1))
) {
// USE query changes the database, son need to track
// while running multiple queries
$is_use_query
= (stripos($import_run_buffer['sql'], "use ") !== false)
? true
: false;
$max_sql_len = max($max_sql_len, strlen($import_run_buffer['sql']));
$go_sql = true;
if (! $sql_query_disabled) {
$sql_query .= $import_run_buffer['full'];
}
$pattern = '@^[[:space:]]*DROP[[:space:]]+(IF EXISTS[[:space:]]+)?'
. 'DATABASE @i';
if (! $cfg['AllowUserDropDatabase']
&& ! $is_superuser
&& preg_match($pattern, $import_run_buffer['sql'])
) {
$GLOBALS['message'] = PMA_Message::error(__('"DROP DATABASE" statements are disabled.'));
$error = true;
$complete_query = $sql_query;
$display_query = $sql_query;
} else {
$complete_query = '';
$display_query = '';
}
$sql_query = $import_run_buffer['sql'];
$sql_data['valid_sql'][] = $import_run_buffer['sql'];
if (! isset($sql_data['valid_queries'])) {
$sql_data['valid_queries'] = 0;
}
$sql_data['valid_queries']++;
$executed_queries++;
// If a 'USE <db>' SQL-clause was found,
// set our current $db to the new one
list($db, $reload) = PMA_lookForUse(
$import_run_buffer['sql'],
$db,
$reload
);
} elseif ($run_query) {
$pattern = '/^[\s]*(SELECT|SHOW|HANDLER)/i';
if ($run_query
&& $GLOBALS['finished']
&& empty($sql)
&& ! $error
&& ((! empty($import_run_buffer['sql'])
&& preg_match($pattern, $import_run_buffer['sql']))
|| ($executed_queries == 1))
) {
$go_sql = true;
if (! $sql_query_disabled) {
$complete_query = $sql_query;
$display_query = $sql_query;
} else {
$complete_query = '';
$display_query = '';
}
$sql_query = $import_run_buffer['sql'];
if ($controluser) {
$result = PMA_queryAsControlUser(
$import_run_buffer['sql']
);
} else {
$result = $GLOBALS['dbi']
->tryQuery($import_run_buffer['sql']);
}
$msg = '# ';
if ($result === false) { // execution failed
if (! isset($my_die)) {
$my_die = array();
}
$my_die[] = array(
'sql' => $import_run_buffer['full'],
'error' => $GLOBALS['dbi']->getError()
);
$msg .= __('Error');
if (! $cfg['IgnoreMultiSubmitErrors']) {
$error = true;
return;
}
} else {
$a_num_rows = (int)@$GLOBALS['dbi']->numRows($result);
$a_aff_rows = (int)@$GLOBALS['dbi']->affectedRows();
if ($a_num_rows > 0) {
$msg .= __('Rows'). ': ' . $a_num_rows;
$last_query_with_results = $import_run_buffer['sql'];
} elseif ($a_aff_rows > 0) {
$message = PMA_Message::getMessageForAffectedRows(
$a_aff_rows
);
$msg .= $message->getMessage();
} else {
$msg .= __(
'MySQL returned an empty result set (i.e. zero '
. 'rows).'
);
}
if (($a_num_rows > 0) || $is_use_query) {
$sql_data['valid_sql'][] = $import_run_buffer['sql'];
if (! isset($sql_data['valid_queries'])) {
$sql_data['valid_queries'] = 0;
}
$sql_data['valid_queries']++;
// If a 'USE <db>' SQL-clause was found,
// set our current $db to the new one
list($db, $reload) = PMA_lookForUse(
$import_run_buffer['sql'],
$db,
$reload
);
} elseif ($run_query) {
if ($controluser) {
$result = PMA_queryAsControlUser(
$import_run_buffer['sql']
);
} else {
$result = $GLOBALS['dbi']
->tryQuery($import_run_buffer['sql']);
}
$msg = '# ';
if ($result === false) { // execution failed
if (! isset($my_die)) {
$my_die = array();
}
$my_die[] = array(
'sql' => $import_run_buffer['full'],
'error' => $GLOBALS['dbi']->getError()
);
$msg .= __('Error');
if (! $cfg['IgnoreMultiSubmitErrors']) {
$error = true;
return;
}
} else {
$a_num_rows = (int)@$GLOBALS['dbi']->numRows($result);
$a_aff_rows = (int)@$GLOBALS['dbi']->affectedRows();
if ($a_num_rows > 0) {
$msg .= __('Rows'). ': ' . $a_num_rows;
$last_query_with_results = $import_run_buffer['sql'];
} elseif ($a_aff_rows > 0) {
$message = PMA_Message::getMessageForAffectedRows(
$a_aff_rows
);
$msg .= $message->getMessage();
} else {
$msg .= __(
'MySQL returned an empty result set (i.e. zero '
. 'rows).'
);
}
if (($a_num_rows > 0) || $is_use_query) {
$sql_data['valid_sql'][] = $import_run_buffer['sql'];
if (! isset($sql_data['valid_queries'])) {
$sql_data['valid_queries'] = 0;
}
$sql_data['valid_queries']++;
}
}
if (! $sql_query_disabled) {
$sql_query .= $msg . "\n";
}
// If a 'USE <db>' SQL-clause was found and the query
// succeeded, set our current $db to the new one
if ($result != false) {
list($db, $reload) = PMA_lookForUse(
$import_run_buffer['sql'],
$db,
$reload
);
}
$pattern = '@^[\s]*(DROP|CREATE)[\s]+(IF EXISTS[[:space:]]+)'
. '?(TABLE|DATABASE)[[:space:]]+(.+)@im';
if ($result != false
&& preg_match($pattern, $import_run_buffer['sql'])
) {
$reload = true;
}
} // end run query
} // end if not DROP DATABASE
// end non empty query
} elseif (! empty($import_run_buffer['full'])) {
if ($go_sql) {
$complete_query .= $import_run_buffer['full'];
$display_query .= $import_run_buffer['full'];
} else {
if (! $sql_query_disabled) {
$sql_query .= $import_run_buffer['full'];
}
}
}
// check length of query unless we decided to pass it to sql.php
// (if $run_query is false, we are just displaying so show
// the complete query in the textarea)
if (! $go_sql && $run_query) {
if (! empty($sql_query)) {
if (strlen($sql_query) > 50000
|| $executed_queries > 50
|| $max_sql_len > 1000
) {
$sql_query = '';
$sql_query_disabled = true;
}
if (! $sql_query_disabled) {
$sql_query .= $msg . "\n";
}
// If a 'USE <db>' SQL-clause was found and the query
// succeeded, set our current $db to the new one
if ($result != false) {
list($db, $reload) = PMA_lookForUse(
$import_run_buffer['sql'],
$db,
$reload
);
}
$pattern = '@^[\s]*(DROP|CREATE)[\s]+(IF EXISTS[[:space:]]+)'
. '?(TABLE|DATABASE)[[:space:]]+(.+)@im';
if ($result != false
&& preg_match($pattern, $import_run_buffer['sql'])
) {
$reload = true;
}
} // end run query
} // end if not DROP DATABASE
// end non empty query
} elseif (! empty($import_run_buffer['full'])) {
if ($go_sql) {
$complete_query .= $import_run_buffer['full'];
$display_query .= $import_run_buffer['full'];
} else {
if (! $sql_query_disabled) {
$sql_query .= $import_run_buffer['full'];
}
} // end do query (no skip)
} // end buffer exists
}
}
// check length of query unless we decided to pass it to sql.php
// (if $run_query is false, we are just displaying so show
// the complete query in the textarea)
if (! $go_sql && $run_query) {
if (! empty($sql_query)) {
if (strlen($sql_query) > 50000
|| $executed_queries > 50
|| $max_sql_len > 1000
) {
$sql_query = '';
$sql_query_disabled = true;
}
}
}
// Do we have something to push into buffer?
if (! empty($sql) || ! empty($full)) {
$import_run_buffer = PMA_importRunQuery_post($import_run_buffer, $sql, $full);
}
/**
* @param $import_run_buffer
* @param $sql
* @param $full
* @return array
*/
function PMA_importRunQuery_post($import_run_buffer, $sql, $full)
{
if (!empty($sql) || !empty($full)) {
$import_run_buffer = array('sql' => $sql, 'full' => $full);
return $import_run_buffer;
} else {
unset($GLOBALS['import_run_buffer']);
return $import_run_buffer;
}
}

View File

@ -648,10 +648,10 @@ class PMA_NavigationTree
$children = $this->_tree->children;
usort($children, array('PMA_NavigationTree', 'sortNode'));
$this->_setVisibility();
for ($i=0; $i<count($children); $i++) {
for ($i=0, $nbChildren = count($children); $i < $nbChildren; $i++) {
if ($i == 0) {
$retval .= $this->_renderNode($children[0], true, 'first');
} else if ($i + 1 != count($children)) {
} else if ($i + 1 != $nbChildren) {
$retval .= $this->_renderNode($children[$i], true);
} else {
$retval .= $this->_renderNode($children[$i], true, 'last');
@ -680,8 +680,8 @@ class PMA_NavigationTree
$retval .= $this->_getPageSelector($node);
$children = $node->children;
usort($children, array('PMA_NavigationTree', 'sortNode'));
for ($i=0; $i<count($children); $i++) {
if ($i + 1 != count($children)) {
for ($i=0, $nbChildren = count($children); $i < $nbChildren; $i++) {
if ($i + 1 != $nbChildren) {
$retval .= $this->_renderNode($children[$i], true);
} else {
$retval .= $this->_renderNode($children[$i], true, 'last');
@ -959,8 +959,8 @@ class PMA_NavigationTree
$children = $node->children;
usort($children, array('PMA_NavigationTree', 'sortNode'));
$buffer = '';
for ($i=0; $i<count($children); $i++) {
if ($i + 1 != count($children)) {
for ($i=0, $nbChildren = count($children); $i < $nbChildren; $i++) {
if ($i + 1 != $nbChildren) {
$buffer .= $this->_renderNode(
$children[$i],
true,

View File

@ -304,116 +304,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()
);
continue;
}
if ($propertyItem->getForce() != null) {
// Same code is also few lines lower, update both if needed
$ret .= ' onclick="if (!this.checked &amp;&amp; '
. '(!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(
// 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(
$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>';
}
$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:;
if ($propertyItem->getForce() != null) {
// Same code is also few lines lower, update both if needed
$ret .= ' onclick="if (!this.checked &amp;&amp; '
. '(!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(
$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 .= '>' . 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:;
}
}
}

View File

@ -656,76 +656,79 @@ function PMA_RTN_getDataFromName($name, $type, $all = true)
$retval['item_param_opts_text'] = $params['opts'];
// Get extra data
if ($all) {
if ($retval['item_type'] == 'FUNCTION') {
$retval['item_type_toggle'] = 'PROCEDURE';
} else {
$retval['item_type_toggle'] = 'FUNCTION';
}
$retval['item_returntype'] = '';
$retval['item_returnlength'] = '';
$retval['item_returnopts_num'] = '';
$retval['item_returnopts_text'] = '';
if (! empty($routine['DTD_IDENTIFIER'])) {
if (strlen($routine['DTD_IDENTIFIER']) > 63) {
// If the DTD_IDENTIFIER string from INFORMATION_SCHEMA is
// at least 64 characters, then it may actually have been
// chopped because that column is a varchar(64), so we will
// parse the output of SHOW CREATE query to get accurate
// information about the return variable.
$dtd = '';
$fetching = false;
for ($i=0; $i<$parsed_query['len']; $i++) {
if ($parsed_query[$i]['type'] == 'alpha_reservedWord'
&& strtoupper($parsed_query[$i]['data']) == 'RETURNS'
) {
$fetching = true;
} else if ($fetching == true
&& $parsed_query[$i]['type'] == 'alpha_reservedWord'
) {
// We will not be looking for options such as UNSIGNED
// or ZEROFILL because there is no way that a numeric
// field's DTD_IDENTIFIER can be longer than 64
// characters. We can safely assume that the return
// datatype is either ENUM or SET, so we only look
// for CHARSET.
$word = strtoupper($parsed_query[$i]['data']);
if ($word == 'CHARSET'
&& ($parsed_query[$i+1]['type'] == 'alpha_charset'
|| $parsed_query[$i+1]['type'] == 'alpha_identifier')
) {
$dtd .= $word . ' ' . $parsed_query[$i+1]['data'];
}
break;
} else if ($fetching == true) {
$dtd .= $parsed_query[$i]['data'] . ' ';
}
}
$routine['DTD_IDENTIFIER'] = $dtd;
}
$returnparam = PMA_RTN_parseOneParameter($routine['DTD_IDENTIFIER']);
$retval['item_returntype'] = $returnparam[2];
$retval['item_returnlength'] = $returnparam[3];
$retval['item_returnopts_num'] = $returnparam[4];
$retval['item_returnopts_text'] = $returnparam[4];
}
$retval['item_definer'] = PMA_RTN_parseRoutineDefiner($parsed_query);
$retval['item_definition'] = $routine['ROUTINE_DEFINITION'];
$retval['item_isdeterministic'] = '';
if ($routine['IS_DETERMINISTIC'] == 'YES') {
$retval['item_isdeterministic'] = " checked='checked'";
}
$retval['item_securitytype_definer'] = '';
$retval['item_securitytype_invoker'] = '';
if ($routine['SECURITY_TYPE'] == 'DEFINER') {
$retval['item_securitytype_definer'] = " selected='selected'";
} else if ($routine['SECURITY_TYPE'] == 'INVOKER') {
$retval['item_securitytype_invoker'] = " selected='selected'";
}
$retval['item_sqldataaccess'] = $routine['SQL_DATA_ACCESS'];
$retval['item_comment'] = $routine['ROUTINE_COMMENT'];
if (!$all) {
return $retval;
}
if ($retval['item_type'] == 'FUNCTION') {
$retval['item_type_toggle'] = 'PROCEDURE';
} else {
$retval['item_type_toggle'] = 'FUNCTION';
}
$retval['item_returntype'] = '';
$retval['item_returnlength'] = '';
$retval['item_returnopts_num'] = '';
$retval['item_returnopts_text'] = '';
if (! empty($routine['DTD_IDENTIFIER'])) {
if (strlen($routine['DTD_IDENTIFIER']) > 63) {
// If the DTD_IDENTIFIER string from INFORMATION_SCHEMA is
// at least 64 characters, then it may actually have been
// chopped because that column is a varchar(64), so we will
// parse the output of SHOW CREATE query to get accurate
// information about the return variable.
$dtd = '';
$fetching = false;
for ($i=0; $i<$parsed_query['len']; $i++) {
if ($parsed_query[$i]['type'] == 'alpha_reservedWord'
&& strtoupper($parsed_query[$i]['data']) == 'RETURNS'
) {
$fetching = true;
} else if ($fetching == true
&& $parsed_query[$i]['type'] == 'alpha_reservedWord'
) {
// We will not be looking for options such as UNSIGNED
// or ZEROFILL because there is no way that a numeric
// field's DTD_IDENTIFIER can be longer than 64
// characters. We can safely assume that the return
// datatype is either ENUM or SET, so we only look
// for CHARSET.
$word = strtoupper($parsed_query[$i]['data']);
if ($word == 'CHARSET'
&& ($parsed_query[$i+1]['type'] == 'alpha_charset'
|| $parsed_query[$i+1]['type'] == 'alpha_identifier')
) {
$dtd .= $word . ' ' . $parsed_query[$i+1]['data'];
}
break;
} else if ($fetching == true) {
$dtd .= $parsed_query[$i]['data'] . ' ';
}
}
$routine['DTD_IDENTIFIER'] = $dtd;
}
$returnparam = PMA_RTN_parseOneParameter($routine['DTD_IDENTIFIER']);
$retval['item_returntype'] = $returnparam[2];
$retval['item_returnlength'] = $returnparam[3];
$retval['item_returnopts_num'] = $returnparam[4];
$retval['item_returnopts_text'] = $returnparam[4];
}
$retval['item_definer'] = PMA_RTN_parseRoutineDefiner($parsed_query);
$retval['item_definition'] = $routine['ROUTINE_DEFINITION'];
$retval['item_isdeterministic'] = '';
if ($routine['IS_DETERMINISTIC'] == 'YES') {
$retval['item_isdeterministic'] = " checked='checked'";
}
$retval['item_securitytype_definer'] = '';
$retval['item_securitytype_invoker'] = '';
if ($routine['SECURITY_TYPE'] == 'DEFINER') {
$retval['item_securitytype_definer'] = " selected='selected'";
} else if ($routine['SECURITY_TYPE'] == 'INVOKER') {
$retval['item_securitytype_invoker'] = " selected='selected'";
}
$retval['item_sqldataaccess'] = $routine['SQL_DATA_ACCESS'];
$retval['item_comment'] = $routine['ROUTINE_COMMENT'];
return $retval;
} // PMA_RTN_getDataFromName()

View File

@ -2020,139 +2020,166 @@ function PMA_getHtmlTableBodyForSpecificDbOrTablePrivs($privMap, $db, $table = n
{
$html_output = '<tbody>';
$odd_row = true;
if (! empty($privMap)) {
foreach ($privMap as $current_user => $val) {
foreach ($val as $current_host => $current_privileges) {
$nbPrivileges = count($current_privileges);
$html_output .= '<tr class="noclick '
. ($odd_row ? 'odd' : 'even') . '">';
// user
$html_output .= '<td';
if ($nbPrivileges > 1) {
$html_output .= ' rowspan="' . $nbPrivileges . '"';
}
$html_output .= '>';
if (empty($current_user)) {
$html_output .= '<span style="color: #FF0000">'
. __('Any') . '</span>';
} else {
$html_output .= htmlspecialchars($current_user);
}
$html_output .= '</td>';
// host
$html_output .= '<td';
if ($nbPrivileges > 1) {
$html_output .= ' rowspan="' . $nbPrivileges . '"';
}
$html_output .= '>';
$html_output .= htmlspecialchars($current_host);
$html_output .= '</td>';
for ($i = 0; $i < $nbPrivileges; $i++) {
$current = $current_privileges[$i];
// type
$html_output .= '<td>';
if ($current['Type'] == 'g') {
$html_output .= __('global');
} elseif ($current['Type'] == 'd') {
if ($current['Db'] == PMA_Util::escapeMysqlWildcards($db)) {
$html_output .= __('database-specific');
} else {
$html_output .= __('wildcard'). ': '
. '<code>'
. htmlspecialchars($current['Db'])
. '</code>';
}
} elseif ($current['Type'] == 't') {
$html_output .= __('table-specific');
}
$html_output .= '</td>';
// privileges
$html_output .= '<td>';
if (isset($current['Table_name'])) {
$privList = explode(',', $current['Table_priv']);
$privs = array();
$grantsArr = PMA_getTableGrantsArray();
foreach ($grantsArr as $grant) {
$privs[$grant[0]] = 'N';
foreach ($privList as $priv) {
if ($grant[0] == $priv) {
$privs[$grant[0]] = 'Y';
}
}
}
$html_output .= '<code>'
. join(
',',
PMA_extractPrivInfo($privs, true, true)
)
. '</code>';
} else {
$html_output .= '<code>'
. join(
',',
PMA_extractPrivInfo($current, true, false)
)
. '</code>';
}
$html_output .= '</td>';
// grant
$html_output .= '<td>';
$containsGrant = false;
if (isset($current['Table_name'])) {
$privList = explode(',', $current['Table_priv']);
foreach ($privList as $priv) {
if ($priv == 'Grant') {
$containsGrant = true;
}
}
} else {
$containsGrant = $current['Grant_priv'] == 'Y';
}
$html_output .= ($containsGrant ? __('Yes') : __('No'));
$html_output .= '</td>';
// action
$html_output .= '<td>';
$specific_db = (isset($current['Db']) && $current['Db'] != '*')
? $current['Db'] : '';
$specific_table = (isset($current['Table_name'])
&& $current['Table_name'] != '*')
? $current['Table_name'] : '';
$html_output .= PMA_getUserEditLink(
$current_user,
$current_host,
$specific_db,
$specific_table
);
$html_output .= '</td>';
$html_output .= '</tr>';
if (($i + 1) < $nbPrivileges) {
$html_output .= '<tr class="noclick '
. ($odd_row ? 'odd' : 'even') . '">';
}
}
$odd_row = ! $odd_row;
}
}
} else {
if (empty($privMap)) {
$html_output .= '<tr class="odd">'
. '<td colspan="6">'
. __('No user found.')
. '</td>'
. '</tr>';
. '<td colspan="6">'
. __('No user found.')
. '</td>'
. '</tr>'
. '</tbody>';
return $html_output;
}
foreach ($privMap as $current_user => $val) {
foreach ($val as $current_host => $current_privileges) {
$nbPrivileges = count($current_privileges);
$html_output .= '<tr class="noclick '
. ($odd_row ? 'odd' : 'even') . '">';
// user
$html_output .= '<td';
if ($nbPrivileges > 1) {
$html_output .= ' rowspan="' . $nbPrivileges . '"';
}
$html_output .= '>';
if (empty($current_user)) {
$html_output .= '<span style="color: #FF0000">'
. __('Any') . '</span>';
} else {
$html_output .= htmlspecialchars($current_user);
}
$html_output .= '</td>';
// host
$html_output .= '<td';
if ($nbPrivileges > 1) {
$html_output .= ' rowspan="' . $nbPrivileges . '"';
}
$html_output .= '>';
$html_output .= htmlspecialchars($current_host);
$html_output .= '</td>';
$html_output .= PMA_getHtmlListOfPrivs(
$db, $current_privileges, $current_user,
$current_host, $odd_row
);
$odd_row = ! $odd_row;
}
}
$html_output .= '</tbody>';
return $html_output;
}
/**
* Get HTML to display privileges
*
* @param string $db Database name
* @param array $current_privileges List of privileges
* @param string $current_user Current user
* @param string $current_host Current host
* @param boolean $odd_row Current row is odd
*
* @return string HTML to display privileges
*/
function PMA_getHtmlListOfPrivs(
$db, $current_privileges, $current_user,
$current_host, $odd_row
) {
$nbPrivileges = count($current_privileges);
$html_output = null;
for ($i = 0; $i < $nbPrivileges; $i++) {
$current = $current_privileges[$i];
// type
$html_output .= '<td>';
if ($current['Type'] == 'g') {
$html_output .= __('global');
} elseif ($current['Type'] == 'd') {
if ($current['Db'] == PMA_Util::escapeMysqlWildcards($db)) {
$html_output .= __('database-specific');
} else {
$html_output .= __('wildcard') . ': '
. '<code>'
. htmlspecialchars($current['Db'])
. '</code>';
}
} elseif ($current['Type'] == 't') {
$html_output .= __('table-specific');
}
$html_output .= '</td>';
// privileges
$html_output .= '<td>';
if (isset($current['Table_name'])) {
$privList = explode(',', $current['Table_priv']);
$privs = array();
$grantsArr = PMA_getTableGrantsArray();
foreach ($grantsArr as $grant) {
$privs[$grant[0]] = 'N';
foreach ($privList as $priv) {
if ($grant[0] == $priv) {
$privs[$grant[0]] = 'Y';
}
}
}
$html_output .= '<code>'
. join(
',',
PMA_extractPrivInfo($privs, true, true)
)
. '</code>';
} else {
$html_output .= '<code>'
. join(
',',
PMA_extractPrivInfo($current, true, false)
)
. '</code>';
}
$html_output .= '</td>';
// grant
$html_output .= '<td>';
$containsGrant = false;
if (isset($current['Table_name'])) {
$privList = explode(',', $current['Table_priv']);
foreach ($privList as $priv) {
if ($priv == 'Grant') {
$containsGrant = true;
}
}
} else {
$containsGrant = $current['Grant_priv'] == 'Y';
}
$html_output .= ($containsGrant ? __('Yes') : __('No'));
$html_output .= '</td>';
// action
$html_output .= '<td>';
$specific_db = (isset($current['Db']) && $current['Db'] != '*')
? $current['Db'] : '';
$specific_table = (isset($current['Table_name'])
&& $current['Table_name'] != '*')
? $current['Table_name'] : '';
$html_output .= PMA_getUserEditLink(
$current_user,
$current_host,
$specific_db,
$specific_table
);
$html_output .= '</td>';
$html_output .= '</tr>';
if (($i + 1) < $nbPrivileges) {
$html_output .= '<tr class="noclick '
. ($odd_row ? 'odd' : 'even') . '">';
}
}
return $html_output;
}
/**
* Returns edit link for a user.
*

View File

@ -23,65 +23,72 @@ function PMA_getZipContents($file, $specific_entry = null)
$error_message = '';
$file_data = '';
$zip_handle = zip_open($file);
if (is_resource($zip_handle)) {
$first_zip_entry = zip_read($zip_handle);
if (false === $first_zip_entry) {
$error_message = __('No files found inside ZIP archive!');
} else {
/* Is the the zip really an ODS file? */
$read = zip_entry_read($first_zip_entry);
$ods_mime = 'application/vnd.oasis.opendocument.spreadsheet';
if (!strcmp($ods_mime, $read)) {
$specific_entry = '/^content\.xml$/';
}
if (isset($specific_entry)) {
/* Return the correct contents, not just the first entry */
for ( ; ; ) {
$entry = zip_read($zip_handle);
if (is_resource($entry)) {
if (preg_match($specific_entry, zip_entry_name($entry))) {
zip_entry_open($zip_handle, $entry, 'r');
$file_data = zip_entry_read(
$entry,
zip_entry_filesize($entry)
);
zip_entry_close($entry);
break;
}
} else {
/**
* Either we have reached the end of the zip and still
* haven't found $specific_entry or there was a parsing
* error that we must display
*/
if ($entry === false) {
$error_message = __('Error in ZIP archive:')
. ' Could not find "' . $specific_entry . '"';
} else {
$error_message = __('Error in ZIP archive:')
. ' ' . PMA_getZipError($zip_handle);
}
break;
}
}
} else {
zip_entry_open($zip_handle, $first_zip_entry, 'r');
/* File pointer has already been moved,
* so include what was read above */
$file_data = $read;
$file_data .= zip_entry_read(
$first_zip_entry,
zip_entry_filesize($first_zip_entry)
);
zip_entry_close($first_zip_entry);
}
}
} else {
if (!is_resource($zip_handle)) {
$error_message = __('Error in ZIP archive:')
. ' ' . PMA_getZipError($zip_handle);
zip_close($zip_handle);
return (array('error' => $error_message, 'data' => $file_data));
}
$first_zip_entry = zip_read($zip_handle);
if (false === $first_zip_entry) {
$error_message = __('No files found inside ZIP archive!');
zip_close($zip_handle);
return (array('error' => $error_message, 'data' => $file_data));
}
/* Is the the zip really an ODS file? */
$read = zip_entry_read($first_zip_entry);
$ods_mime = 'application/vnd.oasis.opendocument.spreadsheet';
if (!strcmp($ods_mime, $read)) {
$specific_entry = '/^content\.xml$/';
}
if (!isset($specific_entry)) {
zip_entry_open($zip_handle, $first_zip_entry, 'r');
/* File pointer has already been moved,
* so include what was read above */
$file_data = $read;
$file_data .= zip_entry_read(
$first_zip_entry,
zip_entry_filesize($first_zip_entry)
);
zip_entry_close($first_zip_entry);
zip_close($zip_handle);
return (array('error' => $error_message, 'data' => $file_data));
}
/* Return the correct contents, not just the first entry */
for ( ; ; ) {
$entry = zip_read($zip_handle);
if (is_resource($entry)) {
if (preg_match($specific_entry, zip_entry_name($entry))) {
zip_entry_open($zip_handle, $entry, 'r');
$file_data = zip_entry_read(
$entry,
zip_entry_filesize($entry)
);
zip_entry_close($entry);
break;
}
} else {
/**
* Either we have reached the end of the zip and still
* haven't found $specific_entry or there was a parsing
* error that we must display
*/
if ($entry === false) {
$error_message = __('Error in ZIP archive:')
. ' Could not find "' . $specific_entry . '"';
} else {
$error_message = __('Error in ZIP archive:')
. ' ' . PMA_getZipError($zip_handle);
}
break;
}
}
zip_close($zip_handle);
return (array('error' => $error_message, 'data' => $file_data));
}