Exemplo n.º 1
0
/**
 * Prints Html For Import Javascript
 *
 * @param int $upload_id The selected upload id
 *
 * @return string
 */
function PMA_getHtmlForImportJS($upload_id)
{
    global $SESSION_KEY;
    $html = '';
    $html .= '<script type="text/javascript">';
    $html .= '    //<![CDATA[';
    //with "\n", so that the following lines won't be commented out by //<![CDATA[
    $html .= "\n";
    $html .= '    $( function() {';
    // add event when user click on "Go" button
    $html .= '      $("#buttonGo").bind("click", function() {';
    // hide form
    $html .= '        $("#upload_form_form").css("display", "none");';
    if ($_SESSION[$SESSION_KEY]["handler"] != 'PMA\\libraries\\plugins\\import\\upload\\UploadNoplugin') {
        $html .= PMA_getHtmlForImportWithPlugin($upload_id);
    } else {
        // no plugin available
        $image_tag = '<img src="' . $GLOBALS['pmaThemeImage'] . 'ajax_clock_small.gif" width="16" height="16" alt="ajax clock" /> ' . PMA_jsFormat(__('Please be patient, the file is being uploaded. ' . 'Details about the upload are not available.'), false) . PMA\libraries\Util::showDocu('faq', 'faq2-9');
        $html .= "   \$('#upload_form_status_info').html('" . $image_tag . "');";
        $html .= '   $("#upload_form_status").css("display", "none");';
    }
    // else
    // onclick
    $html .= '      });';
    // domready
    $html .= '    });';
    $html .= '    //]]>';
    //with "\n", so that the following lines won't be commented out by //]]>
    $html .= "\n";
    $html .= '</script>';
    return $html;
}
/**
 * Returns HTML code for the language selector
 *
 * @param boolean $use_fieldset whether to use fieldset for selection
 * @param boolean $show_doc     whether to show documentation links
 *
 * @return string
 *
 * @access  public
 */
function PMA_getLanguageSelectorHtml($use_fieldset = false, $show_doc = true)
{
    global $lang;
    $retval = '';
    // Display language selection only if there
    // is more than one language to choose from
    if (count($GLOBALS['available_languages']) > 1) {
        $retval .= '<form method="get" action="index.php" class="disableAjax">';
        $_form_params = array('db' => $GLOBALS['db'], 'table' => $GLOBALS['table']);
        $retval .= PMA_URL_getHiddenInputs($_form_params);
        // For non-English, display "Language" with emphasis because it's
        // not a proper word in the current language; we show it to help
        // people recognize the dialog
        $language_title = __('Language') . (__('Language') != 'Language' ? ' - <em>Language</em>' : '');
        if ($show_doc) {
            $language_title .= PMA\libraries\Util::showDocu('faq', 'faq7-2');
        }
        if ($use_fieldset) {
            $retval .= '<fieldset><legend lang="en" dir="ltr">' . $language_title . '</legend>';
        } else {
            $retval .= '<bdo lang="en" dir="ltr"><label for="sel-lang">' . $language_title . ': </label></bdo>';
        }
        $retval .= '<select name="lang" class="autosubmit" lang="en"' . ' dir="ltr" id="sel-lang">';
        uasort($GLOBALS['available_languages'], 'PMA_languageCmp');
        foreach ($GLOBALS['available_languages'] as $id => $tmplang) {
            $lang_name = PMA_languageName($tmplang);
            //Is current one active?
            if ($lang == $id) {
                $selected = ' selected="selected"';
            } else {
                $selected = '';
            }
            $retval .= '<option value="' . $id . '"' . $selected . '>';
            $retval .= $lang_name;
            $retval .= '</option>';
        }
        $retval .= '</select>';
        if ($use_fieldset) {
            $retval .= '</fieldset>';
        }
        $retval .= '</form>';
    }
    return $retval;
}
/**
 * Returns single option in a list element
 *
 * @param string                                       $section        name of
 *                                                                     config
 *                                                                     section in
 *                                                                     $GLOBALS['cfg'][$section]
 *                                                                     for plugin
 * @param string                                       $plugin_name    unique plugin
 *                                                                     name
 * @param array|\PMA\libraries\properties\PropertyItem &$propertyGroup options
 *                                                                     property main
 *                                                                     group
 *                                                                     instance
 * @param boolean                                      $is_subgroup    if this group
 *                                                                     is a subgroup
 *
 * @return string  table row with option
 */
