Esempio n. 1
0
/**
 * Creates a fieldset for adding a new item, if the user has the privileges.
 *
 * @param string $docu String used to create a link to the MySQL docs
 * @param string $priv Privilege to check for adding a new item
 * @param string $name MySQL name of the item
 *
 * @return string An HTML snippet with the link to add a new item
 */
function PMA_RTE_getFooterLinks($docu, $priv, $name)
{
    global $db, $url_query, $ajax_class;
    $icon = 'b_' . strtolower($name) . '_add.png';
    $retval = "";
    $retval .= "<!-- ADD " . $name . " FORM START -->\n";
    $retval .= "<fieldset class='left'>\n";
    $retval .= "    <legend>" . _pgettext('Create new procedure', 'New') . "</legend>\n";
    $retval .= "        <div class='wrap'>\n";
    if (PMA_Util::currentUserHasPrivilege($priv, $db)) {
        $retval .= "            <a {$ajax_class['add']} ";
        $retval .= "href='db_" . strtolower($name) . "s.php";
        $retval .= "?{$url_query}&amp;add_item=1'>";
        $retval .= PMA_Util::getIcon($icon);
        $retval .= PMA_RTE_getWord('add') . "</a>\n";
    } else {
        $retval .= "            " . PMA_Util::getIcon($icon);
        $retval .= PMA_RTE_getWord('no_create') . "\n";
    }
    $retval .= "            " . PMA_Util::showMySQLDocu('SQL-Syntax', $docu) . "\n";
    $retval .= "        </div>\n";
    $retval .= "</fieldset>\n";
    $retval .= "<!-- ADD " . $name . " FORM END -->\n\n";
    return $retval;
}
 /**
  * Test for showPHPDocu
  *
  * @return void
  */
 function testShowPHPDocu()
 {
     $target = "docu";
     $lang = _pgettext('PHP documentation language', 'en');
     $expected = '<a href="./url.php?url=http%3A%2F%2Fphp.net%2Fmanual%2F' . $lang . '%2F' . $target . '" target="documentation">' . '<img src="themes/dot.gif" title="' . __('Documentation') . '" alt="' . __('Documentation') . '" class="icon ic_b_help" /></a>';
     $this->assertEquals($expected, PMA\libraries\Util::showPHPDocu($target));
 }
Esempio n. 3
0
/**
 * Creates a fieldset for adding a new item, if the user has the privileges.
 *
 * @param string $docu String used to create a link to the MySQL docs
 * @param string $priv Privilege to check for adding a new item
 * @param string $name MySQL name of the item
 *
 * @return string An HTML snippet with the link to add a new item
 */
function PMA_RTE_getFooterLinks($docu, $priv, $name)
{
    global $db, $table, $url_query, $ajax_class;
    $icon = mb_strtolower($name) . '_add.png';
    $retval = "";
    $retval .= "<!-- ADD " . $name . " FORM START -->\n";
    $retval .= "<fieldset class='left'>\n";
    $retval .= "<legend>" . _pgettext('Create new procedure', 'New') . "</legend>\n";
    $retval .= "        <div class='wrap'>\n";
    if (PMA\libraries\Util::currentUserHasPrivilege($priv, $db, $table)) {
        $retval .= "            <a {$ajax_class['add']} ";
        $retval .= "href='db_" . mb_strtolower($name) . "s.php";
        $retval .= "{$url_query}&amp;add_item=1' ";
        $retval .= "onclick='\$.datepicker.initialized = false;'>";
        $icon = 'b_' . $icon;
        $retval .= PMA\libraries\Util::getIcon($icon);
        $retval .= PMA_RTE_getWord('add') . "</a>\n";
    } else {
        $icon = 'bd_' . $icon;
        $retval .= PMA\libraries\Util::getIcon($icon);
        $retval .= PMA_RTE_getWord('add') . "\n";
    }
    $retval .= "            " . PMA\libraries\Util::showMySQLDocu($docu) . "\n";
    $retval .= "        </div>\n";
    $retval .= "</fieldset>\n";
    $retval .= "<!-- ADD " . $name . " FORM END -->\n\n";
    return $retval;
}
Esempio n. 4
0
 public function testGettext()
 {
     $this->assertEquals('Typ', _gettext('Type'));
     $this->assertEquals('Typ', __('Type'));
     $this->assertEquals('%d sekundy', _ngettext('%d second', '%d seconds', 2));
     $this->assertEquals('%d seconds', _npgettext('context', '%d second', '%d seconds', 2));
     $this->assertEquals('Tabulka', _pgettext('Display format', 'Table'));
 }
Esempio n. 5
0
 function testShwoPHPDocuNotReplaceHelpImg()
 {
     $GLOBALS['cfg']['ReplaceHelpImg'] = false;
     $target = "docu";
     $lang = _pgettext('PHP documentation language', 'en');
     $expected = '[<a href="./url.php?url=http%3A%2F%2Fphp.net%2Fmanual%2F' . $lang . '%2F' . $target . '&amp;server=99&amp;lang=en&amp;token=token' . '" target="documentation">' . __('Documentation') . '</a>]';
     $this->assertEquals($expected, PMA_showPHPDocu($target));
 }
