Example #1
0
/**
 * Search by tag in pages
 *
 * @param string $query User-entered query string
 * @global CotDB $db
 */
function cot_tag_search_pages($query)
{
    global $db, $t, $L, $lang, $cfg, $usr, $qs, $d, $db_tag_references, $db_pages, $o, $row, $sys;
    if (!cot_module_active('page')) {
        return;
    }
    $query = cot_tag_parse_query($query, 'p.page_id');
    if (empty($query)) {
        return;
    }
    $maxperpage = cot::$cfg['maxrowsperpage'] && is_numeric(cot::$cfg['maxrowsperpage']) && cot::$cfg['maxrowsperpage'] > 0 ? cot::$cfg['maxrowsperpage'] : 15;
    $join_columns = '';
    $join_tables = '';
    $join_where = '';
    switch ($o) {
        case 'title':
            $order = 'ORDER BY `page_title`';
            break;
        case 'date':
            $order = 'ORDER BY `page_date` DESC';
            break;
        case 'category':
            $order = 'ORDER BY `page_cat`';
            break;
        default:
            $order = '';
    }
    /* == Hook == */
    foreach (cot_getextplugins('tags.search.pages.query') as $pl) {
        include $pl;
    }
    /* ===== */
    $totalitems = cot::$db->query("SELECT DISTINCT COUNT(*)\n\t\tFROM {$db_tag_references} AS r LEFT JOIN {$db_pages} AS p\n\t\t\tON r.tag_item = p.page_id {$join_tables}\n\t\tWHERE r.tag_area = 'pages' AND ({$query}) AND p.page_state = 0 {$join_where}")->fetchColumn();
    $sql = $db->query("SELECT DISTINCT p.* {$join_columns}\n\t\tFROM {$db_tag_references} AS r LEFT JOIN {$db_pages} AS p\n\t\t\tON r.tag_item = p.page_id {$join_tables}\n\t\tWHERE r.tag_area = 'pages' AND ({$query}) AND p.page_id IS NOT NULL AND p.page_state = 0 {$join_where}\n\t\t{$order}\n\t\tLIMIT {$d}, {$maxperpage}");
    $t->assign('TAGS_RESULT_TITLE', $L['tags_Found_in_pages']);
    $pcount = $sql->rowCount();
    /* == Hook : Part 1 == */
    $extp = cot_getextplugins('tags.search.pages.loop');
    /* ===== */
    if ($pcount > 0) {
        foreach ($sql->fetchAll() as $row) {
            if ($row['page_begin'] > 0 && $row['page_begin'] > $sys['now'] || $row['page_expire'] > 0 && $sys['now'] > $row['page_expire']) {
                --$pcount;
                continue;
            }
            $tags = cot_tag_list($row['page_id']);
            $tag_list = '';
            $tag_i = 0;
            foreach ($tags as $tag) {
                $tag_t = cot::$cfg['plugin']['tags']['title'] ? cot_tag_title($tag) : $tag;
                $tag_u = cot::$cfg['plugin']['tags']['translit'] ? cot_translit_encode($tag) : $tag;
                $tl = $lang != 'en' && $tag_u != $tag ? 1 : null;
                if ($tag_i > 0) {
                    $tag_list .= ', ';
                }
                $tag_list .= cot_rc_link(cot_url('plug', array('e' => 'tags', 'a' => 'pages', 't' => str_replace(' ', '-', $tag_u), 'tl' => $tl)), htmlspecialchars($tag_t));
                $tag_i++;
            }
            $t->assign(cot_generate_pagetags($row, 'TAGS_RESULT_ROW_', cot::$cfg['page']['cat___default']['truncatetext']));
            $t->assign(array('TAGS_RESULT_ROW_TITLE' => htmlspecialchars($row['page_title']), 'TAGS_RESULT_ROW_PATH' => cot_breadcrumbs(cot_structure_buildpath('page', $row['page_cat']), false), 'TAGS_RESULT_ROW_TAGS' => $tag_list));
            /* == Hook : Part 2 == */
            foreach ($extp as $pl) {
                include $pl;
            }
            /* ===== */
            $t->parse('MAIN.TAGS_RESULT.TAGS_RESULT_ROW');
        }
        $sql->closeCursor();
        $qs_u = cot::$cfg['plugin']['tags']['translit'] ? cot_translit_encode($qs) : $qs;
        $tl = $lang != 'en' && $qs_u != $qs ? 1 : null;
        $pagenav = cot_pagenav('plug', array('e' => 'tags', 'a' => 'pages', 't' => $qs_u, 'tl' => $tl), $d, $totalitems, $maxperpage);
        $t->assign(array('TAGS_PAGEPREV' => $pagenav['prev'], 'TAGS_PAGENEXT' => $pagenav['next'], 'TAGS_PAGNAV' => $pagenav['main']));
        /* == Hook == */
        foreach (cot_getextplugins('tags.search.pages.tags') as $pl) {
            include $pl;
        }
        /* ===== */
    }
    if ($pcount == 0) {
        $t->parse('MAIN.TAGS_RESULT.TAGS_RESULT_NONE');
    }
    $t->parse('MAIN.TAGS_RESULT');
}
Example #2
0
     }
     /* ===== */
     if (empty($sql_page_string)) {
         $sql_page_string = "SELECT SQL_CALC_FOUND_ROWS p.* {$search_join_columns}\n                FROM {$db_pages} AS p {$search_join_condition}\n                WHERE {$where}\n                ORDER BY {$orderby}\n                LIMIT {$d}, " . $cfg_maxitems . $search_union_query;
     }
     $sql = $db->query($sql_page_string);
     $items = $sql->rowCount();
     $totalitems[] = $db->query('SELECT FOUND_ROWS()')->fetchColumn();
     $jj = 0;
     /* === Hook - Part 1 === */
     $extp = cot_getextplugins('search.page.loop');
     /* ===== */
     foreach ($sql->fetchAll() as $row) {
         $url_cat = cot_url('page', 'c=' . $row['page_cat']);
         $url_page = empty($row['page_alias']) ? cot_url('page', 'c=' . $row['page_cat'] . '&id=' . $row['page_id'] . '&highlight=' . $hl) : cot_url('page', 'c=' . $row['page_cat'] . '&al=' . $row['page_alias'] . '&highlight=' . $hl);
         $t->assign(cot_generate_pagetags($row, 'PLUGIN_PR_'));
         $t->assign(array('PLUGIN_PR_CATEGORY' => cot_rc_link($url_cat, $structure['page'][$row['page_cat']]['tpath']), 'PLUGIN_PR_CATEGORY_URL' => $url_cat, 'PLUGIN_PR_TITLE' => cot_rc_link($url_page, htmlspecialchars($row['page_title'])), 'PLUGIN_PR_TEXT' => cot_clear_mark($row['page_text'], $words), 'PLUGIN_PR_TIME' => cot_date('datetime_medium', $row['page_date']), 'PLUGIN_PR_TIMESTAMP' => $row['page_date'], 'PLUGIN_PR_ODDEVEN' => cot_build_oddeven($jj), 'PLUGIN_PR_NUM' => $jj));
         /* === Hook - Part 2 === */
         foreach ($extp as $pl) {
             include $pl;
         }
         /* ===== */
         $t->parse('MAIN.RESULTS.PAGES.ITEM');
         $jj++;
     }
     if ($jj > 0) {
         $t->parse('MAIN.RESULTS.PAGES');
     }
     unset($where_and, $where_or, $where);
 }
 if (($tab == 'frm' || empty($tab)) && cot_module_active('forums') && $cfg['plugin']['search']['forumsearch'] && !cot_error_found()) {
Example #3
0
/**
 * Generates page list widget
 * @param  mixed   $categories       Custom parent categories code
 * @param  integer $count            Number of items to show. 0 - all items
 * @param  string  $template         Path for template file
 * @param  string  $order            Sorting order (SQL)
 * @param  string  $condition        Custom selection filter (SQL)
 * @param  mixed   $active_only	     Custom parent category code
 * @param  boolean $use_subcat       Include subcategories TRUE/FALSE
 * @param  boolean $exclude_current  Exclude the current page from the rowset for pages.
 * @param  string  $blacklist        Category black list, semicolon separated
 * @param  string  $pagination       Pagination symbol
 * @param  integer $cache_ttl        Cache lifetime in seconds, 0 disables cache
 * @return string                    Parsed HTML
 */
function cot_page_enum($categories = '', $count = 0, $template = '', $order = '', $condition = '', $active_only = true, $use_subcat = true, $exclude_current = false, $blacklist = '', $pagination = '', $cache_ttl = null)
{
    global $db, $db_pages, $db_users, $structure, $cfg, $sys, $lang, $cache;
    // Compile lists
    if (!is_array($blacklist)) {
        $blacklist = str_replace(' ', '', $blacklist);
        $blacklist = !empty($blacklist) ? explode(',', $blacklist) : array();
    }
    // Get the cats
    if (!empty($categories)) {
        if (!is_array($categories)) {
            $categories = str_replace(' ', '', $categories);
            $categories = explode(',', $categories);
        }
        $categories = array_unique($categories);
        if ($use_subcat) {
            $total_categogies = array();
            foreach ($categories as $cat) {
                $cats = cot_structure_children('page', $cat, $use_subcat);
                $total_categogies = array_merge($total_categogies, $cats);
            }
            $categories = array_unique($total_categogies);
        }
        $categories = count($blacklist) > 0 ? array_diff($categories, $blacklist) : $categories;
        $where['cat'] = "page_cat IN ('" . implode("','", $cats) . "')";
    } elseif (count($blacklist)) {
        $where['cat_black'] = "page_cat NOT IN ('" . implode("','", $blacklist) . "')";
    }
    $where['condition'] = $condition;
    if ($exclude_current && defined('COT_PAGES') && !defined('COT_LIST')) {
        global $id;
        $where['page_id'] = "page_id != {$id}";
    }
    if ($active_only) {
        $where['state'] = "page_state=0";
        $where['date'] = "page_begin <= {$sys['now']} AND (page_expire = 0 OR page_expire > {$sys['now']})";
    }
    // Get pagination number if necessary
    if (!empty($pagination)) {
        list($pg, $d, $durl) = cot_import_pagenav($pagination, $count);
    } else {
        $d = 0;
    }
    // Display the items
    $mskin = file_exists($template) ? $template : cot_tplfile(array('page', 'enum', $template), 'module');
    /* === Hook === */
    foreach (cot_getextplugins('page.enum.query') as $pl) {
        include $pl;
    }
    /* ===== */
    if (cot_plugin_active('comments')) {
        global $db_com;
        require_once cot_incfile('comments', 'plug');
        $cns_join_columns .= ", (SELECT COUNT(*) FROM `{$db_com}` WHERE com_area = 'page' AND com_code = p.page_id) AS com_count";
    }
    $sql_order = empty($order) ? 'ORDER BY page_date DESC' : "ORDER BY {$order}";
    $sql_limit = $count > 0 ? "LIMIT {$d}, {$count}" : '';
    $where = array_filter($where);
    $where = $where ? 'WHERE ' . implode(' AND ', $where) : '';
    $sql_total = "SELECT COUNT(*) FROM {$db_pages} AS p {$cns_join_tables} {$where}";
    $sql_query = "SELECT p.*, u.* {$cns_join_columns} FROM {$db_pages} AS p LEFT JOIN {$db_users} AS u ON p.page_ownerid = u.user_id\n\t\t\t{$cns_join_tables} {$where} {$sql_order} {$sql_limit}";
    $t = new XTemplate($mskin);
    isset($md5hash) || ($md5hash = 'page_enum_' . md5(str_replace($sys['now'], '_time_', $mskin . $lang . $sql_query)));
    if ($cache && (int) $cache_ttl > 0) {
        $page_query_html = $cache->disk->get($md5hash, 'page', (int) $cache_ttl);
        if (!empty($page_query_html)) {
            return $page_query_html;
        }
    }
    $totalitems = $db->query($sql_total)->fetchColumn();
    $sql = $db->query($sql_query);
    $sql_rowset = $sql->fetchAll();
    $jj = 0;
    foreach ($sql_rowset as $pag) {
        $jj++;
        $t->assign(cot_generate_pagetags($pag, 'PAGE_ROW_'));
        $t->assign(array('PAGE_ROW_NUM' => $jj, 'PAGE_ROW_ODDEVEN' => cot_build_oddeven($jj), 'PAGE_ROW_RAW' => $pag));
        $t->assign(cot_generate_usertags($pag, 'PAGE_ROW_OWNER_'));
        /* === Hook === */
        foreach (cot_getextplugins('page.enum.loop') as $pl) {
            include $pl;
        }
        /* ===== */
        if (cot_plugin_active('comments')) {
            $rowe_urlp = empty($pag['page_alias']) ? array('c' => $pag['page_cat'], 'id' => $pag['page_id']) : array('c' => $pag['page_cat'], 'al' => $pag['page_alias']);
            $t->assign(array('PAGE_ROW_COMMENTS' => cot_comments_link('page', $rowe_urlp, 'page', $pag['page_id'], $pag['page_cat'], $pag), 'PAGE_ROW_COMMENTS_COUNT' => cot_comments_count('page', $pag['page_id'], $pag)));
        }
        $t->parse("MAIN.PAGE_ROW");
    }
    // Render pagination
    $url_params = $_GET;
    $url_area = 'index';
    $module_name = cot_import('e', 'G', 'ALP');
    if (cot_module_active($module_name)) {
        $url_area = $url_params['e'];
        unset($url_params['e']);
    }
    if (cot_plugin_active($module_name)) {
        $url_area = 'plug';
    }
    unset($url_params[$pagination]);
    if (!empty($pagination)) {
        $pagenav = cot_pagenav($url_area, $url_params, $d, $totalitems, $count, $pagination);
    }
    $t->assign(array('PAGE_TOP_PAGINATION' => $pagenav['main'], 'PAGE_TOP_PAGEPREV' => $pagenav['prev'], 'PAGE_TOP_PAGENEXT' => $pagenav['next'], 'PAGE_TOP_FIRST' => $pagenav['first'], 'PAGE_TOP_LAST' => $pagenav['last'], 'PAGE_TOP_CURRENTPAGE' => $pagenav['current'], 'PAGE_TOP_TOTALLINES' => $totalitems, 'PAGE_TOP_MAXPERPAGE' => $count, 'PAGE_TOP_TOTALPAGES' => $pagenav['total']));
    /* === Hook === */
    foreach (cot_getextplugins('pagelist.tags') as $pl) {
        include $pl;
    }
    /* ===== */
    $t->parse("MAIN");
    $page_query_html = $t->text("MAIN");
    if ($cache && (int) $cache_ttl > 0) {
        $cache->disk->store($md5hash, $page_query_html, 'page');
    }
    return $page_query_html;
}
Example #4
0
            cot_message($notfoundet . $perelik . ' - ' . $L['adm_queue_deleted']);
        }
    }
}
$totalitems = $db->query("SELECT COUNT(*) FROM {$db_pages} WHERE " . $sqlwhere)->fetchColumn();
$pagenav = cot_pagenav('admin', $common_params, $d, $totalitems, $cfg['maxrowsperpage'], 'd', '', $cfg['jquery'] && $cfg['turnajax']);
$sql_page = $db->query("SELECT p.*, u.user_name\n\tFROM {$db_pages} as p\n\tLEFT JOIN {$db_users} AS u ON u.user_id=p.page_ownerid\n\tWHERE {$sqlwhere}\n\t\tORDER BY {$sqlsorttype} {$sqlsortway}\n\t\tLIMIT {$d}, " . $cfg['maxrowsperpage']);
$ii = 0;
/* === Hook - Part1 : Set === */
$extp = cot_getextplugins('page.admin.loop');
/* ===== */
foreach ($sql_page->fetchAll() as $row) {
    $sql_page_subcount = $db->query("SELECT SUM(structure_count) FROM {$db_structure} WHERE structure_path LIKE '" . $db->prep($structure['page'][$row["page_cat"]]['rpath']) . "%' ");
    $sub_count = $sql_page_subcount->fetchColumn();
    $row['page_file'] = intval($row['page_file']);
    $t->assign(cot_generate_pagetags($row, 'ADMIN_PAGE_', 200));
    $t->assign(array('ADMIN_PAGE_ID_URL' => cot_url('page', 'c=' . $row['page_cat'] . '&id=' . $row['page_id']), 'ADMIN_PAGE_OWNER' => cot_build_user($row['page_ownerid'], htmlspecialchars($row['user_name'])), 'ADMIN_PAGE_FILE_BOOL' => $row['page_file'], 'ADMIN_PAGE_URL_FOR_VALIDATED' => cot_confirm_url(cot_url('admin', $common_params . '&a=validate&id=' . $row['page_id'] . '&d=' . $durl . '&' . cot_xg()), 'page', 'page_confirm_validate'), 'ADMIN_PAGE_URL_FOR_UNVALIDATE' => cot_confirm_url(cot_url('admin', $common_params . '&a=unvalidate&id=' . $row['page_id'] . '&d=' . $durl . '&' . cot_xg()), 'page', 'page_confirm_unvalidate'), 'ADMIN_PAGE_URL_FOR_DELETED' => cot_confirm_url(cot_url('admin', $common_params . '&a=delete&id=' . $row['page_id'] . '&d=' . $durl . '&' . cot_xg()), 'page', 'page_confirm_delete'), 'ADMIN_PAGE_URL_FOR_EDIT' => cot_url('page', 'm=edit&id=' . $row['page_id']), 'ADMIN_PAGE_ODDEVEN' => cot_build_oddeven($ii), 'ADMIN_PAGE_CAT_COUNT' => $sub_count));
    $t->assign(cot_generate_usertags($row['page_ownerid'], 'ADMIN_PAGE_OWNER_'), htmlspecialchars($row['user_name']));
    /* === Hook - Part2 : Include === */
    foreach ($extp as $pl) {
        include $pl;
    }
    /* ===== */
    $t->parse('MAIN.PAGE_ROW');
    $ii++;
}
$is_row_empty = $sql_page->rowCount() == 0 ? true : false;
$totaldbpages = $db->countRows($db_pages);
$sql_page_queued = $db->query("SELECT COUNT(*) FROM {$db_pages} WHERE page_state=1");
$sys['pagesqueued'] = $sql_page_queued->fetchColumn();
$t->assign(array('ADMIN_PAGE_URL_CONFIG' => cot_url('admin', 'm=config&n=edit&o=module&p=page'), 'ADMIN_PAGE_URL_ADD' => cot_url('page', 'm=add'), 'ADMIN_PAGE_URL_EXTRAFIELDS' => cot_url('admin', 'm=extrafields&n=' . $db_pages), 'ADMIN_PAGE_URL_STRUCTURE' => cot_url('admin', 'm=structure&n=page'), 'ADMIN_PAGE_FORM_URL' => cot_url('admin', $common_params . '&a=update_checked&d=' . $durl), 'ADMIN_PAGE_ORDER' => cot_selectbox($sorttype, 'sorttype', array_keys($sort_type), array_values($sort_type), false), 'ADMIN_PAGE_WAY' => cot_selectbox($sortway, 'sortway', array_keys($sort_way), array_values($sort_way), false), 'ADMIN_PAGE_FILTER' => cot_selectbox($filter, 'filter', array_keys($filter_type), array_values($filter_type), false), 'ADMIN_PAGE_TOTALDBPAGES' => $totaldbpages, 'ADMIN_PAGE_PAGINATION_PREV' => $pagenav['prev'], 'ADMIN_PAGE_PAGNAV' => $pagenav['main'], 'ADMIN_PAGE_PAGINATION_NEXT' => $pagenav['next'], 'ADMIN_PAGE_TOTALITEMS' => $totalitems, 'ADMIN_PAGE_ON_PAGE' => $ii));
Example #5
0
$t->assign(array('LISTCAT_PAGEPREV' => $pagenav_cat['prev'], 'LISTCAT_PAGENEXT' => $pagenav_cat['next'], 'LISTCAT_PAGNAV' => $pagenav_cat['main']));
$jj = 0;
/* === Hook - Part1 : Set === */
$extp = cot_getextplugins('page.list.loop');
/* ===== */
$sqllist_rowset = $sqllist->fetchAll();
$sqllist_rowset_other = false;
/* === Hook === */
foreach (cot_getextplugins('page.list.before_loop') as $pl) {
    include $pl;
}
/* ===== */
if (!$sqllist_rowset_other) {
    foreach ($sqllist_rowset as $pag) {
        $jj++;
        $t->assign(cot_generate_pagetags($pag, 'LIST_ROW_', $cfg['page']['truncatetext'], $usr['isadmin']));
        $t->assign(array('LIST_ROW_OWNER' => cot_build_user($pag['page_ownerid'], htmlspecialchars($pag['user_name'])), 'LIST_ROW_ODDEVEN' => cot_build_oddeven($jj), 'LIST_ROW_NUM' => $jj));
        $t->assign(cot_generate_usertags($pag, 'LIST_ROW_OWNER_'));
        /* === Hook - Part2 : Include === */
        foreach ($extp as $pl) {
            include $pl;
        }
        /* ===== */
        $t->parse('MAIN.LIST_ROW');
    }
}
/* === Hook === */
foreach (cot_getextplugins('page.list.tags') as $pl) {
    include $pl;
}
/* ===== */
Example #6
0
     foreach ($cats as $key => $var) {
         $news_link_params .= $key != $cat && $var[3] != 0 && $xx != 0 ? "&" . $key . "d=" . $var[3]['durl'] : '';
         $xx++;
     }
 }
 $news_link = cot_url('index', $news_link_params);
 $catd = $catn != 0 && !$cfg['plugin']['news']['syncpagination'] ? $cat . "d" : "d";
 $pagenav = cot_pagenav('index', $news_link_params, $v[3]['d'], $totalnews, $v[1], $catd);
 $filename = str_replace(array(' ', ',', '.', '-'), '_', $v[0]);
 $news = new XTemplate(cot_tplfile($catn == 0 ? "news" : "news." . $filename, 'plug'));
 $sql_rowset = $sql->fetchAll();
 $jj = 0;
 foreach ($sql_rowset as $pag) {
     $jj++;
     $url = cot_url('index', 'c=' . $pag['page_cat']);
     $news->assign(cot_generate_pagetags($pag, 'PAGE_ROW_', $v[2]));
     $news->assign(array('PAGE_ROW_NEWSPATH' => cot_rc_link($url, htmlspecialchars($structure['page'][$row['page_cat']]['title'])), 'PAGE_ROW_NEWSPATH_URL' => $url, 'PAGE_ROW_CATDESC' => htmlspecialchars($structure['page'][$pag['page_cat']]['desc']), 'PAGE_ROW_OWNER' => cot_build_user($pag['page_ownerid'], htmlspecialchars($pag['user_name'])), 'PAGE_ROW_ODDEVEN' => cot_build_oddeven($jj), 'PAGE_ROW_NUM' => $jj));
     $news->assign(cot_generate_usertags($pag, 'PAGE_ROW_OWNER_'));
     /* === Hook - Part2 : Include === LOOP === */
     foreach ($news_extp as $pl) {
         include $pl;
     }
     /* ===== */
     $news->parse('NEWS.PAGE_ROW');
 }
 $url_newpage = cot_url('page', 'm=add&c=' . $cat);
 $news->assign(array('PAGE_PAGENAV' => $pagenav['main'], 'PAGE_PAGEPREV' => $pagenav['prev'], 'PAGE_PAGENEXT' => $pagenav['next'], 'PAGE_PAGELAST' => $pagenav['last'], 'PAGE_PAGENUM' => $pagenav['current'], 'PAGE_PAGECOUNT' => $pagenav['total'], 'PAGE_ENTRIES_ONPAGE' => $pagenav['onpage'], 'PAGE_ENTRIES_TOTAL' => $pagenav['entries'], 'PAGE_SUBMITNEWPOST' => cot_auth('page', $cat, 'W') ? cot_rc_link($url_newpage, $L['Submitnew']) : '', 'PAGE_SUBMITNEWPOST_URL' => cot_auth('page', $cat, 'W') ? $url_newpage : '', 'PAGE_CATTITLE' => $structure['page'][$cat]['title'], 'PAGE_CATPATH' => cot_breadcrumbs(cot_structure_buildpath('page', $cat), false), 'PAGE_CAT' => $cat));
 /* === Hook - Part2 : Include === TAGS === */
 foreach ($news_tags_extp as $pl) {
     include $pl;
 }
