Beispiel #1
0
/**
 * Creates a list of categories (with description and more properties) for 
 * the given blog ID.
 * 
 * @param string $blogid
 * @return array
 */
function pivotx_get_blog_cats($blogid)
{
    global $PIVOTX;
    $wcats = $PIVOTX['weblogs']->getCategories($blogid);
    $cats_info = array();
    foreach ($wcats as $cat) {
        // (categoryid is needed by Windows Live Writer.)
        $cats_info[] = array('description' => $cat, 'title' => $cat, 'categoryid' => $cat, 'htmlUrl' => $PIVOTX['paths']['host'] . makeCategoryLink($cat, $blogid));
    }
    return $cats_info;
}
/**
 * Helper function for smarty_link()
 *
 * @see smarty_link()
 */
function _smarty_link_category($params, &$smarty)
{
    global $PIVOTX;
    $params = cleanParams($params);
    if (is_array($params['category'])) {
        debug("The link tag is for single categories - not arrays.");
        return '';
    }
    $cat = $PIVOTX['categories']->getCategory($params['category']);
    if (!empty($cat)) {
        $text = getDefault($params['text'], $cat['display']);
        $title = $params['title'];
        $catlink = makeCategoryLink($cat['name']);
        // Perhaps add the protocol and hostname, to create a full URL.
        if (!empty($params['fullurl'])) {
            $catlink = getHost() . $catlink;
        }
        if (!empty($params['hrefonly'])) {
            $output = $catlink;
        } else {
            $output = sprintf("<a href='%s' title='%s'>%s</a>", $catlink, $title, $text);
        }
        return $output;
    } else {
        debug(sprintf("Can't create category link since the category '%s' doesn't exist.", $params['category']));
        return '';
    }
}