Esempio n. 6
0
 public function testPMA_getPHPDocLink()
 {
     $lang = _pgettext('PHP documentation language', 'en');
     $this->assertEquals(
         PMA_getPHPDocLink('function'),
         './url.php?url=http%3A%2F%2Fphp.net%2Fmanual%2F'
         . $lang . '%2Ffunction&amp;server=99&amp;lang=en&amp;token=token'
     );
 }
 /**
  * Initialises the class
  *
  * @param string $name An identifier for the new node
  *
  * @return Node_Database_Container
  */
 public function __construct($name)
 {
     parent::__construct($name, Node::CONTAINER);
     $new = PMA_NodeFactory::getInstance('Node', _pgettext('Create new database', 'New'));
     $new->isNew = $GLOBALS['is_create_db_priv'];
     $new->icon = PMA_Util::getImage('b_newdb.png', '');
     $new->links = array('text' => 'server_databases.php?server=' . $GLOBALS['server'] . '&amp;token=' . $GLOBALS['token'], 'icon' => 'server_databases.php?server=' . $GLOBALS['server'] . '&amp;token=' . $GLOBALS['token']);
     $new->classes = 'new_database italics';
     $this->addChild($new);
 }
 /**
  * Tests for PMA_getHtmlForChartTypeOptions() method.
  *
  * @return void
  * @test
  */
 public function testPMAGetHtmlForChartTypeOptions()
 {
     $html = PMA_getHtmlForChartTypeOptions();
     $this->assertContains(_pgettext('Chart type', 'Bar'), $html);
     $this->assertContains(_pgettext('Chart type', 'Column'), $html);
     $this->assertContains(_pgettext('Chart type', 'Line'), $html);
     $this->assertContains(_pgettext('Chart type', 'Spline'), $html);
     $this->assertContains(_pgettext('Chart type', 'Area'), $html);
     $this->assertContains(_pgettext('Chart type', 'Pie'), $html);
     $this->assertContains(_pgettext('Chart type', 'Timeline'), $html);
 }
 /**
  * Initialises the class
  *
  * @param string $name An identifier for the new node
  */
 public function __construct($name)
 {
     parent::__construct($name, Node::CONTAINER);
     if ($GLOBALS['is_create_db_priv'] && $GLOBALS['cfg']['ShowCreateDb'] !== false) {
         $new = NodeFactory::getInstance('Node', _pgettext('Create new database', 'New'));
         $new->isNew = true;
         $new->icon = PMA\libraries\Util::getImage('b_newdb.png', '');
         $new->links = array('text' => 'server_databases.php?server=' . $GLOBALS['server'], 'icon' => 'server_databases.php?server=' . $GLOBALS['server']);
         $new->classes = 'new_database italics';
         $this->addChild($new);
     }
 }
 /**
  * Initialises the class
  *
  * @return Node_Column_Container
  */
 public function __construct()
 {
     parent::__construct(__('Columns'), Node::CONTAINER);
     $this->icon = PMA_Util::getImage('pause.png', '');
     $this->links = array('text' => 'tbl_structure.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;table=%1$s' . '&amp;token=' . $GLOBALS['token'], 'icon' => 'tbl_structure.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;table=%1$s' . '&amp;token=' . $GLOBALS['token']);
     $this->real_name = 'columns';
     $new = PMA_NodeFactory::getInstance('Node', _pgettext('Create new column', 'New'));
     $new->isNew = true;
     $new->icon = PMA_Util::getImage('b_column_add.png', '');
     $new->links = array('text' => 'tbl_addfield.php?server=' . $GLOBALS['server'] . '&amp;db=%3$s&amp;table=%2$s' . '&amp;field_where=last&after_field=' . '&amp;token=' . $GLOBALS['token'], 'icon' => 'tbl_addfield.php?server=' . $GLOBALS['server'] . '&amp;db=%3$s&amp;table=%2$s' . '&amp;field_where=last&after_field=' . '&amp;token=' . $GLOBALS['token']);
     $new->classes = 'new_column italics';
     $this->addChild($new);
 }
 /**
  * Initialises the class
  *
  * @return Node_Column_Container
  */
 public function __construct()
 {
     parent::__construct(__('Functions'), Node::CONTAINER);
     $this->icon = PMA_Util::getImage('b_routines.png');
     $this->links = array('text' => 'db_routines.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s&amp;token=' . $GLOBALS['token'], 'icon' => 'db_routines.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s&amp;token=' . $GLOBALS['token']);
     $this->real_name = 'functions';
     $new = PMA_NodeFactory::getInstance('Node', _pgettext('Create new function', 'New'));
     $new->isNew = true;
     $new->icon = PMA_Util::getImage('b_routine_add.png', '');
     $new->links = array('text' => 'db_routines.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;token=' . $GLOBALS['token'] . '&add_item=1&amp;item_type=FUNCTION', 'icon' => 'db_routines.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;token=' . $GLOBALS['token'] . '&add_item=1&amp;item_type=FUNCTION');
     $new->classes = 'new_function italics';
     $this->addChild($new);
 }
    function testShowPHPDocu()
    {
        $target = "docu";
        $lang = _pgettext('PHP documentation language', 'en');
        $expected = '<a href="./url.php?url=http%3A%2F%2Fphp.net%2Fmanual%2F' . $lang
            . '%2F' . $target . '&amp;server=99&amp;lang=en&amp;token=token'
            . '" target="documentation"><img src="themes/dot.gif" title="'
            . __('Documentation') . '" alt="' . __('Documentation') . '" class="icon ic_b_help" /></a>';

        $this->assertEquals(
            $expected, PMA_CommonFunctions::getInstance()->showPHPDocu($target)
        );
    }
 /**
  * Initialises the class
  *
  * @return Node_Event_Container
  */
 public function __construct()
 {
     parent::__construct(__('Events'), Node::CONTAINER);
     $this->icon = PMA_Util::getImage('b_events.png', '');
     $this->links = array('text' => 'db_events.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s&amp;token=' . $_SESSION[' PMA_token '], 'icon' => 'db_events.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s&amp;token=' . $_SESSION[' PMA_token ']);
     $this->real_name = 'events';
     $new = PMA_NodeFactory::getInstance('Node', _pgettext('Create new event', 'New'));
     $new->isNew = true;
     $new->icon = PMA_Util::getImage('b_event_add.png', '');
     $new->links = array('text' => 'db_events.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token '] . '&add_item=1', 'icon' => 'db_events.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token '] . '&add_item=1');
     $new->classes = 'new_event italics';
     $this->addChild($new);
 }
 /**
  * Initialises the class
  *
  * @return Node_View_Container
  */
 public function __construct()
 {
     parent::__construct(__('Views'), Node::CONTAINER);
     $this->icon = PMA_Util::getImage('b_views.png', '');
     $this->links = array('text' => 'db_structure.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s&amp;token=' . $GLOBALS['token'], 'icon' => 'db_structure.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s&amp;token=' . $GLOBALS['token']);
     $this->real_name = 'views';
     $new = PMA_NodeFactory::getInstance('Node', _pgettext('Create new view', 'New'));
     $new->isNew = true;
     $new->icon = PMA_Util::getImage('b_view_add.png', '');
     $new->links = array('text' => 'view_create.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;token=' . $GLOBALS['token'], 'icon' => 'view_create.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;token=' . $GLOBALS['token']);
     $new->classes = 'new_view italics';
     $this->addChild($new);
 }
 /**
  * Initialises the class
  *
  * @return Node_Index_Container
  */
 public function __construct()
 {
     parent::__construct(__('Indexes'), Node::CONTAINER);
     $this->icon = PMA_Util::getImage('b_index.png', '');
     $this->links = array('text' => 'tbl_structure.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;table=%1$s' . '&amp;token=' . $GLOBALS['token'], 'icon' => 'tbl_structure.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;table=%1$s' . '&amp;token=' . $GLOBALS['token']);
     $this->real_name = 'indexes';
     $new = PMA_NodeFactory::getInstance('Node', _pgettext('Create new index', 'New'));
     $new->isNew = true;
     $new->icon = PMA_Util::getImage('b_index_add.png', '');
     $new->links = array('text' => 'tbl_indexes.php?server=' . $GLOBALS['server'] . '&amp;create_index=1&amp;added_fields=2' . '&amp;db=%3$s&amp;table=%2$s&amp;token=' . $GLOBALS['token'], 'icon' => 'tbl_indexes.php?server=' . $GLOBALS['server'] . '&amp;create_index=1&amp;added_fields=2' . '&amp;db=%3$s&amp;table=%2$s&amp;token=' . $GLOBALS['token']);
     $new->classes = 'new_index italics';
     $this->addChild($new);
 }
 /**
  * Initialises the class
  */
 public function __construct()
 {
     parent::__construct(__('Triggers'), Node::CONTAINER);
     $this->icon = PMA\libraries\Util::getImage('b_triggers.png');
     $this->links = array('text' => 'db_triggers.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;table=%1$s', 'icon' => 'db_triggers.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;table=%1$s');
     $this->real_name = 'triggers';
     $new = NodeFactory::getInstance('Node', _pgettext('Create new trigger', 'New'));
     $new->isNew = true;
     $new->icon = PMA\libraries\Util::getImage('b_trigger_add.png', '');
     $new->links = array('text' => 'db_triggers.php?server=' . $GLOBALS['server'] . '&amp;db=%3$s&amp;add_item=1', 'icon' => 'db_triggers.php?server=' . $GLOBALS['server'] . '&amp;db=%3$s&amp;add_item=1');
     $new->classes = 'new_trigger italics';
     $this->addChild($new);
 }
 /**
  * Initialises the class
  *
  * @return Node_Procedure_Container
  */
 public function __construct()
 {
     parent::__construct(__('Procedures'), Node::CONTAINER);
     $this->icon = PMA_Util::getImage('b_routines.png', __('Procedures'));
     $this->links = array('text' => 'db_routines.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s&amp;token=' . $_SESSION[' PMA_token '] . '&amp;type=PROCEDURE', 'icon' => 'db_routines.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s&amp;token=' . $_SESSION[' PMA_token '] . '&amp;type=PROCEDURE');
     $this->real_name = 'procedures';
     $new_label = _pgettext('Create new procedure', 'New');
     $new = PMA_NodeFactory::getInstance('Node', $new_label);
     $new->isNew = true;
     $new->icon = PMA_Util::getImage('b_routine_add.png', $new_label);
     $new->links = array('text' => 'db_routines.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token '] . '&add_item=1', 'icon' => 'db_routines.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token '] . '&add_item=1');
     $new->classes = 'new_procedure italics';
     $this->addChild($new);
 }
 /**
  * Initialises the class
  */
 public function __construct()
 {
     parent::__construct(__('Tables'), Node::CONTAINER);
     $this->icon = PMA_Util::getImage('b_browse.png', __('Tables'));
     $this->links = array('text' => 'db_structure.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s&amp;tbl_type=table' . '&amp;token=' . $_SESSION[' PMA_token '], 'icon' => 'db_structure.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s&amp;tbl_type=table' . '&amp;token=' . $_SESSION[' PMA_token ']);
     $this->real_name = 'tables';
     $this->classes = 'tableContainer subContainer';
     $new_label = _pgettext('Create new table', 'New');
     $new = PMA_NodeFactory::getInstance('Node', $new_label);
     $new->isNew = true;
     $new->icon = PMA_Util::getImage('b_table_add.png', $new_label);
     $new->links = array('text' => 'tbl_create.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token '], 'icon' => 'tbl_create.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token ']);
     $new->classes = 'new_table italics';
     $this->addChild($new);
 }
