Exemple #1
0
 public function tagAction()
 {
     $templ_file = '/search/gettag.tpl';
     $TEMPLATE = page::getTemplate($templ_file);
     if (!is_array($TEMPLATE)) {
         return page::errorNotFound('search.getTag', $templ_file);
     }
     if (system::issetUrl(2) && ($tag = tags::infoTag(system::url(2)))) {
         $msg = lang::get('SEARCH_H1_TAGS') . ' "' . $tag['name'] . '"';
         page::globalVar('h1', $msg);
         page::globalVar('title', $msg);
         // Получаем список классов
         $classes_filter = array();
         if (!empty($_POST['classes'])) {
             $tmp = explode(",", $_POST['classes']);
             $classes_filter = array();
             foreach ($tmp as $v) {
                 $v = trim($v);
                 if (!empty($v)) {
                     $classes_filter[] = $v;
                 }
             }
         }
         $max_count = reg::getKey(ormPages::getPrefix('search') . '/max_count');
         $start = (system::getCurrentNavNum() - 1) * $max_count;
         $result = tags::find(array($tag['id']), $max_count, $start, $classes_filter);
         $list = '';
         while (list($num, $val) = each($result['pages'])) {
             if ($page = ormPages::get($val['page_id'])) {
                 page::assign('obj.id', $page->id);
                 page::assign('obj.num', $num + $start + 1);
                 page::assign('obj.name', $page->name);
                 page::assign('obj.url', $page->_url);
                 //page::assign('obj.content', $page->content);
                 $cn = $page->getClass()->getSName();
                 $block_name = isset($TEMPLATE['list_' . $cn]) ? 'list_' . $cn : 'list';
                 $list .= page::parse($TEMPLATE[$block_name]);
             }
         }
         page::assign('count_page', ceil($result['count'] / $max_count));
     } else {
         $list = '';
         $msg = lang::get('SEARCH_H1_TAGS2');
         page::globalVar('h1', $msg);
         page::globalVar('title', $msg);
     }
     if (!empty($list)) {
         page::assign('list', $list);
         page::fParse('list', $TEMPLATE['frame_list']);
     } else {
         page::fParse('list', $TEMPLATE['not_found']);
     }
     return page::parse($TEMPLATE['frame']);
 }