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); }
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; } }
/** * 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; }
/** * Gets $group * * @return TagsGroups */ public function get_group() { if ($this->group === false) { require_once VIVVO_FS_ROOT . 'lib/vivvo/core/TagsGroups.class.php'; $group_list = new TagsGroups_list(); $this->group = $group_list->get_group_by_id($this->tags_group_id); } return $this->group; }