Changeset 1800

Show
Ignore:
Timestamp:
04/08/08 06:36:25 (8 months ago)
Author:
takayama
Message:

Fixed BugId:77293
* Changed to respect a class attribute

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/release-34/php/lib/MTUtil.php

    r1340 r1800  
    881881} 
    882882 
    883 function get_category_context(&$ctx) { 
     883function get_category_context(&$ctx, $class = 'category') { 
    884884    # Get our hands on the category for the current context 
    885885    # Either in MTCategories, a Category Archive Template 
     
    887887    $cat = $ctx->stash('category') or 
    888888           $ctx->stash('archive_category'); 
    889  
    890889    if (!isset($cat)) { 
    891890        # No category found so far, test the entry 
    892891        if ($ctx->stash('entry')) { 
    893892            $entry = $ctx->stash('entry'); 
    894             $cat = $ctx->mt->db->fetch_category($entry['placement_category_id']); 
     893            if ($class == 'folder') 
     894                $cat = $ctx->mt->db->fetch_folder($entry['placement_category_id']); 
     895            else 
     896                $cat = $ctx->mt->db->fetch_category($entry['placement_category_id']); 
    895897   
    896898            # Return empty string if entry has no category 
  • branches/release-34/php/lib/block.mthasnoparentcategory.php

    r1174 r1800  
    88function smarty_block_mthasnoparentcategory($args, $content, &$ctx, &$repeat) { 
    99    if (!isset($content)) { 
     10        $class = isset($args) && isset($args['class']) ? $args['class'] : 'category'; 
    1011        require_once("MTUtil.php"); 
    1112        $cat = get_category_context($ctx); 
  • branches/release-34/php/lib/block.mthasparentcategory.php

    r1174 r1800  
    88function smarty_block_mthasparentcategory($args, $content, &$ctx, &$repeat) { 
    99    if (!isset($content)) { 
     10        $class = isset($args) && isset($args['class']) ? $args['class'] : 'category'; 
    1011        require_once("MTUtil.php"); 
    11         $cat = get_category_context($ctx); 
     12        $cat = get_category_context($ctx, $class); 
    1213        $has_parent = $cat['category_parent']; 
    1314        return $ctx->_hdlr_if($args, $content, $ctx, $repeat, ($has_parent > 0 ? 1 : 0)); 
  • branches/release-34/php/lib/block.mthassubcategories.php

    r1174 r1800  
    2020 
    2121function _has_sub_categories(&$ctx, $class = 'category') { 
     22    $class = isset($args) && isset($args['class']) ? $args['class'] : 'category'; 
    2223    require_once("MTUtil.php"); 
    23     $cat = get_category_context($ctx); 
     24    $cat = get_category_context($ctx, $class); 
    2425    $has_sub_cats = 0; 
    2526    if (isset($cat['_children'])) { 
  • branches/release-34/php/lib/block.mtifisancestor.php

    r1174 r1800  
    1010    if (!isset($content)) { 
    1111       require_once("MTUtil.php"); 
    12        $cat = get_category_context($ctx); 
     12       $cat = get_category_context($ctx, $class); 
    1313       $ctx->localize($localvars); 
    1414       $children = $ctx->mt->db->fetch_categories(array('label' => $args['child'], 'blog_id' => $ctx->stash('blog_id'), 'show_empty' => 1)); 
  • branches/release-34/php/lib/block.mtparentcategories.php

    r1174 r1800  
    66# $Id$ 
    77 
    8 function get_parent_categories(&$cat, &$ctx, &$list) { 
     8function get_parent_categories(&$cat, &$ctx, &$list, $class = 'category') { 
    99    if ($cat['category_parent']) { 
    10         $parent = $ctx->mt->db->fetch_category($cat['category_parent']); 
     10        if ($class == 'folder') 
     11            $parent = $ctx->mt->db->fetch_folder($cat['category_parent']); 
     12        else 
     13            $parent = $ctx->mt->db->fetch_category($cat['category_parent']); 
    1114        if ($parent) { 
    1215            $cat['_parent'] =& $parent; 
     
    2225        $ctx->localize($localvars); 
    2326        require_once("MTUtil.php"); 
    24         $cat = get_category_context($ctx); 
     27        $class = isset($args) && isset($args['class']) ? $args['class'] : 'category'; 
     28        $cat = get_category_context($ctx, $class); 
    2529        $parents = array(); 
    26         get_parent_categories($cat, $ctx, $parents); 
     30        get_parent_categories($cat, $ctx, $parents, $class); 
    2731        if (!isset($args['exclude_current'])) { 
    2832            $parents[] = $cat; 
  • branches/release-34/php/lib/block.mtparentcategory.php

    r1174 r1800  
    99    if (!isset($content)) { 
    1010        $ctx->localize(array('category', 'conditional', 'else_content')); 
     11        $class = isset($args) && isset($args['class']) ? $args['class'] : 'category'; 
    1112        require_once("MTUtil.php"); 
    12         $cat = get_category_context($ctx); 
     13        $cat = get_category_context($ctx, $class); 
    1314        if (($cat) && ($cat['category_parent'])) { 
    14             $parent_cat = $ctx->mt->db->fetch_category($cat['category_parent']); 
     15            if ($class == 'folder') 
     16                $parent_cat = $ctx->mt->db->fetch_folder($cat['category_parent']); 
     17            else 
     18                $parent_cat = $ctx->mt->db->fetch_category($cat['category_parent']); 
    1519            $ctx->stash('category', $parent_cat); 
    1620        } 
  • branches/release-34/php/lib/mtdb_base.php

    r1794 r1800  
    23262326    } 
    23272327 
     2328    function &fetch_folder($cat_id) { 
     2329        if (isset($this->_cat_id_cache['c'.$cat_id])) { 
     2330            return $this->_cat_id_cache['c'.$cat_id]; 
     2331        } 
     2332 
     2333        $cats =& $this->fetch_categories(array('category_id' => $cat_id, 'show_empty' => 1, 'class' => 'folder')); 
     2334        if ($cats && (count($cats) > 0)) { 
     2335            $this->_cat_id_cache['c'.$cat_id] = $cats[0]; 
     2336            return $cats[0]; 
     2337        } else { 
     2338            return null; 
     2339        } 
     2340    } 
     2341 
    23282342    function &fetch_category($cat_id) { 
    23292343        if (isset($this->_cat_id_cache['c'.$cat_id])) { 
     
    28402854 
    28412855    function include_exclude_blogs(&$args) { 
    2842  
    28432856        if (isset($args['blog_ids']) || isset($args['include_blogs'])) { 
    28442857            // The following are aliased