Beispiel #1
0
 public static function getPluralText($singular, $plural, $number)
 {
     if (self::_getTextMode() == self::GETTEXT_MODE_NATIVE) {
         return ngettext($singular, $plural, $number);
     }
     return _ngettext($singular, $plural, $number);
 }
 /**
  * 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;
 }
Beispiel #3
0
function make_feed_browser($search, $limit, $mode = 1)
{
    if (defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER) {
        return;
    }
    $owner_uid = $_SESSION["uid"];
    $rv = '';
    if ($search) {
        $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('%{$search}%') OR\n\t\t\t\t\t\tUPPER(title) LIKE UPPER('%{$search}%'))";
    } else {
        $search_qpart = "";
    }
    if ($mode == 1) {
        /* $result = db_query("SELECT feed_url, subscribers FROM
        			 ttrss_feedbrowser_cache WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
        			WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url
        			AND owner_uid = '$owner_uid') $search_qpart
        			ORDER BY subscribers DESC LIMIT $limit"); */
        $result = db_query("SELECT feed_url, site_url, title, SUM(subscribers) AS subscribers FROM\n\t\t\t\t\t\t(SELECT feed_url, site_url, title, subscribers FROM ttrss_feedbrowser_cache UNION ALL\n\t\t\t\t\t\t\tSELECT feed_url, site_url, title, subscribers FROM ttrss_linked_feeds) AS qqq\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t(SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf\n\t\t\t\t\t\t\t\tWHERE tf.feed_url = qqq.feed_url\n\t\t\t\t\t\t\t\t\tAND owner_uid = '{$owner_uid}') {$search_qpart}\n\t\t\t\t\t\tGROUP BY feed_url, site_url, title ORDER BY subscribers DESC LIMIT {$limit}");
    } else {
        if ($mode == 2) {
            $result = db_query("SELECT *,\n\t\t\t\t\t\t(SELECT COUNT(*) FROM ttrss_user_entries WHERE\n\t\t\t\t\t \t\torig_feed_id = ttrss_archived_feeds.id) AS articles_archived\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\tttrss_archived_feeds\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t(SELECT COUNT(*) FROM ttrss_feeds\n\t\t\t\t\t\t\tWHERE ttrss_feeds.feed_url = ttrss_archived_feeds.feed_url AND\n\t\t\t\t\t\t\t\towner_uid = '{$owner_uid}') = 0\tAND\n\t\t\t\t\t\towner_uid = '{$owner_uid}' {$search_qpart}\n\t\t\t\t\t\tORDER BY id DESC LIMIT {$limit}");
        }
    }
    $feedctr = 0;
    while ($line = db_fetch_assoc($result)) {
        if ($mode == 1) {
            $feed_url = htmlspecialchars($line["feed_url"]);
            $site_url = htmlspecialchars($line["site_url"]);
            $subscribers = $line["subscribers"];
            $check_box = "<input onclick='toggleSelectListRow2(this)'\n\t\t\t\t\t\t\tdojoType=\"dijit.form.CheckBox\"\n\t\t\t\t\t\t\ttype=\"checkbox\" \">";
            $class = $feedctr % 2 ? "even" : "odd";
            $site_url = "<a target=\"_blank\"\n\t\t\t\t\t\t\thref=\"{$site_url}\">\n\t\t\t\t\t\t\t<span class=\"fb_feedTitle\">" . htmlspecialchars($line["title"]) . "</span></a>";
            $feed_url = "<a target=\"_blank\" class=\"fb_feedUrl\"\n\t\t\t\t\t\t\thref=\"{$feed_url}\"><img src='images/pub_set.png'\n\t\t\t\t\t\t\tstyle='vertical-align : middle'></a>";
            $rv .= "<li>{$check_box} {$feed_url} {$site_url}" . "&nbsp;<span class='subscribers'>({$subscribers})</span></li>";
        } else {
            if ($mode == 2) {
                $feed_url = htmlspecialchars($line["feed_url"]);
                $site_url = htmlspecialchars($line["site_url"]);
                $check_box = "<input onclick='toggleSelectListRow2(this)' dojoType=\"dijit.form.CheckBox\"\n\t\t\t\t\t\t\ttype=\"checkbox\">";
                $class = $feedctr % 2 ? "even" : "odd";
                if ($line['articles_archived'] > 0) {
                    $archived = sprintf(_ngettext("%d archived article", "%d archived articles", $line['articles_archived']), $line['articles_archived']);
                    $archived = "&nbsp;<span class='subscribers'>({$archived})</span>";
                } else {
                    $archived = '';
                }
                $site_url = "<a target=\"_blank\"\n\t\t\t\t\t\t\thref=\"{$site_url}\">\n\t\t\t\t\t\t\t<span class=\"fb_feedTitle\">" . htmlspecialchars($line["title"]) . "</span></a>";
                $feed_url = "<a target=\"_blank\" class=\"fb_feedUrl\"\n\t\t\t\t\t\t\thref=\"{$feed_url}\"><img src='images/pub_set.png'\n\t\t\t\t\t\t\tstyle='vertical-align : middle'></a>";
                $rv .= "<li id=\"FBROW-" . $line["id"] . "\">" . "{$check_box} {$feed_url} {$site_url} {$archived}</li>";
            }
        }
        ++$feedctr;
    }
    if ($feedctr == 0) {
        $rv .= "<li style=\"text-align : center\"><p>" . __('No feeds found.') . "</p></li>";
    }
    return $rv;
}
 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'));
 }
 /**
  * Test for setting and parsing locales
  *
  * @param string $locale locale name
  *
  * @return void
  *
  * @group large
  * @dataProvider listLocales
  */
 public function testGettext($locale)
 {
     /* We should be able to set the language */
     $this->assertTrue(PMA_langSet($locale));
     /* Bind locales */
     _setlocale(LC_MESSAGES, $GLOBALS['lang']);
     _bind_textdomain_codeset('phpmyadmin', 'UTF-8');
     _textdomain('phpmyadmin');
     /* Grab some texts */
     $this->assertContains('%s', _ngettext('%s table', '%s tables', 10));
     $this->assertContains('%s', _ngettext('%s table', '%s tables', 1));
 }
Beispiel #6
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 '';
 }
/**
 * Builds a <select> list for refresh rates
 *
 * @param string $name         Name of select
 * @param int    $defaultRate  Currently chosen rate
 * @param array  $refreshRates List of refresh rates
 *
 * @return string
 */
