Author: nick Date: 2006-07-27 18:13:52 +0100 (Thu, 27 Jul 2006) New Revision: 822
Added: trunk/templates/admin_home.tt Modified: trunk/MANIFEST trunk/lib/OpenGuides.pm Log: Start on the admin interface
Modified: trunk/MANIFEST =================================================================== --- trunk/MANIFEST 2006-07-27 16:27:54 UTC (rev 821) +++ trunk/MANIFEST 2006-07-27 17:13:52 UTC (rev 822) @@ -27,6 +27,7 @@ newpage.cgi preferences.cgi search.cgi +templates/admin_home.tt templates/backlink_results.tt templates/banner.tt templates/delete_confirm.tt
Modified: trunk/lib/OpenGuides.pm =================================================================== --- trunk/lib/OpenGuides.pm 2006-07-27 16:27:54 UTC (rev 821) +++ trunk/lib/OpenGuides.pm 2006-07-27 17:13:52 UTC (rev 822) @@ -1132,6 +1132,68 @@ } }
+=item B<display_admin_interface> +Fetch everything we need to display the admin interface, and passes it off + to the template +=cut +sub display_admin_interface { + my ($self, %args) = @_; + my $return_tt_vars = $args{return_tt_vars} || 0; + my $return_output = $args{return_output} || 0; + + my $wiki = $self->wiki; + my $formatter = $self->wiki->formatter; + my $script_url = $self->config->script_url; + + # Grab all the nodes + my @all_nodes = $wiki->list_all_nodes(with_details=>1); + @all_nodes = sort { $a->{'name'} cmp $b->{'name'} } @all_nodes; + + + # Split into nodes, Locales and Categories + my @nodes; + my @categories; + my @locales; + for my $node (@all_nodes) { + # Make the URLs + my $node_param = uri_escape( $formatter->node_name_to_node_param( $node->{'name'} ) ); + $node->{'view_url'} = $script_url . "?id=" . $node_param; + $node->{'versions_url'} = $script_url . "?action=list_all_versions;id=" . $node_param; + $node->{'moderation_url'} = $script_url . "?action=set_moderation;id=" . $node_param; + + # Filter + if($node->{'name'} =~ /^Category /) { + $node->{'page_name'} = $node->{'name'}; + $node->{'name'} =~ s/^Category //; + push @categories, $node; + } elsif($node->{'name'} =~ /^Locale /) { + $node->{'page_name'} = $node->{'name'}; + $node->{'name'} =~ s/^Locale //; + push @locales, $node; + } else { + push @nodes, $node; + } + } + + # Render in a template + my %tt_vars = ( + not_editable => 1, + not_deletable => 1, + deter_robots => 1, + nodes => @nodes, + categories => @categories, + locales => @locales + ); + return %tt_vars if $return_tt_vars; + my $output = $self->process_template( + id => "", + template => "admin_home.tt", + tt_vars => %tt_vars, + ); + return $output if $return_output; + print $output; +} + sub process_template { my ($self, %args) = @_; my %output_conf = (
Added: trunk/templates/admin_home.tt =================================================================== --- trunk/templates/admin_home.tt 2006-07-27 16:27:54 UTC (rev 821) +++ trunk/templates/admin_home.tt 2006-07-27 17:13:52 UTC (rev 822) @@ -0,0 +1,66 @@ +[% INCLUDE header.tt page_title = "Admin - $site_name" %] +[% INCLUDE banner.tt %] +<div id="content"> +[% INCLUDE navbar.tt %] +<div id="maincontent"> +<h2>Site Administration</h2> +<ul> + <li><a href="#nodes">Nodes</a></li> + <li><a href="#locales">Locales</a></li> + <li><a href="#categories">Categories</a></li> +</ul> + +<a name="nodes"></a> +<table id="nodes"> +<tr><th>Node name</th><th>Current Version</th><th>Moderation</th><th>Actions</th></tr> + [% FOREACH node = nodes %] + <tr> + <td><a href="[% node.view_url %]">[% node.name %]</a></td> + <td>[% node.version %]</td> + <td>[% node.moderate %]</td> + <td><a href="[% node.view_url %]">View</a> or + <a href="[% node.versions_url %]">View all versions</a> or + <a href="[% node.moderation_url %]">Set Moderation</a> + </td> + </tr> + [% END %] +</table> + +<br /><br /> + +<a name="locales"></a> +<table id="locales"> +<tr><th>Locale name</th><th>Current Version</th><th>Moderation</th><th>Actions</th></tr> + [% FOREACH locale = locales %] + <tr> + <td><a href="[% locale.view_url %]">[% locale.name %]</a></td> + <td>[% locale.version %]</td> + <td>[% locale.moderate %]</td> + <td><a href="[% locale.view_url %]">View</a> or + <a href="[% locale.versions_url %]">View all versions</a> or + <a href="[% locale.moderation_url %]">Set Moderation</a> + </td> + </tr> + [% END %] +</table> + +<br /><br /> + +<a name="categories"></a> +<table id="categories"> +<tr><th>Category name</th><th>Current Version</th><th>Moderation</th><th>Actions</th></tr> + [% FOREACH cat = categories %] + <tr> + <td><a href="[% cat.view_url %]">[% cat.name %]</a></td> + <td>[% cat.version %]</td> + <td>[% cat.moderate %]</td> + <td><a href="[% cat.view_url %]">View</a> or + <a href="[% cat.versions_url %]">View all versions</a> or + <a href="[% cat.moderation_url %]">Set Moderation</a> + </td> + </tr> + [% END %] +</table> + +</div> +[% INCLUDE footer.tt %]
openguides-commits@lists.openguides.org