Пример #1
0
/**
 * Make a link to any given $tag.
 *
 * @param string $tag
 * @param string $template
 * @return string
 */
function tagLink($tag, $template = "")
{
    global $Paths, $Current_weblog, $Cfg;
    $tag = normalizeTag($tag);
    if ($Cfg['mod_rewrite'] == 0 && $Cfg['mod_taglinks'] != 1) {
        $link = $Paths['pivot_url'] . "tags.php?tag=" . urlencode($tag);
        if (para_weblog_needed($Current_weblog)) {
            $link .= "&w=" . para_weblog($Current_weblog);
        }
        if ($template != "") {
            $link .= "&t={$template}";
        }
        return $link;
    } else {
        if ($Cfg['mod_rewrite'] == 0) {
            $link = $Paths['pivot_url'] . "tags.php";
            if (para_weblog_needed($Current_weblog)) {
                $link .= "?w=" . para_weblog($Current_weblog);
                if ($template != "") {
                    $link .= "&t={$template}";
                }
            } else {
                if ($template != "") {
                    $link .= "?t={$template}";
                }
            }
            return $link . "/" . urlencode($tag);
        } else {
            $link = $Paths['log_url'] . "tag";
            if (para_weblog_needed($Current_weblog)) {
                $link .= "/w=" . para_weblog($Current_weblog);
            }
            if ($template != "") {
                $link .= "/t={$template}";
            }
            return $link . "/" . urlencode($tag);
        }
    }
}
Пример #2
0
/**
 * Make a link to any given $tag.
 *
 * @param string $tag
 * @param string $template
 * @return string
 */
function tagLink($tag, $template = "")
{
    global $PIVOTX;
    $Current_weblog = $PIVOTX['weblogs']->getCurrent();
    $tag = normalizeTag($tag);
    $site_url = getDefault($PIVOTX['weblogs']->get($Current_weblog, 'site_url'), $PIVOTX['paths']['site_url']);
    if ($PIVOTX['config']->get('mod_rewrite') == 0) {
        $link = $site_url . "?t=" . urlencode($tag);
        if (paraWeblogNeeded($Current_weblog)) {
            $link .= "&w=" . para_weblog($Current_weblog);
        }
        if ($template != "") {
            $link .= "&t={$template}";
        }
    } else {
        $prefix = getDefault($PIVOTX['config']->get('localised_tag_prefix'), 'tag');
        $link = $site_url . makeURI($prefix) . '/' . urlencode($tag);
        if (paraWeblogNeeded($Current_weblog)) {
            $link .= "/" . para_weblog($Current_weblog);
        }
        if ($template != "") {
            $link .= "/?t={$template}";
        }
    }
    // Check if there's a hook set, and if so call it.
    if ($PIVOTX['extensions'] && $PIVOTX['extensions']->hasHook('make_link#tag')) {
        $PIVOTX['extensions']->executeHook('make_link#tag', $link, array('tag' => $tag, 'w' => $Current_weblog));
    }
    return $link;
}