function PMA_getHtmlForRefreshList($name, $defaultRate = 5, $refreshRates = array(1, 2, 5, 10, 20, 40, 60, 120, 300, 600))
{
    $return = '<select name="' . $name . '" id="id_' . $name . '" class="refreshRate">';
    foreach ($refreshRates as $rate) {
        $selected = $rate == $defaultRate ? ' selected="selected"' : '';
        $return .= '<option value="' . $rate . '"' . $selected . '>';
        if ($rate < 60) {
            $return .= sprintf(_ngettext('%d second', '%d seconds', $rate), $rate);
        } else {
            $rate = $rate / 60;
            $return .= sprintf(_ngettext('%d minute', '%d minutes', $rate), $rate);
        }
        $return .= '</option>';
    }
    $return .= '</select>';
    return $return;
}
Beispiel #8
0
function make_feed_browser($search, $limit, $mode = 1)
{
    if ($mode != 1 && $mode != 2) {
        return "";
    }
    $owner_uid = $_SESSION["uid"];
    if ($search) {
        $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('%{$search}%') OR\n                    UPPER(title) LIKE UPPER('%{$search}%'))";
    } else {
        $search_qpart = "";
    }
    if ($mode == 1) {
        $result = db_query("SELECT feed_url, site_url, title, SUM(subscribers) AS subscribers FROM\n                (SELECT feed_url, site_url, title, subscribers FROM ttrss_feedbrowser_cache UNION ALL\n                    SELECT feed_url, site_url, title, subscribers FROM ttrss_linked_feeds) AS qqq\n                WHERE\n                    (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf\n                        WHERE tf.feed_url = qqq.feed_url\n                            AND owner_uid = '{$owner_uid}') {$search_qpart}\n                GROUP BY feed_url, site_url, title\n                ORDER BY subscribers DESC LIMIT {$limit}");
    } elseif ($mode == 2) {
        $result = db_query("SELECT *,\n                (SELECT COUNT(*) FROM ttrss_user_entries WHERE\n                    orig_feed_id = ttrss_archived_feeds.id) AS articles_archived\n                FROM\n                    ttrss_archived_feeds\n                WHERE\n                (SELECT COUNT(*) FROM ttrss_feeds\n                    WHERE ttrss_feeds.feed_url = ttrss_archived_feeds.feed_url AND\n                        owner_uid = '{$owner_uid}') = 0    AND\n                owner_uid = '{$owner_uid}' {$search_qpart}\n                ORDER BY id DESC LIMIT {$limit}");
    }
    $rv = "";
    while ($line = db_fetch_assoc($result)) {
        $feed_url = htmlspecialchars($line['feed_url']);
        $site_url = htmlspecialchars($line['site_url']);
        $check_box = "<input onclick='toggleSelectListRow2(this)'\n            dojoType=\"dijit.form.CheckBox\" type=\"checkbox\">";
        $site_url_tag = "<a target=\"_blank\" href=\"" . $site_url . "\">\n            <span class=\"fb_feedTitle\">" . htmlspecialchars($line['title']) . "</span></a>";
        $feed_url_tag = "<a target=\"_blank\" class=\"fb_feedUrl\"\n            href=\"" . $feed_url . "\"><img src='images/pub_set.png'\n            style='vertical-align:middle;'></a>";
        if ($mode == 1) {
            $id = "";
            $count = $line['subscribers'];
        } elseif ($mode == 2) {
            $id = " id=\"FBROW-" . $line["id"] . "\"";
            if ($line['articles_archived'] > 0) {
                $archived = sprintf(_ngettext("%d archived article", "%d archived articles", $line['articles_archived']), $line['articles_archived']);
                $count = "(" . $archived . ")";
            } else {
                $count = '';
            }
        }
        $rv .= "<li" . $id . ">" . $check_box . " " . $feed_url_tag . " " . $site_url_tag . "&nbsp;<span class='subscribers'>" . $count . "</span></li>";
    }
    if ($rv === "") {
        $rv = "<li style=\"text-align:center;\"><p>" . __('No feeds found.') . "</p></li>";
    }
    return $rv;
}
Beispiel #9
0
 function makefeedtree()
 {
     if ($_REQUEST['mode'] != 2) {
         $search = $_SESSION["prefs_feed_search"];
     } else {
         $search = "";
     }
     if ($search) {
         $search_qpart = " AND LOWER(title) LIKE LOWER('%{$search}%')";
     }
     $root = array();
     $root['id'] = 'root';
     $root['name'] = __('Feeds');
     $root['items'] = array();
     $root['type'] = 'category';
     $enable_cats = get_pref('ENABLE_FEED_CATS');
     if ($_REQUEST['mode'] == 2) {
         if ($enable_cats) {
             $cat = $this->feedlist_init_cat(-1);
         } else {
             $cat['items'] = array();
         }
         foreach (array(-4, -3, -1, -2, 0, -6) as $i) {
             array_push($cat['items'], $this->feedlist_init_feed($i));
         }
         /* Plugin feeds for -1 */
         $feeds = PluginHost::getInstance()->get_feeds(-1);
         if ($feeds) {
             foreach ($feeds as $feed) {
                 $feed_id = PluginHost::pfeed_to_feed_id($feed['id']);
                 $item = array();
                 $item['id'] = 'FEED:' . $feed_id;
                 $item['bare_id'] = (int) $feed_id;
                 $item['auxcounter'] = 0;
                 $item['name'] = $feed['title'];
                 $item['checkbox'] = false;
                 $item['error'] = '';
                 $item['icon'] = $feed['icon'];
                 $item['param'] = '';
                 $item['unread'] = 0;
                 //$feed['sender']->get_unread($feed['id']);
                 $item['type'] = 'feed';
                 array_push($cat['items'], $item);
             }
         }
         if ($enable_cats) {
             array_push($root['items'], $cat);
         } else {
             $root['items'] = array_merge($root['items'], $cat['items']);
         }
         $result = $this->dbh->query("SELECT * FROM\n\t\t\t\tttrss_labels2 WHERE owner_uid = " . $_SESSION['uid'] . " ORDER by caption");
         if ($this->dbh->num_rows($result) > 0) {
             if (get_pref('ENABLE_FEED_CATS')) {
                 $cat = $this->feedlist_init_cat(-2);
             } else {
                 $cat['items'] = array();
             }
             while ($line = $this->dbh->fetch_assoc($result)) {
                 $label_id = label_to_feed_id($line['id']);
                 $feed = $this->feedlist_init_feed($label_id, false, 0);
                 $feed['fg_color'] = $line['fg_color'];
                 $feed['bg_color'] = $line['bg_color'];
                 array_push($cat['items'], $feed);
             }
             if ($enable_cats) {
                 array_push($root['items'], $cat);
             } else {
                 $root['items'] = array_merge($root['items'], $cat['items']);
             }
         }
     }
     if ($enable_cats) {
         $show_empty_cats = $_REQUEST['force_show_empty'] || $_REQUEST['mode'] != 2 && !$search;
         $result = $this->dbh->query("SELECT id, title FROM ttrss_feed_categories\n\t\t\t\tWHERE owner_uid = " . $_SESSION["uid"] . " AND parent_cat IS NULL ORDER BY order_id, title");
         while ($line = $this->dbh->fetch_assoc($result)) {
             $cat = array();
             $cat['id'] = 'CAT:' . $line['id'];
             $cat['bare_id'] = (int) $line['id'];
             $cat['auxcounter'] = 0;
             $cat['name'] = $line['title'];
             $cat['items'] = array();
             $cat['checkbox'] = false;
             $cat['type'] = 'category';
             $cat['unread'] = 0;
             $cat['child_unread'] = 0;
             $cat['items'] = $this->get_category_items($line['id']);
             $num_children = $this->calculate_children_count($cat);
             $cat['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', $num_children), $num_children);
             if ($num_children > 0 || $show_empty_cats) {
                 array_push($root['items'], $cat);
             }
             $root['param'] += count($cat['items']);
         }
         /* Uncategorized is a special case */
         $cat = array();
         $cat['id'] = 'CAT:0';
         $cat['bare_id'] = 0;
         $cat['auxcounter'] = 0;
         $cat['name'] = __("Uncategorized");
         $cat['items'] = array();
         $cat['type'] = 'category';
         $cat['checkbox'] = false;
         $cat['unread'] = 0;
         $cat['child_unread'] = 0;
         $feed_result = $this->dbh->query("SELECT id, title,last_error,\n\t\t\t\t" . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated\n\t\t\t\tFROM ttrss_feeds\n\t\t\t\tWHERE cat_id IS NULL AND owner_uid = " . $_SESSION["uid"] . "{$search_qpart} ORDER BY order_id, title");
         while ($feed_line = $this->dbh->fetch_assoc($feed_result)) {
             $feed = array();
             $feed['id'] = 'FEED:' . $feed_line['id'];
             $feed['bare_id'] = (int) $feed_line['id'];
             $feed['auxcounter'] = 0;
             $feed['name'] = $feed_line['title'];
             $feed['checkbox'] = false;
             $feed['error'] = $feed_line['last_error'];
             $feed['icon'] = getFeedIcon($feed_line['id']);
             $feed['param'] = make_local_datetime($feed_line['last_updated'], true);
             $feed['unread'] = 0;
             $feed['type'] = 'feed';
             array_push($cat['items'], $feed);
         }
         $cat['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', count($cat['items'])), count($cat['items']));
         if (count($cat['items']) > 0 || $show_empty_cats) {
             array_push($root['items'], $cat);
         }
         $num_children = $this->calculate_children_count($root);
         $root['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', $num_children), $num_children);
     } else {
         $feed_result = $this->dbh->query("SELECT id, title, last_error,\n\t\t\t\t" . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated\n\t\t\t\tFROM ttrss_feeds\n\t\t\t\tWHERE owner_uid = " . $_SESSION["uid"] . "{$search_qpart} ORDER BY order_id, title");
         while ($feed_line = $this->dbh->fetch_assoc($feed_result)) {
             $feed = array();
             $feed['id'] = 'FEED:' . $feed_line['id'];
             $feed['bare_id'] = (int) $feed_line['id'];
             $feed['auxcounter'] = 0;
             $feed['name'] = $feed_line['title'];
             $feed['checkbox'] = false;
             $feed['error'] = $feed_line['last_error'];
             $feed['icon'] = getFeedIcon($feed_line['id']);
             $feed['param'] = make_local_datetime($feed_line['last_updated'], true);
             $feed['unread'] = 0;
             $feed['type'] = 'feed';
             array_push($root['items'], $feed);
         }
         $root['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', count($cat['items'])), count($cat['items']));
     }
     $fl = array();
     $fl['identifier'] = 'id';
     $fl['label'] = 'name';
     if ($_REQUEST['mode'] != 2) {
         $fl['items'] = array($root);
     } else {
         $fl['items'] =& $root['items'];
     }
     return $fl;
 }
 /**
  * Provides search results row with browse/delete links.
  * (for a table)
  *
  * @param string  $each_table    One of the tables on which search was performed
  * @param array   $newsearchsqls Contains SQL queries
  * @param bool    $odd_row       For displaying contrasting table rows
  * @param integer $res_cnt       Number of results found
  *
  * @return string HTML row
  */
 private function _getResultsRow($each_table, $newsearchsqls, $odd_row, $res_cnt)
 {
     $this_url_params = array('db' => $GLOBALS['db'], 'table' => $each_table, 'goto' => 'db_sql.php', 'pos' => 0, 'is_js_confirmed' => 0);
     // Start forming search results row
     $html_output = '<tr class="noclick ' . ($odd_row ? 'odd' : 'even') . '">';
     // Displays results count for a table
     $html_output .= '<td>';
     $html_output .= sprintf(_ngettext('%1$s match in <strong>%2$s</strong>', '%1$s matches in <strong>%2$s</strong>', $res_cnt), $res_cnt, htmlspecialchars($each_table));
     $html_output .= '</td>';
     // Displays browse/delete link if result count > 0
     if ($res_cnt > 0) {
         $this_url_params['sql_query'] = $newsearchsqls['select_columns'];
         $browse_result_path = 'sql.php' . PMA_URL_getCommon($this_url_params);
         $html_output .= '<td><a name="browse_search" class="ajax" href="' . $browse_result_path . '" onclick="loadResult(\'' . $browse_result_path . '\',\'' . $each_table . '\',\'' . PMA_URL_getCommon($GLOBALS['db'], $each_table) . '\'' . ');return false;" >' . __('Browse') . '</a></td>';
         $this_url_params['sql_query'] = $newsearchsqls['delete'];
         $delete_result_path = 'sql.php' . PMA_URL_getCommon($this_url_params);
         $html_output .= '<td><a name="delete_search" class="ajax" href="' . $delete_result_path . '" onclick="deleteResult(\'' . $delete_result_path . '\' , \'' . sprintf(__('Delete the matches for the %s table?'), htmlspecialchars($each_table)) . '\');return false;">' . __('Delete') . '</a></td>';
     } else {
         $html_output .= '<td>&nbsp;</td>' . '<td>&nbsp;</td>';
     }
     // end if else
     $html_output .= '</tr>';
     return $html_output;
 }
Beispiel #11
0
/**
 * Handles requests for executing a routine
 */
