diff --git a/lib/WebGUI/Admin.pm b/lib/WebGUI/Admin.pm index d00f68140..fec594f00 100644 --- a/lib/WebGUI/Admin.pm +++ b/lib/WebGUI/Admin.pm @@ -11,6 +11,11 @@ has 'session' => ( required => 1, ); +sub BUILDARGS { + my ( $class, $session, @args ) = @_; + return { session => $session, @args }; +} + #---------------------------------------------------------------------- sub getAdminPluginTemplateVars { @@ -28,44 +33,48 @@ sub getAdminPluginTemplateVars { # If we have a class name, we've got a new WebGUI::Admin::Plugin if ( $funcDef->{className} ) { my $plugin = $funcDef->{className}->new( $session, $funcId, $funcDef ); + next unless $plugin->canUse; $var = { title => $plugin->getTitle, icon => $plugin->getIcon, 'icon.small' => $plugin->getIconSmall, url => $plugin->getUrl, - canUse => $plugin->canUse, }; + + # build the list of processed items + $processed{$plugin->getTitle} = $var; } # Don't know what we have (old admin console functions) else { # make title - my $title = $functions->{$function}{title}; + my $title = $funcDef->{title}; WebGUI::Macro::process( $session, \$title ); # determine if the user can use this thing my $canUse = 0; - if ( defined $functions->{$function}{group} ) { - $canUse = $user->isInGroup( $functions->{$function}{group} ); + if ( defined $funcDef->{group} ) { + $canUse = $user->isInGroup( $funcDef->{group} ); } - elsif ( defined $functions->{$function}{groupSetting} ) { - $canUse = $user->isInGroup( $setting->get( $functions->{$function}{groupSetting} ) ); + elsif ( defined $funcDef->{groupSetting} ) { + $canUse = $user->isInGroup( $setting->get( $funcDef->{groupSetting} ) ); } - if ( $functions->{$function}{uiLevel} > $user->profileField("uiLevel") ) { + if ( $funcDef->{uiLevel} > $user->profileField("uiLevel") ) { $canUse = 0; } + next unless $canUse; # build the attributes $var = { title => $title, - icon => $url->extras( "/adminConsole/" . $functions->{$function}{icon} ), - 'icon.small' => $url->extras( "adminConsole/small/" . $functions->{$function}{icon} ), - url => $functions->{$function}{url}, - canUse => $canUse, + icon => $url->extras( "/adminConsole/" . $funcDef->{icon} ), + 'icon.small' => $url->extras( "adminConsole/small/" . $funcDef->{icon} ), + url => $funcDef->{url}, }; - } ## end else [ if ( $funcDef->{className...})] - # build the list of processed items - $processed{$title} = $var; + # build the list of processed items + $processed{$title} = $var; + + } ## end else [ if ( $funcDef->{className...})] } ## end foreach my $funcId ( keys %...) @@ -115,13 +124,15 @@ sub getVersionTagTemplateVars { my $working = WebGUI::VersionTag->getWorking( $session, "nocreate" ); my $tags = WebGUI::VersionTag->getOpenTags($session); if ( @$tags ) { - next unless $user->isInGroup( $tag->get("groupToUse") ); - push @$vars, { - name => $tag->get("name"), - isWorking => ( $working && $working->getId eq $tag->getId ) ? 1 : 0, - joinUrl => $tag->getJoinUrl, - editUrl => $tag->getEditUrl, - }; + for my $tag ( @$tags ) { + next unless $user->isInGroup( $tag->get("groupToUse") ); + push @$vars, { + name => $tag->get("name"), + isWorking => ( $working && $working->getId eq $tag->getId ) ? 1 : 0, + joinUrl => $tag->getJoinUrl, + editUrl => $tag->getEditUrl, + }; + } } return $vars; @@ -138,7 +149,7 @@ Show the main Admin console wrapper sub www_view { my ($self) = @_; my $session = $self->session; - my ( $user, $url ) = $session->quick(qw{ user url }); + my ( $user, $url, $style ) = $session->quick(qw{ user url style }); my $var; $var->{backToSiteUrl} = $url->page; @@ -146,7 +157,7 @@ sub www_view { # Add vars for AdminBar $var->{adminPlugins} = $self->getAdminPluginTemplateVars; $var->{versionTags} = $self->getVersionTagTemplateVars; - $var->{clipboardAssets} = $self->getClipboardTemplateVars; + #$var->{clipboardAssets} = $self->getClipboardTemplateVars; $var->{newContentTabs} = $self->getNewContentTemplateVars; # Add vars for current user @@ -161,10 +172,42 @@ sub www_view { $var->{leaveUrl} = ""; #TODO } + $style->setScript($url->extras('yui/build/utilities/utilities.js'), {type=>'text/javascript'}); + $style->setScript($url->extras('accordion/accordion.js'), {type=>'text/javascript'}); + $style->setLink($url->extras('macro/AdminBar/slidePanel.css'), {type=>'text/css', rel=>'stylesheet'}); + # Use the template in our __DATA__ block + my $tdata = do { local $/ = undef; }; + my $tmpl = WebGUI::Asset::Template::HTMLTemplate->new( $session ); + # Use the blank style + my $output = $style->process( $tmpl->process( $tdata, $var ), "PBtmplBlankStyle000001" ); return $output; } ## end sub www_view 1; + +__DATA__ +
+ +
+
^International("admin console","AdminConsole");
+
+ + + icon + + + +
+
+ +

This is where cool stuff goes

+ + + + +
diff --git a/lib/WebGUI/Content/Admin.pm b/lib/WebGUI/Content/Admin.pm index fc921c346..1d830ac23 100644 --- a/lib/WebGUI/Content/Admin.pm +++ b/lib/WebGUI/Content/Admin.pm @@ -63,5 +63,3 @@ sub handler { 1; #vim:ft=perl - -__DATA__