本文整理汇总了PHP中cot_structure_children函数的典型用法代码示例。如果您正苦于以下问题:PHP cot_structure_children函数的具体用法?PHP cot_structure_children怎么用?PHP cot_structure_children使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cot_structure_children函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cot_usercategories_sync
/**
* 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: cot_market_sync
/**
* 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: unset
}
/* ===== */
$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: array
$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: cot_structure_children
$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: cot_build_recentpages
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') : '';
}
示例7: defined
/**
* 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: cot_build_structure_folio_tree
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: array
/* ===== */
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: adList
//.........这里部分代码省略.........
}
/* ===== */
$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;
}
示例11: foreach
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();
示例12: defined
* @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}");
示例13: cot_usercategories_tree
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");
}
示例14: defined
* @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: banner
/**
* 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);
}