function PMA_RTN_handleExecute()
{
    global $_GET, $_POST, $_REQUEST, $GLOBALS, $db, $cfg;
    /**
     * Handle all user requests other than the default of listing routines
     */
    if (!empty($_REQUEST['execute_routine']) && !empty($_REQUEST['item_name'])) {
        // Build the queries
        $routine = PMA_RTN_getDataFromName($_REQUEST['item_name'], $_REQUEST['item_type'], false);
        if ($routine !== false) {
            $queries = array();
            $end_query = array();
            $args = array();
            for ($i = 0; $i < $routine['item_num_params']; $i++) {
                if (isset($_REQUEST['params'][$routine['item_param_name'][$i]])) {
                    $value = $_REQUEST['params'][$routine['item_param_name'][$i]];
                    if (is_array($value)) {
                        // is SET type
                        $value = implode(',', $value);
                    }
                    $value = PMA_sqlAddSlashes($value);
                    if (!empty($_REQUEST['funcs'][$routine['item_param_name'][$i]]) && in_array($_REQUEST['funcs'][$routine['item_param_name'][$i]], $cfg['Functions'])) {
                        $queries[] = "SET @p{$i}={$_REQUEST['funcs'][$routine['item_param_name'][$i]]}('{$value}');\n";
                    } else {
                        $queries[] = "SET @p{$i}='{$value}';\n";
                    }
                    $args[] = "@p{$i}";
                } else {
                    $args[] = "@p{$i}";
                }
                if ($routine['item_type'] == 'PROCEDURE') {
                    if ($routine['item_param_dir'][$i] == 'OUT' || $routine['item_param_dir'][$i] == 'INOUT') {
                        $end_query[] = "@p{$i} AS " . PMA_backquote($routine['item_param_name'][$i]);
                    }
                }
            }
            if ($routine['item_type'] == 'PROCEDURE') {
                $queries[] = "CALL " . PMA_backquote($routine['item_name']) . "(" . implode(', ', $args) . ");\n";
                if (count($end_query)) {
                    $queries[] = "SELECT " . implode(', ', $end_query) . ";\n";
                }
            } else {
                $queries[] = "SELECT " . PMA_backquote($routine['item_name']) . "(" . implode(', ', $args) . ") " . "AS " . PMA_backquote($routine['item_name']) . ";\n";
            }
            // Execute the queries
            $affected = 0;
            $result = null;
            $outcome = true;
            foreach ($queries as $query) {
                $resource = PMA_DBI_try_query($query);
                if ($resource === false) {
                    $outcome = false;
                    break;
                }
                while (true) {
                    if (!PMA_DBI_more_results()) {
                        break;
                    }
                    PMA_DBI_next_result();
                }
                if (substr($query, 0, 6) == 'SELECT') {
                    $result = $resource;
                } else {
                    if (substr($query, 0, 4) == 'CALL') {
                        $result = $resource ? $resource : $result;
                        $affected = PMA_DBI_affected_rows() - PMA_DBI_num_rows($resource);
                    }
                }
            }
            // Generate output
            if ($outcome) {
                $message = __('Your SQL query has been executed successfully');
                if ($routine['item_type'] == 'PROCEDURE') {
                    $message .= '<br />';
                    $message .= sprintf(_ngettext('%d row affected by the last statement inside the procedure', '%d rows affected by the last statement inside the procedure', $affected), $affected);
                }
                $message = PMA_message::success($message);
                // Pass the SQL queries through the "pretty printer"
                $output = '<code class="sql" style="margin-bottom: 1em;">';
                $output .= PMA_SQP_formatHtml(PMA_SQP_parse(implode($queries)));
                $output .= '</code>';
                // Display results
                if ($result) {
                    $output .= "<fieldset><legend>";
                    $output .= sprintf(__('Execution results of routine %s'), PMA_backquote(htmlspecialchars($routine['item_name'])));
                    $output .= "</legend>";
                    $output .= "<table><tr>";
                    foreach (PMA_DBI_get_fields_meta($result) as $key => $field) {
                        $output .= "<th>";
                        $output .= htmlspecialchars($field->name);
                        $output .= "</th>";
                    }
                    $output .= "</tr>";
                    // Stored routines can only ever return ONE ROW.
                    $data = PMA_DBI_fetch_single_row($result);
                    foreach ($data as $key => $value) {
                        if ($value === null) {
                            $value = '<i>NULL</i>';
                        } else {
                            $value = htmlspecialchars($value);
                        }
                        $output .= "<td class='odd'>" . $value . "</td>";
                    }
                    $output .= "</table></fieldset>";
                } else {
                    $notice = __('MySQL returned an empty result set (i.e. zero rows).');
                    $output .= PMA_message::notice($notice)->getDisplay();
                }
            } else {
                $output = '';
                $message = PMA_message::error(sprintf(__('The following query has failed: "%s"'), $query) . '<br /><br />' . __('MySQL said: ') . PMA_DBI_getError(null));
            }
            // Print/send output
            if ($GLOBALS['is_ajax_request']) {
                $extra_data = array('dialog' => false);
                PMA_ajaxResponse($message->getDisplay() . $output, $message->isSuccess(), $extra_data);
            } else {
                echo $message->getDisplay() . $output;
                if ($message->isError()) {
                    // At least one query has failed, so shouldn't
                    // execute any more queries, so we quit.
                    exit;
                }
                unset($_POST);
                // Now deliberately fall through to displaying the routines list
            }
        } else {
            $message = __('Error in processing request') . ' : ';
            $message .= sprintf(PMA_RTE_getWord('not_found'), htmlspecialchars(PMA_backquote($_REQUEST['item_name'])), htmlspecialchars(PMA_backquote($db)));
            $message = PMA_message::error($message);
            if ($GLOBALS['is_ajax_request']) {
                PMA_ajaxResponse($message, $message->isSuccess());
            } else {
                echo $message->getDisplay();
                unset($_POST);
            }
        }
    } else {
        if (!empty($_GET['execute_dialog']) && !empty($_GET['item_name'])) {
            /**
             * Display the execute form for a routine.
             */
            $routine = PMA_RTN_getDataFromName($_GET['item_name'], $_GET['item_type'], true);
            if ($routine !== false) {
                $form = PMA_RTN_getExecuteForm($routine);
                if ($GLOBALS['is_ajax_request'] == true) {
                    $extra_data = array();
                    $extra_data['dialog'] = true;
                    $extra_data['title'] = __("Execute routine") . " ";
                    $extra_data['title'] .= PMA_backquote(htmlentities($_GET['item_name'], ENT_QUOTES));
                    PMA_ajaxResponse($form, true, $extra_data);
                } else {
                    echo "\n\n<h2>" . __("Execute routine") . "</h2>\n\n";
                    echo $form;
                    include './libraries/footer.inc.php';
                    // exit;
                }
            } else {
                if ($GLOBALS['is_ajax_request'] == true) {
                    $message = __('Error in processing request') . ' : ';
                    $message .= sprintf(PMA_RTE_getWord('not_found'), htmlspecialchars(PMA_backquote($_REQUEST['item_name'])), htmlspecialchars(PMA_backquote($db)));
                    $message = PMA_message::error($message);
                    PMA_ajaxResponse($message, false);
                }
            }
        }
    }
}
Beispiel #12
0
/**
 * Get HTML body for table summery
 *
 * @param integer $num_tables          number of tables
 * @param boolean $server_slave_status server slave state
 * @param boolean $db_is_system_schema whether database is information schema or not
 * @param integer $sum_entries         sum entries
 * @param string  $db_collation        collation of given db
 * @param boolean $is_show_stats       whether stats is show or not
 * @param double  $sum_size            sum size
 * @param double  $overhead_size       overhead size
 * @param string  $create_time_all     create time
 * @param string  $update_time_all     update time
 * @param string  $check_time_all      check time
 * @param integer $sum_row_count_pre   sum row count pre
 *
 * @return string $html_output
 */
function PMA_getHtmlBodyForTableSummary($num_tables, $server_slave_status, $db_is_system_schema, $sum_entries, $db_collation, $is_show_stats, $sum_size, $overhead_size, $create_time_all, $update_time_all, $check_time_all, $sum_row_count_pre)
{
    if ($is_show_stats) {
        list($sum_formatted, $unit) = PMA_Util::formatByteDown($sum_size, 3, 1);
        list($overhead_formatted, $overhead_unit) = PMA_Util::formatByteDown($overhead_size, 3, 1);
    }
    $html_output = '<tbody id="tbl_summary_row">' . '<tr><th></th>';
    $html_output .= '<th class="tbl_num nowrap">';
    $html_output .= sprintf(_ngettext('%s table', '%s tables', $num_tables), PMA_Util::formatNumber($num_tables, 0));
    $html_output .= '</th>';
    if ($server_slave_status) {
        $html_output .= '<th>' . __('Replication') . '</th>' . "\n";
    }
    $html_output .= '<th colspan="' . ($db_is_system_schema ? 4 : 7) . '">' . __('Sum') . '</th>';
    $html_output .= '<th class="value tbl_rows">' . $sum_row_count_pre . PMA_Util::formatNumber($sum_entries, 0) . '</th>';
    if (!($GLOBALS['cfg']['PropertiesNumColumns'] > 1)) {
        $default_engine = $GLOBALS['dbi']->fetchValue('SHOW VARIABLES LIKE \'storage_engine\';', 0, 1);
        $html_output .= '<th class="center">' . "\n" . '<dfn title="' . sprintf(__('%s is the default storage engine on this MySQL server.'), $default_engine) . '">' . $default_engine . '</dfn></th>' . "\n";
        // we got a case where $db_collation was empty
        $html_output .= '<th>' . "\n";
        if (!empty($db_collation)) {
            $html_output .= '<dfn title="' . PMA_getCollationDescr($db_collation) . ' (' . __('Default') . ')">' . $db_collation . '</dfn>';
        }
        $html_output .= '</th>';
    }
    if ($is_show_stats) {
        $html_output .= '<th class="value tbl_size">' . $sum_formatted . ' ' . $unit . '</th>';
        $html_output .= '<th class="value tbl_overhead">' . $overhead_formatted . ' ' . $overhead_unit . '</th>';
    }
    if ($GLOBALS['cfg']['ShowDbStructureCreation']) {
        $html_output .= '<th class="value tbl_creation">' . "\n" . '        ' . ($create_time_all ? PMA_Util::localisedDate(strtotime($create_time_all)) : '-') . '</th>';
    }
    if ($GLOBALS['cfg']['ShowDbStructureLastUpdate']) {
        $html_output .= '<th class="value tbl_last_update">' . "\n" . '        ' . ($update_time_all ? PMA_Util::localisedDate(strtotime($update_time_all)) : '-') . '</th>';
    }
    if ($GLOBALS['cfg']['ShowDbStructureLastCheck']) {
        $html_output .= '<th class="value tbl_last_check">' . "\n" . '        ' . ($check_time_all ? PMA_Util::localisedDate(strtotime($check_time_all)) : '-') . '</th>';
    }
    $html_output .= '</tr>' . '</tbody>';
    return $html_output;
}
Beispiel #13
0
 /**
  * Test for setting and parsing locales
  *
  * @param string $locale locale name
  *
  * @return void
  *
  * @group large
  * @dataProvider listLocales
  */
 public function testGettext($locale)
 {
     /* We should be able to set the language */
     $this->manager->getLanguage($locale)->activate();
     /* Grab some texts */
     $this->assertContains('%s', _ngettext('%s table', '%s tables', 10));
     $this->assertContains('%s', _ngettext('%s table', '%s tables', 1));
     $this->assertEquals($locale, $this->manager->getCurrentLanguage()->getCode());
 }
Beispiel #14
0
                <?php 
            }
            ?>
            </table>
            <?php 
        }
        ?>
    </td>
</tr>
        <?php 
    }
    ?>
