Changeset 1800
- Timestamp:
- 04/08/08 06:36:25 (8 months ago)
- Files:
-
- branches/release-34/php/lib/MTUtil.php (modified) (2 diffs)
- branches/release-34/php/lib/block.mthasnoparentcategory.php (modified) (1 diff)
- branches/release-34/php/lib/block.mthasparentcategory.php (modified) (1 diff)
- branches/release-34/php/lib/block.mthassubcategories.php (modified) (1 diff)
- branches/release-34/php/lib/block.mtifisancestor.php (modified) (1 diff)
- branches/release-34/php/lib/block.mtparentcategories.php (modified) (2 diffs)
- branches/release-34/php/lib/block.mtparentcategory.php (modified) (1 diff)
- branches/release-34/php/lib/mtdb_base.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/release-34/php/lib/MTUtil.php
r1340 r1800 881 881 } 882 882 883 function get_category_context(&$ctx ) {883 function get_category_context(&$ctx, $class = 'category') { 884 884 # Get our hands on the category for the current context 885 885 # Either in MTCategories, a Category Archive Template … … 887 887 $cat = $ctx->stash('category') or 888 888 $ctx->stash('archive_category'); 889 890 889 if (!isset($cat)) { 891 890 # No category found so far, test the entry 892 891 if ($ctx->stash('entry')) { 893 892 $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']); 895 897 896 898 # Return empty string if entry has no category branches/release-34/php/lib/block.mthasnoparentcategory.php
r1174 r1800 8 8 function smarty_block_mthasnoparentcategory($args, $content, &$ctx, &$repeat) { 9 9 if (!isset($content)) { 10 $class = isset($args) && isset($args['class']) ? $args['class'] : 'category'; 10 11 require_once("MTUtil.php"); 11 12 $cat = get_category_context($ctx); branches/release-34/php/lib/block.mthasparentcategory.php
r1174 r1800 8 8 function smarty_block_mthasparentcategory($args, $content, &$ctx, &$repeat) { 9 9 if (!isset($content)) { 10 $class = isset($args) && isset($args['class']) ? $args['class'] : 'category'; 10 11 require_once("MTUtil.php"); 11 $cat = get_category_context($ctx );12 $cat = get_category_context($ctx, $class); 12 13 $has_parent = $cat['category_parent']; 13 14 return $ctx->_hdlr_if($args, $content, $ctx, $repeat, ($has_parent > 0 ? 1 : 0)); branches/release-34/php/lib/block.mthassubcategories.php
r1174 r1800 20 20 21 21 function _has_sub_categories(&$ctx, $class = 'category') { 22 $class = isset($args) && isset($args['class']) ? $args['class'] : 'category'; 22 23 require_once("MTUtil.php"); 23 $cat = get_category_context($ctx );24 $cat = get_category_context($ctx, $class); 24 25 $has_sub_cats = 0; 25 26 if (isset($cat['_children'])) { branches/release-34/php/lib/block.mtifisancestor.php
r1174 r1800 10 10 if (!isset($content)) { 11 11 require_once("MTUtil.php"); 12 $cat = get_category_context($ctx );12 $cat = get_category_context($ctx, $class); 13 13 $ctx->localize($localvars); 14 14 $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 6 6 # $Id$ 7 7 8 function get_parent_categories(&$cat, &$ctx, &$list ) {8 function get_parent_categories(&$cat, &$ctx, &$list, $class = 'category') { 9 9 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']); 11 14 if ($parent) { 12 15 $cat['_parent'] =& $parent; … … 22 25 $ctx->localize($localvars); 23 26 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); 25 29 $parents = array(); 26 get_parent_categories($cat, $ctx, $parents );30 get_parent_categories($cat, $ctx, $parents, $class); 27 31 if (!isset($args['exclude_current'])) { 28 32 $parents[] = $cat; branches/release-34/php/lib/block.mtparentcategory.php
r1174 r1800 9 9 if (!isset($content)) { 10 10 $ctx->localize(array('category', 'conditional', 'else_content')); 11 $class = isset($args) && isset($args['class']) ? $args['class'] : 'category'; 11 12 require_once("MTUtil.php"); 12 $cat = get_category_context($ctx );13 $cat = get_category_context($ctx, $class); 13 14 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']); 15 19 $ctx->stash('category', $parent_cat); 16 20 } branches/release-34/php/lib/mtdb_base.php
r1794 r1800 2326 2326 } 2327 2327 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 2328 2342 function &fetch_category($cat_id) { 2329 2343 if (isset($this->_cat_id_cache['c'.$cat_id])) { … … 2840 2854 2841 2855 function include_exclude_blogs(&$args) { 2842 2843 2856 if (isset($args['blog_ids']) || isset($args['include_blogs'])) { 2844 2857 // The following are aliased
