getList() публичный статический Метод

Gets the list of bookmarks defined for the current database
public static getList ( string | boolean $db = false ) : Bookmark[]
$db string | boolean the current database name or false
Результат Bookmark[] the bookmarks list
Пример #1
0
 /**
  * Renders the bookmark content
  *
  * @access public
  * @return string
  */
 public static function getBookmarkContent()
 {
     $cfgBookmark = Bookmark::getParams();
     if ($cfgBookmark) {
         $bookmarks = Bookmark::getList();
         $count_bookmarks = count($bookmarks);
         if ($count_bookmarks > 0) {
             $welcomeMessage = sprintf(_ngettext('Showing %1$d bookmark (both private and shared)', 'Showing %1$d bookmarks (both private and shared)', $count_bookmarks), $count_bookmarks);
         } else {
             $welcomeMessage = __('No bookmarks');
         }
         unset($count_bookmarks, $private_message, $shared_message);
         return Template::get('console/bookmark_content')->render(array('welcomeMessage' => $welcomeMessage, 'bookmarks' => $bookmarks));
     }
     return '';
 }
Пример #2
0
 /**
  * Tests for Bookmark::getList()
  *
  * @return void
  */
 public function testGetList()
 {
     $this->assertEquals(array(), Bookmark::getList('phpmyadmin'));
 }
Пример #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)
{
    $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 = Bookmark::getList($db);
        foreach ($bookmarks as $bookmark) {
            if ($bookmark->getLabel() == $bkm_label) {
                $bookmark->delete();
            }
        }
    }
    $bookmark = Bookmark::createBookmark($bfields, isset($_POST['bkm_all_users']));
    $bookmark->save();
}
Пример #4
0
/**
 * return HTML for sql Query Form Bookmark
 *
 * @return string|null
 *
 * @usedby  PMA_getHtmlForSqlQueryForm()
 */
function PMA_getHtmlForSqlQueryFormBookmark()
{
    $bookmark_list = 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 $bookmark) {
        $html .= '<option value="' . htmlspecialchars($bookmark->getId()) . '"' . ' data-varcount="' . $bookmark->getVariableCount() . '">' . htmlspecialchars($bookmark->getLabel()) . (empty($bookmark->getUser()) ? ' (' . __('shared') . ')' : '') . '</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;
}