コード例 #1
0
ファイル: config.php プロジェクト: irbees2008/ngcms_eshop
function list_comment($params)
{
    global $tpl, $mysql, $twig, $parse, $config;
    $tpath = locatePluginTemplates(array('config/main', 'config/list_comment'), 'eshop', 1);
    $tVars = array();
    $news_per_page = isset($_REQUEST['rpp']) ? intval($_REQUEST['rpp']) : intval($admCookie['eshop']['pp_comment']);
    // - Set default value for `Records Per Page` parameter
    if ($news_per_page < 2 || $news_per_page > 2000) {
        $news_per_page = 10;
    }
    // - Save into cookies current value
    $admCookie['eshop']['pp_comment'] = $news_per_page;
    admcookie_set($admCookie);
    $conditions = array();
    $fSort = "ORDER BY c.postdate DESC";
    $sqlQPart = "from " . prefix . "_eshop_products_comments c LEFT JOIN " . prefix . "_users u ON c.author_id = u.id LEFT JOIN " . prefix . "_eshop_products p ON c.product_id = p.id " . (count($conditions) ? "where " . implode(" AND ", $conditions) : '') . ' ' . $fSort;
    $sqlQ = "select c.id as cid, u.id as uid, u.name as uname, c.name as name, p.id as product_id, p.url as url, p.name as title, c.mail as mail, c.postdate as postdate, c.author as author, c.author_id as author_id, u.avatar as avatar, c.reg as reg, c.text as text, c.status as status " . $sqlQPart;
    $sqlQCount = "SELECT COUNT(*) as CNT FROM (" . $sqlQ . ") AS T ";
    $pageNo = intval($_REQUEST['page']) ? $_REQUEST['page'] : 0;
    if ($pageNo < 1) {
        $pageNo = 1;
    }
    if (!$start_from) {
        $start_from = ($pageNo - 1) * $news_per_page;
    }
    $count = $mysql->result($sqlQCount);
    $countPages = ceil($count / $news_per_page);
    foreach ($mysql->select($sqlQ . ' LIMIT ' . $start_from . ', ' . $news_per_page) as $row) {
        // Add [hide] tag processing
        $text = $row['text'];
        if ($config['use_bbcodes']) {
            $text = $parse->bbcodes($text);
        }
        if ($config['use_htmlformatter']) {
            $text = $parse->htmlformatter($text);
        }
        if ($config['use_smilies']) {
            $text = $parse->smilies($text);
        }
        if ($config['use_avatars']) {
            if ($row['avatar']) {
                $avatar = avatars_url . "/" . $row['avatar'];
            } else {
                $avatar = $noAvatarURL;
            }
        } else {
            $avatar = '';
        }
        $view_link = checkLinkAvailable('eshop', 'show') ? generateLink('eshop', 'show', array('alt' => $row['url'])) : generateLink('core', 'plugin', array('plugin' => 'eshop', 'handler' => 'show'), array('alt' => $row['url']));
        $tEntries[] = array('id' => $row['cid'], 'mail' => $row['mail'], 'author' => $row['name'], 'date' => $row['postdate'], 'profile_link' => checkLinkAvailable('uprofile', 'show') ? generateLink('uprofile', 'show', array('name' => $row['author'], 'id' => $row['author_id'])) : generateLink('core', 'plugin', array('plugin' => 'uprofile', 'handler' => 'show'), array('id' => $row['author_id'])), 'avatar' => $avatar, 'name' => $row['uname'], 'commenttext' => $text, 'title' => $row['title'], 'view_link' => $view_link, 'product_edit_link' => "?mod=extra-config&plugin=eshop&action=edit_product&id=" . $row['product_id'] . "", 'reg' => $row['reg'], 'status' => $row['status']);
    }
    $xt = $twig->loadTemplate($tpath['config/list_comment'] . 'config/' . 'list_comment.tpl');
    $tVars = array('entries' => isset($tEntries) ? $tEntries : '', 'pagesss' => generateAdminPagelist(array('current' => $pageNo, 'count' => $countPages, 'url' => admin_url . '/admin.php?mod=extra-config&plugin=eshop&action=list_comment' . ($news_per_page ? '&rpp=' . $news_per_page : '') . '&page=%page%')), 'rpp' => $news_per_page);
    $xg = $twig->loadTemplate($tpath['config/main'] . 'config/' . 'main.tpl');
    $tVars = array('entries' => $xt->render($tVars), 'php_self' => $PHP_SELF, 'plugin_url' => admin_url . '/admin.php?mod=extra-config&plugin=eshop', 'skins_url' => skins_url, 'admin_url' => admin_url, 'home' => home, 'current_title' => 'Комментарии');
    print $xg->render($tVars);
}
コード例 #2
0
ファイル: config.php プロジェクト: web-padawan/ng_guestbook
function show_messages()
{
    global $tpl, $mysql, $lang, $twig, $config;
    $tpath = locatePluginTemplates(array('config/main', 'config/messages_list'), 'guestbook', 1);
    $tVars = array();
    $news_per_page = pluginGetVariable('guestbook', 'admin_count');
    $fSort = "ORDER BY id DESC";
    $sqlQPart = "from " . prefix . "_guestbook " . $fSort;
    $sqlQCount = "select count(id) " . $sqlQPart;
    $sqlQ = "select * " . $sqlQPart;
    $pageNo = intval($_REQUEST['page']) ? $_REQUEST['page'] : 0;
    if ($pageNo < 1) {
        $pageNo = 1;
    }
    if (!$start_from) {
        $start_from = ($pageNo - 1) * $news_per_page;
    }
    $count = $mysql->result($sqlQCount);
    $countPages = ceil($count / $news_per_page);
    foreach ($mysql->select($sqlQ . ' LIMIT ' . $start_from . ', ' . $news_per_page) as $row) {
        $tEntry[] = array('id' => $row['id'], 'postdate' => $row['postdate'], 'message' => $row['message'], 'answer' => $row['answer'], 'author' => $row['author'], 'ip' => $row['ip'], 'status' => $row['status']);
    }
    $xt = $twig->loadTemplate($tpath['config/messages_list'] . 'config/messages_list.tpl');
    $tVars = array('pagesss' => generateAdminPagelist(array('current' => $pageNo, 'count' => $countPages, 'url' => admin_url . '/admin.php?mod=extra-config&plugin=guestbook&action=show_messages&page=%page%')), 'entries' => isset($tEntry) ? $tEntry : '', 'php_self' => $PHP_SELF, 'skins_url' => skins_url, 'home' => home);
    $xg = $twig->loadTemplate($tpath['config/main'] . 'config/main.tpl');
    $tVars = array('entries' => $xt->render($tVars));
    print $xg->render($tVars);
}