Esempio n. 19
0
 /**
  * Initialises the class
  */
 public function __construct()
 {
     parent::__construct(__('Views'), Node::CONTAINER);
     $this->icon = PMA\libraries\Util::getImage('b_views.png', __('Views'));
     $this->links = array('text' => 'db_structure.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s&amp;tbl_type=view', 'icon' => 'db_structure.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s&amp;tbl_type=view');
     $this->classes = 'viewContainer subContainer';
     $this->real_name = 'views';
     $new_label = _pgettext('Create new view', 'New');
     $new = NodeFactory::getInstance('Node', $new_label);
     $new->isNew = true;
     $new->icon = PMA\libraries\Util::getImage('b_view_add.png', $new_label);
     $new->links = array('text' => 'view_create.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s', 'icon' => 'view_create.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s');
     $new->classes = 'new_view italics';
     $this->addChild($new);
 }
Esempio n. 20
0
/**
 * prints out diagnostic info for pma relation feature
 *
 * @param array $cfgRelation
 *
 * @return void
 */
function PMA_printRelationsParamDiagnostic($cfgRelation)
{
    $messages['error'] = '<font color="red"><strong>' . __('not OK') . '</strong></font> [ <a href="Documentation.html#%s" target="documentation">' . __('Documentation') . '</a> ]';
    $messages['ok'] = '<font color="green"><strong>' . _pgettext('Correctly working', 'OK') . '</strong></font>';
    $messages['enabled'] = '<font color="green">' . __('Enabled') . '</font>';
    $messages['disabled'] = '<font color="red">' . __('Disabled') . '</font>';
    if (false === $GLOBALS['cfg']['Server']['pmadb']) {
        echo 'PMA Database ... ' . sprintf($messages['error'], 'pmadb') . '<br />' . "\n" . __('General relation features') . ' <font color="green">' . __('Disabled') . '</font>' . "\n";
        return;
    }
    echo '<table>' . "\n";
    PMA_printDiagMessageForParameter('pmadb', $GLOBALS['cfg']['Server']['pmadb'], $messages, 'pmadb');
    PMA_printDiagMessageForParameter('relation', isset($cfgRelation['relation']), $messages, 'relation');
    PMA_printDiagMessageForFeature(__('General relation features'), 'relwork', $messages);
    PMA_printDiagMessageForParameter('table_info', isset($cfgRelation['table_info']), $messages, 'table_info');
    PMA_printDiagMessageForFeature(__('Display Features'), 'displaywork', $messages);
    PMA_printDiagMessageForParameter('table_coords', isset($cfgRelation['table_coords']), $messages, 'table_coords');
    PMA_printDiagMessageForParameter('pdf_pages', isset($cfgRelation['pdf_pages']), $messages, 'table_coords');
    PMA_printDiagMessageForFeature(__('Creation of PDFs'), 'pdfwork', $messages);
    PMA_printDiagMessageForParameter('column_info', isset($cfgRelation['column_info']), $messages, 'col_com');
    PMA_printDiagMessageForFeature(__('Displaying Column Comments'), 'commwork', $messages, false);
    PMA_printDiagMessageForFeature(__('Browser transformation'), 'mimework', $messages);
    if ($cfgRelation['commwork'] && !$cfgRelation['mimework']) {
        echo '<tr><td colspan=2 class="left">' . __('Please see the documentation on how to update your column_comments table') . '</td></tr>' . "\n";
    }
    PMA_printDiagMessageForParameter('bookmarktable', isset($cfgRelation['bookmark']), $messages, 'bookmark');
    PMA_printDiagMessageForFeature(__('Bookmarked SQL query'), 'bookmarkwork', $messages);
    PMA_printDiagMessageForParameter('history', isset($cfgRelation['history']), $messages, 'history');
    PMA_printDiagMessageForFeature(__('SQL history'), 'historywork', $messages);
    PMA_printDiagMessageForParameter('designer_coords', isset($cfgRelation['designer_coords']), $messages, 'designer_coords');
    PMA_printDiagMessageForFeature(__('Designer'), 'designerwork', $messages);
    PMA_printDiagMessageForParameter('recent', isset($cfgRelation['recent']), $messages, 'recent');
    PMA_printDiagMessageForFeature(__('Persistent recently used tables'), 'recentwork', $messages);
    PMA_printDiagMessageForParameter('table_uiprefs', isset($cfgRelation['table_uiprefs']), $messages, 'table_uiprefs');
    PMA_printDiagMessageForFeature(__('Persistent tables\' UI preferences'), 'uiprefswork', $messages);
    PMA_printDiagMessageForParameter('tracking', isset($cfgRelation['tracking']), $messages, 'tracking');
    PMA_printDiagMessageForFeature(__('Tracking'), 'trackingwork', $messages);
    PMA_printDiagMessageForParameter('userconfig', isset($cfgRelation['userconfig']), $messages, 'userconfig');
    PMA_printDiagMessageForFeature(__('User preferences'), 'userconfigwork', $messages);
    echo '</table>' . "\n";
    echo '<p>' . __('Quick steps to setup advanced features:') . '</p>';
    echo '<ul>';
    echo '<li>' . __('Create the needed tables with the <code>examples/create_tables.sql</code>.') . ' ' . PMA_showDocu('linked-tables') . '</li>';
    echo '<li>' . __('Create a pma user and give access to these tables.') . ' ' . PMA_showDocu('pmausr') . '</li>';
    echo '<li>' . __('Enable advanced features in configuration file (<code>config.inc.php</code>), for example by starting from <code>config.sample.inc.php</code>.') . ' ' . PMA_showDocu('quick_install') . '</li>';
    echo '<li>' . __('Re-login to phpMyAdmin to load the updated configuration file.') . '</li>';
    echo '</ul>';
}
 /**
  * Initialises the class
  *
  * @return Node_Table_Container
  */
 public function __construct()
 {
     parent::__construct(__('Tables'), Node::CONTAINER);
     $this->icon = PMA_Util::getImage('b_browse.png', '');
     $this->links = array('text' => 'db_structure.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s&amp;token=' . $GLOBALS['token'], 'icon' => 'db_structure.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s&amp;token=' . $GLOBALS['token']);
     if ($GLOBALS['cfg']['NavigationTreeEnableGrouping']) {
         $this->separator = $GLOBALS['cfg']['NavigationTreeTableSeparator'];
         $this->separator_depth = (int) $GLOBALS['cfg']['NavigationTreeTableLevel'];
     }
     $this->real_name = 'tables';
     $new = PMA_NodeFactory::getInstance('Node', _pgettext('Create new table', 'New'));
     $new->isNew = true;
     $new->icon = PMA_Util::getImage('b_table_add.png', '');
     $new->links = array('text' => 'tbl_create.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;token=' . $GLOBALS['token'], 'icon' => 'tbl_create.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;token=' . $GLOBALS['token']);
     $new->classes = 'new_table italics';
     $this->addChild($new);
 }
 /**
  * Initialises the class
  *
  * @return Node_View_Container
  */
 public function __construct()
 {
     parent::__construct(__('Views'), Node::CONTAINER);
     $this->icon = PMA_Util::getImage('b_views.png', __('Views'));
     $this->links = array('text' => 'db_structure.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s&amp;tbl_type=view' . '&amp;token=' . $_SESSION[' PMA_token '], 'icon' => 'db_structure.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s&amp;tbl_type=view' . '&amp;token=' . $_SESSION[' PMA_token ']);
     if ($GLOBALS['cfg']['NavigationTreeEnableGrouping']) {
         $this->separator = $GLOBALS['cfg']['NavigationTreeTableSeparator'];
         $this->separator_depth = (int) $GLOBALS['cfg']['NavigationTreeTableLevel'];
     }
     $this->classes = 'viewContainer subContainer';
     $this->real_name = 'views';
     $new_label = _pgettext('Create new view', 'New');
     $new = PMA_NodeFactory::getInstance('Node', $new_label);
     $new->isNew = true;
     $new->icon = PMA_Util::getImage('b_view_add.png', $new_label);
     $new->links = array('text' => 'view_create.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token '], 'icon' => 'view_create.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token ']);
     $new->classes = 'new_view italics';
     $this->addChild($new);
 }
