Ejemplo n.º 1
0
function thread_url_replace($tid, $url)
{
    $arr = thread_url_read($tid);
    if ($url) {
        if (empty($arr)) {
            return thread_url_create($tid, $url);
        } else {
            return thread_url_update($tid, $url);
        }
    } else {
        if (!empty($arr)) {
            return thread_url_delete($tid);
        }
        return TRUE;
    }
}
Ejemplo n.º 2
0
function thread_format(&$thread)
{
    global $conf, $forumlist;
    if (empty($thread)) {
        return;
    }
    $thread['create_date_fmt'] = humandate($thread['create_date']);
    $thread['last_date_fmt'] = humandate($thread['last_date']);
    $user = user_read_cache($thread['uid']);
    empty($user) and $user = user_guest();
    $thread['username'] = $user['username'];
    $thread['user_avatar_url'] = $user['avatar_url'];
    $forum = $forumlist[$thread['fid']];
    $thread['forumname'] = $forum['name'];
    if ($thread['last_date'] == $thread['create_date']) {
        $thread['last_date'] = 0;
        $thread['lastuid'] = 0;
        $thread['lastusername'] = '';
    } else {
        $lastuser = $thread['lastuid'] ? user_read_cache($thread['lastuid']) : array();
        $thread['lastusername'] = $thread['lastuid'] ? $lastuser['username'] : '******';
    }
    $thread['seo_url'] = $conf['seo_url_rewrite'] && $thread['url_on'] ? thread_url_read($thread['tid']) : '';
    $thread['url'] = $thread['seo_url'] ? $thread['seo_url'] : "thread-{$thread['tid']}.htm";
    $thread['user_url'] = "user-{$thread['uid']}" . ($thread['uid'] ? '' : "-{$thread['firstpid']}") . ".htm";
    $n = $thread['agrees'] + $thread['posts'];
    $agree_level = thread_get_level($n, $conf['agrees_level']);
    $thread['posts_class'] = 'posts_' . thread_get_level($thread['posts'], $conf['posts_level']);
    $thread['agrees_class'] = 'agrees_' . $agree_level;
    $thread['thread_class'] = 'thread_agrees_' . $agree_level;
    $thread['top_class'] = $thread['top'] ? 'thread_top_' . $thread['top'] : '';
}