<tr>
    <th align="center">
        <?php 
    echo sprintf(_ngettext('%s table', '%s tables', $num_tables), PMA_formatNumber($num_tables, 0));
    ?>
    </th>
    <th align="right" nowrap="nowrap">
        <?php 
    echo PMA_formatNumber($sum_entries, 0);
    ?>
    </th>
    <th align="center">
        --
    </th>
    <?php 
    if ($cfg['ShowStats']) {
        list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
        ?>
    <th align="right" nowrap="nowrap">
function _jn($str, $str_plural, $n)
{
    return utf8_encode(_ngettext($str, $str_plural, $n));
}
 /**
  * Renders a part of the tree, used for Ajax
  * requests in light mode
  *
  * @return string HTML code for the navigation tree
  */
 public function renderPath()
 {
     $node = $this->_buildPath();
     if ($node === false) {
         $retval = false;
     } else {
         $this->groupTree();
         $retval = "<div class='list_container' style='display: none;'>";
         $retval .= "<ul>";
         $retval .= $this->_fastFilterHtml($node);
         $retval .= $this->_getPageSelector($node);
         $children = $node->children;
         usort($children, array('PMA_NavigationTree', 'sortNode'));
         for ($i = 0; $i < count($children); $i++) {
             if ($i + 1 != count($children)) {
                 $retval .= $this->_renderNode($children[$i], true);
             } else {
                 $retval .= $this->_renderNode($children[$i], true, 'last');
             }
         }
         $retval .= "</ul>";
         $retval .= "</div>";
     }
     if (!empty($this->_searchClause) || !empty($this->_searchClause2)) {
         if (!empty($this->_searchClause2)) {
             $results = $node->realParent()->getPresence($node->real_name, $this->_searchClause2);
         } else {
             $results = $this->_tree->getPresence('databases', $this->_searchClause);
         }
         $clientResults = 0;
         if (!empty($_REQUEST['results'])) {
             $clientResults = (int) $_REQUEST['results'];
         }
         $otherResults = $results - $clientResults;
         if ($otherResults < 1) {
             $otherResults = '';
         } else {
             $otherResults = sprintf(_ngettext('%s other result found', '%s other results found', $otherResults), $otherResults);
         }
         PMA_Response::getInstance()->addJSON('results', $otherResults);
     }
     return $retval;
 }
 /**
  * Renders a part of the tree, used for Ajax
  * requests in light mode
  *
  * @return string HTML code for the navigation tree
  */
 public function renderPath()
 {
     $node = $this->_buildPath();
     if ($node === false) {
         $retval = false;
     } else {
         $this->groupTree();
         $retval = "<div class='list_container' style='display: none;'>";
         if (!empty($this->_searchClause) || !empty($this->_searchClause2)) {
             $retval .= "<ul class='search_results'>";
         } else {
             $retval .= "<ul>";
         }
         $listContent = $this->_fastFilterHtml($node);
         $listContent .= $this->_getPageSelector($node);
         $children = $node->children;
         usort($children, array('PMA_NavigationTree', 'sortNode'));
         for ($i = 0, $nbChildren = count($children); $i < $nbChildren; $i++) {
             if ($i + 1 != $nbChildren) {
                 $listContent .= $this->_renderNode($children[$i], true);
             } else {
                 $listContent .= $this->_renderNode($children[$i], true, 'last');
             }
         }
         $retval .= $listContent;
         $retval .= "</ul>";
         if (!$GLOBALS['cfg']['ShowDatabasesNavigationAsTree']) {
             $retval .= "<span class='hide loaded_db'>";
             $parents = $node->parents(true);
             $retval .= urlencode($parents[0]->real_name);
             $retval .= "</span>";
             if (empty($listContent)) {
                 $retval .= "<div style='margin:0.75em'>";
                 $retval .= __('No tables found in database.');
                 $retval .= "</div>";
             }
         }
         $retval .= "</div>";
     }
     if (!empty($this->_searchClause) || !empty($this->_searchClause2)) {
         $results = 0;
         if (!empty($this->_searchClause2)) {
             if (is_object($node->realParent())) {
                 $results = $node->realParent()->getPresence($node->real_name, $this->_searchClause2);
             }
         } else {
             $results = $this->_tree->getPresence('databases', $this->_searchClause);
         }
         $results = sprintf(_ngettext('%s result found', '%s results found', $results), $results);
         PMA_Response::getInstance()->addJSON('results', $results);
     }
     return $retval;
 }
Beispiel #18
0
function refreshList($name, $defaultRate = 5, $refreshRates = array(1, 2, 5, 10, 20, 40, 60, 120, 300, 600))
{
    ?>
    <select name="<?php 
    echo $name;
    ?>
" id="id_<?php 
    echo $name;
    ?>
">
        <?php 
    foreach ($refreshRates as $rate) {
        $selected = $rate == $defaultRate ? ' selected="selected"' : '';
        if ($rate < 60) {
            echo '<option value="' . $rate . '"' . $selected . '>' . sprintf(_ngettext('%d second', '%d seconds', $rate), $rate) . '</option>';
        } else {
            echo '<option value="' . $rate . '"' . $selected . '>' . sprintf(_ngettext('%d minute', '%d minutes', $rate / 60), $rate / 60) . '</option>';
        }
    }
    ?>
    </select>
<?php 
}
 function ngettext($singular, $plural, $number)
 {
     return _ngettext($singular, $plural, $number);
 }
Beispiel #20
0
}
// Show correct message
if (!empty($id_bookmark) && $_REQUEST['action_bookmark'] == 2) {
    $message = PMA\libraries\Message::success(__('The bookmark has been deleted.'));
    $display_query = $import_text;
    $error = false;
    // unset error marker, it was used just to skip processing
} elseif (!empty($id_bookmark) && $_REQUEST['action_bookmark'] == 1) {
    $message = PMA\libraries\Message::notice(__('Showing bookmark'));
} elseif ($bookmark_created) {
    $special_message = '[br]' . sprintf(__('Bookmark %s has been created.'), htmlspecialchars($_POST['bkm_label']));
} elseif ($finished && !$error) {
    // Do not display the query with message, we do it separately
    $display_query = ';';
    if ($import_type != 'query') {
        $message = PMA\libraries\Message::success('<em>' . _ngettext('Import has been successfully finished, %d query executed.', 'Import has been successfully finished, %d queries executed.', $executed_queries) . '</em>');
        $message->addParam($executed_queries);
        if ($import_notice) {
            $message->addString($import_notice);
        }
        if (!empty($local_import_file)) {
            $message->addString('(' . htmlspecialchars($local_import_file) . ')');
        } else {
            $message->addString('(' . htmlspecialchars($_FILES['import_file']['name']) . ')');
        }
    }
}
// Did we hit timeout? Tell it user.
if ($timeout_passed) {
    $importUrl = $err_url .= '&timeout_passed=1&offset=' . urlencode($GLOBALS['offset']);
    if (isset($local_import_file)) {
Beispiel #21
0
/**
 * Get HTML body for table summery
 *
 * @param integer $num_tables          number of tables
 * @param boolean $server_slave_status server slave state
 * @param boolean $db_is_system_schema whether database is information schema or not
 * @param integer $sum_entries         sum entries
 * @param string  $db_collation        collation of given db
 * @param boolean $is_show_stats       whether stats is show or not
 * @param double  $sum_size            sum size
 * @param double  $overhead_size       overhead size
 * @param string  $create_time_all     create time
 * @param string  $update_time_all     update time
 * @param string  $check_time_all      check time
 * @param boolean $approx_rows         whether any table has approx row count or not
 *
 * @return string $html_output
 */
function PMA_getHtmlBodyForTableSummary($num_tables, $server_slave_status, $db_is_system_schema, $sum_entries, $db_collation, $is_show_stats, $sum_size, $overhead_size, $create_time_all, $update_time_all, $check_time_all, $approx_rows)
{
    $html_output = '<tbody id="tbl_summary_row">' . '<tr><th></th>';
    $html_output .= '<th class="tbl_num nowrap">';
    $html_output .= sprintf(_ngettext('%s table', '%s tables', $num_tables), PMA_Util::formatNumber($num_tables, 0));
    $html_output .= '</th>';
    if ($server_slave_status) {
        $html_output .= '<th>' . __('Replication') . '</th>' . "\n";
    }
    $sum_colspan = $db_is_system_schema ? 4 : 7;
    if ($GLOBALS['cfg']['NumFavoriteTables'] == 0) {
        $sum_colspan--;
    }
    $html_output .= '<th colspan="' . $sum_colspan . '">' . __('Sum') . '</th>';
    $row_count_sum = PMA_Util::formatNumber($sum_entries, 0);
    // If a table shows approximate rows count, display update-all-real-count anchor.
    $row_sum_url = array();
    if (isset($approx_rows)) {
        $row_sum_url = array('ajax_request' => true, 'db' => $GLOBALS['db'], 'real_row_count' => 'true', 'real_row_count_all' => 'true');
    }
    $cell_text = $approx_rows ? '<a href="db_structure.php' . PMA_URL_getCommon($row_sum_url) . '" class="ajax row_count_sum">' . '~' . $row_count_sum . '</a>' : $row_count_sum;
    $html_output .= '<th class="value tbl_rows">' . $cell_text . '</th>';
    if (!($GLOBALS['cfg']['PropertiesNumColumns'] > 1)) {
        $default_engine = $GLOBALS['dbi']->fetchValue('SHOW VARIABLES LIKE \'storage_engine\';', 0, 1);
        $html_output .= '<th class="center">' . "\n" . '<dfn title="' . sprintf(__('%s is the default storage engine on this MySQL server.'), $default_engine) . '">' . $default_engine . '</dfn></th>' . "\n";
        // we got a case where $db_collation was empty
        $html_output .= '<th>' . "\n";
        if (!empty($db_collation)) {
            $html_output .= '<dfn title="' . PMA_getCollationDescr($db_collation) . ' (' . __('Default') . ')">' . $db_collation . '</dfn>';
        }
        $html_output .= '</th>';
    }
    if ($is_show_stats) {
        list($sum_formatted, $unit) = PMA_Util::formatByteDown($sum_size, 3, 1);
        list($overhead_formatted, $overhead_unit) = PMA_Util::formatByteDown($overhead_size, 3, 1);
        $html_output .= '<th class="value tbl_size">' . $sum_formatted . ' ' . $unit . '</th>';
        $html_output .= '<th class="value tbl_overhead">' . $overhead_formatted . ' ' . $overhead_unit . '</th>';
    }
    if ($GLOBALS['cfg']['ShowDbStructureCreation']) {
        $html_output .= '<th class="value tbl_creation">' . "\n" . '        ' . ($create_time_all ? PMA_Util::localisedDate(strtotime($create_time_all)) : '-') . '</th>';
    }
    if ($GLOBALS['cfg']['ShowDbStructureLastUpdate']) {
        $html_output .= '<th class="value tbl_last_update">' . "\n" . '        ' . ($update_time_all ? PMA_Util::localisedDate(strtotime($update_time_all)) : '-') . '</th>';
    }
    if ($GLOBALS['cfg']['ShowDbStructureLastCheck']) {
        $html_output .= '<th class="value tbl_last_check">' . "\n" . '        ' . ($check_time_all ? PMA_Util::localisedDate(strtotime($check_time_all)) : '-') . '</th>';
    }
    $html_output .= '</tr>' . '</tbody>';
    return $html_output;
}
Beispiel #22
0
/**
 * Plural translation.
 *
 * @param string  $singular Singular.
 * @param string  $plural   Plural.
 * @param integer $count    Count.
 * @param string  $domain   Gettext domain.
 *
 * @throws Exception If $domain is an array.
 * @return string
 */
function _n($singular, $plural, $count, $domain = null)
{
    return isset($domain) ? _dngettext($domain, $singular, $plural, (int) $count) : _ngettext($singular, $plural, (int) $count);
}
Beispiel #23
0
 /**
  * get PMA_Message for number of inserted rows
  *
  * shorthand for getting a customized message
  *
  * @param integer $rows Number of rows
  *
  * @return PMA_Message
  * @static
  */
 public static function getMessageForInsertedRows($rows)
 {
     $message = PMA_Message::success(_ngettext('%1$d row inserted.', '%1$d rows inserted.', $rows));
     $message->addParam($rows);
     return $message;
 }
Beispiel #24
0
 private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view, $next_unread_feed, $offset, $vgr_last_feed = false, $override_order = false, $include_children = false)
 {
     if (isset($_REQUEST["DevForceUpdate"])) {
         header("Content-Type: text/plain; charset=utf-8");
     }
     $disable_cache = false;
     $reply = array();
     $rgba_cache = array();
     $timing_info = microtime(true);
     $topmost_article_ids = array();
     if (!$offset) {
         $offset = 0;
     }
     if ($method == "undefined") {
         $method = "";
     }
     $method_split = explode(":", $method);
     if ($method == "ForceUpdate" && $feed > 0 && is_numeric($feed)) {
         // Update the feed if required with some basic flood control
         $result = $this->dbh->query("SELECT cache_images," . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated\n\t\t\t\t\tFROM ttrss_feeds WHERE id = '{$feed}'");
         if ($this->dbh->num_rows($result) != 0) {
             $last_updated = strtotime($this->dbh->fetch_result($result, 0, "last_updated"));
             $cache_images = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "cache_images"));
             if (!$cache_images && time() - $last_updated > 120 || isset($_REQUEST['DevForceUpdate'])) {
                 include "rssfuncs.php";
                 update_rss_feed($feed, true, true);
             } else {
                 $this->dbh->query("UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01'\n\t\t\t\t\t\t\tWHERE id = '{$feed}'");
             }
         }
     }
     if ($method_split[0] == "MarkAllReadGR") {
         catchup_feed($method_split[1], false);
     }
     // FIXME: might break tag display?
     if (is_numeric($feed) && $feed > 0 && !$cat_view) {
         $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE id = '{$feed}' LIMIT 1");
         if ($this->dbh->num_rows($result) == 0) {
             $reply['content'] = "<div align='center'>" . __('Feed not found.') . "</div>";
         }
     }
     @($search = $this->dbh->escape_string($_REQUEST["query"]));
     if ($search) {
         $disable_cache = true;
     }
     @($search_mode = $this->dbh->escape_string($_REQUEST["search_mode"]));
     if ($_REQUEST["debug"]) {
         $timing_info = print_checkpoint("H0", $timing_info);
     }
     //		error_log("format_headlines_list: [" . $feed . "] method [" . $method . "]");
     if ($search_mode == '' && $method != '') {
         $search_mode = $method;
     }
     //		error_log("search_mode: " . $search_mode);
     if (!$cat_view && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) {
         $handler = PluginHost::getInstance()->get_feed_handler(PluginHost::feed_to_pfeed_id($feed));
         //	function queryFeedHeadlines($feed, $limit, $view_mode, $cat_view, $search, $search_mode, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false, $ignore_vfeed_group = false) {
         if ($handler) {
             $options = array("limit" => $limit, "view_mode" => $view_mode, "cat_view" => $cat_view, "search" => $search, "search_mode" => $search_mode, "override_order" => $override_order, "offset" => $offset, "owner_uid" => $_SESSION["uid"], "filter" => false, "since_id" => 0, "include_children" => $include_children);
             $qfh_ret = $handler->get_headlines(PluginHost::feed_to_pfeed_id($feed), $options);
         }
     } else {
         $qfh_ret = queryFeedHeadlines($feed, $limit, $view_mode, $cat_view, $search, $search_mode, $override_order, $offset, 0, false, 0, $include_children);
     }
     $vfeed_group_enabled = get_pref("VFEED_GROUP_BY_FEED") && $feed != -6;
     if ($_REQUEST["debug"]) {
         $timing_info = print_checkpoint("H1", $timing_info);
     }
     $result = $qfh_ret[0];
     $feed_title = $qfh_ret[1];
     $feed_site_url = $qfh_ret[2];
     $last_error = $qfh_ret[3];
     $last_updated = strpos($qfh_ret[4], '1970-') === FALSE ? make_local_datetime($qfh_ret[4], false) : __("Never");
     $highlight_words = $qfh_ret[5];
     $vgroup_last_feed = $vgr_last_feed;
     $reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url, $feed_title, $feed, $cat_view, $search, $search_mode, $view_mode, $last_error, $last_updated);
     $headlines_count = $this->dbh->num_rows($result);
     /* if (get_pref('COMBINED_DISPLAY_MODE')) {
     			$button_plugins = array();
     			foreach (explode(",", ARTICLE_BUTTON_PLUGINS) as $p) {
     				$pclass = "button_" . trim($p);
     
     				if (class_exists($pclass)) {
     					$plugin = new $pclass();
     					array_push($button_plugins, $plugin);
     				}
     			}
     		} */
     if ($offset == 0) {
         foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HEADLINES_BEFORE) as $p) {
             $reply['content'] .= $p->hook_headlines_before($feed, $cat_view, $qfh_ret);
         }
     }
     if ($this->dbh->num_rows($result) > 0) {
         $lnum = $offset;
         $num_unread = 0;
         $cur_feed_title = '';
         if ($_REQUEST["debug"]) {
             $timing_info = print_checkpoint("PS", $timing_info);
         }
         $expand_cdm = get_pref('CDM_EXPANDED');
         while ($line = $this->dbh->fetch_assoc($result)) {
             $line["content_preview"] = "&mdash; " . truncate_string(strip_tags($line["content"]), 250);
             foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
                 $line = $p->hook_query_headlines($line, 250, false);
             }
             if (get_pref('SHOW_CONTENT_PREVIEW')) {
                 $content_preview = $line["content_preview"];
             }
             $id = $line["id"];
             $feed_id = $line["feed_id"];
             $label_cache = $line["label_cache"];
             $labels = false;
             if ($label_cache) {
                 $label_cache = json_decode($label_cache, true);
                 if ($label_cache) {
                     if ($label_cache["no-labels"] == 1) {
                         $labels = array();
                     } else {
                         $labels = $label_cache;
                     }
                 }
             }
             if (!is_array($labels)) {
                 $labels = get_article_labels($id);
             }
             $labels_str = "<span class=\"HLLCTR-{$id}\">";
             $labels_str .= format_article_labels($labels, $id);
             $labels_str .= "</span>";
             if (count($topmost_article_ids) < 3) {
                 array_push($topmost_article_ids, $id);
             }
             $class = "";
             if (sql_bool_to_bool($line["unread"])) {
                 $class .= " Unread";
                 ++$num_unread;
             }
             if (sql_bool_to_bool($line["marked"])) {
                 $marked_pic = "<img\n\t\t\t\t\t\tsrc=\"images/mark_set.png\"\n\t\t\t\t\t\tclass=\"markedPic\" alt=\"Unstar article\"\n\t\t\t\t\t\tonclick='toggleMark({$id})'>";
                 $class .= " marked";
             } else {
                 $marked_pic = "<img\n\t\t\t\t\t\tsrc=\"images/mark_unset.png\"\n\t\t\t\t\t\tclass=\"markedPic\" alt=\"Star article\"\n\t\t\t\t\t\tonclick='toggleMark({$id})'>";
             }
             if (sql_bool_to_bool($line["published"])) {
                 $published_pic = "<img src=\"images/pub_set.png\"\n\t\t\t\t\t\tclass=\"pubPic\"\n\t\t\t\t\t\t\talt=\"Unpublish article\" onclick='togglePub({$id})'>";
                 $class .= " published";
             } else {
                 $published_pic = "<img src=\"images/pub_unset.png\"\n\t\t\t\t\t\tclass=\"pubPic\"\n\t\t\t\t\t\talt=\"Publish article\" onclick='togglePub({$id})'>";
             }
             #				$content_link = "<a target=\"_blank\" href=\"".$line["link"]."\">" .
             #					$line["title"] . "</a>";
             #				$content_link = "<a
             #					href=\"" . htmlspecialchars($line["link"]) . "\"
             #					onclick=\"view($id,$feed_id);\">" .
             #					$line["title"] . "</a>";
             #				$content_link = "<a href=\"javascript:viewContentUrl('".$line["link"]."');\">" .
             #					$line["title"] . "</a>";
             $updated_fmt = make_local_datetime($line["updated"], false);
             $date_entered_fmt = T_sprintf("Imported at %s", make_local_datetime($line["date_entered"], false));
             $score = $line["score"];
             $score_pic = "images/" . get_score_pic($score);
             /*				$score_title = __("(Click to change)");
             				$score_pic = "<img class='hlScorePic' src=\"images/$score_pic\"
             					onclick=\"adjustArticleScore($id, $score)\" title=\"$score $score_title\">"; */
             $score_pic = "<img class='hlScorePic' score='{$score}' onclick='changeScore({$id}, this)' src=\"{$score_pic}\"\n\t\t\t\t\ttitle=\"{$score}\">";
             if ($score > 500) {
                 $hlc_suffix = "high";
             } else {
                 if ($score < -100) {
                     $hlc_suffix = "low";
                 } else {
                     $hlc_suffix = "";
                 }
             }
             $entry_author = $line["author"];
             if ($entry_author) {
                 $entry_author = " &mdash; {$entry_author}";
             }
             $has_feed_icon = feed_has_icon($feed_id);
             if ($has_feed_icon) {
                 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . "/{$feed_id}.ico\" alt=\"\">";
             } else {
                 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/pub_set.png\" alt=\"\">";
             }
             $entry_site_url = $line["site_url"];
             //setting feed headline background color, needs to change text color based on dark/light
             $fav_color = $line['favicon_avg_color'];
             require_once "colors.php";
             if ($fav_color && $fav_color != 'fail') {
                 if (!isset($rgba_cache[$feed_id])) {
                     $rgba_cache[$feed_id] = join(",", _color_unpack($fav_color));
                 }
             }
             if (!get_pref('COMBINED_DISPLAY_MODE')) {
                 if ($vfeed_group_enabled) {
                     if ($feed_id != $vgroup_last_feed && $line["feed_title"]) {
                         $cur_feed_title = $line["feed_title"];
                         $vgroup_last_feed = $feed_id;
                         $cur_feed_title = htmlspecialchars($cur_feed_title);
                         $vf_catchup_link = "<a class='catchup' onclick='catchupFeedInGroup({$feed_id});' href='#'>" . __('mark feed as read') . "</a>";
                         $reply['content'] .= "<div id='FTITLE-{$feed_id}' class='cdmFeedTitle'>" . "<div style='float : right'>{$feed_icon_img}</div>" . "<a class='title' href=\"#\" onclick=\"viewfeed({$feed_id})\">" . $line["feed_title"] . "</a>\n\t\t\t\t\t\t\t\t{$vf_catchup_link}</div>";
                     }
                 }
                 $mouseover_attrs = "onmouseover='postMouseIn(event, {$id})'\n\t\t\t\t\t\tonmouseout='postMouseOut({$id})'";
                 $reply['content'] .= "<div class='hl {$class}' orig-feed-id='{$feed_id}' id='RROW-{$id}' {$mouseover_attrs}>";
                 $reply['content'] .= "<div class='hlLeft'>";
                 $reply['content'] .= "<input dojoType=\"dijit.form.CheckBox\"\n\t\t\t\t\t\t\ttype=\"checkbox\" onclick=\"toggleSelectRow2(this)\"\n\t\t\t\t\t\t\tclass='rchk'>";
                 $reply['content'] .= "{$marked_pic}";
                 $reply['content'] .= "{$published_pic}";
                 $reply['content'] .= "</div>";
                 $reply['content'] .= "<div onclick='return hlClicked(event, {$id})'\n\t\t\t\t\t\tclass=\"hlTitle\"><span class='hlContent {$hlc_suffix}'>";
                 $reply['content'] .= "<a id=\"RTITLE-{$id}\" class=\"title {$hlc_suffix}\"\n\t\t\t\t\t\thref=\"" . htmlspecialchars($line["link"]) . "\"\n\t\t\t\t\t\tonclick=\"\">" . truncate_string($line["title"], 200);
                 if (get_pref('SHOW_CONTENT_PREVIEW')) {
                     $reply['content'] .= "<span class=\"contentPreview\">" . $line["content_preview"] . "</span>";
                 }
                 $reply['content'] .= "</a></span>";
                 $reply['content'] .= $labels_str;
                 $reply['content'] .= "</div>";
                 if (!$vfeed_group_enabled) {
                     if (@$line["feed_title"]) {
                         $rgba = @$rgba_cache[$feed_id];
                         $reply['content'] .= "<span class=\"hlFeed\"><a style=\"background : rgba({$rgba}, 0.3)\" href=\"#\" onclick=\"viewfeed({$feed_id})\">" . truncate_string($line["feed_title"], 30) . "</a></span>";
                     }
                 }
                 $reply['content'] .= "<span class=\"hlUpdated\">";
                 $reply['content'] .= "<div title='{$date_entered_fmt}'>{$updated_fmt}</div>\n\t\t\t\t\t\t</span>";
                 $reply['content'] .= "<div class=\"hlRight\">";
                 $reply['content'] .= $score_pic;
                 if ($line["feed_title"] && !$vfeed_group_enabled) {
                     $reply['content'] .= "<span onclick=\"viewfeed({$feed_id})\"\n\t\t\t\t\t\t\tstyle=\"cursor : pointer\"\n\t\t\t\t\t\t\ttitle=\"" . htmlspecialchars($line['feed_title']) . "\">\n\t\t\t\t\t\t\t{$feed_icon_img}</span>";
                 }
                 $reply['content'] .= "</div>";
                 $reply['content'] .= "</div>";
             } else {
                 if ($line["tag_cache"]) {
                     $tags = explode(",", $line["tag_cache"]);
                 } else {
                     $tags = false;
                 }
                 $line["content"] = sanitize($line["content"], sql_bool_to_bool($line['hide_images']), false, $entry_site_url, $highlight_words, $line["id"]);
                 foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_CDM) as $p) {
                     $line = $p->hook_render_article_cdm($line);
                 }
                 if ($vfeed_group_enabled && $line["feed_title"]) {
                     if ($feed_id != $vgroup_last_feed) {
                         $cur_feed_title = $line["feed_title"];
                         $vgroup_last_feed = $feed_id;
                         $cur_feed_title = htmlspecialchars($cur_feed_title);
                         $vf_catchup_link = "<a class='catchup' onclick='catchupFeedInGroup({$feed_id});' href='#'>" . __('mark feed as read') . "</a>";
                         $has_feed_icon = feed_has_icon($feed_id);
                         if ($has_feed_icon) {
                             $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . "/{$feed_id}.ico\" alt=\"\">";
                         } else {
                             //$feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\" alt=\"\">";
                         }
                         $reply['content'] .= "<div id='FTITLE-{$feed_id}' class='cdmFeedTitle'>" . "<div style=\"float : right\">{$feed_icon_img}</div>" . "<a href=\"#\" class='title' onclick=\"viewfeed({$feed_id})\">" . $line["feed_title"] . "</a> {$vf_catchup_link}</div>";
                     }
                 }
                 $mouseover_attrs = "onmouseover='postMouseIn(event, {$id})'\n\t\t\t\t\t\tonmouseout='postMouseOut({$id})'";
                 $expanded_class = $expand_cdm ? "expanded" : "expandable";
                 $reply['content'] .= "<div class=\"cdm {$hlc_suffix} {$expanded_class} {$class}\"\n\t\t\t\t\t\tid=\"RROW-{$id}\" orig-feed-id='{$feed_id}' {$mouseover_attrs}>";
                 $reply['content'] .= "<div class=\"cdmHeader\">";
                 $reply['content'] .= "<div style=\"vertical-align : middle\">";
                 $reply['content'] .= "<input dojoType=\"dijit.form.CheckBox\"\n\t\t\t\t\t\t\ttype=\"checkbox\" onclick=\"toggleSelectRow2(this, false, true)\"\n\t\t\t\t\t\t\tclass='rchk'>";
                 $reply['content'] .= "{$marked_pic}";
                 $reply['content'] .= "{$published_pic}";
                 $reply['content'] .= "</div>";
                 if ($highlight_words && count($highlight_words > 0)) {
                     foreach ($highlight_words as $word) {
                         $line["title"] = preg_replace("/(\\Q{$word}\\E)/i", "<span class=\"highlight\">\$1</span>", $line["title"]);
                     }
                 }
                 $reply['content'] .= "<span id=\"RTITLE-{$id}\"\n\t\t\t\t\t\tonclick=\"return cdmClicked(event, {$id});\"\n\t\t\t\t\t\tclass=\"titleWrap {$hlc_suffix}\">\n\t\t\t\t\t\t<a class=\"title {$hlc_suffix}\"\n\t\t\t\t\t\ttarget=\"_blank\" href=\"" . htmlspecialchars($line["link"]) . "\">" . $line["title"] . "</a> <span class=\"author\">{$entry_author}</span>";
                 $reply['content'] .= $labels_str;
                 $reply['content'] .= "<span class='collapseBtn' style='display : none'>\n\t\t\t\t\t\t<img src=\"images/collapse.png\" onclick=\"cdmCollapseArticle(event, {$id})\"\n\t\t\t\t\t\ttitle=\"" . __("Collapse article") . "\"/></span>";
                 if (!$expand_cdm) {
                     $content_hidden = "style=\"display : none\"";
                 } else {
                     $excerpt_hidden = "style=\"display : none\"";
                 }
                 $reply['content'] .= "<span {$excerpt_hidden} id=\"CEXC-{$id}\" class=\"cdmExcerpt\">" . $content_preview . "</span>";
                 $reply['content'] .= "</span>";
                 if (!$vfeed_group_enabled) {
                     if (@$line["feed_title"]) {
                         $rgba = @$rgba_cache[$feed_id];
                         $reply['content'] .= "<div class=\"hlFeed\">\n\t\t\t\t\t\t\t\t<a href=\"#\" style=\"background-color: rgba({$rgba},0.3)\"\n\t\t\t\t\t\t\t\tonclick=\"viewfeed({$feed_id})\">" . truncate_string($line["feed_title"], 30) . "</a>\n\t\t\t\t\t\t\t</div>";
                     }
                 }
                 $reply['content'] .= "<span class='updated' title='{$date_entered_fmt}'>\n\t\t\t\t\t\t{$updated_fmt}</span>";
                 $reply['content'] .= "<div class='scoreWrap' style=\"vertical-align : middle\">";
                 $reply['content'] .= "{$score_pic}";
                 if (!get_pref("VFEED_GROUP_BY_FEED") && $line["feed_title"]) {
                     $reply['content'] .= "<span style=\"cursor : pointer\"\n\t\t\t\t\t\t\ttitle=\"" . htmlspecialchars($line["feed_title"]) . "\"\n\t\t\t\t\t\t\tonclick=\"viewfeed({$feed_id})\">{$feed_icon_img}</span>";
                 }
                 $reply['content'] .= "</div>";
                 $reply['content'] .= "</div>";
                 $reply['content'] .= "<div class=\"cdmContent\" {$content_hidden}\n\t\t\t\t\t\tonclick=\"return cdmClicked(event, {$id});\"\n\t\t\t\t\t\tid=\"CICD-{$id}\">";
                 $reply['content'] .= "<div id=\"POSTNOTE-{$id}\">";
                 if ($line['note']) {
                     $reply['content'] .= format_article_note($id, $line['note']);
                 }
                 $reply['content'] .= "</div>";
                 if (!$line['lang']) {
                     $line['lang'] = 'en';
                 }
                 $reply['content'] .= "<div class=\"cdmContentInner\" lang=\"" . $line['lang'] . "\">";
                 if ($line["orig_feed_id"]) {
                     $tmp_result = $this->dbh->query("SELECT * FROM ttrss_archived_feeds\n\t\t\t\t\tWHERE id = " . $line["orig_feed_id"]);
                     if ($this->dbh->num_rows($tmp_result) != 0) {
                         $reply['content'] .= "<div clear='both'>";
                         $reply['content'] .= __("Originally from:");
                         $reply['content'] .= "&nbsp;";
                         $tmp_line = $this->dbh->fetch_assoc($tmp_result);
                         $reply['content'] .= "<a target='_blank'\n\t\t\t\t\t\t\t\thref=' " . htmlspecialchars($tmp_line['site_url']) . "'>" . $tmp_line['title'] . "</a>";
                         $reply['content'] .= "&nbsp;";
                         $reply['content'] .= "<a target='_blank' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>";
                         $reply['content'] .= "<img title='" . __('Feed URL') . "'class='tinyFeedIcon' src='images/pub_unset.png'></a>";
                         $reply['content'] .= "</div>";
                     }
                 }
                 $reply['content'] .= "<span id=\"CWRAP-{$id}\">";
                 //					if (!$expand_cdm) {
                 $reply['content'] .= "<span id=\"CENCW-{$id}\" style=\"display : none\">";
                 $reply['content'] .= htmlspecialchars($line["content"]);
                 $reply['content'] .= "</span.";
                 //					} else {
                 //						$reply['content'] .= $line["content"];
                 //					}
                 $reply['content'] .= "</span>";
                 $always_display_enclosures = sql_bool_to_bool($line["always_display_enclosures"]);
                 $reply['content'] .= format_article_enclosures($id, $always_display_enclosures, $line["content"], sql_bool_to_bool($line["hide_images"]));
                 $reply['content'] .= "</div>";
                 $reply['content'] .= "<div class=\"cdmFooter\">";
                 foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) {
                     $reply['content'] .= $p->hook_article_left_button($line);
                 }
                 $tags_str = format_tags_string($tags, $id);
                 $reply['content'] .= "<img src='images/tag.png' alt='Tags' title='Tags'>\n\t\t\t\t\t\t<span id=\"ATSTR-{$id}\">{$tags_str}</span>\n\t\t\t\t\t\t<a title=\"" . __('Edit tags for this article') . "\"\n\t\t\t\t\t\thref=\"#\" onclick=\"editArticleTags({$id})\">(+)</a>";
                 $num_comments = $line["num_comments"];
                 $entry_comments = "";
                 if ($num_comments > 0) {
                     if ($line["comments"]) {
                         $comments_url = htmlspecialchars($line["comments"]);
                     } else {
                         $comments_url = htmlspecialchars($line["link"]);
                     }
                     $entry_comments = "<a class=\"postComments\"\n\t\t\t\t\t\t\ttarget='_blank' href=\"{$comments_url}\">{$num_comments} " . _ngettext("comment", "comments", $num_comments) . "</a>";
                 } else {
                     if ($line["comments"] && $line["link"] != $line["comments"]) {
                         $entry_comments = "<a class=\"postComments\" target='_blank' href=\"" . htmlspecialchars($line["comments"]) . "\">" . __("comments") . "</a>";
                     }
                 }
                 if ($entry_comments) {
                     $reply['content'] .= "&nbsp;({$entry_comments})";
                 }
                 $reply['content'] .= "<div style=\"float : right\">";
                 //					$reply['content'] .= "$marked_pic";
                 //					$reply['content'] .= "$published_pic";
                 foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_BUTTON) as $p) {
                     $reply['content'] .= $p->hook_article_button($line);
                 }
                 $reply['content'] .= "</div>";
                 $reply['content'] .= "</div>";
                 $reply['content'] .= "</div>";
                 $reply['content'] .= "</div>";
             }
             ++$lnum;
         }
         if ($_REQUEST["debug"]) {
             $timing_info = print_checkpoint("PE", $timing_info);
         }
     } else {
         $message = "";
         switch ($view_mode) {
             case "unread":
                 $message = __("No unread articles found to display.");
                 break;
             case "updated":
                 $message = __("No updated articles found to display.");
                 break;
             case "marked":
                 $message = __("No starred articles found to display.");
                 break;
             default:
                 if ($feed < LABEL_BASE_INDEX) {
                     $message = __("No articles found to display. You can assign articles to labels manually from article header context menu (applies to all selected articles) or use a filter.");
                 } else {
                     $message = __("No articles found to display.");
                 }
         }
         if (!$offset && $message) {
             $reply['content'] .= "<div class='whiteBox'>{$message}";
             $reply['content'] .= "<p><span class=\"insensitive\">";
             $result = $this->dbh->query("SELECT " . SUBSTRING_FOR_DATE . "(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds\n\t\t\t\t\tWHERE owner_uid = " . $_SESSION['uid']);
             $last_updated = $this->dbh->fetch_result($result, 0, "last_updated");
             $last_updated = make_local_datetime($last_updated, false);
             $reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
             $result = $this->dbh->query("SELECT COUNT(id) AS num_errors\n\t\t\t\t\tFROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION["uid"]);
             $num_errors = $this->dbh->fetch_result($result, 0, "num_errors");
             if ($num_errors > 0) {
                 $reply['content'] .= "<br/>";
                 $reply['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">" . __('Some feeds have update errors (click for details)') . "</a>";
             }
             $reply['content'] .= "</span></p></div>";
         }
     }
     if ($_REQUEST["debug"]) {
         $timing_info = print_checkpoint("H2", $timing_info);
     }
     return array($topmost_article_ids, $headlines_count, $feed, $disable_cache, $vgroup_last_feed, $reply);
 }
Beispiel #25
0
if ($is_show_stats) {
    list($sum_formatted, $unit) = PMA_formatByteDown($sum_size, 3, 1);
    list($overhead_formatted, $overhead_unit) = PMA_formatByteDown($overhead_size, 3, 1);
}
?>
</tbody>
<tbody id="tbl_summary_row">
<tr><th></th>
    <th align="center" nowrap="nowrap">
        <?php 
// for blobstreaming - if the number of tables is 0, set tableReductionCount to 0
// (we don't want negative numbers here)
if ($num_tables == 0) {
    $tableReductionCount = 0;
}
echo sprintf(_ngettext('%s table', '%s tables', $num_tables - $tableReductionCount), PMA_formatNumber($num_tables - $tableReductionCount, 0));
?>
    </th>
    <?php 
if ($server_slave_status) {
    echo '    <th>' . __('Replication') . '</th>' . "\n";
}
?>
    <th colspan="<?php 
echo $db_is_information_schema ? 3 : 6;
?>
" align="center">
        <?php 
echo __('Sum');
?>
</th>
 /**
  * Index action
  *
  * @return void
  */
 public function indexAction()
 {
     PMA_PageSettings::showGroup('TableStructure');
     /**
      * Function implementations for this script
      */
     include_once 'libraries/check_user_privileges.lib.php';
     include_once 'libraries/index.lib.php';
     include_once 'libraries/sql.lib.php';
     include_once 'libraries/bookmark.lib.php';
     $this->response->getHeader()->getScripts()->addFiles(array('tbl_structure.js', 'indexes.js'));
     /**
      * Handle column moving
      */
     if (isset($_REQUEST['move_columns']) && is_array($_REQUEST['move_columns']) && $this->response->isAjax()) {
         $this->moveColumns();
         return;
     }
     /**
      * handle MySQL reserved words columns check
      */
     if (isset($_REQUEST['reserved_word_check'])) {
         if ($GLOBALS['cfg']['ReservedWordDisableWarning'] === false) {
             $columns_names = $_REQUEST['field_name'];
             $reserved_keywords_names = array();
             foreach ($columns_names as $column) {
                 if (SqlParser\Context::isKeyword(trim($column), true)) {
                     $reserved_keywords_names[] = trim($column);
                 }
             }
             if (SqlParser\Context::isKeyword(trim($this->table), true)) {
                 $reserved_keywords_names[] = trim($this->table);
             }
             if (count($reserved_keywords_names) == 0) {
                 $this->response->isSuccess(false);
             }
             $this->response->addJSON('message', sprintf(_ngettext('The name \'%s\' is a MySQL reserved keyword.', 'The names \'%s\' are MySQL reserved keywords.', count($reserved_keywords_names)), implode(',', $reserved_keywords_names)));
         } else {
             $this->response->isSuccess(false);
         }
         return;
     }
     /**
      * A click on Change has been made for one column
      */
     if (isset($_REQUEST['change_column'])) {
         $this->displayHtmlForColumnChange(null, 'tbl_structure.php');
         return;
     }
     /**
      * handle multiple field commands if required
      *
      * submit_mult_*_x comes from IE if <input type="img" ...> is used
      */
     $submit_mult = $this->getMultipleFieldCommandType();
     if (!empty($submit_mult)) {
         if (isset($_REQUEST['selected_fld'])) {
             if ($submit_mult == 'browse') {
                 // browsing the table displaying only selected columns
                 $this->displayTableBrowseForSelectedColumns($GLOBALS['goto'], $GLOBALS['pmaThemeImage']);
             } else {
                 // handle multiple field commands
                 // handle confirmation of deleting multiple columns
                 $action = 'tbl_structure.php';
                 $GLOBALS['selected'] = $_REQUEST['selected_fld'];
                 list($what_ret, $query_type_ret, $is_unset_submit_mult, $mult_btn_ret, $centralColsError) = $this->getDataForSubmitMult($submit_mult, $_REQUEST['selected_fld'], $action);
                 //update the existing variables
                 // todo: refactor mult_submits.inc.php such as
                 // below globals are not needed anymore
                 if (isset($what_ret)) {
                     $GLOBALS['what'] = $what_ret;
                     global $what;
                 }
                 if (isset($query_type_ret)) {
                     $GLOBALS['query_type'] = $query_type_ret;
                     global $query_type;
                 }
                 if ($is_unset_submit_mult) {
                     unset($submit_mult);
                 }
                 if (isset($mult_btn_ret)) {
                     $GLOBALS['mult_btn'] = $mult_btn_ret;
                     global $mult_btn;
                 }
                 include 'libraries/mult_submits.inc.php';
                 /**
                  * if $submit_mult == 'change', execution will have stopped
                  * at this point
                  */
                 if (empty($message)) {
                     $message = PMA_Message::success();
                 }
                 $this->response->addHTML(PMA_Util::getMessage($message, $sql_query));
             }
         } else {
             $this->response->isSuccess(false);
             $this->response->addJSON('message', __('No column selected.'));
         }
     }
     // display secondary level tabs if necessary
     $engine = $this->table_obj->sGetStatusInfo('ENGINE');
     $this->response->addHTML(Template::get('table/secondary_tabs')->render(array('url_params' => array('db' => $this->db, 'table' => $this->table), 'engine' => $engine)));
     $this->response->addHTML('<div id="structure_content">');
     /**
      * Modifications have been submitted -> updates the table
      */
     if (isset($_REQUEST['do_save_data'])) {
         $regenerate = $this->updateColumns();
         if ($regenerate) {
             // This happens when updating failed
             // @todo: do something appropriate
         } else {
             // continue to show the table's structure
             unset($_REQUEST['selected']);
         }
     }
     /**
      * Adding indexes
      */
     if (isset($_REQUEST['add_key'])) {
         //todo: set some variables for sql.php include, to be eliminated
         //after refactoring sql.php
         $db = $this->db;
         $table = $this->table;
         $cfg = $GLOBALS['cfg'];
         $is_superuser = $GLOBALS['dbi']->isSuperuser();
         $pmaThemeImage = $GLOBALS['pmaThemeImage'];
         include 'sql.php';
         $GLOBALS['reload'] = true;
     }
     /**
      * Gets the relation settings
      */
     $cfgRelation = PMA_getRelationsParam();
     /**
      * Runs common work
      */
     // set db, table references, for require_once that follows
     // got to be eliminated in long run
     $db =& $this->db;
     $table =& $this->table;
     include_once 'libraries/tbl_common.inc.php';
     $this->_url_query = $url_query . '&amp;goto=tbl_structure.php&amp;back=tbl_structure.php';
     $url_params['goto'] = 'tbl_structure.php';
     $url_params['back'] = 'tbl_structure.php';
     /**
      * Gets tables information
      */
     include_once 'libraries/tbl_info.inc.php';
     include_once 'libraries/Index.class.php';
     // 2. Gets table keys and retains them
     // @todo should be: $server->db($db)->table($table)->primary()
     $primary = PMA_Index::getPrimary($this->table, $this->db);
     $columns_with_index = $this->dbi->getTable($this->db, $this->table)->getColumnsWithIndex(PMA_Index::UNIQUE | PMA_Index::INDEX | PMA_Index::SPATIAL | PMA_Index::FULLTEXT);
     $columns_with_unique_index = $this->dbi->getTable($this->db, $this->table)->getColumnsWithIndex(PMA_Index::UNIQUE);
     // 3. Get fields
     $fields = (array) $this->dbi->getColumns($this->db, $this->table, null, true);
     // Get more complete field information
     // For now, this is done just for MySQL 4.1.2+ new TIMESTAMP options
     // but later, if the analyser returns more information, it
     // could be executed for any MySQL version and replace
     // the info given by SHOW FULL COLUMNS FROM.
     //
     // We also need this to correctly learn if a TIMESTAMP is NOT NULL, since
     // SHOW FULL COLUMNS or INFORMATION_SCHEMA incorrectly says NULL
     // and SHOW CREATE TABLE says NOT NULL (tested
     // in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910).
     $show_create_table = $this->table_obj->showCreate();
     $parser = new SqlParser\Parser($show_create_table);
     /**
      * @var CreateStatement $stmt
      */
     $stmt = $parser->statements[0];
     $create_table_fields = SqlParser\Utils\Table::getFields($stmt);
     //display table structure
     $this->response->addHTML($this->displayStructure($cfgRelation, $columns_with_unique_index, $url_params, $primary, $fields, $columns_with_index, $create_table_fields));
     $this->response->addHTML('</div>');
 }
Beispiel #27
0
');return false;" ><?php 
            echo __('Delete');
            ?>
</a>   </td>
            <?php 
        } else {
            echo '<td>&nbsp;</td>' . "\n" . '<td>&nbsp;</td>' . "\n";
        }
        // end if else
        $odd_row = !$odd_row;
        echo '</tr>' . "\n";
    }
    // end for
    echo '</table>' . "\n";
    if (count($tables_selected) > 1) {
        echo '<p>' . sprintf(_ngettext('<b>Total:</b> <i>%s</i> match', '<b>Total:</b> <i>%s</i> matches', $num_search_result_total), $num_search_result_total) . '</p>' . "\n";
    }
}
// end 1.
/**
 * If we are in an Ajax request, we need to exit after displaying all the HTML
 */
