当前位置: 首页>>代码示例>>PHP>>正文


PHP get_category_context函数代码示例

本文整理汇总了PHP中get_category_context函数的典型用法代码示例。如果您正苦于以下问题:PHP get_category_context函数的具体用法?PHP get_category_context怎么用?PHP get_category_context使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_category_context函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: smarty_block_mtifisancestor

function smarty_block_mtifisancestor($args, $content, &$ctx, &$repeat)
{
    $localvars = array('conditional', 'else_content');
    if (!isset($content)) {
        require_once "MTUtil.php";
        $cat = get_category_context($ctx, $class);
        $ctx->localize($localvars);
        $children = $ctx->mt->db->fetch_categories(array('label' => $args['child'], 'blog_id' => $ctx->stash('blog_id'), 'show_empty' => 1));
        $ret = false;
        if ($children) {
            foreach ($children as $child) {
                if (_is_ancestor($cat, $child, $ctx)) {
                    $ret = true;
                    break;
                }
            }
            unset($child);
        }
        $ctx->stash('else_content', null);
        $ctx->stash('conditional', $ret ? 1 : 0);
    } else {
        if (!$ctx->stash('conditional')) {
            $content = $ctx->stash('else_content');
        }
        $ctx->restore($localvars);
    }
    return $content;
}
开发者ID:jayallen,项目名称:movable-type,代码行数:28,代码来源:block.mtifisancestor.php

示例2: smarty_block_mtparentcategory

function smarty_block_mtparentcategory($args, $content, &$ctx, &$repeat)
{
    if (!isset($content)) {
        $ctx->localize(array('category', 'conditional', 'else_content'));
        $class = isset($args) && isset($args['class']) ? $args['class'] : 'category';
        require_once "MTUtil.php";
        $cat = get_category_context($ctx, $class);
        if ($cat && $cat->category_parent) {
            if ($class == 'folder') {
                $parent_cat = $ctx->mt->db()->fetch_folder($cat->category_parent);
            } else {
                $parent_cat = $ctx->mt->db()->fetch_category($cat->category_parent);
            }
            $ctx->stash('category', $parent_cat);
        }
        $ctx->stash('conditional', isset($parent_cat));
        $ctx->stash('else_content', null);
    } else {
        if (!$ctx->stash('conditional')) {
            $content = $ctx->stash('else_content');
        }
        $ctx->restore(array('category', 'conditional', 'else_content'));
    }
    return $content;
}
开发者ID:OCMO,项目名称:movabletype,代码行数:25,代码来源:block.mtparentcategory.php

示例3: smarty_function_mtcategorydescription

function smarty_function_mtcategorydescription($args, &$ctx)
{
    require_once "MTUtil.php";
    $cat = get_category_context($ctx);
    if (!$cat) {
        return '';
    }
    return $cat->category_description;
}
开发者ID:benvanstaveren,项目名称:movabletype,代码行数:9,代码来源:function.mtcategorydescription.php

示例4: smarty_function_mtcategorycount

function smarty_function_mtcategorycount($args, &$ctx)
{
    require_once "MTUtil.php";
    $category = get_category_context($ctx);
    if (!$category) {
        return '';
    }
    $count = $category->entry_count();
    return $ctx->count_format($count, $args);
}
开发者ID:benvanstaveren,项目名称:movabletype,代码行数:10,代码来源:function.mtcategorycount.php

示例5: smarty_block_mthasparentcategory

function smarty_block_mthasparentcategory($args, $content, &$ctx, &$repeat)
{
    if (!isset($content)) {
        $class = isset($args) && isset($args['class']) ? $args['class'] : 'category';
        require_once "MTUtil.php";
        $cat = get_category_context($ctx, $class);
        $has_parent = $cat['category_parent'];
        return $ctx->_hdlr_if($args, $content, $ctx, $repeat, $has_parent > 0 ? 1 : 0);
    } else {
        return $ctx->_hdlr_if($args, $content, $ctx, $repeat);
    }
}
开发者ID:benvanstaveren,项目名称:melody,代码行数:12,代码来源:block.mthasparentcategory.php

示例6: smarty_block_mtparentcategories