Example #7
0
$out['canonical_uri'] = cot_url('page', $pageurl_params);
$mskin = cot_tplfile(array('page', $cat['tpl']));
$env['last_modified'] = $pag['page_updated'];
/* === Hook === */
foreach (cot_getextplugins('page.main') as $pl) {
    include $pl;
}
/* ===== */
if ($pag['page_file']) {
    unset($_SESSION['dl']);
    $_SESSION['dl'] = $id;
}
require_once $cfg['system_dir'] . '/header.php';
require_once cot_incfile('users', 'module');
$t = new XTemplate($mskin);
$t->assign(cot_generate_pagetags($pag, 'PAGE_', 0, $usr['isadmin'], $cfg['homebreadcrumb']));
$t->assign('PAGE_OWNER', cot_build_user($pag['page_ownerid'], htmlspecialchars($pag['user_name'])));
$t->assign(cot_generate_usertags($pag, 'PAGE_OWNER_'));
$pag['page_file'] = intval($pag['page_file']);
if ($pag['page_file'] > 0) {
    if ($sys['now'] > $pag['page_begin']) {
        if (!empty($pag['page_url'])) {
            $dotpos = mb_strrpos($pag['page_url'], ".") + 1;
            $type = mb_strtolower(mb_substr($pag['page_url'], $dotpos, 5));
            $pag['page_fileicon'] = cot_rc('page_icon_file_path');
            if (!file_exists($pag['page_fileicon'])) {
                $pag['page_fileicon'] = cot_rc('page_icon_file_default');
            }
            $pag['page_fileicon'] = cot_rc('page_icon_file', array('icon' => $pag['page_fileicon']));
        } else {
            $pag['page_fileicon'] = '';
Example #8
0
        $sql = $db->query("SELECT p.*, u.* FROM {$db_pages} AS p\n\t\t\t\tLEFT JOIN {$db_users} AS u ON p.page_ownerid = u.user_id\n\t\t\tWHERE page_state=0 AND page_begin <= {$sys['now']} AND (page_expire = 0 OR page_expire > {$sys['now']}) AND page_cat NOT LIKE 'system' AND page_cat IN ('" . implode("','", $catsub) . "')\n\t\t\tORDER BY page_date DESC LIMIT " . $cfg['rss']['rss_maxitems']);
    } else {
        $sql = $db->query("SELECT p.*, u.* FROM {$db_pages} AS p\n\t\t\t\tLEFT JOIN {$db_users} AS u ON p.page_ownerid = u.user_id\n\t\t\tWHERE page_state=0 AND page_begin <= {$sys['now']} AND (page_expire = 0 OR page_expire > {$sys['now']}) AND page_cat NOT LIKE 'system'\n\t\t\tORDER BY page_date DESC LIMIT " . $cfg['rss']['rss_maxitems']);
    }
    $i = 0;
    while ($row = $sql->fetch()) {
        $url = empty($row['page_alias']) ? cot_url('page', 'c=' . $row['page_cat'] . '&id=' . $row['page_id'], '', true) : cot_url('page', 'c=' . $row['page_cat'] . '&al=' . $row['page_alias'], '', true);
        $rssDate = $row['page_date'];
        if (!empty(cot::$usr['timezone'])) {
            $rssDate += cot::$usr['timezone'] * 3600;
        }
        $items[$i]['title'] = $row['page_title'];
        $items[$i]['link'] = strpos($url, '://') === false ? COT_ABSOLUTE_URL . $url : $url;
        $items[$i]['pubDate'] = date('r', $rssDate);
        $items[$i]['description'] = cot_parse_page_text($row['page_text'], $url, $row['page_parser']);
        $items[$i]['fields'] = cot_generate_pagetags($row);
        $i++;
    }
    $sql->closeCursor();
}
$rssNow = cot::$sys['now'];
if (!empty(cot::$usr['timezone'])) {
    $rssNow += cot::$usr['timezone'] * 3600;
}
$t = new XTemplate(cot_tplfile('rss'));
$t->assign(array('RSS_ENCODING' => $cfg['rss']['rss_charset'], 'RSS_TITLE' => htmlspecialchars($rss_title), 'RSS_LINK' => $rss_link, 'RSS_LANG' => $cfg['defaultlang'], 'RSS_DESCRIPTION' => htmlspecialchars($rss_description), 'RSS_DATE' => cot_fix_pubdate(date("r", $rssNow))));
if (count($items) > 0) {
    foreach ($items as $item) {
        $t->assign(array('RSS_ROW_TITLE' => htmlspecialchars($item['title']), 'RSS_ROW_DESCRIPTION' => cot_convert_relative_urls($item['description']), 'RSS_ROW_DATE' => cot_fix_pubdate($item['pubDate']), 'RSS_ROW_LINK' => $item['link'], 'RSS_ROW_FIELDS' => $item['fields']));
        $t->parse('MAIN.ITEM_ROW');
    }
Example #9
0
     foreach ($cot_extrafields[$db_tag_references] as $exfld) {
         $tag = mb_strtoupper($exfld['field_name']);
         $tt->assign(array('ADMIN_TAGS_' . $tag . '_TITLE' => isset($L['tags_' . $exfld['field_name'] . '_title']) ? $L['tags_' . $exfld['field_name'] . '_title'] : $exfld['field_description'], 'ADMIN_TAGS_' . $tag => cot_build_extrafields_data('tags', $exfld, $row['tag_' . $exfld['field_name']]), 'ADMIN_TAGS_' . $tag . '_VALUE' => $row['tag_' . $exfld['field_name']]));
     }
 }
 if (!empty($row['tag_grp'])) {
     $item_mas = array();
     $items = explode(',', $row['tag_grp']);
     foreach ($items as $val) {
         $item = explode(':', $val);
         $item_mas[$item[0]][] = $item[1];
     }
     foreach ($item_mas as $k => $v) {
         if ($k == 'pages') {
             foreach ($v as $kk => $vv) {
                 $row_item = cot_generate_pagetags($vv, 'ADMIN_TAGS_ITEM_', 200);
                 if ($row_item['ADMIN_TAGS_ITEM_TITLE'] == 'Удалено') {
                 } else {
                     $tt->assign($row_item);
                     //$tt->assign(cot_generate_usertags($row_item['page_ownerid'], 'ADMIN_TAGS_PAGE_OWNER_'), htmlspecialchars($row['user_name']));
                     $tt->parse('MAIN.ADMIN_TAGS_ROW.ADMIN_TAGS_ROW_ITEMS');
                 }
             }
         } elseif ($k == 'forum') {
         }
     }
 }
 $tt->assign(array('ADMIN_TAGS_FORM_ACTION' => cot_url('admin', 'm=other&p=tags&d=' . $durl), 'ADMIN_TAGS_DEL_URL' => cot_url('admin', 'm=other&p=tags&a=delete&tag=' . str_replace(' ', '_', $row['tag']) . '&' . cot_xg()), 'ADMIN_TAGS_CODE' => $row['tag'], 'ADMIN_TAGS_TAG' => cot_inputbox('text', 'tag', htmlspecialchars_decode($row['tag']), array('size' => '30', 'maxlength' => '255')), 'ADMIN_TAGS_AREA' => $row['tag_area'], 'ADMIN_TAGS_COUNT' => $row['tag_cnt'], 'ADMIN_TAGS_ITEMS' => str_replace(array('pages:', ','), array('', ', '), $row['tag_grp']), 'ADMIN_TAGS_ODDEVEN' => cot_build_oddeven($ii)));
 /* === Hook - Part2 : Include === */
 foreach ($extp as $pl) {
     include $pl;
function cot_build_recentpages($template, $mode = 'recent', $maxperpage = 5, $d = 0, $titlelength = 0, $textlength = 0, $rightprescan = true, $cat = '')
{
    global $db, $structure, $db_pages, $db_users, $sys, $cfg, $L, $cot_extrafields, $usr;
    $recentitems = new XTemplate(cot_tplfile($template, 'plug'));
    // Load all cats and subcats in white list if set
    if (!empty($cfg['plugin']['recentitems']['whitelist'])) {
        $whitelist = array();
        foreach (preg_split('#\\r?\\n#', $cfg['plugin']['recentitems']['whitelist']) as $c) {
            $whitelist = array_merge($whitelist, cot_structure_children('page', $c, true, true, $rightprescan));
        }
    } else {
        $whitelist = false;
    }
    // Load all cats and subcats in black list if set
    if (!empty($cfg['plugin']['recentitems']['blacklist'])) {
        $blacklist = array();
        foreach (preg_split('#\\r?\\n#', $cfg['plugin']['recentitems']['blacklist']) as $c) {
            $blacklist = array_merge($blacklist, cot_structure_children('page', $c, true, true, $rightprescan));
        }
    } else {
        $blacklist = false;
    }
    if ($rightprescan || $cat) {
        // Get selected cats
        $catsub = cot_structure_children('page', $cat, true, true, $rightprescan);
        if ($whitelist) {
            // Must be both in selected and whitelist
            $catsub = array_intersect($catsub, $whitelist);
        } elseif ($blacklist) {
            // Must be in selected but not in blacklist
            $catsub = array_diff($catsub, $blacklist);
        }
        $incat = "AND page_cat IN ('" . implode("','", $catsub) . "')";
    } elseif ($whitelist) {
        // Only cats from white list
        $incat = "AND page_cat IN ('" . implode("','", $whitelist) . "')";
    } elseif ($blacklist) {
        // All cats but not in black list
        $incat = "AND page_cat NOT IN ('" . implode("','", $blacklist) . "')";
    }
    if ($mode == 'recent') {
        $where = "WHERE page_state=0 AND page_begin <= {$sys['now']} AND (page_expire = 0 OR page_expire > {$sys['now']}) AND page_cat <> 'system' " . $incat;
        $totalrecent['pages'] = $cfg['plugin']['recentitems']['maxpages'];
    } else {
        $where = "WHERE page_date >= {$mode} AND page_begin <= {$sys['now']} AND (page_expire = 0 OR page_expire > {$sys['now']}) AND page_state=0 AND page_cat <> 'system' " . $incat;
        $totalrecent['pages'] = $db->query("SELECT COUNT(*) FROM {$db_pages} " . $where)->fetchColumn();
    }
    $join_columns = '';
    $join_tables = '';
    /* === Hook === */
    foreach (cot_getextplugins('recentitems.recentpages.first') as $pl) {
        include $pl;
    }
    /* ===== */
    $sql = $db->query("SELECT p.*, u.* {$join_columns}\n\t\tFROM {$db_pages} AS p\n\t\t\tLEFT JOIN {$db_users} AS u ON u.user_id=p.page_ownerid\n\t\t{$join_tables}\n\t\t{$where} ORDER by page_date desc LIMIT {$d}, {$maxperpage}");
    $jj = 0;
    /* === Hook - Part1 === */
    $extp = cot_getextplugins('recentitems.recentpages.tags');
    /* ===== */
    foreach ($sql->fetchAll() as $pag) {
        $jj++;
        if ((int) $titlelength > 0 && mb_strlen($pag['page_title']) > $titlelength) {
            $pag['page_title'] = cot_string_truncate($pag['page_title'], $titlelength, false) . "...";
        }
        $recentitems->assign(cot_generate_pagetags($pag, 'PAGE_ROW_', $textlength));
        $recentitems->assign(array('PAGE_ROW_SHORTTITLE' => htmlspecialchars($pag['page_title']), 'PAGE_ROW_OWNER' => cot_build_user($pag['page_ownerid'], htmlspecialchars($pag['user_name'])), 'PAGE_ROW_ODDEVEN' => cot_build_oddeven($jj), 'PAGE_ROW_NUM' => $jj));
        $recentitems->assign(cot_generate_usertags($pag, 'PAGE_ROW_OWNER_'));
        /* === Hook - Part2 === */
        foreach ($extp as $pl) {
            include $pl;
        }
        /* ===== */
        $recentitems->parse('MAIN.PAGE_ROW');
    }
    if ($d == 0 && $jj == 0) {
        $recentitems->parse('MAIN.NO_PAGES_FOUND');
    }
    $recentitems->parse('MAIN');
    return $d == 0 || $jj > 0 ? $recentitems->text('MAIN') : '';
}