function PMA_pluginGetOneOption($section, $plugin_name, &$propertyGroup, $is_subgroup = false)
{
    $ret = "\n";
    if (!$is_subgroup) {
        // for subgroup headers
        if (mb_strpos(get_class($propertyGroup), "PropertyItem")) {
            $properties = array($propertyGroup);
        } else {
            // for main groups
            $ret .= '<div class="export_sub_options" id="' . $plugin_name . '_' . $propertyGroup->getName() . '">';
            if (method_exists($propertyGroup, 'getText')) {
                $text = $propertyGroup->getText();
            }
            if ($text != null) {
                $ret .= '<h4>' . PMA_getString($text) . '</h4>';
            }
            $ret .= '<ul>';
        }
    }
    if (!isset($properties)) {
        $not_subgroup_header = true;
        if (method_exists($propertyGroup, 'getProperties')) {
            $properties = $propertyGroup->getProperties();
        }
    }
    if (isset($properties)) {
        /** @var OptionsPropertySubgroup $propertyItem */
        foreach ($properties as $propertyItem) {
            $property_class = get_class($propertyItem);
            // if the property is a subgroup, we deal with it recursively
            if (mb_strpos($property_class, "Subgroup")) {
                // for subgroups
                // each subgroup can have a header, which may also be a form element
                /** @var OptionsPropertyItem $subgroup_header */
                $subgroup_header = $propertyItem->getSubgroupHeader();
                if (isset($subgroup_header)) {
                    $ret .= PMA_pluginGetOneOption($section, $plugin_name, $subgroup_header);
                }
                $ret .= '<li class="subgroup"><ul';
                if (isset($subgroup_header)) {
                    $ret .= ' id="ul_' . $subgroup_header->getName() . '">';
                } else {
                    $ret .= '>';
                }
                $ret .= PMA_pluginGetOneOption($section, $plugin_name, $propertyItem, true);
                continue;
            }
            // single property item
            $ret .= PMA_getHtmlForProperty($section, $plugin_name, $propertyItem);
        }
    }
    if ($is_subgroup) {
        // end subgroup
        $ret .= '</ul></li>';
    } else {
        // end main group
        if (!empty($not_subgroup_header)) {
            $ret .= '</ul></div>';
        }
    }
    if (method_exists($propertyGroup, "getDoc")) {
        $doc = $propertyGroup->getDoc();
        if ($doc != null) {
            if (count($doc) == 3) {
                $ret .= PMA\libraries\Util::showMySQLDocu($doc[1], false, $doc[2]);
            } elseif (count($doc) == 1) {
                $ret .= PMA\libraries\Util::showDocu('faq', $doc[0]);
            } else {
                $ret .= PMA\libraries\Util::showMySQLDocu($doc[1]);
            }
        }
    }
    // Close the list element after $doc link is displayed
    if (isset($property_class)) {
        if ($property_class == 'PMA\\libraries\\properties\\options\\items\\BoolPropertyItem' || $property_class == 'PMA\\libraries\\properties\\options\\items\\MessageOnlyPropertyItem' || $property_class == 'PMA\\libraries\\properties\\options\\items\\SelectPropertyItem' || $property_class == 'PMA\\libraries\\properties\\options\\items\\TextPropertyItem') {
            $ret .= '</li>';
        }
    }
    $ret .= "\n";
    return $ret;
}
Exemplo n.º 4
0
/**
 * prints out diagnostic info for pma relation feature
 *
 * @param array $cfgRelation Relation configuration
 *
 * @return string
 */