if ($GLOBALS['is_ajax_request'] == true) {
    exit;
} else {
    echo '</div>';
    //end searchresults div
}
/**
 * 2. Displays the main search form
 */
Beispiel #28
0
/**
 * Deal with Drops multiple databases
 *
 * @return null
 */
function PMA_dropMultiDatabases()
{
    if (!isset($_REQUEST['selected_dbs']) && !isset($_REQUEST['query_type'])) {
        $message = PMA_Message::error(__('No databases selected.'));
    } else {
        $action = 'server_databases.php';
        $submit_mult = 'drop_db';
        $err_url = 'server_databases.php?' . PMA_URL_getCommon();
        if (isset($_REQUEST['selected_dbs']) && !isset($_REQUEST['is_js_confirmed'])) {
            $selected_db = $_REQUEST['selected_dbs'];
        }
        if (isset($_REQUEST['is_js_confirmed'])) {
            $_REQUEST = array('query_type' => $submit_mult, 'selected' => $_REQUEST['selected_dbs'], 'mult_btn' => __('Yes'), 'db' => $GLOBALS['db'], 'table' => $GLOBALS['table']);
        }
        //the following variables will be used on mult_submits.inc.php
        global $query_type, $selected, $mult_btn;
        include 'libraries/mult_submits.inc.php';
        unset($action, $submit_mult, $err_url, $selected_db, $GLOBALS['db']);
        if (empty($message)) {
            if ($mult_btn == __('Yes')) {
                $number_of_databases = count($selected);
            } else {
                $number_of_databases = 0;
            }
            $message = PMA_Message::success(_ngettext('%1$d database has been dropped successfully.', '%1$d databases have been dropped successfully.', $number_of_databases));
            $message->addParam($number_of_databases);
        }
    }
    if ($GLOBALS['is_ajax_request'] && $message instanceof PMA_Message) {
        $response = PMA_Response::getInstance();
        $response->isSuccess($message->isSuccess());
        $response->addJSON('message', $message);
        exit;
    }
}
/**
 * Handles requests for executing a routine
 *
 * @return void
 */
