Changeset 15
- Timestamp:
- 08/29/06 12:02:05 (2 years ago)
- Files:
-
- trunk/apps/snippets/modules/sidebar/actions/components.class.php (modified) (1 diff)
- trunk/apps/snippets/modules/sidebar/templates/_listAll.php (modified) (1 diff)
- trunk/apps/snippets/modules/tag/actions/actions.class.php (modified) (1 diff)
- trunk/apps/snippets/modules/tag/templates/indexSuccess.php (modified) (1 diff)
- trunk/apps/snippets/templates/layout.php (modified) (1 diff)
- trunk/lib/model/SnippetTagPeer.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/apps/snippets/modules/sidebar/actions/components.class.php
r7 r15 9 9 public function executeListAll() 10 10 { 11 $this->tags = SnippetTagPeer::get AllWithCount();11 $this->tags = SnippetTagPeer::getPopular(); 12 12 $this->comments = SnippetCommentPeer::getLatests(sfConfig::get('app_sidebar_comments')); 13 13 } trunk/apps/snippets/modules/sidebar/templates/_listAll.php
r10 r15 1 1 <?php echo use_helper('Date') ?> 2 <h2>Tags</h2> 3 <ul> 2 <h2>Popular Tags</h2> 4 3 <?php foreach($tags as $tag => $count): ?> 5 <li> 6 <?php echo link_to($tag, 'snippet/listByTag?tag='.$tag) ?> (<?php echo $count ?>) 7 <?php if($sf_user->hasCredential('admin')): ?> 8 <?php echo link_to('[delete]', 'tag/delete?tag='.$tag, 'confim=Are you sure you want to delete '.$count.' tags ?') ?> 9 <?php endif; ?> 10 </li> 4 <?php echo link_to($tag, 'snippet/listByTag?tag='.$tag, 'class=tag_'.$count) ?> 11 5 <?php endforeach; ?> 12 </ul>13 6 <h2> 14 7 Latest comments trunk/apps/snippets/modules/tag/actions/actions.class.php
r11 r15 17 17 public function executeIndex() 18 18 { 19 $this->tags = SnippetTagPeer::getAllWithCount(1000); 20 $this->column_count = intval(count($this->tags)/3); 19 21 } 20 22 trunk/apps/snippets/modules/tag/templates/indexSuccess.php
r2 r15 1 <h1>Module tag</h1> 2 3 <p>Congratulations!</p> 1 <h1>List of snippet tags</h1> 2 <table class="tags"><tr><td valign="top"> 3 <ul> 4 <?php $pos=0; foreach($tags as $tag => $count): $pos++;?> 5 <?php if ($pos > $column_count): $pos = 0;?> 6 </td><td valign="top"> 7 <?php endif; ?> 8 <li> 9 <?php echo link_to($tag, 'snippet/listByTag?tag='.$tag) ?> (<?php echo $count ?>) 10 <?php if($sf_user->hasCredential('admin')): ?> 11 <?php echo link_to('[delete]', 'tag/delete?tag='.$tag, 'confim=Are you sure you want to delete '.$count.' tags ?') ?> 12 <?php endif; ?> 13 </li> 14 <?php endforeach; ?> 15 </ul> 16 </td></tr></table> trunk/apps/snippets/templates/layout.php
r2 r15 23 23 <li><?php echo link_to('latest snippets', '@homepage') ?></li> 24 24 <li><?php echo link_to('popular snippets', '@snippet_list?sort=popularity') ?></li> 25 <li><?php echo link_to('snippet tags', 'tag/index') ?></li> 25 26 </ul> 26 27 <?php include_component_slot('sidebar') ?> trunk/lib/model/SnippetTagPeer.php
r2 r15 47 47 return $tags; 48 48 } 49 50 public function getPopular() 51 { 52 $all_tags = self::getAllWithCount(200); 53 $max_count = max($all_tags); 54 $tags = array(); 55 foreach($all_tags as $tag => $count) 56 { 57 if($count/$max_count > 0.2) 58 { 59 $tags[$tag] = intval(3*$count/$max_count); 60 } 61 } 62 return $tags; 63 } 49 64 50 65 public static function getForSnippetsWithCount($snippets, $excluded_tags, $max = 100)