function PMA_getRelationsParamDiagnostic($cfgRelation)
{
    $retval = '<br>';
    $messages = array();
    $messages['error'] = '<span style="color:red"><strong>' . __('not OK') . '</strong></span>';
    $messages['ok'] = '<span style="color:green"><strong>' . _pgettext('Correctly working', 'OK') . '</strong></span>';
    $messages['enabled'] = '<span style="color:green">' . __('Enabled') . '</span>';
    $messages['disabled'] = '<span style="color:red">' . __('Disabled') . '</span>';
    if (empty($cfgRelation['db'])) {
        $retval .= __('Configuration of pmadb… ') . $messages['error'] . PMA\libraries\Util::showDocu('setup', 'linked-tables') . '<br />' . "\n" . __('General relation features') . ' <font color="green">' . __('Disabled') . '</font>' . "\n";
        if ($GLOBALS['cfg']['ZeroConf']) {
            if (empty($GLOBALS['db'])) {
                $retval .= PMA_getHtmlFixPMATables(true, true);
            } else {
                $retval .= PMA_getHtmlFixPMATables(true);
            }
        }
    } else {
        $retval .= '<table>' . "\n";
        if (!$cfgRelation['allworks'] && $GLOBALS['cfg']['ZeroConf'] && PMA_arePmadbTablesDefined()) {
            $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\libraries\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'), 'centralcolumnswork', $messages);
        $retval .= PMA_getDiagMessageForParameter('designer_settings', isset($cfgRelation['designer_settings']), $messages, 'designer_settings');
        $retval .= PMA_getDiagMessageForFeature(__('Remembering Designer Settings'), 'designersettingswork', $messages);
        $retval .= PMA_getDiagMessageForParameter('export_templates', isset($cfgRelation['export_templates']), $messages, 'export_templates');
        $retval .= PMA_getDiagMessageForFeature(__('Saving export templates'), 'exporttemplateswork', $messages);
        $retval .= '</table>' . "\n";
        if (!$cfgRelation['allworks']) {
            $retval .= '<p>' . __('Quick steps to set up advanced features:') . '</p>';
            $items = array();
            $items[] = sprintf(__('Create the needed tables with the ' . '<code>%screate_tables.sql</code>.'), htmlspecialchars(SQL_DIR)) . ' ' . PMA\libraries\Util::showDocu('setup', 'linked-tables');
            $items[] = __('Create a pma user and give access to these tables.') . ' ' . PMA\libraries\Util::showDocu('config', 'cfg_Servers_controluser');
            $items[] = __('Enable advanced features in configuration file ' . '(<code>config.inc.php</code>), for example by ' . 'starting from <code>config.sample.inc.php</code>.') . ' ' . PMA\libraries\Util::showDocu('setup', 'quick-install');
            $items[] = __('Re-login to phpMyAdmin to load the updated configuration file.');
            $retval .= PMA\libraries\Template::get('list/unordered')->render(array('items' => $items));
        }
    }
    return $retval;
}
Exemplo n.º 5
0
 /**
  * Test for showDocu
  *
  * @return void
  */
 function testShowDocu()
 {
     $this->assertEquals('<a href="./url.php?url=http%3A%2F%2Fdocs.phpmyadmin.net%2Fen%2Flatest%2Fpage.html%23anchor" target="documentation"><img src="themes/dot.gif" title="Documentation" alt="Documentation" class="icon ic_b_help" /></a>', PMA\libraries\Util::showDocu('page', 'anchor'));
 }
Exemplo n.º 6
0
/**
 * To get the message if a column index is missing. If not will return null
 *
 * @param string  $table      current table
 * @param string  $db         current database
 * @param boolean $editable   whether the results table can be editable or not
 * @param boolean $has_unique whether there is a unique key
 *
 * @return Message $message
 */
function PMA_getMessageIfMissingColumnIndex($table, $db, $editable, $has_unique)
{
    if (!empty($table) && ($GLOBALS['dbi']->isSystemSchema($db) || !$editable)) {
        $missing_unique_column_msg = Message::notice(sprintf(__('Current selection does not contain a unique column.' . ' Grid edit, checkbox, Edit, Copy and Delete features' . ' are not available. %s'), PMA\libraries\Util::showDocu('config', 'cfg_RowActionLinksWithoutUnique')));
    } elseif (!empty($table) && !$has_unique) {
        $missing_unique_column_msg = Message::notice(sprintf(__('Current selection does not contain a unique column.' . ' Grid edit, Edit, Copy and Delete features may result in' . ' undesired behavior. %s'), PMA\libraries\Util::showDocu('config', 'cfg_RowActionLinksWithoutUnique')));
    } else {
        $missing_unique_column_msg = null;
    }
    return $missing_unique_column_msg;
}
/**
 * return HTML for sql Query Form Bookmark
 *
 * @return string|null
 *
 * @usedby  PMA_getHtmlForSqlQueryForm()
 */
function PMA_getHtmlForSqlQueryFormBookmark()
{
    $bookmark_list = PMA_Bookmark_getList($GLOBALS['db']);
    if (empty($bookmark_list) || count($bookmark_list) < 1) {
        return null;
    }
    $html = '<fieldset id="fieldsetBookmarkOptions">';
    $html .= '<legend>';
    $html .= __('Bookmarked SQL query') . '</legend>' . "\n";
    $html .= '<div class="formelement">';
    $html .= '<select name="id_bookmark" id="id_bookmark">' . "\n";
    $html .= '<option value="">&nbsp;</option>' . "\n";
    foreach ($bookmark_list as $key => $value) {
        $html .= '<option value="' . htmlspecialchars($key) . '"' . ' data-varcount="' . PMA_Bookmark_getVariableCount($value['query']) . '">' . htmlspecialchars($value['label']) . '</option>' . "\n";
    }
    // &nbsp; is required for correct display with styles/line height
    $html .= '</select>&nbsp;' . "\n";
    $html .= '</div>' . "\n";
    $html .= '<div class="formelement">' . "\n";
    $html .= '<input type="radio" name="action_bookmark" value="0"' . ' id="radio_bookmark_exe" checked="checked" />' . '<label for="radio_bookmark_exe">' . __('Submit') . '</label>' . "\n";
    $html .= '<input type="radio" name="action_bookmark" value="1"' . ' id="radio_bookmark_view" />' . '<label for="radio_bookmark_view">' . __('View only') . '</label>' . "\n";
    $html .= '<input type="radio" name="action_bookmark" value="2"' . ' id="radio_bookmark_del" />' . '<label for="radio_bookmark_del">' . __('Delete') . '</label>' . "\n";
    $html .= '</div>' . "\n";
    $html .= '<div class="clearfloat"></div>' . "\n";
    $html .= '<div class="formelement hide">' . "\n";
    $html .= __('Variables');
    $html .= PMA\libraries\Util::showDocu('faq', 'faqbookmark');
    $html .= '<div id="bookmark_variables"></div>';
    $html .= '</div>' . "\n";
    $html .= '</fieldset>' . "\n";
    $html .= '<fieldset id="fieldsetBookmarkOptionsFooter" class="tblFooters">';
    $html .= '<input type="submit" name="SQL" id="button_submit_bookmark" value="' . __('Go') . '" />';
    $html .= '<div class="clearfloat"></div>' . "\n";
    $html .= '</fieldset>' . "\n";
    return $html;
}