/**
 * Recalculates users category counters
 *
 * @param string $cat Cat code
 * @return int
 * @global CotDB $db
 */
function cot_usercategories_sync($cat)
{
    global $db, $db_structure, $db_users;
    $subcats = cot_structure_children('usercategories', $cat);
    if (count($subcats) > 0) {
        foreach ($subcats as $val) {
            $cat_query[] = "FIND_IN_SET('" . $db->prep($val) . "', user_cats)";
        }
        $where = implode(' OR ', $cat_query);
    } else {
        $where = "FIND_IN_SET('" . $db->prep($cat) . "', user_cats)";
    }
    $sql = $db->query("SELECT COUNT(*) FROM {$db_users}\n\t\tWHERE " . $where);
    return (int) $sql->fetchColumn();
}
Пример #2
0
/**
 * Update market categories counters
 *
 * @param string $cat Cat code
 * @return int
 * @global CotDB $db
 */
function cot_market_sync($cat)
{
    global $db, $db_structure, $db_market, $cache;
    $parent = cot_structure_parents('market', $cat, 'first');
    $cats = cot_structure_children('market', $parent, true, true);
    foreach ($cats as $c) {
        $subcats = cot_structure_children('market', $c, true, true);
        $count = $db->query("SELECT COUNT(*) FROM {$db_market} WHERE item_cat IN ('" . implode("','", $subcats) . "') AND item_state = 0")->fetchColumn();
        $db->query("UPDATE {$db_structure} SET structure_count=" . (int) $count . " WHERE structure_area='market' AND structure_code = ?", $c);
        $summcount += $count;
        if ($cat == $c) {
            $catcount = $count;
        }
    }
    $cache && $cache->db->remove('structure', 'system');
    return $catcount;
}
Пример #3
0
         }
         /* ===== */
         $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()) {
     if ($rs['frmsub'][0] != 'all' && count($rs['frmsub']) > 0) {
         if ($rs['frmsubcat']) {
             $tempcat = array();
             foreach ($rs['frmsub'] as $scat) {
                 $tempcat = array_merge(cot_structure_children('forums', $scat), $tempcat);
             }
             $tempcat = array_unique($tempcat);
             $where_and['cat'] = "t.ft_cat IN ('" . implode("','", $tempcat) . "')";
         } else {
             $tempcat = array();
             foreach ($rs['frmsub'] as $scat) {
                 $tempcat[] = $db->prep($scat);
             }
             $where_and['cat'] = "t.ft_cat IN ('" . implode("','", $tempcat) . "')";
         }
     } else {
         $where_and['cat'] = "t.ft_cat IN ('" . implode("','", $frm_catauth) . "')";
     }
     $where_and['reply'] = $rs['frmreply'] == '1' ? "t.ft_postcount > 1" : "";
     $where_and['time'] = $rs['setlimit'] > 0 ? "p.fp_creation >= " . $rs['setfrom'] . " AND p.fp_updated <= " . $rs['setto'] : "";
Пример #4
0
    $out['subtitle'] = !empty($out['subtitle']) ? $out['subtitle'] : $L['projects'];
    $out['desc'] = !empty($cfg['projects']['cat_' . $c]['metadesc']) ? $cfg['projects']['cat_' . $c]['metadesc'] : $cfg['projects']['cat___default']['metadesc'];
    $out['keywords'] = !empty($cfg['projects']['cat_' . $c]['keywords']) ? $cfg['projects']['cat_' . $c]['keywords'] : $cfg['projects']['cat___default']['keywords'];
} else {
    $out['subtitle'] = !empty($cfg['projects']['cat___default']['metatitle']) ? $cfg['projects']['cat___default']['metatitle'] : $L['projects'];
    $out['desc'] = $cfg['projects']['cat___default']['metadesc'];
    $out['keywords'] = $cfg['projects']['cat___default']['keywords'];
}
$where = array();
$order = array();
$where['state'] = "item_state=0";
if ($realized == 1) {
    $where['realized'] = "item_realized=1";
}
if (!empty($c)) {
    $catsub = cot_structure_children('projects', $c);
    $where['cat'] = "item_cat IN ('" . implode("','", $catsub) . "')";
}
if (!empty($type)) {
    $where['type'] = "item_type=" . $type;
}
if (!empty($sq)) {
    $words = explode(' ', preg_replace("'\\s+'", " ", $sq));
    $sqlsearch = '%' . implode('%', $words) . '%';
    $where['search'] = "(item_title LIKE '" . $db->prep($sqlsearch) . "' OR item_text LIKE '" . $db->prep($sqlsearch) . "')";
}
// Extra fields
foreach ($cot_extrafields[$db_projects] as $exfld) {
    $fld_value = cot_import($exfld['field_name'], 'G', 'TXT');
    $fld_value = $db->prep($fld_value);
    if (!empty($shfld[$exfld['field_name']])) {
Пример #5
0
    $t->assign(array('LIST_TOP_' . $uname . '_URL_ASC' => $url_asc, 'LIST_TOP_' . $uname . '_URL_DESC' => $url_desc));
}
$kk = 0;
$allsub = cot_structure_children('page', $c, false, false, true, false);
$subcat = array_slice($allsub, $dc, $cfg['page']['maxlistsperpage']);
/* === Hook === */
foreach (cot_getextplugins('page.list.rowcat.first') as $pl) {
    include $pl;
}
/* ===== */
/* === Hook - Part1 : Set === */
$extp = cot_getextplugins('page.list.rowcat.loop');
/* ===== */
foreach ($subcat as $x) {
    $kk++;
    $cat_childs = cot_structure_children('page', $x);
    $sub_count = 0;
    foreach ($cat_childs as $cat_child) {
        $sub_count += (int) $structure['page'][$cat_child]['count'];
    }
    $sub_url_path = $list_url_path;
    $sub_url_path['c'] = $x;
    $t->assign(array('LIST_ROWCAT_ID' => $structure['page'][$x]['id'], 'LIST_ROWCAT_URL' => cot_url('page', $sub_url_path), 'LIST_ROWCAT_TITLE' => $structure['page'][$x]['title'], 'LIST_ROWCAT_DESC' => $structure['page'][$x]['desc'], 'LIST_ROWCAT_ICON' => $structure['page'][$x]['icon'], 'LIST_ROWCAT_COUNT' => $sub_count, 'LIST_ROWCAT_ODDEVEN' => cot_build_oddeven($kk), 'LIST_ROWCAT_NUM' => $kk));
    // Extra fields for structure
    if (!empty(cot::$extrafields[cot::$db->structure])) {
        foreach (cot::$extrafields[cot::$db->structure] as $exfld) {
            $uname = strtoupper($exfld['field_name']);
            $exfld_title = cot_extrafield_title($exfld, 'structure_');
            $t->assign(array('LIST_ROWCAT_' . $uname . '_TITLE' => $exfld_title, 'LIST_ROWCAT_' . $uname => cot_build_extrafields_data('structure', $exfld, cot::$structure['page'][$x][$exfld['field_name']]), 'LIST_ROWCAT_' . $uname . '_VALUE' => cot::$structure['page'][$x][$exfld['field_name']]));
        }
    }
Пример #6
0
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') : '';
}
/**
 * projects module
 *
 * @package projects
 * @version 2.5.2
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru, littledev.ru
 * @license BSD
 */
defined('COT_CODE') or die('Wrong URL.');
if ($cfg['projects']['prjsearch'] && ($tab == 'projects' || empty($tab)) && cot_module_active('projects') && !cot_error_found()) {
    if ($rs['projectssub'][0] != 'all' && count($rs['projectssub']) > 0) {
        if ($rs['projectssubcat']) {
            $tempcat = array();
            foreach ($rs['projectssub'] as $scat) {
                $tempcat = array_merge(cot_structure_children('projects', $scat), $tempcat);
            }
            $tempcat = array_unique($tempcat);
            $where_and['cat'] = "item_cat IN ('" . implode("','", $tempcat) . "')";
        } else {
            $tempcat = array();
            foreach ($rs['projectssub'] as $scat) {
                $tempcat[] = $db->prep($scat);
            }
            $where_and['cat'] = "item_cat IN ('" . implode("','", $tempcat) . "')";
        }
    } else {
        $where_and['cat'] = "item_cat IN ('" . implode("','", $prj_catauth) . "')";
    }
    $where_and['state'] = "item_state = 0";
    $where_and['date'] = $rs['setlimit'] > 0 ? "item_date >= " . $rs['setfrom'] . " AND item_date <= " . $rs['setto'] : "";
Пример #8
0
function cot_build_structure_folio_tree($parent = '', $selected = array(), $level = 0, $template = '')
{
    global $structure, $cfg, $db, $sys;
    global $i18n_notmain, $i18n_locale, $i18n_write, $i18n_admin, $i18n_read, $db_i18n_pages;
    if (empty($parent)) {
        $i18n_enabled = $i18n_read;
        $children = array();
        foreach ($structure['folio'] as $i => $x) {
            if (mb_substr_count($structure['folio'][$i]['path'], ".") == 0) {
                $children[] = $i;
            }
        }
    } else {
        $i18n_enabled = $i18n_read && cot_i18n_enabled($parent);
        $children = cot_structure_children('folio', $parent, false, false);
    }
    //cot_print($children, $parent);
    $t1 = new XTemplate(cot_tplfile(array('folio', 'tree', $template), 'module'));
    if (count($children) == 0) {
        return false;
    }
    $jj = 0;
    foreach ($children as $row) {
        $jj++;
        $t1->assign(array("ROW_TITLE" => htmlspecialchars($structure['folio'][$row]['title']), "ROW_DESC" => $structure['folio'][$row]['desc'], "ROW_COUNT" => $structure['folio'][$row]['count'], "ROW_ICON" => $structure['folio'][$row]['icon'], "ROW_HREF" => cot_url("folio", "c=" . $row . "&type=" . $type), "ROW_SELECTED" => in_array($row, $selected) ? 1 : 0, "ROW_SUBCAT" => cot_build_structure_folio_tree($row, $selected, $level + 1), "ROW_LEVEL" => $level, "ROW_ODDEVEN" => cot_build_oddeven($jj), "ROW_JJ" => $jj));
        if ($i18n_enabled && $i18n_notmain) {
            $x_i18n = cot_i18n_get_cat($row, $i18n_locale);
            if ($x_i18n) {
                $urlparams = !$cfg['plugin']['i18n']['omitmain'] || $i18n_locale != $cfg['defaultlang'] ? "c={$row}&l={$i18n_locale}" : "c={$row}";
                $t1->assign(array('ROW_URL' => cot_url('folio', $urlparams), 'ROW_TITLE' => $x_i18n['title'], 'ROW_DESC' => $x_i18n['desc']));
            }
        }
        $t1->parse("MAIN.CATS");
        $t1->assign(array("TITLE" => htmlspecialchars($structure['folio'][$parent]['title']), "DESC" => $structure['folio'][$parent]['desc'], "COUNT" => $structure['folio'][$parent]['count'], "ICON" => $structure['folio'][$parent]['icon'], "HREF" => cot_url("folio", "c=" . $parent), "LEVEL" => $level));
    }
    if ($jj == 0) {
        return false;
    }
    $t1->parse("MAIN");
    return $t1->text("MAIN");
}
Пример #9
0
/* ===== */
if (!empty($c)) {
    $out['subtitle'] = !empty($cfg['folio']['cat_' . $c]['metatitle']) ? $cfg['folio']['cat_' . $c]['metatitle'] : $cfg['folio']['cat___default']['metatitle'];
    $out['subtitle'] = !empty($out['subtitle']) ? $out['subtitle'] : $L['folio'];
    $out['desc'] = !empty($cfg['folio']['cat_' . $c]['metadesc']) ? $cfg['folio']['cat_' . $c]['metadesc'] : $cfg['folio']['cat___default']['metadesc'];
    $out['keywords'] = !empty($cfg['folio']['cat_' . $c]['keywords']) ? $cfg['folio']['cat_' . $c]['keywords'] : $cfg['folio']['cat___default']['keywords'];
} else {
    $out['subtitle'] = !empty($cfg['folio']['cat___default']['metatitle']) ? $cfg['folio']['cat___default']['metatitle'] : $L['folio'];
    $out['desc'] = $cfg['folio']['cat___default']['metadesc'];
    $out['keywords'] = $cfg['folio']['cat___default']['keywords'];
}
$where = array();
$order = array();
$where['state'] = "item_state=0";
if (!empty($c)) {
    $catsub = cot_structure_children('folio', $c);
    $where['cat'] = "item_cat IN ('" . implode("','", $catsub) . "')";
}
if (!empty($sq)) {
    $words = explode(' ', preg_replace("'\\s+'", " ", $sq));
    $sqlsearch = '%' . implode('%', $words) . '%';
    $where['search'] = "(item_title LIKE '" . $db->prep($sqlsearch) . "' OR item_text LIKE '" . $db->prep($sqlsearch) . "')";
}
// Extra fields
foreach ($cot_extrafields[$db_folio] as $exfld) {
    $fld_value = cot_import($exfld['field_name'], 'G', 'TXT');
    $fld_value = $db->prep($fld_value);
    if (!empty($shfld[$exfld['field_name']])) {
        $where[$exfld['field_name']] = "item_" . $exfld['field_name'] . " LIKE '%" . $fld_value . "%'";
    }
}
Пример #10
0
 /**
  * Список объявлений
  * @param $c
  * @return string
  * @throws Exception
  */
 public function adList($c)
 {
     global $structure, $cot_extrafields, $db_structure, $Ls;
     if ($c == 'all') {
         cot_block(cot::$usr['isadmin']);
     } elseif (!in_array($c, array('unvalidated', 'saved-drafts'))) {
         if (!isset($structure['advboard'][$c])) {
             cot_die_message(404, TRUE);
         } else {
             list(cot::$usr['auth_read'], cot::$usr['auth_write'], cot::$usr['isadmin']) = cot_auth('advboard', $c);
             cot_block(cot::$usr['auth_read']);
         }
     }
     $sort = cot_import('s', 'G', 'ALP');
     // order field name
     $way = cot_import('w', 'G', 'ALP', 4);
     // order way (asc, desc)
     $maxrowsperpage = cot::$cfg['advboard']['cat_' . $c]['maxrowsperpage'] ? cot::$cfg['advboard']['cat_' . $c]['maxrowsperpage'] : cot::$cfg['advboard']['cat___default']['maxrowsperpage'];
     if ($maxrowsperpage < 1) {
         $maxrowsperpage = 1;
     }
     list($pg, $d, $durl) = cot_import_pagenav('d', $maxrowsperpage);
     //page number for pages list
     list($pgc, $dc, $dcurl) = cot_import_pagenav('dc', cot::$cfg['advboard']['maxlistsperpage']);
     // page number for cats list
     // Фильтры для модератора
     $mf = array('period' => 0, 'state' => -2);
     if (cot::$usr['isadmin']) {
         $mf['period'] = isset($_GET['mf']['period']) ? cot_import($_GET['mf']['period'], 'D', 'ALP') : 0;
         $mf['state'] = isset($_GET['mf']['state']) ? cot_import($_GET['mf']['state'], 'D', 'INT') : -2;
     }
     /* === Hook === */
     foreach (cot_getextplugins('advboard.list.first') as $pl) {
         include $pl;
     }
     /* ===== */
     $category = array('config' => array());
     if (isset($structure['advboard'][$c])) {
         $category = $structure['advboard'][$c];
         $category['config'] = cot::$cfg['advboard']['cat_' . $c];
     }
     $category['code'] = $c;
     $fields = advboard_model_Advert::getColumns();
     if (empty($sort)) {
         $sort = cot::$cfg['advboard']['cat_' . $c]['order'];
     } elseif (!in_array($sort, $fields)) {
         $sort = 'sort';
     }
     $way = empty($way) ? cot::$cfg['advboard']['cat_' . $c]['way'] : $way;
     $sort = empty($sort) ? cot::$cfg['advboard']['cat___default']['order'] : $sort;
     $way = empty($way) || !in_array($way, array('asc', 'desc')) ? cot::$cfg['advboard']['cat___default']['way'] : $way;
     $urlParams = array('c' => $c);
     if ($sort != cot::$cfg['advboard']['cat_' . $c]['order']) {
         $urlParams['s'] = $sort;
     }
     if ($way != cot::$cfg['advboard']['cat_' . $c]['way']) {
         $urlParams['w'] = $way;
     }
     $canonicalUrlParams = array('c' => $c);
     if ($durl > 1) {
         $canonicalUrlParams['d'] = $durl;
     }
     if ($dcurl > 1) {
         $canonicalUrlParams['dc'] = $dcurl;
     }
     $template = array('advboard', 'list');
     $where = array();
     if ($c == 'unvalidated') {
         $template = array('advboard', 'list', 'unvalidated');
         $where['state'] = array('state', advboard_model_Advert::AWAITING_MODERATION);
         if (!cot::$usr['isadmin']) {
             $where['user'] = array('user', cot::$usr['id']);
         }
         $category['title'] = cot::$L['page_validation'];
         $category['desc'] = cot::$L['page_validation_desc'];
         $sort = 'created';
         $way = 'desc';
     } elseif ($c == 'saved-drafts') {
         $template = array('advboard', 'list', 'unvalidated');
         $where['state'] = array('state', advboard_model_Advert::DRAFT);
         if (!cot::$usr['isadmin']) {
             $where['user'] = array('user', cot::$usr['id']);
         }
         $category['title'] = cot::$L['page_drafts'];
         $category['desc'] = cot::$L['page_drafts_desc'];
         $sort = 'created';
         $way = 'desc';
     } elseif ($c == 'all') {
         $category['title'] = cot::$L['advboard_ads_board'];
     } else {
         $where['category'] = array('category', $c);
         $where['state'] = array('state', advboard_model_Advert::PUBLISHED);
         $where['begin'] = array('begin', cot::$sys['now'], '<=');
         $where['expire'] = array('SQL', "expire = 0 OR expire > " . cot::$sys['now']);
         $template = array('advboard', 'list', $structure['advboard'][$c]['tpl']);
     }
     $moderatorFilters = array();
     if (cot::$usr['isadmin']) {
         if ($mf['state'] == -1) {
             unset($where['state']);
         } elseif ($mf['state'] >= 0 && $mf['state'] < 3) {
             $where['state'] = array('state', $mf['state']);
         }
         if ($mf['period'] == 'all') {
             unset($where['begin'], $where['expire']);
         } elseif ($mf['period'] == 'exp') {
             unset($where['begin']);
             $where['expire'] = array('SQL', "expire > 0 AND expire <= " . cot::$sys['now']);
         } elseif ($mf['period'] == 'fut') {
             unset($where['expire']);
             $where['begin'] = array('begin', cot::$sys['now'], '>');
         }
         $tmp = array(-2 => cot::$R['code_option_empty'], -1 => cot::$L['All'], 0 => cot::$L['advboard_state_0'], 1 => cot::$L['advboard_state_1'], 2 => cot::$L['advboard_state_2']);
         $moderatorFilters['state'] = cot_selectbox($mf['state'], 'mf[state]', array_keys($tmp), array_values($tmp), false);
         $tmp = array('0' => cot::$R['code_option_empty'], 'all' => cot::$L['All'], 'exp' => cot::$L['advboard_expired'], 'fut' => cot::$L['advboard_future']);
         $moderatorFilters['period'] = cot_selectbox(strval($mf['period']), 'mf[period]', array_keys($tmp), array_values($tmp), false);
         $moderatorFilters['action'] = cot_url('advboard', $urlParams);
         $moderatorFilters['hidden'] = '';
         foreach ($urlParams as $key => $val) {
             $moderatorFilters['hidden'] .= cot_inputbox('hidden', $key, $val);
         }
         $moderatorFilters['reset'] = cot_url('advboard', $urlParams);
     }
     cot_die(empty($category['title']) && !cot::$usr['isadmin']);
     cot::$out['desc'] = htmlspecialchars(strip_tags($category['desc']));
     cot::$out['subtitle'] = $category['title'];
     if (!empty(cot::$cfg['advboard']['cat_' . $c]['keywords'])) {
         cot::$out['keywords'] = cot::$cfg['advboard']['cat_' . $c]['keywords'];
     }
     if (!empty(cot::$cfg['advboard']['cat_' . $c]['metadesc'])) {
         cot::$out['desc'] = cot::$cfg['advboard']['cat_' . $c]['metadesc'];
     }
     if (!empty(cot::$cfg['advboard']['cat_' . $c]['metatitle'])) {
         cot::$out['subtitle'] = cot::$cfg['advboard']['cat_' . $c]['metatitle'];
     }
     // Building the canonical URL
     cot::$out['canonical_uri'] = cot_url('advboard', $canonicalUrlParams);
     $condition = array();
     foreach ($where as $key => $val) {
         $condition[] = $val;
     }
     $order = array(array('sticky', 'desc'), array($sort, $way));
     /* === Hook === */
     foreach (cot_getextplugins('advboard.list.query') as $pl) {
         include $pl;
     }
     /* ===== */
     $totallines = advboard_model_Advert::count($condition);
     $advertisement = null;
     if ($totallines > 0) {
         $advertisement = advboard_model_Advert::find($condition, $maxrowsperpage, $d, $order);
     }
     $allowComments = cot_plugin_active('comments');
     if ($allowComments) {
         if (!isset(cot::$cfg['advboard']['cat_' . $c])) {
             $allowComments = false;
         } else {
             $allowComments = cot::$cfg['advboard']['cat_' . $c]['enable_comments'];
         }
     }
     $addNewUrl = '';
     if ((cot::$usr['auth_write'] || cot::$usr['isadmin']) && !empty($category['id'])) {
         $addNewUrl = cot_url('advboard', array('a' => 'edit', 'c' => $category['code']));
     }
     /* === Hook === */
     foreach (cot_getextplugins('advboard.list.main') as $pl) {
         include $pl;
     }
     /* ===== */
     // Extra fields for structure
     foreach ($cot_extrafields[$db_structure] as $exfld) {
         $uname = $exfld['field_name'];
         $val = $structure['advboard'][$c][$exfld['field_name']];
         $category[$uname . '_title'] = isset(cot::$L['structure_' . $exfld['field_name'] . '_title']) ? cot::$L['structure_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
         $category[$uname] = cot_build_extrafields_data('structure', $exfld, $val);
         $category[$uname . '_value'] = $val;
     }
     $kk = 0;
     $allsub = cot_structure_children('advboard', $c, false, false, true, false);
     $subcat = array_slice($allsub, $dc, cot::$cfg['advboard']['maxlistsperpage']);
     /* === Hook === */
     foreach (cot_getextplugins('advboard.list.rowcat.first') as $pl) {
         include $pl;
     }
     /* ===== */
     /* === Hook - Part1 : Set === */
     $extp = cot_getextplugins('advboard.list.rowcat.loop');
     /* ===== */
     $subCategories = array();
     foreach ($subcat as $x) {
         $kk++;
         $cat_childs = cot_structure_children('advboard', $x);
         $sub_count = 0;
         foreach ($cat_childs as $cat_child) {
             $sub_count += (int) $structure['advboard'][$cat_child]['count'];
         }
         $sub_url_path = $urlParams;
         $sub_url_path['c'] = $x;
         $subCategories[$x] = $structure['advboard'][$x];
         $subCategories[$x]['config'] = cot::$cfg['advboard']['cat_' . $x];
         $subCategories[$x]['code'] = $x;
         $subCategories[$x]['count'] = $sub_count;
         $subCategories[$x]['num'] = $kk;
         // Extra fields for structure
         foreach ($cot_extrafields[$db_structure] as $exfld) {
             $uname = $exfld['field_name'];
             $val = $structure['advboard'][$x][$exfld['field_name']];
             $subCategories[$x][$uname . '_title'] = isset(cot::$L['structure_' . $exfld['field_name'] . '_title']) ? cot::$L['structure_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
             $subCategories[$x][$uname] = cot_build_extrafields_data('structure', $exfld, $val);
             $subCategories[$x][$uname . '_value'] = $val;
         }
         /* === Hook - Part2 : Include === */
         foreach ($extp as $pl) {
             include $pl;
         }
         /* ===== */
     }
     $crumbs = array();
     if (!empty($category['id'])) {
         $crumbs = cot_structure_buildpath('advboard', $c);
         if (cot::$cfg['advboard']['firstCrumb']) {
             array_unshift($crumbs, array(cot_url('advboard'), cot::$L['advboard_ads']));
         }
     }
     // Фильтры для модератора
     if (cot::$usr['isadmin']) {
         if ($mf['period'] != '0') {
             $urlParams['mf[period]'] = $mf['period'];
         }
         if ($mf['state'] != -2) {
             $urlParams['mf[state]'] = $mf['state'];
         }
     }
     $pagenavCategory = cot_pagenav('advboard', $urlParams + array('d' => $durl), $dc, count($allsub), cot::$cfg['advboard']['maxlistsperpage'], 'dc');
     if (empty($pagenavCategory['current'])) {
         $pagenavCategory['current'] = 1;
     }
     $pagenav = cot_pagenav('advboard', $urlParams + array('dc' => $dcurl), $d, $totallines, $maxrowsperpage);
     if (empty($pagenav['current'])) {
         $pagenav['current'] = 1;
     }
     $breadcrumbs = '';
     if (!empty($crumbs)) {
         $breadcrumbs = cot_breadcrumbs($crumbs, cot::$cfg['homebreadcrumb'], true);
     }
     $pageUrlParams = $urlParams;
     if ($durl > 1) {
         $pageUrlParams['d'] = $durl;
     }
     $view = new View();
     $view->breadcrumbs = $breadcrumbs;
     $view->page_title = htmlspecialchars($category['title']);
     $view->category = $category;
     $view->subCategories = $subCategories;
     $view->condition = $condition;
     $view->order = $order;
     $view->advertisement = $advertisement;
     $view->totalitems = $totallines;
     $view->allowComments = $allowComments;
     $view->pagenav = $pagenav;
     $view->pagenavCategory = $pagenavCategory;
     $view->moderatorFilters = $moderatorFilters;
     $view->addNewUrl = $addNewUrl;
     $view->urlParams = $urlParams;
     $view->pageUrlParams = $pageUrlParams;
     /* === Hook === */
     foreach (cot_getextplugins('advboard.list.view') as $pl) {
         include $pl;
     }
     /* ===== */
     return $view->render($template);
 }
Пример #11
0
foreach (cot_getextplugins('forums.topics.main') as $pl) {
    include $pl;
}
/* ===== */
require_once $cfg['system_dir'] . '/header.php';
$mskin = cot_tplfile(array('forums', 'topics', $structure['forums'][$s]['tpl']));
$t = new XTemplate($mskin);
$arraychilds = cot_structure_children('forums', $s, false, false);
if (count($arraychilds) > 0) {
    /* === Hook - Part1 : Set === */
    $extp = cot_getextplugins('forums.topics.sections.loop');
    /* ===== */
    $jj = 0;
    foreach ($arraychilds as $cat) {
        $jj++;
        $all = cot_structure_children('forums', $cat);
        $last = $db->query("SELECT fs_lt_id, fs_lt_title, fs_lt_date, fs_lt_posterid, fs_lt_postername FROM {$db_forum_stats}\n\t\t\t\tWHERE fs_cat IN (\"" . implode('", "', $all) . "\") ORDER BY fs_lt_date DESC LIMIT 1")->fetch();
        $stat = $db->query("SELECT SUM(fs_topiccount) AS topiccount, SUM(fs_postcount) AS postcount, SUM(fs_viewcount) AS viewcount\n\t\t\t\tFROM {$db_forum_stats}\n\t\t\t\tWHERE fs_cat IN (\"" . implode('", "', $all) . "\") ORDER BY fs_lt_date DESC LIMIT 1")->fetch();
        $last = is_array($last) && is_array($stat) ? $stat + $last : '';
        $t->assign(cot_generate_sectiontags($cat, 'FORUMS_SECTIONS_ROW_', $last));
        $t->assign(array('FORUMS_SECTIONS_ROW_ODDEVEN' => cot_build_oddeven($jj), 'FORUMS_SECTIONS_ROW_NUM' => $jj));
        /* === Hook - Part2 : Include === */
        foreach ($extp as $pl) {
            include $pl;
        }
        /* ===== */
        $t->parse('MAIN.FORUMS_SECTIONS.FORUMS_SECTIONS_ROW_SECTION');
    }
    $t->parse('MAIN.FORUMS_SECTIONS');
}
$where = is_array($where) ? $where : array();
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru, littledev.ru
 * @license BSD
 *  */
defined('COT_CODE') or die('Wrong URL.');
if ($cfg['plugin']['tagslance']['market']) {
    require_once cot_incfile('tags', 'plug');
    // I18n or not i18n
    if (cot_plugin_active('i18n') && $i18n_enabled && $i18n_notmain) {
        $tags_extra = array('tag_locale' => $i18n_locale);
        $tags_where .= " AND tag_locale = '{$i18n_locale}'";
    } else {
        $tags_extra = null;
    }
    // Get all subcategories
    $tc_cats = cot_structure_children('market', $c);
    $tc_cats = implode("','", $tc_cats);
    // Get all pages from all subcategories and all tags with counts for them
    $limit = $cfg['plugin']['tags']['lim_pages'] == 0 ? '' : ' LIMIT ' . (int) $cfg['plugin']['tags']['lim_pages'];
    $order = $cfg['plugin']['tags']['order'];
    switch ($order) {
        case 'Alphabetical':
            $order = 'tag';
            break;
        case 'Frequency':
            $order = 'cnt DESC';
            break;
        default:
            $order = 'RAND()';
    }
    $tc_res = $db->query("SELECT r.tag AS tag, COUNT(r.tag_item) AS cnt\n\t\tFROM {$db_tag_references} AS r LEFT JOIN {$db_market} AS p\n\t\tON r.tag_item = p.item_id\n\t\tWHERE r.tag_area = 'market' {$tags_where} AND p.item_cat IN ('" . $tc_cats . "') AND p.item_state = 0\n\t\tGROUP BY r.tag\n\t\tORDER BY {$order} {$limit}");
function cot_usercategories_tree($chosen = '', $parent = '', $template = '', $level = 0)
{
    global $structure, $cfg, $gm, $group;
    global $i18n_notmain, $i18n_locale, $i18n_read;
    if (empty($structure['usercategories'])) {
        return false;
    }
    if (!is_array($chosen)) {
        $chosen = explode(',', $chosen);
    }
    if (empty($parent)) {
        $i18n_enabled = $i18n_read;
        $children = array();
        foreach ($structure['usercategories'] as $i => $x) {
            if (mb_substr_count($structure['usercategories'][$i]['path'], ".") == 0) {
                $children[] = $i;
            }
        }
    } else {
        $i18n_enabled = $i18n_read && cot_i18n_enabled($parent);
        $children = cot_structure_children('usercategories', $parent, false, false);
    }
    if (count($children) == 0) {
        return false;
    }
    $t1 = new XTemplate(cot_tplfile(array('usercategories', 'cattree', $template), 'plug'));
    $level++;
    $jj = 0;
    foreach ($children as $row) {
        $jj++;
        $subcats = cot_structure_children('usercategories', $row, false, false);
        $t1->assign(array("CAT_ROW_CAT" => $row, "CAT_ROW_TITLE" => htmlspecialchars($structure['usercategories'][$row]['title']), "CAT_ROW_DESC" => $structure['usercategories'][$row]['desc'], "CAT_ROW_COUNT" => $structure['usercategories'][$row]['count'], "CAT_ROW_ICON" => $structure['usercategories'][$row]['icon'], "CAT_ROW_URL" => cot_url("users", "gm=" . $gm . "&cat=" . $row . "&group=" . $group), "CAT_ROW_SELECTED" => is_array($chosen) && in_array($row, $chosen) || !is_array($chosen) && $row == $chosen ? 1 : 0, "CAT_ROW_SUBCAT" => count($subcats) > 0 ? cot_usercategories_tree($chosen, $row, $template, $level) : '', "CAT_ROW_ODDEVEN" => cot_build_oddeven($jj), "CAT_ROW_JJ" => $jj));
        if ($i18n_enabled && $i18n_notmain) {
            $x_i18n = cot_i18n_get_cat($row, $i18n_locale);
            if ($x_i18n) {
                $urlparams = !$cfg['plugin']['i18n']['omitmain'] || $i18n_locale != $cfg['defaultlang'] ? "gm=" . $gm . "&cat=" . $row . "&group=" . $group . "&l=" . $i18n_locale : "gm=" . $gm . "&cat=" . $row . "&group=" . $group;
                $t1->assign(array('CAT_ROW_URL' => cot_url('users', $urlparams), 'CAT_ROW_TITLE' => $x_i18n['title'], 'CAT_ROW_DESC' => $x_i18n['desc']));
            }
        }
        $t1->parse("MAIN.CAT_ROW");
        if ($parent) {
            $t1->assign(array("CAT_TITLE" => htmlspecialchars($structure['usercategories'][$parent]['title']), "CAT_DESC" => $structure['usercategories'][$parent]['desc'], "CAT_COUNT" => $structure['usercategories'][$parent]['count'], "CAT_ICON" => $structure['usercategories'][$parent]['icon']));
        }
        $t1->assign(array("CAT_URL" => cot_url("users", "gm=" . $gm . "&cat=" . $parent . "&group=" . $group), "CAT_LEVEL" => $level));
    }
    if ($jj == 0) {
        return false;
    }
    $t1->parse("MAIN");
    return $t1->text("MAIN");
}
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru, littledev.ru
 * @license BSD
 *  */
defined('COT_CODE') or die('Wrong URL.');
if ($cfg['plugin']['tagslance']['folio']) {
    require_once cot_incfile('tags', 'plug');
    // I18n or not i18n
    if (cot_plugin_active('i18n') && $i18n_enabled && $i18n_notmain) {
        $tags_extra = array('tag_locale' => $i18n_locale);
        $tags_where .= " AND tag_locale = '{$i18n_locale}'";
    } else {
        $tags_extra = null;
    }
    // Get all subcategories
    $tc_cats = cot_structure_children('folio', $c);
    $tc_cats = implode("','", $tc_cats);
    // Get all pages from all subcategories and all tags with counts for them
    $limit = $cfg['plugin']['tags']['lim_pages'] == 0 ? '' : ' LIMIT ' . (int) $cfg['plugin']['tags']['lim_pages'];
    $order = $cfg['plugin']['tags']['order'];
    switch ($order) {
        case 'Alphabetical':
            $order = 'tag';
            break;
        case 'Frequency':
            $order = 'cnt DESC';
            break;
        default:
            $order = 'RAND()';
    }
    $tc_res = $db->query("SELECT r.tag AS tag, COUNT(r.tag_item) AS cnt\n\t\tFROM {$db_tag_references} AS r LEFT JOIN {$db_folio} AS p\n\t\tON r.tag_item = p.item_id\n\t\tWHERE r.tag_area = 'folio' {$tags_where} AND p.item_cat IN ('" . $tc_cats . "') AND p.item_state = 0\n\t\tGROUP BY r.tag\n\t\tORDER BY {$order} {$limit}");
Пример #15
0
 /**
  * Generates a banner widget.
  *
  * @param string $tpl
  * @param array|string $cat  Category, semicolon separated
  * @param string $order  'order' OR 'rand'
  * @param int $cnt  Banner count
  * @param int|bool $client
  * @param int|bool $subcats
  * @return string
  *
  */
 public static function banner($cat = '', $cnt = 1, $tpl = 'brs.banner', $order = 'order', $client = false, $subcats = false)
 {
     global $cache_ext;
     $cats = array();
     $client = (int) $client;
     $cnt = (int) $cnt;
     if (!empty($cat)) {
         if (is_array($cat)) {
             $cats = $cat;
         } elseif ($cat != '') {
             $categs = explode(';', $cat);
             if (is_array($categs)) {
                 foreach ($categs as $tmp) {
                     $tmp = trim($tmp);
                     if (empty($tmp)) {
                         continue;
                     }
                     if ($subcats) {
                         // Specific cat
                         //                    var_dump(cot_structure_children('banners', $tmp));
                         $cats = array_merge($cats, cot_structure_children('brs', $tmp, true, true, false, false));
                     } else {
                         $cats[] = $tmp;
                     }
                 }
             }
             $cats = array_unique($cats);
         }
     }
     $nullDate = date('Y-m-d H:i:s', 0);
     // 1970-01-01 00:00:00
     $condition = array(array('published', 1), array('publish_up', date('Y-m-d H:i:s', cot::$sys['now']), '<='), array('SQL', "publish_down >='" . date('Y-m-d H:i:s', cot::$sys['now']) . "' OR publish_down ='{$nullDate}'"), array('SQL', "imptotal = 0 OR impressions < imptotal"));
     if (count($cats) > 0) {
         $condition[] = array('category', $cats);
     }
     if ($client) {
         $condition[] = array('client', $client);
     }
     $ord = "lastimp ASC";
     if ($order == 'rand') {
         $ord = 'RAND()';
     }
     $items = brs_model_Banner::find($condition, $cnt, 0, $ord);
     if (!$items) {
         return '';
     }
     // Display the items
     $t = new XTemplate(cot_tplfile($tpl, 'plug'));
     foreach ($items as $itemRow) {
         // Если включено кеширование и это незарег не засчитываем показ. Баннер будет запрошен аяксом
         if (!(!empty($cache_ext) && cot::$usr['id'] == 0 && cot::$cfg['cache_' . $cache_ext])) {
             $itemRow->impress();
         }
         self::$count++;
         // Порядковый номер баннера на странице
         $itemRow->number = self::$count;
     }
     $view = new View();
     $view->items = $items;
     $view->order = $order;
     $view->client = $client;
     return $view->render($tpl);
 }
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru, littledev.ru
 * @license BSD
 *  */
defined('COT_CODE') or die('Wrong URL.');
if ($cfg['plugin']['tagslance']['projects']) {
    require_once cot_incfile('tags', 'plug');
    // I18n or not i18n
    if (cot_plugin_active('i18n') && $i18n_enabled && $i18n_notmain) {
        $tags_extra = array('tag_locale' => $i18n_locale);
        $tags_where .= " AND tag_locale = '{$i18n_locale}'";
    } else {
        $tags_extra = null;
    }
    // Get all subcategories
    $tc_cats = cot_structure_children('projects', $c);
    $tc_cats = implode("','", $tc_cats);
    // Get all pages from all subcategories and all tags with counts for them
    $limit = $cfg['plugin']['tags']['lim_pages'] == 0 ? '' : ' LIMIT ' . (int) $cfg['plugin']['tags']['lim_pages'];
    $order = $cfg['plugin']['tags']['order'];
    switch ($order) {
        case 'Alphabetical':
            $order = 'tag';
            break;
        case 'Frequency':
            $order = 'cnt DESC';
            break;
        default:
            $order = 'RAND()';
    }
    $tc_res = $db->query("SELECT r.tag AS tag, COUNT(r.tag_item) AS cnt\n\t\tFROM {$db_tag_references} AS r LEFT JOIN {$db_projects} AS p\n\t\tON r.tag_item = p.item_id\n\t\tWHERE r.tag_area = 'projects' {$tags_where} AND p.item_cat IN ('" . $tc_cats . "') AND p.item_state = 0\n\t\tGROUP BY r.tag\n\t\tORDER BY {$order} {$limit}");
Пример #17
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;
}
Пример #18
0
$filter = cot_import('filter', 'R', 'ALP');
$filter = empty($filter) ? 'valqueue' : $filter;
$filter_type = array('all' => $L['All'], 'valqueue' => $L['adm_valqueue'], 'validated' => $L['adm_validated'], 'expired' => $L['adm_expired'], 'drafts' => $L['page_drafts']);
$common_params = 'm=page&sorttype=' . $sorttype . '&sortway=' . $sortway . '&filter=' . $filter;
if ($filter == 'all') {
    $sqlwhere = "1 ";
} elseif ($filter == 'valqueue') {
    $sqlwhere = "page_state=1";
} elseif ($filter == 'validated') {
    $sqlwhere = "page_state=0";
} elseif ($filter == 'drafts') {
    $sqlwhere = "page_state=2";
} elseif ($filter == 'expired') {
    $sqlwhere = "page_begin > {$sys['now']} OR (page_expire <> 0 AND page_expire < {$sys['now']})";
}
$catsub = cot_structure_children('page', '');
if (count($catsub) < count($structure['page'])) {
    $sqlwhere .= " AND page_cat IN ('" . join("','", $catsub) . "')";
}
/* === Hook  === */
foreach (cot_getextplugins('page.admin.first') as $pl) {
    include $pl;
}
/* ===== */
if ($a == 'validate') {
    cot_check_xg();
    /* === Hook  === */
    foreach (cot_getextplugins('page.admin.validate') as $pl) {
        include $pl;
    }
    /* ===== */
Пример #19
0
<?php

/*
 * [BEGIN_COT_EXT]
 * Hooks=page.list.query
 * Order=1
 * [END_COT_EXT]
 */
/**
 * Subcat Plugin for Cotonti Siena CMF
 *
 * @version 4.00
 * @author esclkm
 * @copyright (c) 2008-2011 esclkm
 */
defined('COT_CODE') or die('Wrong URL');
$subcat = cot_import('cs', 'G', 'BOL') ? 1 : 0;
$nosubcat = cot_import('ncs', 'G', 'BOL') ? 1 : 0;
$subcat && ($list_url_path['sc'] = $subcat);
$nosubcat && ($list_url_path['nsc'] = $nosubcat);
$scats = explode(',', $cfg['plugin']['subcat']['cats']);
array_walk($scats, 'trim');
$scatarray = array();
foreach ($scats as $scat) {
    $scatarray = array_merge(cot_structure_children('page', $scat), $scatarray);
}
if (!$nosubcat && ($subcat || in_array($c, $scatarray)) && $c != 'all' && $c != 'unvalidated') {
    $catlist2 = cot_structure_children('page', $c);
    $where['cat'] = "page_cat IN ('" . implode("','", $catlist2) . "')";
}
/**
 * market module
 *
 * @package market
 * @version 2.5.2
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru, littledev.ru
 * @license BSD
 */
defined('COT_CODE') or die('Wrong URL.');
if ($cfg['market']['marketsearch'] && ($tab == 'market' || empty($tab)) && cot_module_active('market') && !cot_error_found()) {
    if ($rs['marketsub'][0] != 'all' && count($rs['marketsub']) > 0) {
        if ($rs['marketsubcat']) {
            $tempcat = array();
            foreach ($rs['marketsub'] as $scat) {
                $tempcat = array_merge(cot_structure_children('market', $scat), $tempcat);
            }
            $tempcat = array_unique($tempcat);
            $where_and['cat'] = "item_cat IN ('" . implode("','", $tempcat) . "')";
        } else {
            $tempcat = array();
            foreach ($rs['marketsub'] as $scat) {
                $tempcat[] = $db->prep($scat);
            }
            $where_and['cat'] = "item_cat IN ('" . implode("','", $tempcat) . "')";
        }
    } else {
        $where_and['cat'] = "item_cat IN ('" . implode("','", $market_catauth) . "')";
    }
    $where_and['state'] = "item_state = 0";
    $where_and['date'] = $rs['setlimit'] > 0 ? "item_date >= " . $rs['setfrom'] . " AND item_date <= " . $rs['setto'] : "";
Пример #21
0
/* ===== */
if (!empty($c)) {
    $out['subtitle'] = !empty($cfg['market']['cat_' . $c]['metatitle']) ? $cfg['market']['cat_' . $c]['metatitle'] : $cfg['market']['cat___default']['metatitle'];
    $out['subtitle'] = !empty($out['subtitle']) ? $out['subtitle'] : $L['market'];
    $out['desc'] = !empty($cfg['market']['cat_' . $c]['metadesc']) ? $cfg['market']['cat_' . $c]['metadesc'] : $cfg['market']['cat___default']['metadesc'];
    $out['keywords'] = !empty($cfg['market']['cat_' . $c]['keywords']) ? $cfg['market']['cat_' . $c]['keywords'] : $cfg['market']['cat___default']['keywords'];
} else {
    $out['subtitle'] = !empty($cfg['market']['cat___default']['metatitle']) ? $cfg['market']['cat___default']['metatitle'] : $L['market'];
    $out['desc'] = $cfg['market']['cat___default']['metadesc'];
    $out['keywords'] = $cfg['market']['cat___default']['keywords'];
}
$where = array();
$order = array();
$where['state'] = "item_state=0";
if (!empty($c)) {
    $catsub = cot_structure_children('market', $c);
    $where['cat'] = "item_cat IN ('" . implode("','", $catsub) . "')";
}
if (!empty($sq)) {
    $words = explode(' ', preg_replace("'\\s+'", " ", $sq));
    $sqlsearch = '%' . implode('%', $words) . '%';
    $where['search'] = "(item_title LIKE '" . $db->prep($sqlsearch) . "' OR item_text LIKE '" . $db->prep($sqlsearch) . "')";
}
// Extra fields
foreach ($cot_extrafields[$db_market] as $exfld) {
    $fld_value = cot_import($exfld['field_name'], 'G', 'TXT');
    $fld_value = $db->prep($fld_value);
    if (!empty($shfld[$exfld['field_name']])) {
        $where[$exfld['field_name']] = "item_" . $exfld['field_name'] . " LIKE '%" . $fld_value . "%'";
    }
}
/**
 * [BEGIN_COT_EXT]
 * Hooks=users.query
 * Order=99
 * [END_COT_EXT]
 */
/**
 * User Categories plugin
 *
 * @package usercategories
 * @version 2.5.0
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru, littledev.ru
 * @license BSD
 */
defined('COT_CODE') or die('Wrong URL.');
require_once cot_incfile('usercategories', 'plug');
$cat = cot_import('cat', 'G', 'ALP');
if (!empty($cat)) {
    $subcats = cot_structure_children('usercategories', $cat);
    if (count($subcats) > 0) {
        foreach ($subcats as $val) {
            $cat_query[] = "FIND_IN_SET('" . $db->prep($val) . "', user_cats)";
        }
        $where['cat'] = "(" . implode(' OR ', $cat_query) . ")";
    } else {
        $where['cat'] = "user_id=0";
    }
    $users_url_path['cat'] = $cat;
}