diff --git a/lib/WebGUI/Macro/AdminBar.pm b/lib/WebGUI/Macro/AdminBar.pm deleted file mode 100644 index 0dceb6e48..000000000 --- a/lib/WebGUI/Macro/AdminBar.pm +++ /dev/null @@ -1,202 +0,0 @@ -package WebGUI::Macro::AdminBar; - -#------------------------------------------------------------------- -# WebGUI is Copyright 2001-2009 Plain Black Corporation. -#------------------------------------------------------------------- -# Please read the legal notices (docs/legal.txt) and the license -# (docs/license.txt) that came with this distribution before using -# this software. -#------------------------------------------------------------------- -# http://www.plainblack.com info@plainblack.com -#------------------------------------------------------------------- - -use strict qw(refs vars); -use WebGUI::AdminConsole; -use WebGUI::Asset; -use WebGUI::International; -use WebGUI::Macro; -use WebGUI::VersionTag; - -=head1 NAME - -Package WebGUI::Macro::AdminBar - -=head1 DESCRIPTION - -Macro for displaying administrative functions to a user with Admin turned on. - -=head2 process ( ) - -process takes one optional parameters for customizing the layout of the Admin bar. - -=cut - - -sub process { - my $session = shift; - return undef unless $session->isAdminOn; - my $i18n = WebGUI::International->new($session,'Macro_AdminBar'); - my ($url, $style, $asset, $user, $config) = $session->quick(qw(url style asset user config)); - $style->setScript($url->extras('yui/build/utilities/utilities.js')); - $style->setScript($url->extras('accordion/accordion.js')); - $style->setCss($url->extras('macro/AdminBar/slidePanel.css')); - - my $out = q{
}; - - # admin console - my $ac = WebGUI::AdminConsole->new($session); - $out .= q{
}.$i18n->get("admin console","AdminConsole").q{
}; - foreach my $item (@{$ac->getAdminFunction}) { - next unless $item->{canUse}; - $out .= q{} - .q{icon } - .$item->{title}.q{}; - } - $out .= qq{
\n}; - - # version tags - my $versionTags = WebGUI::VersionTag->getOpenTags($session); - if (scalar(@$versionTags)) { - $out .= q{
}.$i18n->get("version tags","VersionTag").q{
}; - my $working = WebGUI::VersionTag->getWorking($session, 1); - my $workingId = ""; - if ($working) { - $workingId = $working->getId; - my $commitUrl = ""; - if ($session->setting->get("skipCommitComments")) { - $commitUrl = $url->page("op=commitVersionTagConfirm;tagId=".$workingId); - } - else { - $commitUrl = $url->page("op=commitVersionTag;tagId=".$workingId); - } - $out .= WebGUI::Form::formHeader($session, { action => $commitUrl, }) - . q{} - . WebGUI::Form::formFooter($session); - } - foreach my $tag (@{$versionTags}) { - next unless $user->isInGroup($tag->get("groupToUse")); - my $switchUrl = $url->page("op=" . ($tag->getId eq $workingId ? "editVersionTag" : "setWorkingVersionTag") . ";backToSite=1;tagId=".$tag->getId); - my $title = ($tag->getId eq $workingId) ? '* '.$tag->get("name").'' : $tag->get("name"); - $out .= q{}.$title.q{}; - } - $out .= qq{
\n}; - } - - - # stuff to do if we're on a page with an asset - if ($asset) { - - my $proceed = $session->form->get('op') eq 'assetManager' ? ';proceed=manageAssets' : ''; - # clipboard - my $clipboardItems = $session->asset->getAssetsInClipboard(1); - if (scalar (@$clipboardItems)) { - my $formProceed = $session->form->get('op') eq 'assetManager' ? 'manageAssets' : ''; - $out .= q{
}.$i18n->get("1082").q{
} - . WebGUI::Form::formHeader($session, - { action => $session->url->page('func=pasteList;assetId=0;proceed='.$formProceed), extras => "id='adminBarClip'", } - ); - foreach my $item (@{$clipboardItems}) { - my $title = $asset->getTitle; - $out .= q{getId.$proceed).q{" onclick="var thisForm = document.getElementById('adminBarClip'); thisForm.assetId.value='}.$item->getId.q{'; thisForm.submit(); return false;">} - .q{icon } - .$item->getTitle.q{}; - } - $out .= WebGUI::Form::formFooter($session) - . qq{
\n}; - } - - ### new content menu - - # determine new content categories - my %rawCategories = %{$config->get('assetCategories')}; - my %categories; - my %categoryTitles; - my $userUiLevel = $user->get('uiLevel'); - foreach my $category (keys %rawCategories) { - next if $rawCategories{$category}{uiLevel} > $userUiLevel; - next if (exists $rawCategories{$category}{group} && !$user->isInGroup($rawCategories{$category}{group})); - my $title = $rawCategories{$category}{title}; - WebGUI::Macro::process($session, \$title); - $categories{$category}{title} = $title; - $categoryTitles{$title} = $category; - } - - # assets - my %assetList = %{$config->get('assets')}; - foreach my $assetClass (keys %assetList) { - my $dummy = WebGUI::Asset->newByPropertyHashRef($session,{dummy=>1, className=>$assetClass}); - next unless defined $dummy; - my $assetConfig = $assetList{$assetClass}; - next if $dummy->getUiLevel( $assetConfig->{uiLevel} ) > $userUiLevel; - next unless ($dummy->canAdd($session)); - my $assetInfo = { - icon => $dummy->getIcon(1), - url => $asset->getUrl("func=add;className=" . $dummy->get('className')), - title => $dummy->getTitle, - }; - my @assetCategories = ref $assetConfig->{category} ? @{$assetConfig->{category}} : $assetConfig->{category}; - for my $category (@assetCategories) { - next unless exists $categories{$category}; - $categories{$category}{items} ||= []; - push @{ $categories{$category}{items} }, $assetInfo; - } - } - - # packages - foreach my $package (@{$session->asset->getPackageList}) { - next unless ($package->canView && $package->canAdd($session) && $package->getUiLevel <= $userUiLevel); - $categories{packages}{items} ||= []; - push @{$categories{packages}{items}}, { - title => $package->getTitle, - url => $asset->getUrl("func=deployPackage;assetId=".$package->getId.$proceed), - icon => $package->getIcon(1), - }; - } - if ($categories{packages}{items} && @{$categories{packages}{items}}) { - $categories{packages}{title} = $i18n->get('packages'); - $categoryTitles{$i18n->get('packages')} = "packages"; - } - - # prototypes - foreach my $prototype (@{ $session->asset->getPrototypeList }) { - next unless ($prototype->canView && $prototype->canAdd($session) && $prototype->getUiLevel <= $userUiLevel); - $categories{prototypes}{items} ||= []; - push @{$categories{prototypes}{items}}, { - title => $prototype->getTitle, - url => $asset->getUrl( - "func=add;className=".$prototype->get('className').";prototype=".$prototype->getId.$proceed - ), - icon => $prototype->getIcon(1), - }; - } - if ($categories{prototypes}{items} && @{$categories{prototypes}{items}}) { - $categories{prototypes}{title} = $i18n->get('prototypes'); - $categoryTitles{$i18n->get('prototypes')} = "prototypes"; - } - - # render new content menu - $out .= q{
}.$i18n->get("1083").q{
}; - foreach my $categoryTitle (sort keys %categoryTitles) { - $out .= '
'.$categoryTitle.'
'; - my $items = $categories{$categoryTitles{$categoryTitle}}{items}; - next unless (ref $items eq 'ARRAY'); # in case the category is empty - foreach my $item (sort { $a->{title} cmp $b->{title} } @{$items}) { - $out .= q{} - .q{icon } - .$item->{title}.q{}; - } - $out .= '
'; - } - $out .= qq{
\n}; - } - - $out .= q{
- }; - return $out; -} - -1; - diff --git a/t/Macro/AdminBar.t b/t/Macro/AdminBar.t deleted file mode 100644 index d92e5e43a..000000000 --- a/t/Macro/AdminBar.t +++ /dev/null @@ -1,30 +0,0 @@ -#------------------------------------------------------------------- -# WebGUI is Copyright 2001-2009 Plain Black Corporation. -#------------------------------------------------------------------- -# Please read the legal notices (docs/legal.txt) and the license -# (docs/license.txt) that came with this distribution before using -# this software. -#------------------------------------------------------------------- -# http://www.plainblack.com info@plainblack.com -#------------------------------------------------------------------- - -use strict; - -use WebGUI::Test; -use WebGUI::Session; -use WebGUI::Macro::AdminBar; -use HTML::TokeParser; - -use Test::More; # increment this value for each test you create - -my $session = WebGUI::Test->session; - -plan tests => 2; - -my $output; -$output = WebGUI::Macro::AdminBar::process($session); -is($output, undef, 'AdminBar returns undef unless admin is on'); -$session->switchAdminOn; -$output = WebGUI::Macro::AdminBar::process($session); -ok($output, 'AdminBar returns something when admin is on'); -