Beispiel #1
0
function tag_url_handler(&$sm, $url_array)
{
    $um =& $sm->get_url_manager();
    $params = array('url_module' => 'tag');
    if (VIVVO_MODULES_TAGS == 1) {
        array_shift($url_array);
        $last_chunk = end($url_array);
        $url_count = count($_url_array);
        if (preg_match('/index\\.(\\d+)?.*' . $um->list['output_type'] . '?/i', $last_chunk, $filename)) {
            if (!empty($filename[1])) {
                $params['pg'] = $filename[1];
            }
            array_pop($url_array);
            $last_chunk = end($url_array);
        }
        if ($last_chunk) {
            require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Tags.class.php';
            $tag_list = new Tags_list($sm);
            $tag = $tag_list->get_tag_by_sefriendly(urldecode($last_chunk));
            if ($tag) {
                $params['search_tag_id'] = $tag->id;
            } else {
                go_404();
            }
        } else {
            // show tags main page
            $params['show_tags'] = 1;
        }
        return $params;
    } else {
        go_404();
    }
}
Beispiel #2
0
function topic_url_handler(&$sm, $url_array)
{
    $um = $sm->get_url_manager();
    $params = array();
    require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/TagsGroups.class.php';
    $tags_groups_list = new TagsGroups_list($sm);
    $topic_url = urldecode($params['url_module'] = $url_array[0]);
    $label_url = false;
    if (($count = count($url_array)) > 1) {
        $label_url = urldecode($url_array[1]);
        if (preg_match('/index\\.(\\d+)\\.html/', $label_url, $matches)) {
            $label_url = false;
            $pg = +$matches[1];
        } elseif ($count == 3) {
            if (preg_match('/index\\.(\\d+)\\.html/', $url_array[2], $matches)) {
                $pg = +$matches[1];
            } else {
                go_404();
            }
        } elseif ($count != 2) {
            go_404();
        }
    } elseif (!$count) {
        go_404();
    }
    if ($topic = $tags_groups_list->get_group_by_url($topic_url)) {
        $params['search_tid'] = (int) $topic->get_id();
        if ($params['search_tid'] == 1) {
            // 'System' topic
            go_404();
        }
        if ($label_url) {
            require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Tags.class.php';
            $tags_list = new Tags_list($sm);
            if ($tag = $tags_list->get_tag_by_sefriendly($label_url)) {
                $params['search_lid'] = (int) $tag->get_id();
            } else {
                go_404();
            }
        }
        if ($pg) {
            $params['pg'] = $pg;
        }
        return $params;
    }
    go_404();
}
Beispiel #3
0
 /**
  * Add new tag
  *
  * @param	string	$name
  * @param	string	$sefriendly
  */
 public function add_tag($name, $sefriendly)
 {
     if (!vivvo_hooks_manager::call('tag_add', array(&$name, &$sefriendly))) {
         return vivvo_hooks_manager::get_status();
     }
     $user = vivvo_lite_site::get_instance()->user;
     if ($user && $user->can('MANAGE_TAGS')) {
         $tag_list = new Tags_list();
         if ($tag = $tag_list->get_tag_by_sefriendly($sefriendly)) {
             if ($tag->get_id() < 100) {
                 $this->set_error_code(2423);
                 return false;
             }
             return $tag->get_id();
         }
         //				if ($tag = $tag_list->get_tag_by_name(addslashes($name))) {
         //					if ($tag->get_id() < 100){
         //						$this->set_error_code(2423);
         //						return false;
         //					}
         //					return $tag->get_id();
         //				}
         if (empty($sefriendly)) {
             $sefriendly = make_sefriendly($name);
         } else {
             $sefriendly = make_sefriendly($sefriendly);
         }
         $tag = new Tags();
         // $tag->set_name(htmlspecialchars($name, ENT_QUOTES, 'UTF-8'));
         $tag->set_name($name);
         $tag->set_sefriendly($sefriendly);
         $this->_post_master->set_data_object($tag);
         if (!$this->_post_master->sql_insert()) {
             $this->set_error_code(2401);
             return false;
         }
         $work_id = $this->_post_master->get_work_id();
         admin_log($user->get_username(), 'Created tag #' . $work_id);
         return $work_id;
     }
     $this->set_error_code(2410);
     return false;
 }