/**
 * Creates a fieldset for adding a new item, if the user has the privileges.
 *
 * @param string $docu String used to create a link to the MySQL docs
 * @param string $priv Privilege to check for adding a new item
 * @param string $name MySQL name of the item
 *
 * @return string An HTML snippet with the link to add a new item
 */
function PMA_RTE_getFooterLinks($docu, $priv, $name)
{
    global $db, $url_query, $ajax_class;
    /** @var PMA_String $pmaString */
    $pmaString = $GLOBALS['PMA_String'];
    $icon = 'b_' . $pmaString->strtolower($name) . '_add.png';
    $retval = "";
    $retval .= "<!-- ADD " . $name . " FORM START -->\n";
    $retval .= "<fieldset class='left'>\n";
    $retval .= "<legend>" . _pgettext('Create new procedure', 'New') . "</legend>\n";
    $retval .= "        <div class='wrap'>\n";
    $retval .= "            <a {$ajax_class['add']} ";
    $retval .= "href='db_" . $pmaString->strtolower($name) . "s.php";
    $retval .= "?{$url_query}&amp;add_item=1' onclick='\$.datepicker.initialized = false;'>";
    $retval .= PMA_Util::getIcon($icon);
    $retval .= PMA_RTE_getWord('add') . "</a>\n";
    $retval .= "            " . PMA_Util::showMySQLDocu($docu) . "\n";
    $retval .= "        </div>\n";
    $retval .= "</fieldset>\n";
    $retval .= "<!-- ADD " . $name . " FORM END -->\n\n";
    return $retval;
}
/**
 * Get HTML for display Add userfieldset
 *
 * @param string $db    the database
 * @param string $table the table name
 *
 * @return string html output
 */
