Esempio n. 1
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();
}