Changeset 1739

Show
Ignore:
Timestamp:
05/17/08 05:18:16 (8 months ago)
Author:
michaeltwofish
Message:

Tags are now displayed correctly when renamed. Make admin/tags use the tag_collection template to display tags. Return that template with the rename tags AJAX call. This makes the admin/tag much nicer (less complex JavaScript), and removes duplication from ajax_tags.

Location:
trunk/htdocs/system
Files:
1 added
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/htdocs/system/admin/tags.php

    r1732 r1739  
    88    <span class="newer pct10"><a href="#">Newer &raquo;</a></span> 
    99</div> 
    10 <?php 
    11     $tags= $available_tags; 
    12     //what's the max count? 
    13     //ugly! and probably needs to be a Tags method or something 
    14     $max=0; 
    15     foreach ($tags as $tag){if ($max < $tag->count) $max=$tag->count;} 
    16 ?> 
    17 <div class="container tags"> 
    18 <?php foreach ($tags as $tag) { ?> 
    19     <a href="#" id="<?php echo 'tag_' . $tag->id ?>" class="tag wt<?php echo round(($tag->count * 10)/$max); ?>"><span><?php echo $tag->tag; ?></span><sup><?php echo $tag->count; ?></sup></a> 
    20 <?php } ?> 
    21         <ul class="dropbutton"> 
    22             <li><a href="#">Select Visible</a></li> 
    23             <li><a href="#">Select All</a></li> 
    24             <li><a href="#">Deselect All</a></li> 
    25         </ul> 
     10<div id="tag_collection" class="container tags"> 
     11  <?php $theme->display( 'tag_collection' ); ?> 
    2612</div> 
    2713 
     
    116102            //TODO When there's a loupe, update it 
    117103            //timelineHandle.updateLoupeInfo(); 
    118             master_found= false; 
    119             // Update the master tag count 
    120             $('.tags .tag:contains(' + master + ')').each(function() { 
    121                 if ($(this).find('span').text() == master) { 
    122                     $(this).find('sup').text(data['count']); 
    123                     // TODO should change the wt%d class 
    124                     master_found= true; 
    125                 } 
    126             }) 
    127             // master wasn't an existing tag, add it to the list 
    128             // It's going to be last, not in order 
    129             if (!master_found) { 
    130                 $('.tags .tag:last').after('<a href="#" id="tag_' + data['id'] + '" class="tag wt' + data['wt'] + '"><span>' + master + '</span><sup>' + data['count'] + '</sup></a>'); 
    131                 $('.tags .tag:last').click(function() { 
     104            $('#tag_collection').html(data['tags']); 
     105            $('.tags .tag').click(function() { 
    132106                    $(this).toggleClass('selected'); 
    133107                    tagManage.changeTag(); 
    134                 }); 
    135             } 
    136             selected.remove(); 
     108                } 
     109            ); 
     110            tagManage.changeTag(); 
    137111            humanMsg.displayMsg(data['msg']); 
    138112        }, 
  • trunk/htdocs/system/classes/adminhandler.php

    r1726 r1739  
    471471                $this->theme->assign( 'settings', $settings ); 
    472472            } 
    473             $this->theme->display('users'); 
     473            $this->theme->display( 'users' ); 
    474474        } 
    475475    } 
     
    13601360    { 
    13611361        $this->theme->wsse= Utils::WSSE(); 
    1362         $this->theme->available_tags= Tags::get(); 
    13631362        $this->display( 'tags' ); 
    13641363    } 
     
    13931392            case 'rename': 
    13941393                if ( isset($this->handler_vars['master']) ) { 
     1394                    $theme_dir= Plugins::filter( 'admin_theme_dir', Site::get_dir( 'admin_theme', TRUE ) ); 
     1395                    $this->theme= Themes::create( 'admin', 'RawPHPEngine', $theme_dir ); 
    13951396                    $master= $this->handler_vars['master']; 
    13961397                    $tag_names= array(); 
     
    14051406                    Tags::rename($master, $tag_names); 
    14061407                    $msg_status= sprintf( _t('Tags %s have been renamed to %s.'), implode($tag_names, ', '), $master ); 
    1407                     $master= Tags::get_one( $master ); 
    1408                     $wt= round(($master->count * 10)/$master->count); 
    1409                     echo json_encode( array( 'msg' => $msg_status, 'count' => $master->count, 'id' => $master->id, 'wt' => $wt ) ); 
     1408                    echo json_encode( array( 'msg' => $msg_status, 'tags' => $this->theme->fetch( 'tag_collection' ) ) ); 
    14101409                } 
    14111410                break;