Changeset 1151 for trunk/Navigator

Show
Ignore:
Timestamp:
10/01/08 19:33:27 (18 months ago)
Author:
breese
Message:

plumbed everything to the database for beau. your turn @beausmith

Files:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Navigator/plugins/Navigator/lib/Navigator/Plugin.pm

    r1147 r1151  
    33# GNU General Public License, version 2. 
    44# 
    5 # $Id: CMS.pm 2576 2008-06-14 00:35:33Z bchoate $ 
     5# $Id: $ 
    66 
    7 package Navigator::CMS; 
     7package Navigator::Plugin; 
     8 
    89use strict; 
    9 use MT::Util qw(relative_date); 
    1010 
    1111sub edit_navigation { 
     
    1515    $app->return_to_dashboard( redirect => 1 ) unless $blog_id; 
    1616 
    17     my $blog = MT::Blog->load($blog_id); 
    18     return $app->errtrans("Invalid request") unless $blog; 
     17    my $blog = $app->blog; 
    1918 
     19    # For displaying the page: 
     20    # 1. load all pages 
     21    # 2. load all index templates 
     22    # 3. load all manually created links (eventually) 
     23    # 4. load existing navigation for site 
    2024 
     25    require MT::Page; 
     26    my @pages = MT::Page->load({  
     27        blog_id => $blog->id, 
     28    });  
     29    require MT::Template; 
     30    my @tmpls = MT::Template->load({  
     31        blog_id => $blog->id, 
     32        type => 'index', 
     33    });  
    2134 
     35    $param{pages} = \@pages; 
     36    $param{tmpls} = \@tmpls 
     37; 
    2238 
    23  
    24         # This anonymous subroutine will process each row of data. It takes 
    25         # as input the object associated with the current row, and an empty 
    26         # hash for the row that should be populated with content from the  
    27         # $obj passed to it. 
    28     my $code = sub { 
    29         my ($obj, $row) = @_; 
    30         $row->{'column1'} = $obj->id; 
    31         $row->{'column2'} = $obj->title; 
    32         my $ts = $row->{created_on}; 
    33         $row->{date} = relative_date($ts, time); 
    34     }; 
    35  
    36         # %terms is used in case you want to filter the contents of the 
    37         # table in someway 
    38     my %terms = ( 
    39     #    author_id => $app->user->id, 
    40     ); 
    41  
    42         # %args is used in case you want to sort or otherwise modify the  
    43         # query arguments of the table 
    44     my %args = ( 
    45         sort => 'created_on', 
    46         direction => 'descend', 
    47     ); 
    48  
    49         # %params is an addition hash of input parameters into the template 
    50         # and can be used to hold an arbitrary set of name/value pairs that 
    51         # can be displayed in your template. 
    52         my %params = ( 
    53                 some_variable => 'You can do ANYTHING in Movable Type', 
    54         ); 
    55  
    56         # Fetch an instance of the current plugin using the plugin's key 
    57     my $plugin = MT->component('Navigator'); 
    58  
    59         # The main work horse of your handler. This will actually conduct 
    60         # the query to the database for you, populate all that is necessary  
    61         # for the pagination controls and more. The query is filtered and 
    62         # controlled using the %terms and %args parameters.  
    63     $app->listing({ 
    64         type     => 'page', # the ID of the object in the registry 
    65         terms    => \%terms, 
    66         args     => \%args, 
    67         # listing_screen => 1, 
    68         code     => $code, 
    69         template => $plugin->load_tmpl('view.tmpl'), 
    70         params   => \%params, 
    71     }); 
    72  
    73  
    74  
    75     # $app->build_page( 'view.tmpl', \%param ); 
     39    $app->build_page( 'edit.tmpl', \%param ); 
    7640} 
    7741