function PMA_getAddUserHtmlFieldset($db = '', $table = '')
{
    if (!$GLOBALS['is_createuser']) {
        return '';
    }
    $rel_params = array();
    $url_params = array('adduser' => 1);
    if (!empty($db)) {
        $url_params['dbname'] = $rel_params['checkprivsdb'] = $db;
    }
    if (!empty($table)) {
        $url_params['tablename'] = $rel_params['checkprivstable'] = $table;
    }
    return '<fieldset id="fieldset_add_user">' . "\n" . '<legend>' . _pgettext('Create new user', 'New') . '</legend>' . '<a id="add_user_anchor" href="server_privileges.php' . PMA_URL_getCommon($url_params) . '" ' . (!empty($rel_params) ? 'rel="' . PMA_URL_getCommon($rel_params) . '" ' : '') . '>' . "\n" . PMA_Util::getIcon('b_usradd.png') . '            ' . __('Add user') . '</a>' . "\n" . '</fieldset>' . "\n";
}
 /**
  * Tests for PMA_getHtmlForColumns() method.
  *
  * @return void
  * @test
  */
 public function testPMAGetHtmlForColumns()
 {
     $columns = array(array('Field' => 'Field1', 'Type' => 'Type1', 'Collation' => 'Collation1', "Null" => 'YES', 'Extra' => 'Extra1', 'Key' => 'PRI', 'Comment' => 'Comment1'), array('Field' => 'Field2', 'Type' => 'Type2', 'Collation' => 'Collation2', "Null" => 'No', 'Extra' => 'Extra2', 'Key' => 'Key2', 'Comment' => 'Comment2'));
     $html = PMA_getHtmlForColumns($columns);
     $this->assertContains(__('Column'), $html);
     $this->assertContains(__('Type'), $html);
     $this->assertContains(__('Collation'), $html);
     $this->assertContains(__('Default'), $html);
     $this->assertContains(__('Comment'), $html);
     //column1
     $item1 = $columns[0];
     $this->assertContains(htmlspecialchars($item1['Field']), $html);
     $this->assertContains(htmlspecialchars($item1['Type']), $html);
     $this->assertContains(htmlspecialchars($item1['Collation']), $html);
     $this->assertContains('<i>NULL</i>', $html);
     $this->assertContains(htmlspecialchars($item1['Comment']), $html);
     //column2
     $item1 = $columns[1];
     $this->assertContains(htmlspecialchars($item1['Field']), $html);
     $this->assertContains(htmlspecialchars($item1['Type']), $html);
     $this->assertContains(htmlspecialchars($item1['Collation']), $html);
     $this->assertContains(_pgettext('None for default', 'None'), $html);
     $this->assertContains(htmlspecialchars($item1['Comment']), $html);
 }
