/**
  * Tags list (tags in topic, search results)
  */
 public function _tag_list()
 {
     $sm = vivvo_lite_site::get_instance();
     $um = $sm->get_url_manager();
     $list_template = $this->load_template($this->_template_root . 'tag_list.xml');
     $params = Tags_list::get_search_params_from_url($sm);
     $params['search_advanced_mode'] = 1;
     if ($um->isset_param('topic_id')) {
         $topic = TagsGroups_list::factory()->get_group_by_id($um->get_param('topic_id'));
         $params['search_topic_id'] = $topic->get_id();
         $list_template->assign('topic', $topic);
     }
     $list_template->assign('tag_list_params', $params);
     $search_sort_by = $params['search_sort_by'] . '.' . $params['search_order'];
     $list_template->assign('search_sort_by', $search_sort_by);
     $list_template->assign('search_limit', $params['search_limit']);
     return $list_template;
 }
Esempio n. 2
0
 /**
  * Returns list of all tags applied to this article
  *
  * @return	array
  */
 public function get_tag_links()
 {
     if ($this->tag_links === false) {
         $this->tag_links = array();
         class_exists('TagsGroups') or (require VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/TagsGroups.class.php');
         class_exists('Tags') or (require VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Tags.class.php');
         $this->topics = TagsGroups_list::factory()->get_groups_by_article_id($this->id, 1);
         $tag_list = Tags_list::factory();
         foreach ($this->topics as $topic) {
             $topic->set_article_tags($tags = $tag_list->get_tags_by_article_topic($this, $topic, true));
             $this->tag_links = array_merge($this->tag_links, $tags);
         }
     }
     return $this->tag_links;
 }
Esempio n. 3
0
 /**
  * Advaced search list generator
  *
  * @param	array	$params	Search parameters
  * @param	string	$order	Order parameters
  * @param	integer	$limit	Limit
  * @param	integer	$offset	Offset
  * @return	array	Array of articles
  */
 function &search($params, $order = '', $direction = 'ascending', $limit = 0, $offset = 0, $set_list = true)
 {
     $this->_default_query($advanced = !empty($params['search_advanced_mode']) and empty($params['set_rating']), !empty($params['set_rating']));
     $this->_query->set_limit((int) $limit);
     $this->_query->set_offset((int) $offset);
     if ($advanced and defined('VIVVO_ADMIN_MODE') and !empty($params['search_name'])) {
         $params['search_name_like'] = $params['search_name'];
         unset($params['search_name']);
     }
     foreach ($params as $param => $value) {
         if (isset(self::$search_params[$param])) {
             $this->add_filter(self::$search_params[$param], $value);
         }
     }
     $search_direction = $direction === 'descending' ? ' DESC' : ' ASC';
     switch ($order) {
         case 'id':
         case 'name':
         case 'sefriendly':
             $this->_query->add_order("t.{$order} {$search_direction}");
         case '%no-sort':
         default:
             // ignore
     }
     if (!empty($params['set_rating'])) {
         $this->_query->add_order('rating DESC');
         $this->_query->add_fields('at.tags_group_id AS topic_id');
         if (!defined('VIVVO_ADMIN_MODE')) {
             $this->add_filter('article_status', 1);
         }
     }
     if ($set_list) {
         $this->set_list();
         if (!empty($params['set_rating'])) {
             $this->set_fontsize();
             class_exists('TagsGroups') or (require VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/TagsGroups.class.php');
             $topic_list = TagsGroups_list::factory();
             foreach ($this->list as $tag) {
                 if ($topic = $topic_list->get_group_by_id($tag->get_topic_id())) {
                     $tag->set_group_name($topic->get_name());
                     $tag->set_group_url($topic->get_href());
                 }
             }
         }
         return $this->list;
     }
 }
 function _list_output()
 {
     $sm = vivvo_lite_site::get_instance();
     $um = $sm->get_url_manager();
     $content_template = $this->load_template($this->_template_root . 'list.xml');
     if (!$sm->user->is_admin()) {
         $editor_restriction = $sm->user->get_privilege_object_ids('WRITE', 'Categories');
         if (!in_array('0', $editor_restriction)) {
             if (isset($sm->article_list_params['search_options']['search_cid'])) {
                 if (!is_array($sm->article_list_params['search_options']['search_cid'])) {
                     $sm->article_list_params['search_options']['search_cid'] = explode(',', $sm->article_list_params['search_options']['search_cid']);
                 }
                 $sm->article_list_params['search_options']['search_cid'] = array_intersect($editor_restriction, $sm->article_list_params['search_options']['search_cid']);
             }
             if (empty($sm->article_list_params['search_options']['search_cid'])) {
                 $sm->article_list_params['search_options']['search_cid'] = $editor_restriction;
             }
             if ($um->isset_param('search_category_id')) {
                 $search_cid = array_intersect(explode(',', $um->get_param('search_category_id')), $sm->article_list_params['search_options']['search_cid']);
             }
         }
     }
     if (!$search_cid and $um->isset_param('search_category_id')) {
         $search_cid = explode(',', $um->get_param('search_category_id'));
     }
     if ($search_cid) {
         $sm->article_list_params['search_options']['search_cid'] = $search_cid;
         $content_template->assign('search_category_id', secure_sql_in($search_cid));
     }
     foreach (array('search_tag_id', 'search_topic_id', 'search_author', 'search_user_id') as $filter) {
         if ($um->isset_param($filter)) {
             $sm->article_list_params[$filter] = $um->get_param($filter);
             $content_template->assign($filter, $um->get_param($filter));
         }
     }
     $content_template->assign('search_limit', $sm->article_list_params['search_limit']);
     $content_template->assign('search_sort_by', strval($sm->article_list_params['search_sort_by'] . '.' . $sm->article_list_params['search_order']));
     if ($sm->article_list_params['search_options']['search_tag'] != '') {
         $content_template->assign('disable_all', intval(1));
     }
     $content_template->assign('list_output', intval(1));
     $content_template->assign('content_params', $sm->article_list_params);
     class_exists('TagsGroups') or (require VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/TagsGroups.class.php');
     $topic = TagsGroups_list::factory()->get_group_by_id(0);
     $content_template->assign('default_topic', $topic);
     return $content_template;
 }
 /**
  * Default view
  */
 public function _default_view()
 {
     $sm = vivvo_lite_site::get_instance();
     $template = $sm->get_template();
     $um = $sm->get_url_manager();
     $action = $sm->action_status;
     if ($um->isset_param('action') and $action === false or $um->get_param('save_action') == 'add' and !$um->get_param('search_id') or $um->get_param('ref') == 'quick_post') {
         $in_article = $um->get_param_regexp('/^ARTICLE_/');
         $current_article = new Articles($sm, $in_article);
         $template->assign('article', $current_article);
     } else {
         $sm->set_content();
     }
     $tags_groups_list = new TagsGroups_list($sm);
     $template->assign('topics', $tags_groups_list->get_all_groups());
     $article_config = $sm->get_configuration();
     $tab_list = $article_config->get_configuration_property_list('article_tabs');
     $template->assign('article_tabs', $tab_list);
     $template->set_template_file($this->_template_root . 'frame.xml');
     $time_zone = date('Z', VIVVO_START_TIME);
     $template->assign('current_time', date('Y-m-d H:i:00', time()));
     class_exists('TagsGroups') or (require VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/TagsGroups.class.php');
     $topic = TagsGroups_list::factory()->get_group_by_id(0);
     $template->assign('default_topic', $topic);
     return $template;
 }