function PMA_RTN_handleExecute()
{
    global $_GET, $_POST, $_REQUEST, $GLOBALS, $db;
    /**
     * Handle all user requests other than the default of listing routines
     */
    if (!empty($_REQUEST['execute_routine']) && !empty($_REQUEST['item_name'])) {
        // Build the queries
        $routine = PMA_RTN_getDataFromName($_REQUEST['item_name'], $_REQUEST['item_type'], false, true);
        if ($routine === false) {
            $message = __('Error in processing request:') . ' ';
            $message .= sprintf(PMA_RTE_getWord('not_found'), htmlspecialchars(PMA\libraries\Util::backquote($_REQUEST['item_name'])), htmlspecialchars(PMA\libraries\Util::backquote($db)));
            $message = Message::error($message);
            if ($GLOBALS['is_ajax_request']) {
                $response = PMA\libraries\Response::getInstance();
                $response->setRequestStatus(false);
                $response->addJSON('message', $message);
                exit;
            } else {
                echo $message->getDisplay();
                unset($_POST);
            }
        }
        $queries = array();
        $end_query = array();
        $args = array();
        $all_functions = $GLOBALS['PMA_Types']->getAllFunctions();
        for ($i = 0; $i < $routine['item_num_params']; $i++) {
            if (isset($_REQUEST['params'][$routine['item_param_name'][$i]])) {
                $value = $_REQUEST['params'][$routine['item_param_name'][$i]];
                if (is_array($value)) {
                    // is SET type
                    $value = implode(',', $value);
                }
                $value = $GLOBALS['dbi']->escapeString($value);
                if (!empty($_REQUEST['funcs'][$routine['item_param_name'][$i]]) && in_array($_REQUEST['funcs'][$routine['item_param_name'][$i]], $all_functions)) {
                    $queries[] = "SET @p{$i}=" . $_REQUEST['funcs'][$routine['item_param_name'][$i]] . "('{$value}');\n";
                } else {
                    $queries[] = "SET @p{$i}='{$value}';\n";
                }
                $args[] = "@p{$i}";
            } else {
                $args[] = "@p{$i}";
            }
            if ($routine['item_type'] == 'PROCEDURE') {
                if ($routine['item_param_dir'][$i] == 'OUT' || $routine['item_param_dir'][$i] == 'INOUT') {
                    $end_query[] = "@p{$i} AS " . PMA\libraries\Util::backquote($routine['item_param_name'][$i]);
                }
            }
        }
        if ($routine['item_type'] == 'PROCEDURE') {
            $queries[] = "CALL " . PMA\libraries\Util::backquote($routine['item_name']) . "(" . implode(', ', $args) . ");\n";
            if (count($end_query)) {
                $queries[] = "SELECT " . implode(', ', $end_query) . ";\n";
            }
        } else {
            $queries[] = "SELECT " . PMA\libraries\Util::backquote($routine['item_name']) . "(" . implode(', ', $args) . ") " . "AS " . PMA\libraries\Util::backquote($routine['item_name']) . ";\n";
        }
        // Get all the queries as one SQL statement
        $multiple_query = implode("", $queries);
        $outcome = true;
        $affected = 0;
        // Execute query
        if (!$GLOBALS['dbi']->tryMultiQuery($multiple_query)) {
            $outcome = false;
        }
        // Generate output
        if ($outcome) {
            // Pass the SQL queries through the "pretty printer"
            $output = PMA\libraries\Util::formatSql(implode($queries, "\n"));
            // Display results
            $output .= "<fieldset><legend>";
            $output .= sprintf(__('Execution results of routine %s'), PMA\libraries\Util::backquote(htmlspecialchars($routine['item_name'])));
            $output .= "</legend>";
            $nbResultsetToDisplay = 0;
            do {
                $result = $GLOBALS['dbi']->storeResult();
                $num_rows = $GLOBALS['dbi']->numRows($result);
                if ($result !== false && $num_rows > 0) {
                    $output .= "<table><tr>";
                    foreach ($GLOBALS['dbi']->getFieldsMeta($result) as $field) {
                        $output .= "<th>";
                        $output .= htmlspecialchars($field->name);
                        $output .= "</th>";
                    }
                    $output .= "</tr>";
                    $color_class = 'odd';
                    while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
                        $output .= "<tr>" . browseRow($row, $color_class) . "</tr>";
                        $color_class = $color_class == 'odd' ? 'even' : 'odd';
                    }
                    $output .= "</table>";
                    $nbResultsetToDisplay++;
                    $affected = $num_rows;
                }
                if (!$GLOBALS['dbi']->moreResults()) {
                    break;
                }
                $output .= "<br/>";
                $GLOBALS['dbi']->freeResult($result);
            } while ($GLOBALS['dbi']->nextResult());
            $output .= "</fieldset>";
            $message = __('Your SQL query has been executed successfully.');
            if ($routine['item_type'] == 'PROCEDURE') {
                $message .= '<br />';
                // TODO : message need to be modified according to the
                // output from the routine
                $message .= sprintf(_ngettext('%d row affected by the last statement inside the ' . 'procedure.', '%d rows affected by the last statement inside the ' . 'procedure.', $affected), $affected);
            }
            $message = Message::success($message);
            if ($nbResultsetToDisplay == 0) {
                $notice = __('MySQL returned an empty result set (i.e. zero rows).');
                $output .= Message::notice($notice)->getDisplay();
            }
        } else {
            $output = '';
            $message = Message::error(sprintf(__('The following query has failed: "%s"'), htmlspecialchars($multiple_query)) . '<br /><br />' . __('MySQL said: ') . $GLOBALS['dbi']->getError(null));
        }
        // Print/send output
        if ($GLOBALS['is_ajax_request']) {
            $response = PMA\libraries\Response::getInstance();
            $response->setRequestStatus($message->isSuccess());
            $response->addJSON('message', $message->getDisplay() . $output);
            $response->addJSON('dialog', false);
            exit;
        } else {
            echo $message->getDisplay(), $output;
            if ($message->isError()) {
                // At least one query has failed, so shouldn't
                // execute any more queries, so we quit.
                exit;
            }
            unset($_POST);
            // Now deliberately fall through to displaying the routines list
        }
        return;
    } else {
        if (!empty($_GET['execute_dialog']) && !empty($_GET['item_name'])) {
            /**
             * Display the execute form for a routine.
             */
            $routine = PMA_RTN_getDataFromName($_GET['item_name'], $_GET['item_type'], true, true);
            if ($routine !== false) {
                $form = PMA_RTN_getExecuteForm($routine);
                if ($GLOBALS['is_ajax_request'] == true) {
                    $title = __("Execute routine") . " " . PMA\libraries\Util::backquote(htmlentities($_GET['item_name'], ENT_QUOTES));
                    $response = PMA\libraries\Response::getInstance();
                    $response->addJSON('message', $form);
                    $response->addJSON('title', $title);
                    $response->addJSON('dialog', true);
                } else {
                    echo "\n\n<h2>" . __("Execute routine") . "</h2>\n\n";
                    echo $form;
                }
                exit;
            } else {
                if ($GLOBALS['is_ajax_request'] == true) {
                    $message = __('Error in processing request:') . ' ';
                    $message .= sprintf(PMA_RTE_getWord('not_found'), htmlspecialchars(PMA\libraries\Util::backquote($_REQUEST['item_name'])), htmlspecialchars(PMA\libraries\Util::backquote($db)));
                    $message = Message::error($message);
                    $response = PMA\libraries\Response::getInstance();
                    $response->setRequestStatus(false);
                    $response->addJSON('message', $message);
                    exit;
                }
            }
        }
    }
}
Beispiel #30
0
            $endDate->modify("+{$withdrawalDay} day");
        }
        if ($currentDate < $startDate) {
            $startDate->modify("-1 month");
            $endDate->modify("-1 month");
        }
        $currency = configgetvalue('system', 'main', NULL, 'currency');
        $tariffPrice = smoneyf($user->calculateTariffPrice());
        $formattedTariffPrice = sprintf(_ngettext("%s {$currency}", "%s {$currency}", $tariffPrice), $tariffPrice);
        $fenom->display($theme->getTemplateLocation('header.tpl'), $headerData);
        if (isset($_POST['code'])) {
            $paySum = $sc->pay($_POST['code'], $user->getId());
            if ($paySum) {
                $currency = configgetvalue('system', 'main', NULL, 'currency');
                $formattedFundSum = sprintf(ngettext("%s {$currency}", "%s {$currency}", $paySum), $paySum);
                $tpl = array("formattedFundSum" => $formattedFundSum);
                $fenom->display($theme->getTemplateLocation('goodcard.tpl'), $tpl);
            } else {
                $fenom->display($theme->getTemplateLocation('badcard.tpl'));
            }
        } else {
            $currentTariff = getCurrentTariff($user->getId());
            $selectedTariff = $user->getSelectedTariff();
            if (!$currentTariff && $selectedTariff) {
                $fenom->display($theme->getTemplateLocation('notification.tpl'), array("className" => "tip", "errorText" => sprintf(__('After updating service "%s" from %s to %s will be automatically paid for %s.'), $selectedTariff['name'], $currentDate->format($dateFormat), $endDate->format($dateFormat), sprintf(_ngettext("%s {$currency}", "%s {$currency}", $tariffPrice), $tariffPrice))));
            }
            $fenom->display($theme->getTemplateLocation('paywithcard.tpl'));
        }
        $fenom->display($theme->getTemplateLocation('footer.tpl'));
    }
}