Changeset 1926
- Timestamp:
- 04/16/08 10:50:21 (15 months ago)
- Location:
- branches/release-35
- Files:
-
- 12 modified
-
lib/MT/Template/ContextHandlers.pm (modified) (21 diffs)
-
php/lib/MTUtil.php (modified) (1 diff)
-
php/lib/block.mtassettags.php (modified) (4 diffs)
-
php/lib/block.mtcategories.php (modified) (4 diffs)
-
php/lib/block.mtentries.php (modified) (3 diffs)
-
php/lib/block.mtentryadditionalcategories.php (modified) (3 diffs)
-
php/lib/block.mtentrycategories.php (modified) (3 diffs)
-
php/lib/block.mtentrytags.php (modified) (4 diffs)
-
php/lib/block.mtfor.php (modified) (4 diffs)
-
php/lib/block.mtloop.php (modified) (4 diffs)
-
php/lib/block.mtparentcategories.php (modified) (4 diffs)
-
php/lib/block.mttags.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/release-35/lib/MT/Template/ContextHandlers.pm
r1911 r1926 1324 1324 my $vars = $ctx->{__stash}{vars} ||= {}; 1325 1325 my $glue = $args->{glue}; 1326 $glue = '' unless defined $glue;1327 1326 my $var = $args->{var}; 1328 1327 for (my $i = $start; $i <= $end; $i += $incr) { … … 1336 1335 my $res = $builder->build($ctx, $tokens, $cond); 1337 1336 return $ctx->error($builder->errstr) unless defined $res; 1338 if ($res ne '') { 1339 $out .= $glue if $cnt > 1; 1340 $out .= $res; 1341 $cnt++; 1342 } 1337 $out .= $glue 1338 if defined $glue && $cnt > 1 && length($out) && length($res); 1339 $out .= $res; 1340 $cnt++; 1343 1341 } 1344 1342 return $out; … … 1590 1588 my $vars = $ctx->{__stash}{vars} ||= {}; 1591 1589 my $glue = $args->{glue}; 1592 $glue = '' unless defined $glue;1593 1590 foreach my $item (@$var) { 1594 1591 local $vars->{__first__} = $i == 1; … … 1625 1622 return $ctx->error($builder->errstr) unless defined $res; 1626 1623 if ($res ne '') { 1627 $out .= $glue if $i > 1;1624 $out .= $glue if defined $glue && $i > 1 && length($out) && length($res); 1628 1625 $out .= $res; 1629 1626 $i++; … … 1916 1913 my $tokens = $ctx->stash('tokens'); 1917 1914 my $needs_entries = (($ctx->stash('uncompiled') || '') =~ /<MT:?Entries/i) ? 1 : 0; 1918 my $glue = $args->{glue} || '';1915 my $glue = $args->{glue}; 1919 1916 my $res = ''; 1920 1917 local $ctx->{__stash}{all_tag_count} = undef; … … 1974 1971 defined(my $out = $builder->build($ctx, $tokens, $cond)) 1975 1972 or return $ctx->error( $builder->errstr ); 1976 $res .= $glue if $res ne '';1973 $res .= $glue if defined $glue && length($res) && length($out); 1977 1974 $res .= $out; 1978 1975 } … … 2097 2094 my $entry = $ctx->stash('entry'); 2098 2095 return '' unless $entry; 2099 my $glue = $args->{glue} || '';2096 my $glue = $args->{glue}; 2100 2097 2101 2098 local $ctx->{__stash}{tag_max_count} = undef; … … 2113 2110 defined(my $out = $builder->build($ctx, $tokens, $cond)) 2114 2111 or return $ctx->error( $builder->errstr ); 2115 $res .= $glue if $res ne '';2112 $res .= $glue if defined $glue && length($res) && length($out); 2116 2113 $res .= $out; 2117 2114 } … … 4229 4226 return $ctx->error( $builder->errstr ) unless defined $out; 4230 4227 $last_day = $this_day; 4231 $res .= $glue if defined $glue && $i ;4228 $res .= $glue if defined $glue && $i && length($res) && length($out); 4232 4229 $res .= $out; 4233 4230 $i++; … … 4739 4736 my $builder = $ctx->stash('builder'); 4740 4737 my $tokens = $ctx->stash('tokens'); 4741 my @res; 4738 my $res; 4739 my $glue = $args->{glue}; 4742 4740 for my $cat (@$cats) { 4743 4741 local $ctx->{__stash}->{category} = $cat; 4744 4742 defined(my $out = $builder->build($ctx, $tokens, $cond)) 4745 4743 or return $ctx->error( $builder->errstr ); 4746 push @res, $out if $out ne '';4747 }4748 my $sep = $args->{glue} || '';4749 join $sep, @res;4744 $res .= $glue if defined $glue && length($res) && length($out); 4745 $res .= $out; 4746 } 4747 $res; 4750 4748 } 4751 4749 … … 6314 6312 my $builder = $ctx->stash('builder'); 6315 6313 my $tokens = $ctx->stash('tokens'); 6316 my $glue = exists $args->{glue} ? $args->{glue} : '';6314 my $glue = $args->{glue}; 6317 6315 ## In order for this handler to double as the handler for 6318 6316 ## <MTArchiveList archive_type="Category">, it needs to support … … 6356 6354 ArchiveListFooter => $last })) 6357 6355 or return $ctx->error( $builder->errstr ); 6358 $res .= $glue if $res ne '';6356 $res .= $glue if defined $glue && length($res) && length($out); 6359 6357 $res .= $out; 6360 6358 $cat = $next_cat; … … 6637 6635 my $builder = $ctx->stash('builder'); 6638 6636 my $tokens = $ctx->stash('tokens'); 6639 my @res; 6637 my $res; 6638 my $glue = $args->{glue}; 6640 6639 for my $cat (@$cats) { 6641 6640 next if $e->category && ($cat->label eq $e->category->label); … … 6643 6642 defined(my $out = $builder->build($ctx, $tokens, $cond)) 6644 6643 or return $ctx->error( $builder->errstr ); 6645 push @res, $out;6646 }6647 my $sep = $args->{glue} || '';6648 join $sep, @res;6644 $res .= $glue if defined $glue && length($res) && length($out); 6645 $res .= $out if length($out); 6646 } 6647 $res; 6649 6648 } 6650 6649 … … 7189 7188 # Get the arguments 7190 7189 my $exclude_current = $args->{'exclude_current'}; 7191 my $glue = $args->{'glue'} || '';7190 my $glue = $args->{'glue'}; 7192 7191 7193 7192 # Get the current category … … 7196 7195 return '' if ($cat eq ''); 7197 7196 7198 my @res;7197 my $res; 7199 7198 7200 7199 # Put together the list of parent categories … … 7211 7210 $out = 'cat-' . $c->id; 7212 7211 } 7213 push @res, $out; 7214 } 7215 7216 # Slap them all together with some glue 7217 return join $glue, @res; 7212 $res .= $glue if defined $glue && length($res) && length($out); 7213 $res .= $out if length($out); 7214 } 7215 $res; 7218 7216 } 7219 7217 … … 7922 7920 my $asset = $ctx->stash('asset'); 7923 7921 return '' unless $asset; 7924 my $glue = $args->{glue} || '';7922 my $glue = $args->{glue}; 7925 7923 7926 7924 local $ctx->{__stash}{tag_max_count} = undef; … … 7943 7941 defined(my $out = $builder->build($ctx, $tokens, $cond)) 7944 7942 or return $ctx->error( $builder->errstr ); 7945 $res .= $glue if $res ne '';7943 $res .= $glue if defined $glue && length($res) && length($out); 7946 7944 $res .= $out; 7947 7945 } … … 8850 8848 8851 8849 my $glue = $args->{glue}; 8852 $glue = q() unless defined $glue;8853 8850 8854 8851 my $output = q(); … … 8868 8865 } 8869 8866 )) or return $ctx->error( $build->errstr ); 8870 $output .= $glue if $i > 1;8867 $output .= $glue if defined $glue && $i > 1 && length($output) && length($out); 8871 8868 $output .= $out; 8872 8869 } -
branches/release-35/php/lib/MTUtil.php
r1800 r1926 891 891 if ($ctx->stash('entry')) { 892 892 $entry = $ctx->stash('entry'); 893 if (empty($entry['placement_category_id'])) 894 return null; 893 895 if ($class == 'folder') 894 896 $cat = $ctx->mt->db->fetch_folder($entry['placement_category_id']); -
branches/release-35/php/lib/block.mtassettags.php
r1174 r1926 7 7 8 8 function smarty_block_mtassettags($args, $content, &$ctx, &$repeat) { 9 $localvars = array('_tags', 'Tag', '_tags_counter', 'tag_min_count', 'tag_max_count','all_tag_count' );9 $localvars = array('_tags', 'Tag', '_tags_counter', 'tag_min_count', 'tag_max_count','all_tag_count', '__out'); 10 10 if (!isset($content)) { 11 11 $ctx->localize($localvars); … … 32 32 if (!is_array($tags)) $tags = array(); 33 33 $ctx->stash('_tags', $tags); 34 $ctx->stash('__out', false); 34 35 35 36 $counter = 0; … … 37 38 $tags = $ctx->stash('_tags'); 38 39 $counter = $ctx->stash('_tags_counter'); 40 $out = $ctx->stash('__out'); 39 41 } 40 42 if ($counter < count($tags)) { … … 43 45 $ctx->stash('_tags_counter', $counter + 1); 44 46 $repeat = true; 45 if (($counter > 0) && isset($args['glue'])) { 46 $content = $content . $args['glue']; 47 if (isset($args['glue']) && !empty($content)) { 48 if ($out) 49 $content = $args['glue'] . $content; 50 else 51 $ctx->stash('__out', true); 47 52 } 48 53 } else { 54 if (isset($args['glue']) && $out && !empty($content)) 55 $content = $args['glue'] . $content; 49 56 $ctx->restore($localvars); 50 57 $repeat = false; -
branches/release-35/php/lib/block.mtcategories.php
r1174 r1926 9 9 // status: incomplete 10 10 // parameters: show_empty 11 $localvars = array('_categories', '_categories_counter', 'category', 'inside_mt_categories', 'entries', '_categories_glue', 'blog_id', 'blog' );11 $localvars = array('_categories', '_categories_counter', 'category', 'inside_mt_categories', 'entries', '_categories_glue', 'blog_id', 'blog', '__out'); 12 12 if (!isset($content)) { 13 13 $ctx->localize($localvars); … … 19 19 $ctx->stash('inside_mt_categories', 1); 20 20 $ctx->stash('show_empty', isset($args['show_empty']) ? $args['show_empty'] : '0'); 21 $ctx->stash('__out', false); 21 22 $counter = 0; 22 23 } else { … … 24 25 $counter = $ctx->stash('_categories_counter'); 25 26 $glue = $ctx->stash('_categories_glue'); 27 $out =$ctx->stash('__out'); 26 28 } 27 29 if ($counter < count($categories)) { … … 35 37 $ctx->stash('blog', 36 38 $ctx->mt->db->fetch_blog($category['category_blog_id'])); 37 if ($counter > 0) $content = $content . $glue; 39 if (!empty($glue) && !empty($content)) { 40 if ($out) 41 $content = $glue . $content; 42 else 43 $ctx->stash('__out', true); 44 } 38 45 $repeat = true; 39 46 } else { 47 if (!empty($glue) && $out && !empty($content)) 48 $content = $glue . $content; 40 49 $ctx->restore($localvars); 41 50 $repeat = false; -
branches/release-35/php/lib/block.mtentries.php
r1335 r1926 7 7 8 8 function smarty_block_mtentries($args, $content, &$ctx, &$repeat) { 9 $localvars = array('entry', '_entries_counter','entries','current_timestamp','modification_timestamp','_entries_lastn', 'current_timestamp_end', 'DateHeader', 'DateFooter', '_entries_glue', 'blog', 'blog_id', 'conditional', 'else_content' );9 $localvars = array('entry', '_entries_counter','entries','current_timestamp','modification_timestamp','_entries_lastn', 'current_timestamp_end', 'DateHeader', 'DateFooter', '_entries_glue', 'blog', 'blog_id', 'conditional', 'else_content', '__out'); 10 10 if (isset($args['sort_by']) && $args['sort_by'] == 'score' && !isset($args['namespace'])) { 11 11 return $ctx->error($ctx->mt->translate('sort_by="score" must be used in combination with namespace.')); … … 29 29 $lastn = $args['lastn']; 30 30 $ctx->stash('_entries_lastn', $lastn); 31 $ctx->stash('__out', false); 31 32 } else { 32 33 $lastn = $ctx->stash('_entries_lastn'); 33 34 $counter = $ctx->stash('_entries_counter'); 35 $out = $ctx->stash('__out'); 34 36 } 35 37 if (!isset($args['class'])) { … … 119 121 $_REQUEST['entry_ids_published'][$entry['entry_id']] = 1; 120 122 $glue = $ctx->stash('_entries_glue'); 121 if ($glue != '') $content = $content . $glue; 123 if (isset($glue) && !empty($content)) { 124 if ($out) 125 $content = $glue . $content; 126 else 127 $ctx->stash('__out', true); 128 } 122 129 $repeat = true; 123 130 } else { 131 $glue = $ctx->stash('_entries_glue'); 132 if (isset($glue) && $out && !empty($content)) 133 $content = $glue . $content; 124 134 $ctx->restore($localvars); 125 135 $repeat = false; -
branches/release-35/php/lib/block.mtentryadditionalcategories.php
r1174 r1926 7 7 8 8 function smarty_block_mtentryadditionalcategories($args, $content, &$ctx, &$repeat) { 9 $localvars = array('_categories', 'category', '_categories_counter' );9 $localvars = array('_categories', 'category', '_categories_counter', '__out'); 10 10 if (!isset($content)) { 11 11 $ctx->localize($localvars); … … 23 23 } 24 24 $ctx->stash('_categories', $categories); 25 $ctx->stash('__out', false); 25 26 $counter = 0; 26 27 } else { 27 28 $categories = $ctx->stash('_categories'); 28 29 $counter = $ctx->stash('_categories_counter'); 30 $out = $ctx->stash('__out'); 29 31 } 30 32 if ($counter < count($categories)) { … … 33 35 $ctx->stash('_categories_counter', $counter + 1); 34 36 $repeat = true; 35 if (($counter > 0) && isset($args['glue'])) { 36 $content = $content . $args['glue']; 37 if (isset($args['glue']) && !empty($content)) { 38 if ($out) 39 $content = $args['glue'] . $content; 40 else 41 $ctx->stash('__out', true); 37 42 } 38 43 } else { 44 if (isset($args['glue']) && $out && !empty($content)) 45 $content = $args['glue'] . $content; 39 46 $ctx->restore($localvars); 40 47 $repeat = false; -
branches/release-35/php/lib/block.mtentrycategories.php
r1174 r1926 7 7 8 8 function smarty_block_mtentrycategories($args, $content, &$ctx, &$repeat) { 9 $localvars = array('_categories', 'category', '_categories_counter');9 $localvars = array('_categories', 'category', '_categories_counter', '__out'); 10 10 if (!isset($content)) { 11 11 $ctx->localize($localvars); … … 14 14 $categories = $ctx->mt->db->fetch_categories($args); 15 15 $ctx->stash('_categories', $categories); 16 $ctx->stash('__out', false); 16 17 $counter = 0; 17 18 } else { 18 19 $categories = $ctx->stash('_categories'); 19 20 $counter = $ctx->stash('_categories_counter'); 21 $out = $ctx->stash('__out'); 20 22 } 21 23 if ($counter < count($categories)) { … … 24 26 $ctx->stash('_categories_counter', $counter + 1); 25 27 $repeat = true; 26 if (($counter > 0) && isset($args['glue'])) { 27 $content = $content . $args['glue']; 28 if (isset($args['glue']) && !empty($content)) { 29 if ($out) 30 $content = $args['glue'] . $content; 31 else 32 $ctx->stash('__out', true); 28 33 } 29 34 } else { 35 if (isset($args['glue']) && $out && !empty($content)) 36 $content = $args['glue'] . $content; 30 37 $ctx->restore($localvars); 31 38 $repeat = false; -
branches/release-35/php/lib/block.mtentrytags.php
r1174 r1926 7 7 8 8 function smarty_block_mtentrytags($args, $content, &$ctx, &$repeat) { 9 $localvars = array('_tags', 'Tag', '_tags_counter', 'tag_min_count', 'tag_max_count','all_tag_count' );9 $localvars = array('_tags', 'Tag', '_tags_counter', 'tag_min_count', 'tag_max_count','all_tag_count', '__out'); 10 10 if (!isset($content)) { 11 11 $class = 'entry'; … … 37 37 if (!is_array($tags)) $tags = array(); 38 38 $ctx->stash('_tags', $tags); 39 $ctx->stash('__out', false); 39 40 40 41 $counter = 0; … … 42 43 $tags = $ctx->stash('_tags'); 43 44 $counter = $ctx->stash('_tags_counter'); 45 $out = $ctx->stash('__out'); 44 46 } 45 47 if ($counter < count($tags)) { … … 48 50 $ctx->stash('_tags_counter', $counter + 1); 49 51 $repeat = true; 50 if (($counter > 0) && isset($args['glue'])) { 51 $content = $content . $args['glue']; 52 if (isset($args['glue']) && !empty($content)) { 53 if ($out) 54 $content = $args['glue']. $content; 55 else 56 $ctx->stash('__out', true); 52 57 } 53 58 } else { 59 if (isset($args['glue']) && $out && !empty($content)) 60 $content = $args['glue']. $content; 54 61 $ctx->restore($localvars); 55 62 $repeat = false; -
branches/release-35/php/lib/block.mtfor.php
r1174 r1926 7 7 8 8 function smarty_block_mtfor($args, $content, &$ctx, &$repeat) { 9 $localvars = array('__for_end', '__for_var' );9 $localvars = array('__for_end', '__for_var', '__out'); 10 10 11 11 if (!isset($content)) { … … 30 30 $ctx->stash('__for_end', $end); 31 31 $ctx->stash('__for_var', $var); 32 $ctx->stash('__out', false); 32 33 } else { 33 34 $index = $ctx->__stash['vars']['__index__'] + 1; … … 35 36 $end = $ctx->stash('__for_end'); 36 37 $var = $ctx->stash('__for_var'); 38 $out = $ctx->stash('__out'); 37 39 } 38 40 … … 46 48 if ($var) 47 49 $ctx->__stash['vars'][$var] = $index; 48 if (array_key_exists('glue', $args)) { 49 if ($index < $end) 50 $content = $content . $args['glue']; 50 if (isset($args['glue']) && !empty($content)) { 51 if ($out) 52 $content = $args['glue'] . $content; 53 else 54 $ctx->stash('__out', true); 51 55 } 52 56 $repeat = true; 53 57 } else { 58 if (isset($args['glue']) && $out && !empty($content)) 59 $content = $args['glue'] . $content; 54 60 $ctx->restore($localvars); 55 61 $repeat = false; -
branches/release-35/php/lib/block.mtloop.php
r1174 r1926 7 7 8 8 function smarty_block_mtloop($args, $content, &$ctx, &$repeat) { 9 $localvars = array('__loop_keys', '__loop_values' );9 $localvars = array('__loop_keys', '__loop_values', '__out'); 10 10 11 11 if (!isset($content)) { … … 67 67 $counter = 1; 68 68 $ctx->stash('__loop_values', $value); 69 $ctx->stash('__out', false); 69 70 } 70 71 else { … … 72 73 $keys = $ctx->stash('__loop_keys'); 73 74 $value = $ctx->stash('__loop_values'); 75 $out = $ctx->stash('__out'); 74 76 if (!isset($keys) || $keys == 0) { 75 77 $ctx->restore($localvars); 76 78 $repeat = false; 79 if (isset($args['glue']) && $out && !empty($content)) 80 $content = $args['glue'] . $content; 77 81 return $content; 78 82 } … … 97 101 } 98 102 } 99 if (array_key_exists('glue', $args)) { 100 if (1 < $counter) 101 $content = $content . $args['glue']; 103 if (isset($args['glue']) && !empty($content)) { 104 if ($out) 105 $content = $args['glue'] . $content; 106 else 107 $ctx->stash('__out', true); 102 108 } 103 109 if ( 0 === count($keys) ) -
branches/release-35/php/lib/block.mtparentcategories.php
r1800 r1926 21 21 22 22 function smarty_block_mtparentcategories($args, $content, &$ctx, &$repeat) { 23 $localvars = array('_categories', 'category', '_categories_counter','glue' );23 $localvars = array('_categories', 'category', '_categories_counter','glue', '__out'); 24 24 if (!isset($content)) { 25 25 $ctx->localize($localvars); … … 39 39 $ctx->stash('_categories', $parents); 40 40 $ctx->stash('glue', $glue); 41 $ctx->stash('__out', false); 41 42 $counter = 0; 42 43 } else { … … 44 45 $counter = $ctx->stash('_categories_counter'); 45 46 $glue = $ctx->stash('glue'); 47 $out = $ctx->stash('__out'); 46 48 } 47 49 … … 50 52 $ctx->stash('_categories_counter', $counter + 1); 51 53 $repeat = true; 54 if (!empty($glue) && !empty($content)) { 55 if ($out) 56 $content = $glue . $content; 57 else 58 $ctx->stash('__out', true); 59 } 52 60 } else { 61 if (!empty($glue) && $out && !empty($content)) 62 $content = $glue . $content; 53 63 $repeat = false; 54 64 $glue = ''; 55 65 $ctx->restore($localvars); 56 66 } 57 return $content .$glue;67 return $content; 58 68 } 59 69 ?> -
branches/release-35/php/lib/block.mttags.php
r1174 r1926 7 7 8 8 function smarty_block_mttags($args, $content, &$ctx, &$repeat) { 9 $localvars = array('_tags', 'Tag', '_tags_counter', 'tag_min_count', 'tag_max_count', 'all_tag_count', 'include_blogs', 'exclude_blogs', 'blog_ids');9 $localvars = array('_tags', 'Tag', '_tags_counter', 'tag_min_count', 'tag_max_count', 'all_tag_count', 'include_blogs', 'exclude_blogs', 'blog_ids', '__out'); 10 10 if (!isset($content)) { 11 11 $ctx->localize($localvars); … … 54 54 $ctx->stash('all_tag_count', $all_count); 55 55 $ctx->stash('_tags', $tags); 56 $ctx->stash('__out', false); 56 57 $counter = 0; 57 58 } else { 58 59 $tags = $ctx->stash('_tags'); 59 60 $counter = $ctx->stash('_tags_counter'); 61 $out = $ctx->stash('__out'); 60 62 } 61 63 … … 65 67 $ctx->stash('_tags_counter', $counter + 1); 66 68 $repeat = true; 67 if (($counter > 0) && isset($args['glue'])) { 68 $content = $content . $args['glue']; 69 if (isset($args['glue'])) { 70 if ($out && !empty($content)) 71 $content = $args['glue'] . $content; 72 if (!$out && !empty($content)) 73 $ctx->stash('__out', true); 69 74 } 70 75 } else { 76 if (isset($args['glue'])) { 77 if ($out && !empty($content)) 78 $content = $args['glue'] . $content; 79 } 71 80 $ctx->restore($localvars); 72 81 $repeat = false;
