Exemplo n.º 1
0
function topic_content_handler(&$sm)
{
    $template = $sm->get_template();
    $header = $sm->get_header_manager();
    $um = $sm->get_url_manager();
    if (!$um->isset_param('search_tid')) {
        go_404();
    }
    require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/TagsGroups.class.php';
    $tags_groups_list = new TagsGroups_list($sm);
    $tags_group = $tags_groups_list->get_group_by_id($um->get_param('search_tid'));
    if (!$tags_group) {
        go_404();
    }
    $tag = false;
    if ($um->isset_param('search_lid')) {
        require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Tags.class.php';
        $tags_list = new Tags_list($sm);
        $tag = $tags_list->get_tag_by_id($um->get_param('search_lid'));
        if (!$tag) {
            go_404();
        }
        $tag->set_group_url($tags_group->get_href());
        $tag->set_group_name($tags_group->get_name());
    }
    $template->assign('topic', $tags_group);
    $template->assign('tag', $tag);
    $template->assign('label', $tag);
    // @deprecated
    if ($um->isset_param('pg')) {
        $template->assign('pg', $um->get_param('pg'));
    }
    if ($tag) {
        $dir = 'label/';
        $file = $tags_group->get_tag_template();
    } else {
        $dir = 'topic/';
        $file = $tags_group->get_template();
    }
    $base = VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR;
    if (!is_file($tpl = $base . $dir . $file)) {
        $tpl = $base . $dir . 'default.tpl';
    }
    $template->set_template_file($tpl);
}
 /**
  * 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;
 }
Exemplo n.º 3
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;
 }
 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;
 }
Exemplo n.º 5
0
 function &get_rated_tags($limit = 0, $group = -1, $category = -1)
 {
     $this->_default_query();
     $this->add_filter('user_tag_id', $group);
     $this->_query->add_order('rating DESC');
     if ($category != -1) {
         $this->add_filter('category_id', $category);
     }
     $this->_query->set_limit($limit);
     $this->set_list();
     if (!empty($this->list)) {
         $ids = array();
         foreach ($this->list as $tag) {
             $ids[] = $tag->id;
         }
         $this->_query->reset_query();
         $this->_default_query();
         $this->add_filter('id_in', implode(',', $ids));
         $this->_query->add_order('name ASC');
         $this->_query->set_limit($limit);
         $this->set_list();
         if ($group >= 0) {
             require_once dirname(__FILE__) . '/TagsGroups.class.php';
             $tags_groups_list = new TagsGroups_list();
             $topic = $tags_groups_list->get_group_by_id($group);
             $group_url = $topic->get_href();
             $group_name = $topic->get_name();
             foreach ($this->list as &$tag) {
                 $tag->set_group_name($group_name);
                 $tag->set_group_url($group_url);
             }
             unset($tag);
         }
         return $this->list;
     } else {
         return false;
     }
 }
Exemplo n.º 6
0
 /**
  * Add tag to tag group
  *
  * @param	int		$tag_id
  * @param	int		$group_id
  */
 public function add_tag_to_group($tag_id, $group_id, $article_id = 0)
 {
     if (!vivvo_hooks_manager::call('tag_addTagToGroup', array(&$tag_id, &$group_id, &$article_id))) {
         return vivvo_hooks_manager::get_status();
     }
     $user = vivvo_lite_site::get_instance()->user;
     if ($user && $user->can('MANAGE_TAGS')) {
         $tag_group_list = new TagsGroups_list();
         $tag_group = $tag_group_list->get_group_by_id($group_id);
         $tag_list = new Tags_list();
         $tag = $tag_list->get_tag_by_id($tag_id);
         if ($tag_group && $tag) {
             $tg_list = new TagsToTagsGroups_list();
             if (!$tg_list->get_rel($tag_id, $group_id)) {
                 $tag_group_rel = new TagsToTagsGroups();
                 $tag_group_rel->set_tag_id($tag_id);
                 $tag_group_rel->set_tags_group_id($group_id);
                 $this->_post_master->set_data_object($tag_group_rel);
                 if (!$this->_post_master->sql_insert()) {
                     $this->set_error_code(2415);
                     return false;
                 }
             }
             if ($article_id > 0) {
                 $tg_list = new ArticlesTags_list();
                 if (!$tg_list->search(array('search_tag_id' => $tag_id, 'search_tags_group_id' => $group_id, 'search_article_id' => $article_id))) {
                     $tag_link = new ArticlesTags();
                     $tag_link->set_article_id($article_id);
                     $tag_link->set_tag_id($tag_id);
                     $tag_link->set_tags_group_id($group_id);
                     $tag_link->set_user_id($user->get_id());
                     $this->_post_master->set_data_object($tag_link);
                     if (!$this->_post_master->sql_insert()) {
                         $this->set_error_code(2415);
                         return false;
                     }
                 }
             }
             return true;
         }
         $this->set_error_code(2415);
         return false;
     }
     $this->set_error_code(2410);
     return false;
 }
Exemplo n.º 7
0
 function get_articles_tags_by_topic_id($article_id, $topic_id)
 {
     $tag_list = array();
     require_once dirname(__FILE__) . '/TagsGroups.class.php';
     $tags_groups_list = new TagsGroups_list();
     $groups = $tags_groups_list->get_groups_by_ids($topic_id);
     if (!$groups) {
         return false;
     }
     foreach ($groups as $group) {
         $group_url = $group->get_href();
         $group_name = $group->get_name();
         $this->_query->reset_query();
         $this->_default_query();
         $this->add_filter('article_id', $article_id);
         $this->add_filter('tags_group_id', $group->get_id());
         $this->set_list();
         if (!empty($this->list)) {
             foreach ($this->list as &$tag) {
                 $tag->set_group_url($group_url);
                 $tag->set_group_name($group_name);
             }
         }
         $tag_list = array_merge($tag_list, $this->list);
     }
     $this->list = $tag_list;
     return empty($this->list) ? false : $this->list;
 }
 /**
  * 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;
 }
Exemplo n.º 9
0
 function generate_output($params)
 {
     $this->set_template($params);
     require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/TagsGroups.class.php';
     $list = new TagsGroups_list();
     $list->search_from_params($params);
     $this->_template->assign('tags_groups_list', $list->list);
     $this->_template->assign('tags_groups', $list);
     $this->_template->assign('topics_list', $list->list);
     $this->_template->assign('topics', $list);
     if (isset($params['title'])) {
         $this->_template->assign('title', $params['title']);
     }
     $this->_template->assign('box_id', $params['box_id']);
 }