function smarty_block_mtparentcategories($args, $content, &$ctx, &$repeat)
{
    $localvars = array('_categories', 'category', '_categories_counter', 'glue', '__out');
    if (!isset($content)) {
        $ctx->localize($localvars);
        require_once "MTUtil.php";
        $class = isset($args) && isset($args['class']) ? $args['class'] : 'category';
        $cat = get_category_context($ctx, $class);
        $parents = array();
        get_parent_categories($cat, $ctx, $parents, $class);
        if (!isset($args['exclude_current'])) {
            $parents[] = $cat;
        }
        if (isset($args['glue'])) {
            $glue = $args['glue'];
        } else {
            $glue = '';
        }
        $ctx->stash('_categories', $parents);
        $ctx->stash('glue', $glue);
        $ctx->stash('__out', false);
        $counter = 0;
    } else {
        $parents = $ctx->stash('_categories');
        $counter = $ctx->stash('_categories_counter');
        $glue = $ctx->stash('glue');
        $out = $ctx->stash('__out');
    }
    if ($counter < count($parents)) {
        $ctx->stash('category', $parents[$counter]);
        $ctx->stash('_categories_counter', $counter + 1);
        $repeat = true;
        if (!empty($glue) && !empty($content)) {
            if ($out) {
                $content = $glue . $content;
            } else {
                $ctx->stash('__out', true);
            }
        }
    } else {
        if (!empty($glue) && $out && !empty($content)) {
            $content = $glue . $content;
        }
        $repeat = false;
        $glue = '';
        $ctx->restore($localvars);
    }
    return $content;
}
开发者ID:aim-web-projects,项目名称:kobe-chuoh,代码行数:49,代码来源:block.mtparentcategories.php

示例7: _has_sub_categories

function _has_sub_categories(&$ctx, $class = 'category')
{
    require_once "MTUtil.php";
    $cat = get_category_context($ctx, $class);
    $has_sub_cats = 0;
    $children = $cat->children();
    if (isset($children)) {
        $has_sub_cats = count($cat->children()) > 0;
    } else {
        $cats = $ctx->mt->db()->fetch_categories(array('blog_id' => $ctx->stash('blog_id'), 'category_id' => $cat->category_id, 'children' => 1, 'show_empty' => 1, 'class' => $class));
        if (isset($cats)) {
            $cat->children($cats);
            $has_sub_cats = count($cats) > 0;
        }
    }
    return $has_sub_cats;
}
开发者ID:benvanstaveren,项目名称:movabletype,代码行数:17,代码来源:block.mthassubcategories.php

示例8: _has_sub_categories

function _has_sub_categories(&$ctx, $class = 'category')
{
    $class = isset($args) && isset($args['class']) ? $args['class'] : 'category';
    require_once "MTUtil.php";
    $cat = get_category_context($ctx, $class);
    $has_sub_cats = 0;
    if (isset($cat['_children'])) {
        $has_sub_cats = count($cat['_children']) > 0;
    } else {
        $cats =& $ctx->mt->db->fetch_categories(array('blog_id' => $ctx->stash('blog_id'), 'category_id' => $cat['category_id'], 'children' => 1, 'show_empty' => 1, 'class' => $class));
        if (isset($cats)) {
            $cat['_children'] = $cats;
            $has_sub_cats = count($cats) > 0;
        }
    }
    return $has_sub_cats;
}
开发者ID:aim-web-projects,项目名称:kobe-chuoh,代码行数:17,代码来源:block.mthassubcategories.php

示例9: smarty_function_mtcategorybasename

function smarty_function_mtcategorybasename($args, &$ctx)
{
    require_once "MTUtil.php";
    $cat = get_category_context($ctx);
    if (!$cat) {
        return '';
    }
    $basename = $cat->category_basename;
    if ($sep = $args['separator']) {
        if ($sep == '-') {
            $basename = preg_replace('/_/', '-', $basename);
        } elseif ($sep == '_') {
            $basename = preg_replace('/-/', '_', $basename);
        }
    }
    return $basename;
}
开发者ID:benvanstaveren,项目名称:movabletype,代码行数:17,代码来源:function.mtcategorybasename.php

示例10: smarty_block_mttoplevelparent

function smarty_block_mttoplevelparent($args, $content, &$ctx, &$repeat)
{
    if (!isset($content)) {
        $ctx->localize(array('category', 'conditional', 'else_content'));
        require_once "MTUtil.php";
        $cat = get_category_context($ctx);
        require_once "block.mtparentcategories.php";
        $list = array();
        get_parent_categories($cat, $ctx, $list);
        $ctx->stash('else_content', null);
        if (count($list) > 0) {
            $cat = array_pop($list);
            $ctx->stash('category', $cat);
        }
        $ctx->stash('conditional', $cat ? 1 : 0);
    } else {
        if (!$ctx->stash('conditional')) {
            $content = $ctx->stash('else_content');
        }
        $ctx->restore(array('category', 'conditional', 'else_content'));
    }
    return $content;
}
开发者ID:benvanstaveren,项目名称:melody,代码行数:23,代码来源:block.mttoplevelparent.php


注:本文中的get_category_context函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。