Skip to content

Commit

Permalink
Merge remote-tracking branch 'chanaka/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed Jul 31, 2012
2 parents 138dc52 + c433abd commit 3b78768
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 6 deletions.
87 changes: 82 additions & 5 deletions libraries/DisplayResults.class.php
Expand Up @@ -66,6 +66,12 @@ class PMA_DisplayResults
const TABLE_TYPE_INNO_DB = 'InnoDB';
const ALL_ROWS = 'all';
const QUERY_TYPE_SELECT = 'SELECT';

const MYSQL_SCHEMA = 'mysql';
const USER_FIELD = 'user';
const HOST_FIELD = 'host';
const USER_TABLE = 'user';
const DB_TABLE = 'db';


// Declare global fields
Expand Down Expand Up @@ -2685,6 +2691,7 @@ private function _getRowValues(
$fields_meta = $this->__get('_fields_meta');
$highlight_columns = $this->__get('_highlight_columns');
$mime_map = $this->__get('_mime_map');
$host = '';

for ($j = 0; $j < $this->__get('_fields_cnt'); ++$j) {

Expand Down Expand Up @@ -2784,7 +2791,7 @@ private function _getRowValues(
$vertical_display = $this->__get('_vertical_display');

// Check whether the field needs to display with syntax highlighting
if ($this->_isNeedToSytaxHighliight($meta->name)
if ($this->_isNeedToSytaxHighlight($meta->name)
&& (trim($row[$i]) != '')
) {

Expand All @@ -2807,8 +2814,63 @@ private function _getRowValues(
$this->sytax_highlighting_column_info[strtolower($this->__get('_db'))][strtolower($this->__get('_table'))][strtolower($meta->name)][2]
);

}
}

// Check for the fields need to show as link in mysql schema
include_once 'libraries/mysql_schema_relation.lib.php';

// Host should initialize for create link to edit user privilages page
if ((strtolower($this->__get('_db')) == self::MYSQL_SCHEMA)
&& (strtolower($meta->name) == self::HOST_FIELD)
) {
$host = $row[$i];
}

if (isset($GLOBALS['mysql_schema_relation'])
&& ($this->_isFieldNeedToLink(strtolower($meta->name)))
&& (strtolower($this->__get('_db')) == self::MYSQL_SCHEMA)
) {

$linking_url_params = array();
$link_relations = $GLOBALS['mysql_schema_relation'][strtolower($this->__get('_table'))][strtolower($meta->name)];

foreach ($link_relations['link_params'] as $link_param) {

// If link param is an array, set the key and value
// from that array
if (is_array($link_param)) {
$linking_url_params[$link_param[0]] = $link_param[1];
} else {
$linking_url_params[$link_param] = $row[$i];

// To create link to edit user privilages page
if ((strtolower($meta->name) == self::USER_FIELD)
&& ((strtolower($this->__get('_table') == self::USER_TABLE))
|| (strtolower($this->__get('_table') == self::DB_TABLE)))
) {
$linking_url_params['hostname'] = $host;
}
}

}

$linking_url = $link_relations['default_page']
. PMA_generate_common_url($linking_url_params);
include_once "libraries/plugins/transformations/Text_Plain_Link.class.php";
$transformation_plugin = new Text_Plain_Link(null);

$transform_options = array(
0 => $linking_url,
2 => true
);

$meta->mimetype = str_replace(
'_', '/',
'Text/Plain'
);

}

if ($meta->numeric == 1) {
// n u m e r i c

Expand Down Expand Up @@ -3007,13 +3069,28 @@ private function _gatherLinksForLaterOutputs(
*
* @return boolean
*/
private function _isNeedToSytaxHighliight($field) {
private function _isNeedToSytaxHighlight($field) {
if (! empty($this->sytax_highlighting_column_info[strtolower($this->__get('_db'))][strtolower($this->__get('_table'))][strtolower($field)])) {
return true;
}
return false;
}



/**
* Check whether the field needs to be link
*
* @param string $field field to check
*
* @return boolean
*/
private function _isFieldNeedToLink($field) {
if (! empty($GLOBALS['mysql_schema_relation'][strtolower($this->__get('_table'))][$field])) {
return true;
}
return false;
}


/**
* Get url sql query without conditions to shorten URLs
Expand Down Expand Up @@ -3520,7 +3597,7 @@ private function _getDataCellForBlobColumns(
// replacements will be made
if ((PMA_strlen($column) > $GLOBALS['cfg']['LimitChars'])
&& ($_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT)
&& ! $this->_isNeedToSytaxHighliight(strtolower($meta->name))
&& ! $this->_isNeedToSytaxHighlight(strtolower($meta->name))
) {
$column = PMA_substr($column, 0, $GLOBALS['cfg']['LimitChars'])
. '...';
Expand Down
46 changes: 46 additions & 0 deletions libraries/mysql_schema_relation.lib.php
@@ -0,0 +1,46 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}

/**
* This global variable represent the details for generating links inside
* mysql schema.
* Major element represent a table
*
* This global variable has not modified anywhere
*/
$GLOBALS['mysql_schema_relation'] = array(
'db' => array(
'db' => array(
'link_params' => array('db'),
'default_page' => 'index.php'
),
'user' => array(
'link_params' => array('username'),
'default_page' => 'server_privileges.php'
)

),
'proc' => array(
'db' => array(
'link_params' => array('db'),
'default_page' => 'index.php'
)

),
'user' => array(
'user' => array(
'link_params' => array('username'),
'default_page' => 'server_privileges.php'
)

)
);

?>
Expand Up @@ -45,9 +45,12 @@ public static function getInfo()
*/
public function applyTransformation($buffer, $options = array(), $meta = '')
{

$append_part = (isset($options[2]) && $options[2]) ? '' : $buffer;

$transform_options = array (
'string' => '<a href="'
. PMA_linkURL((isset($options[0]) ? $options[0] : '') . $buffer)
. PMA_linkURL((isset($options[0]) ? $options[0] : '') . $append_part)
. '" title="' . (isset($options[1]) ? $options[1] : '')
. '">' . (isset($options[1]) ? $options[1] : $buffer) . '</a>'
);
Expand Down

0 comments on commit 3b78768

Please sign in to comment.