Esempio n. 1
0
 /**
  * Test for PMA_Bookmark_getList
  *
  * @return void
  */
 public function testPMA_Bookmark_getList()
 {
     $this->assertEquals(
         array(),
         PMA_Bookmark_getList('phpmyadmin')
     );
 }
Esempio n. 2
0
 /**
  * Renders the bookmark content
  *
  * @access public
  * @return string
  */
 public static function getBookmarkContent()
 {
     $output = '';
     $cfgBookmark = PMA_Bookmark_getParams();
     if ($cfgBookmark) {
         $tpl_bookmark_actions = '<span class="action collapse">' . __('Collapse') . '</span> ' . '<span class="action expand">' . __('Expand') . '</span> ' . '<span class="action requery">' . __('Requery') . '</span> ' . '<span class="action edit_bookmark">' . __('Edit') . '</span> ' . '<span class="action delete_bookmark">' . __('Delete') . '</span> ' . '<span class="text targetdb">' . __('Database') . ': <span>%s</span></span>';
         $bookmarks = PMA_Bookmark_getList();
         $output .= '<div class="message welcome"><span>';
         $count_bookmarks = count($bookmarks);
         if ($count_bookmarks > 0) {
             $bookmarks_message = sprintf(_ngettext('Total %d bookmark', 'Total %d bookmarks', $count_bookmarks), $count_bookmarks);
             $private_message = sprintf('<span class="bookmark_label">%1$s</span>', __('private'));
             $shared_message = sprintf('<span class="bookmark_label shared">%1$s</span>', __('shared'));
             $output .= sprintf(__('%1$s, %2$s and %3$s bookmarks included'), $bookmarks_message, $private_message, $shared_message);
         } else {
             $output .= __('No bookmarks');
         }
         unset($count_bookmarks, $private_message, $shared_message);
         $output .= '</span></div>';
         foreach ($bookmarks as $val) {
             $output .= '<div class="message collapsed bookmark" bookmarkid="' . $val['id'] . '" targetdb="' . htmlspecialchars($val['db']) . '"><div class="action_content">' . sprintf($tpl_bookmark_actions, htmlspecialchars($val['db'])) . '</div><span class="bookmark_label ' . ($val['shared'] ? 'shared' : '') . '">' . htmlspecialchars($val['label']) . '</span> <span class="query">' . htmlspecialchars($val['query']) . '</span></div>';
         }
     }
     return $output;
 }
Esempio n. 3
0
/**
 * Function to store the query as a bookmark
 *
 * @param String  $db                     the current database
 * @param String  $bkm_user               the bookmarking user
 * @param String  $sql_query_for_bookmark the query to be stored in bookmark
 * @param String  $bkm_label              bookmark label
 * @param boolean $bkm_replace            whether to replace existing bookmarks
 *
 * @return void
 */