Esempio n. 26
0
/**
 * prints out diagnostic info for pma relation feature
 *
 * @param array $cfgRelation Relation configuration
 *
 * @return string
 */
function PMA_getRelationsParamDiagnostic($cfgRelation)
{
    $retval = '';
    $messages = array();
    $messages['error'] = '<font color="red"><strong>' . __('not OK') . '</strong></font>';
    $messages['ok'] = '<font color="green"><strong>' . _pgettext('Correctly working', 'OK') . '</strong></font>';
    $messages['enabled'] = '<font color="green">' . __('Enabled') . '</font>';
    $messages['disabled'] = '<font color="red">' . __('Disabled') . '</font>';
    if (empty($cfgRelation['db'])) {
        $retval .= __('Configuration of pmadb… ') . $messages['error'] . PMA_Util::showDocu('setup', 'linked-tables') . '<br />' . "\n" . __('General relation features') . ' <font color="green">' . __('Disabled') . '</font>' . "\n";
        if (!empty($GLOBALS['db']) && $GLOBALS['cfg']['ZeroConf']) {
            $retval .= PMA_getHtmlFixPMATables(true);
        }
    } else {
        $retval .= '<table>' . "\n";
        if (!$cfgRelation['allworks'] && $GLOBALS['cfg']['ZeroConf']) {
            $retval .= PMA_getHtmlFixPMATables(false);
            $retval .= '<br />';
        }
        $retval .= PMA_getDiagMessageForParameter('pmadb', $cfgRelation['db'], $messages, 'pmadb');
        $retval .= PMA_getDiagMessageForParameter('relation', isset($cfgRelation['relation']), $messages, 'relation');
        $retval .= PMA_getDiagMessageForFeature(__('General relation features'), 'relwork', $messages);
        $retval .= PMA_getDiagMessageForParameter('table_info', isset($cfgRelation['table_info']), $messages, 'table_info');
        $retval .= PMA_getDiagMessageForFeature(__('Display Features'), 'displaywork', $messages);
        $retval .= PMA_getDiagMessageForParameter('table_coords', isset($cfgRelation['table_coords']), $messages, 'table_coords');
        $retval .= PMA_getDiagMessageForParameter('pdf_pages', isset($cfgRelation['pdf_pages']), $messages, 'pdf_pages');
        $retval .= PMA_getDiagMessageForFeature(__('Designer and creation of PDFs'), 'pdfwork', $messages);
        $retval .= PMA_getDiagMessageForParameter('column_info', isset($cfgRelation['column_info']), $messages, 'column_info');
        $retval .= PMA_getDiagMessageForFeature(__('Displaying Column Comments'), 'commwork', $messages, false);
        $retval .= PMA_getDiagMessageForFeature(__('Browser transformation'), 'mimework', $messages);
        if ($cfgRelation['commwork'] && !$cfgRelation['mimework']) {
            $retval .= '<tr><td colspan=2 class="left error">';
            $retval .= __('Please see the documentation on how to' . ' update your column_info table. ');
            $retval .= PMA_Util::showDocu('config', 'cfg_Servers_column_info');
            $retval .= '</td></tr>';
        }
        $retval .= PMA_getDiagMessageForParameter('bookmarktable', isset($cfgRelation['bookmark']), $messages, 'bookmark');
        $retval .= PMA_getDiagMessageForFeature(__('Bookmarked SQL query'), 'bookmarkwork', $messages);
        $retval .= PMA_getDiagMessageForParameter('history', isset($cfgRelation['history']), $messages, 'history');
        $retval .= PMA_getDiagMessageForFeature(__('SQL history'), 'historywork', $messages);
        $retval .= PMA_getDiagMessageForParameter('recent', isset($cfgRelation['recent']), $messages, 'recent');
        $retval .= PMA_getDiagMessageForFeature(__('Persistent recently used tables'), 'recentwork', $messages);
        $retval .= PMA_getDiagMessageForParameter('favorite', isset($cfgRelation['favorite']), $messages, 'favorite');
        $retval .= PMA_getDiagMessageForFeature(__('Persistent favorite tables'), 'favoritework', $messages);
        $retval .= PMA_getDiagMessageForParameter('table_uiprefs', isset($cfgRelation['table_uiprefs']), $messages, 'table_uiprefs');
        $retval .= PMA_getDiagMessageForFeature(__('Persistent tables\' UI preferences'), 'uiprefswork', $messages);
        $retval .= PMA_getDiagMessageForParameter('tracking', isset($cfgRelation['tracking']), $messages, 'tracking');
        $retval .= PMA_getDiagMessageForFeature(__('Tracking'), 'trackingwork', $messages);
        $retval .= PMA_getDiagMessageForParameter('userconfig', isset($cfgRelation['userconfig']), $messages, 'userconfig');
        $retval .= PMA_getDiagMessageForFeature(__('User preferences'), 'userconfigwork', $messages);
        $retval .= PMA_getDiagMessageForParameter('users', isset($cfgRelation['users']), $messages, 'users');
        $retval .= PMA_getDiagMessageForParameter('usergroups', isset($cfgRelation['usergroups']), $messages, 'usergroups');
        $retval .= PMA_getDiagMessageForFeature(__('Configurable menus'), 'menuswork', $messages);
        $retval .= PMA_getDiagMessageForParameter('navigationhiding', isset($cfgRelation['navigationhiding']), $messages, 'navigationhiding');
        $retval .= PMA_getDiagMessageForFeature(__('Hide/show navigation items'), 'navwork', $messages);
        $retval .= PMA_getDiagMessageForParameter('savedsearches', isset($cfgRelation['savedsearches']), $messages, 'savedsearches');
        $retval .= PMA_getDiagMessageForFeature(__('Saving Query-By-Example searches'), 'savedsearcheswork', $messages);
        $retval .= PMA_getDiagMessageForParameter('central_columns', isset($cfgRelation['central_columns']), $messages, 'central_columns');
        $retval .= PMA_getDiagMessageForFeature(__('Managing Central list of columns'), 'central_columnswork', $messages);
        $retval .= '</table>' . "\n";
        if (!$cfgRelation['allworks']) {
            $retval .= '<p>' . __('Quick steps to setup advanced features:') . '</p>';
            $retval .= '<ul>';
            $retval .= '<li>';
            $retval .= sprintf(__('Create the needed tables with the ' . '<code>%screate_tables.sql</code>.'), htmlspecialchars(SQL_DIR));
            $retval .= ' ' . PMA_Util::showDocu('setup', 'linked-tables');
            $retval .= '</li>';
            $retval .= '<li>';
            $retval .= __('Create a pma user and give access to these tables.');
            $retval .= ' ' . PMA_Util::showDocu('config', 'cfg_Servers_controluser');
            $retval .= '</li>';
            $retval .= '<li>';
            $retval .= __('Enable advanced features in configuration file ' . '(<code>config.inc.php</code>), for example by ' . 'starting from <code>config.sample.inc.php</code>.');
            $retval .= ' ' . PMA_Util::showDocu('setup', 'quick-install');
            $retval .= '</li>';
            $retval .= '<li>';
            $retval .= __('Re-login to phpMyAdmin to load the updated configuration file.');
            $retval .= '</li>';
            $retval .= '</ul>';
        }
    }
    return $retval;
}
Esempio n. 27
0
/**
 * Displays on which column(s) a table-specific privilege is granted
 *
 * @param array  $columns
 * @param array  $row
 * @param string $name_for_select
 * @param string $priv_for_header
 * @param string $name
 * @param string $name_for_dfn
 * @param string $name_for_current
 *
 * @return void
 */
