Bare minimum working

This commit is contained in:
Doug Bell 2010-04-02 18:44:46 -05:00
parent 8f4024a4b2
commit 5e77a948ad
2 changed files with 66 additions and 25 deletions

View file

@ -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; <WebGUI::Admin::DATA> };
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__
<div id="wrapper" class="yui-skin-sam">
<dl class="accordion-menu">
<dt class="a-m-t">^International("admin console","AdminConsole");</dt>
<dd class="a-m-d"><div class="bd">
<TMPL_LOOP adminPlugins>
<a class="link" href="<tmpl_var url>">
<img src="<tmpl_var icon.small>" style="border: 0px; vertical-align: middle;" alt="icon" />
<tmpl_var title>
</a>
</TMPL_LOOP>
</div></dd>
</dl>
<p>This is where cool stuff goes</p>
<!-- Put this in style where belongs -->
<script type="text/javascript">
YAHOO.util.Event.onDOMReady(function () { document.body.style.marginLeft = "160px"; });
</script>
</div>

View file

@ -63,5 +63,3 @@ sub handler {
1;
#vim:ft=perl
__DATA__