Changeset 15

Show
Ignore:
Timestamp:
08/29/06 12:02:05 (4 years ago)
Author:
fabien
Message:

changed the sidebar tag list to a cloud, added a new tag list page

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/apps/snippets/modules/sidebar/actions/components.class.php

    r7 r15  
    99  public function executeListAll() 
    1010  { 
    11     $this->tags = SnippetTagPeer::getAllWithCount(); 
     11    $this->tags = SnippetTagPeer::getPopular(); 
    1212    $this->comments = SnippetCommentPeer::getLatests(sfConfig::get('app_sidebar_comments')); 
    1313  } 
  • trunk/apps/snippets/modules/sidebar/templates/_listAll.php

    r10 r15  
    11<?php echo use_helper('Date') ?> 
    2 <h2>Tags</h2> 
    3 <ul> 
     2<h2>Popular Tags</h2> 
    43<?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) ?>     
    115<?php endforeach; ?> 
    12 </ul> 
    136<h2> 
    147  Latest comments 
  • trunk/apps/snippets/modules/tag/actions/actions.class.php

    r11 r15  
    1717  public function executeIndex() 
    1818  { 
     19    $this->tags = SnippetTagPeer::getAllWithCount(1000); 
     20    $this->column_count = intval(count($this->tags)/3); 
    1921  } 
    2022 
  • 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  
    2323    <li><?php echo link_to('latest snippets', '@homepage') ?></li> 
    2424    <li><?php echo link_to('popular snippets', '@snippet_list?sort=popularity') ?></li> 
     25    <li><?php echo link_to('snippet tags', 'tag/index') ?></li> 
    2526  </ul> 
    2627  <?php include_component_slot('sidebar') ?> 
  • trunk/lib/model/SnippetTagPeer.php

    r2 r15  
    4747    return $tags; 
    4848  } 
     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  } 
    4964 
    5065  public static function getForSnippetsWithCount($snippets, $excluded_tags, $max = 100)