function PMA_displayColumnPrivs($columns, $row, $name_for_select,
    $priv_for_header, $name, $name_for_dfn, $name_for_current
) {
    echo '    <div class="item" id="div_item_' . $name . '">' . "\n"
       . '        <label for="select_' . $name . '_priv">' . "\n"
       . '            <code><dfn title="' . $name_for_dfn . '">'
        . $priv_for_header . '</dfn></code>' . "\n"
       . '        </label><br />' . "\n"
       . '        <select id="select_' . $name . '_priv" name="'
        . $name_for_select . '[]" multiple="multiple" size="8">' . "\n";

    foreach ($columns as $current_column => $current_column_privileges) {
        echo '            <option value="' . htmlspecialchars($current_column) . '"';
        if ($row[$name_for_select] == 'Y' || $current_column_privileges[$name_for_current]) {
            echo ' selected="selected"';
        }
        echo '>' . htmlspecialchars($current_column) . '</option>' . "\n";
    }

    echo '        </select>' . "\n"
       . '        <i>' . __('Or') . '</i>' . "\n"
       . '        <label for="checkbox_' . $name_for_select
        . '_none"><input type="checkbox"'
        . (empty($GLOBALS['checkall']) ?  '' : ' checked="checked"')
        . ' name="' . $name_for_select . '_none" id="checkbox_'
        . $name_for_select . '_none" title="'
        . _pgettext('None privileges', 'None') . '" />'
        . _pgettext('None privileges', 'None') . '</label>' . "\n"
       . '    </div>' . "\n";
} // end function
 /**
  * Test for PMA_getHtmlForSpecificTablePrivileges
  *
  * @return void
  */
 public function testPMAGetHtmlForSpecificTablePrivileges()
 {
     $dbi_old = $GLOBALS['dbi'];
     $dbi = $this->getMockBuilder('PMA\\libraries\\DatabaseInterface')->disableOriginalConstructor()->getMock();
     $fields_info = array(array('COLUMN_NAME' => 'Host', 'CHARACTER_MAXIMUM_LENGTH' => 80), array('COLUMN_NAME' => 'User', 'CHARACTER_MAXIMUM_LENGTH' => 40));
     $dbi->expects($this->any())->method('fetchResult')->will($this->returnValue($fields_info));
     $GLOBALS['dbi'] = $dbi;
     $db = "pma_dbname";
     $table = "pma_table";
     $html = PMA_getHtmlForSpecificTablePrivileges($db, $table);
     //validate 1: $db, $table
     $this->assertContains(htmlspecialchars($db) . '.' . htmlspecialchars($table), $html);
     //validate 2: PMA_URL_getCommon
     $item = PMA_URL_getCommon(array('db' => $db, 'table' => $table));
     $this->assertContains($item, $html);
     //validate 3: items
     $this->assertContains(__('User'), $html);
     $this->assertContains(__('Host'), $html);
     $this->assertContains(__('Type'), $html);
     $this->assertContains(__('Privileges'), $html);
     $this->assertContains(__('Grant'), $html);
     $this->assertContains(__('Action'), $html);
     //_pgettext('Create new user', 'New')
     $this->assertContains(_pgettext('Create new user', 'New'), $html);
     $this->assertContains(PMA_URL_getCommon(array('checkprivsdb' => $db, 'checkprivstable' => $table)), $html);
     $GLOBALS['dbi'] = $dbi_old;
 }
 /**
  * Returns array of all column types available.
  *
  * @return string[]
  *
  */
 public function getColumns()
 {
     $types_num = array('INTEGER', 'BIGINT', '-', 'DECIMAL', 'DOUBLE', '-', 'BOOLEAN', 'SERIAL', 'UUID');
     $types_date = array('DATE', 'DATETIME', 'TIMESTAMP', 'TIME');
     $types_string = array('VARCHAR', 'TEXT', '-', 'VARBINARY', 'BLOB', '-', 'ENUM');
     if (PMA_MYSQL_INT_VERSION >= 70132) {
         $types_string[] = '-';
         $types_string[] = 'IPV6';
     }
     $ret = parent::getColumns();
     // numeric
     $ret[_pgettext('numeric types', 'Numeric')] = $types_num;
     // Date/Time
     $ret[_pgettext('date and time types', 'Date and time')] = $types_date;
     // Text
     $ret[_pgettext('string types', 'String')] = $types_string;
     return $ret;
 }