function PMA_storeTheQueryAsBookmark($db, $bkm_user, $sql_query_for_bookmark, $bkm_label, $bkm_replace)
{
    include_once 'libraries/bookmark.lib.php';
    $bfields = array('bkm_database' => $db, 'bkm_user' => $bkm_user, 'bkm_sql_query' => urlencode($sql_query_for_bookmark), 'bkm_label' => $bkm_label);
    // Should we replace bookmark?
    if (isset($bkm_replace)) {
        $bookmarks = PMA_Bookmark_getList($db);
        foreach ($bookmarks as $key => $val) {
            if ($val == $bkm_label) {
                PMA_Bookmark_delete($key);
            }
        }
    }
    PMA_Bookmark_save($bfields, isset($_POST['bkm_all_users']));
}
Esempio n. 4
0
            break;
    }
}
// end bookmarks reading
// Do no run query if we show PHP code
if (isset($GLOBALS['show_as_php'])) {
    $run_query = FALSE;
    $go_sql = TRUE;
}
// Store the query as a bookmark before executing it if bookmarklabel was given
if (!empty($bkm_label) && !empty($import_text)) {
    require_once './libraries/bookmark.lib.php';
    $bfields = array('dbase' => $db, 'user' => $cfg['Bookmark']['user'], 'query' => urlencode($import_text), 'label' => $bkm_label);
    // Should we replace bookmark?
    if (isset($bkm_replace)) {
        $bookmarks = PMA_Bookmark_getList($db);
        foreach ($bookmarks as $key => $val) {
            if ($val == $bkm_label) {
                PMA_Bookmark_delete($db, $key);
            }
        }
    }
    PMA_Bookmark_save($bfields, isset($bkm_all_users));
    $bookmark_created = TRUE;
}
// end store bookmarks
// We can not read all at once, otherwise we can run out of memory
$memory_limit = trim(@ini_get('memory_limit'));
// 2 MB as default
if (empty($memory_limit)) {
    $memory_limit = 2 * 1024 * 1024;
/**
 * return HTML for sql Query Form Bookmark
 *
 * @return string|null
 *
 * @usedby  PMA_getHtmlForSqlQueryForm()
 */
function PMA_getHtmlForSqlQueryFormBookmark()
{
    $bookmark_list = PMA_Bookmark_getList($GLOBALS['db']);
    if (!$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) . '">' . htmlspecialchars($value) . '</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 .= __('Variable');
    $html .= PMA_Util::showDocu('faq', 'faqbookmark');
    $html .= '<input type="text" name="bookmark_variable" class="textfield"' . ' size="10" />' . "\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 .= '</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;
}
/**
 * prints bookmark fieldset
 *
 * @usedby  PMA_sqlQueryForm()
 * @uses    PMA_Bookmark_getList()
 * @uses    $GLOBALS['db']
 * @uses    $GLOBALS['pmaThemeImage']
 * @uses    $GLOBALS['cfg']['ReplaceHelpImg']
 * @uses    $GLOBALS['strBookmarkQuery']
 * @uses    $GLOBALS['strBookmarkView']
 * @uses    $GLOBALS['strDelete']
 * @uses    $GLOBALS['strDocu']
 * @uses    $GLOBALS['strGo']
 * @uses    $GLOBALS['strSubmit']
 * @uses    $GLOBALS['strVar']
 * @uses    count()
 * @uses    htmlspecialchars()
 */
function PMA_sqlQueryFormBookmark()
{
    $bookmark_list = PMA_Bookmark_getList($GLOBALS['db']);
    if (! $bookmark_list || count($bookmark_list) < 1) {
        return;
    }

    echo '<fieldset id="bookmarkoptions">';
    echo '<legend>';
    echo $GLOBALS['strBookmarkQuery'] . '</legend>' . "\n";
    echo '<div class="formelement">';
    echo '<select name="id_bookmark">' . "\n";
    echo '<option value="">&nbsp;</option>' . "\n";
    foreach ($bookmark_list as $key => $value) {
        echo '<option value="' . htmlspecialchars($key) . '">'
            .htmlspecialchars($value) . '</option>' . "\n";
    }
    // &nbsp; is required for correct display with styles/line height
    echo '</select>&nbsp;' . "\n";
    echo '</div>' . "\n";
    echo '<div class="formelement">' . "\n";
    echo $GLOBALS['strVar'];
    if ($GLOBALS['cfg']['ReplaceHelpImg']) {
        echo ' <a href="./Documentation.html#faqbookmark"'
            .' target="documentation">'
            .'<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_help.png"'
            .' border="0" width="11" height="11" align="middle"'
            .' alt="' . $GLOBALS['strDocu'] . '" /></a> ';
    } else {
        echo ' (<a href="./Documentation.html#faqbookmark"'
            .' target="documentation">' . $GLOBALS['strDocu'] . '</a>): ';
    }
    echo '<input type="text" name="bookmark_variable" class="textfield"'
        .' size="10" />' . "\n";
    echo '</div>' . "\n";
    echo '<div class="formelement">' . "\n";
    echo '<input type="radio" name="action_bookmark" value="0"'
        .' id="radio_bookmark_exe" checked="checked" />'
        .'<label for="radio_bookmark_exe">' . $GLOBALS['strSubmit']
        .'</label>' . "\n";
    echo '<input type="radio" name="action_bookmark" value="1"'
        .' id="radio_bookmark_view" />'
        .'<label for="radio_bookmark_view">' . $GLOBALS['strBookmarkView']
        .'</label>' . "\n";
    echo '<input type="radio" name="action_bookmark" value="2"'
        .' id="radio_bookmark_del" />'
        .'<label for="radio_bookmark_del">' . $GLOBALS['strDelete']
        .'</label>' . "\n";
    echo '</div>' . "\n";
    echo '<div class="clearfloat"></div>' . "\n";
    echo '</fieldset>' . "\n";

    echo '<fieldset id="bookmarkoptionsfooter" class="tblFooters">' . "\n";
    echo '<input type="submit" name="SQL" value="' . $GLOBALS['strGo'] . '" />';
    echo '<div class="clearfloat"></div>' . "\n";
    echo '</fieldset>' . "\n";
}
Esempio n. 7
0
/**
 * prints bookmark fieldset
 *
 * @usedby  PMA_sqlQueryForm()
 */
function PMA_sqlQueryFormBookmark()
{
    $bookmark_list = PMA_Bookmark_getList($GLOBALS['db']);
    if (!$bookmark_list || count($bookmark_list) < 1) {
        return;
    }
    echo '<fieldset id="bookmarkoptions">';
    echo '<legend>';
    echo __('Bookmarked SQL query') . '</legend>' . "\n";
    echo '<div class="formelement">';
    echo '<select name="id_bookmark" id="id_bookmark">' . "\n";
    echo '<option value="">&nbsp;</option>' . "\n";
    foreach ($bookmark_list as $key => $value) {
        echo '<option value="' . htmlspecialchars($key) . '">' . htmlspecialchars($value) . '</option>' . "\n";
    }
    // &nbsp; is required for correct display with styles/line height
    echo '</select>&nbsp;' . "\n";
    echo '</div>' . "\n";
    echo '<div class="formelement">' . "\n";
    echo __('Variable');
    if ($GLOBALS['cfg']['ReplaceHelpImg']) {
        echo ' <a href="Documentation.html#faqbookmark"' . ' target="documentation">' . PMA_getImage('b_help.png', __('Documentation')) . '</a>';
    } else {
        echo ' (<a href="Documentation.html#faqbookmark"' . ' target="documentation">' . __('Documentation') . '</a>): ';
    }
    echo '<input type="text" name="bookmark_variable" class="textfield"' . ' size="10" />' . "\n";
    echo '</div>' . "\n";
    echo '<div class="formelement">' . "\n";
    echo '<input type="radio" name="action_bookmark" value="0"' . ' id="radio_bookmark_exe" checked="checked" />' . '<label for="radio_bookmark_exe">' . __('Submit') . '</label>' . "\n";
    echo '<input type="radio" name="action_bookmark" value="1"' . ' id="radio_bookmark_view" />' . '<label for="radio_bookmark_view">' . __('View only') . '</label>' . "\n";
    echo '<input type="radio" name="action_bookmark" value="2"' . ' id="radio_bookmark_del" />' . '<label for="radio_bookmark_del">' . __('Delete') . '</label>' . "\n";
    echo '</div>' . "\n";
    echo '<div class="clearfloat"></div>' . "\n";
    echo '</fieldset>' . "\n";
    echo '<fieldset id="bookmarkoptionsfooter" class="tblFooters">' . "\n";
    echo '<input type="submit" name="SQL" id="button_submit_bookmark" value="' . __('Go') . '" />';
    echo '<div class="clearfloat"></div>' . "\n";
    echo '</fieldset>' . "\n";
}