Esempio n. 30
0
 /**
  * Prepare move forward buttons - next and last
  *
  * @param string  $html_sql_query the sql encoded by htmlspecialchars()
  * @param integer $pos_next       the offset for the "next" page
  * @param boolean $is_innodb      whether it's InnoDB or not
  *
  * @return  string  $buttons_html   html content
  *
  * @access  private
  *
  * @see     _getTableNavigation()
  */
 private function _getMoveForwardButtonsForTableNavigation($html_sql_query, $pos_next, $is_innodb)
 {
     // display the Next button
     $buttons_html = $this->_getTableNavigationButton('&gt;', _pgettext('Next page', 'Next'), $pos_next, $html_sql_query, false);
     // prepare some options for the End button
     if ($is_innodb && $this->__get('unlim_num_rows') > $GLOBALS['cfg']['MaxExactCount']) {
         $input_for_real_end = '<input id="real_end_input" type="hidden" ' . 'name="find_real_end" value="1" />';
         // no backquote around this message
         $onclick = '';
     } else {
         $input_for_real_end = $onclick = '';
     }
     $maxRows = $_SESSION['tmpval']['max_rows'];
     $onsubmit = 'onsubmit="return ' . ($_SESSION['tmpval']['pos'] + $maxRows < $this->__get('unlim_num_rows') && $this->__get('num_rows') >= $maxRows) ? 'true' : 'false' . '"';
     // display the End button
     $buttons_html .= $this->_getTableNavigationButton('&gt;&gt;', _pgettext('Last page', 'End'), @((ceil($this->__get('unlim_num_rows') / $_SESSION['tmpval']['max_rows']) - 1) * $maxRows), $html_sql_query, false, $onsubmit, $input_for_real_end, $onclick);
     return $buttons_html;
 }