diff --git a/lib/WebGUI/Operation/Page.pm b/lib/WebGUI/Operation/Page.pm
deleted file mode 100644
index 6dfcbc81d..000000000
--- a/lib/WebGUI/Operation/Page.pm
+++ /dev/null
@@ -1,927 +0,0 @@
-package WebGUI::Operation::Page;
-
-#-------------------------------------------------------------------
-# WebGUI is Copyright 2001-2004 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 File::Path;
-use WebGUI::DateTime;
-use WebGUI::FormProcessor;
-use WebGUI::Grouping;
-use WebGUI::HTMLForm;
-use WebGUI::HTTP;
-use WebGUI::Icon;
-use WebGUI::International;
-use WebGUI::Page;
-use WebGUI::Privilege;
-use WebGUI::Session;
-use WebGUI::SQL;
-use WebGUI::TabForm;
-use WebGUI::URL;
-use WebGUI::Utility;
-use WebGUI::Export;
-
-#-------------------------------------------------------------------
-=head2 _changeWobjectPrivileges ( page )
-
-This private function changes the privileges of all wobjects on page.
-
-=cut
-sub _changeWobjectPrivileges {
- my($wobject,$sth);
- $sth = WebGUI::SQL->read("select wobjectId,namespace from wobject where pageId=".quote($_[0]));
- while ($wobject = $sth->hashRef) {
- my $cmd = "WebGUI::Wobject::".$wobject->{namespace};
- my $load = "use ".$cmd;
- eval($load);
- WebGUI::ErrorHandler::warn("Wobject failed to compile: $cmd.".$@) if($@);
- my $w = $cmd->new($wobject);
- if ($w->canEdit) {
- $w->set({
- startDate=>WebGUI::FormProcessor::dateTime("startDate"),
- endDate=>WebGUI::FormProcessor::dateTime("endDate"),
- ownerId=>$session{form}{ownerId},
- groupIdView=>$session{form}{ownerId},
- groupIdEdit=>$session{form}{groupIdEdit}
- });
- }
- }
-}
-
-#-------------------------------------------------------------------
-=head2 _recursivelyChangeProperties ( page )
-
-This private function set an entire subtree with $page as root to the same privilege and/or
-style settings. These properties are set to be a duplicate of those in page.
-
-=head3 page
-
-This is the page whose ancestors should be changed. This must be an WebGUI::Page instance.
-
-=cut
-# This combines _recusivelyChangePrivileges and _recusivelyChangeStyle, since there's no use in walking down a tree twice.
-sub _recursivelyChangeProperties {
- my ($page, $currentPage);
- $page = shift;
-
- _changeWobjectPrivileges($page->get("pageId")) unless $session{form}{wobjectPrivileges};
-
- $page->traversePreOrder(
- sub {
- $currentPage = shift;
- if (WebGUI::Page::canEdit($currentPage->get('pageId'))) {
- $currentPage->setWithoutRecache({
- startDate => WebGUI::FormProcessor::dateTime("startDate"),
- endDate => WebGUI::FormProcessor::dateTime("endDate"),
- ownerId => $session{form}{ownerId},
- groupIdView => $session{form}{groupIdView},
- groupIdEdit => $session{form}{groupIdEdit}
- }) if ($session{form}{recursePrivs});
- $currentPage->setWithoutRecache({
- styleId => $session{form}{styleId},
- printableStyleId => $session{form}{printableStyleId}
- }) if ($session{form}{recurseStyle});
- }
- return 1;
- }
- );
-
- WebGUI::Page->recacheNavigation;
-}
-
-#-------------------------------------------------------------------
-sub _selectPositions {
- my ($templates, $output, $f, $key);
- $f = WebGUI::HTMLForm->new(1);
- $templates = WebGUI::Page::getTemplateList();
- $f->template(
- -value=>$_[0],
- -namespace=>"page",
- -afterEdit=>'op=editPage&npp='.$session{form}{npp},
- -extras=>'onChange="changeTemplatePreview(this.form.templateId.value)"'
- );
- my $headtags = '
- ';
- WebGUI::Style::setRawHeadTags($headtags);
- $output .= $f->printRowsOnly;
- $output .= '
';
- return $output;
-}
-
-#-------------------------------------------------------------------
-
-=head2 _traversePageTree( pageId [, initialDepth ] )
-
-Walks down the page tree from page with id pageId and returns an indented list of the pages it
-walks over. Also prints edit/delete/move buttons.
-
-=head3 pageId
-
-The id of the page you want to start from
-
-=head3 initialDepth
-
-The depth the tree should start with. Defaults to zero.
-
-=cut
-
-sub _traversePageTree {
- my (%wobject, $output, $spacer, $page, $currentPage, $currentPageId, $currentUrlizedTitle, $wobjects);
- my ($parentId, $initialDepth) = @_;
-
- tie %wobject, 'Tie::CPHash';
- $spacer = '
';
- my $sth = WebGUI::SQL->read("select pageId,isSystem,urlizedTitle,title from page where parentId=".quote($parentId)." order by nestedSetLeft");
- while (my ($pageId,$isSystem,$url,$title) = $sth->array) {
- unless ($isSystem) {
- $output .= $spacer x $initialDepth
- .pageIcon()
- .deleteIcon('op=deletePageConfirm',$url,WebGUI::International::get(101))
- .moveLeftIcon(sprintf('op=moveTreePageLeft&pageId=%s',$pageId), $url)
- .moveUpIcon(sprintf('op=moveTreePageUp&pageId=%s',$pageId), $url)
- .moveDownIcon(sprintf('op=moveTreePageDown&pageId=%s',$pageId), $url)
- .moveRightIcon(sprintf('op=moveTreePageRight&pageId=%s',$pageId), $url)
- .editIcon('op=editPage', $url)
- .' '.$title.'
';
- $wobjects = WebGUI::SQL->read("select wobjectId,title from wobject where pageId=".quote($pageId));
- while (%wobject = $wobjects->hash) {
- $output .= $spacer x $initialDepth. $spacer
- .wobjectIcon()
- .deleteIcon('func=deleteConfirm&wid='.$wobject{wobjectId},$url,WebGUI::International::get(43))
- .editIcon('func=edit&wid='.$wobject{wobjectId},$url)
- .' '. $wobject{title}.'
';
- }
- $wobjects->finish;
- $output .= _traversePageTree($pageId,$initialDepth+1);
- }
- }
- $sth->finish;
- return $output;
-}
-
-#-------------------------------------------------------------------
-=head2 www_cutPage
-
-This will cut the page defined by $session{page}{pageId} (ie. the current page) and all it's
-children from the pagetree and place it on the clipboard.
-
-=cut
-sub www_cutPage {
- my ($page);
- if ($session{page}{isSystem}) {
- return WebGUI::Privilege::vitalComponent();
-
- } elsif (WebGUI::Page::canEdit()) {
- $page = WebGUI::Page->getPage($session{page}{pageId});
- my $parentId = $page->get("parentId") || 1;
- $page->cut;
- WebGUI::Session::refreshPageInfo($parentId);
- return "";
- } else {
- return WebGUI::Privilege::insufficient();
- }
-}
-
-#-------------------------------------------------------------------
-=head2 www_deletePageConfirm
-
-Actually transfers the page to the trash.
-
-=cut
-sub www_deletePageConfirm {
- if ($session{page}{isSystem}) {
- return WebGUI::Privilege::vitalComponent();
- } elsif (WebGUI::Page::canEdit()) {
- my $page = WebGUI::Page->getPage($session{page}{pageId});
- $page->delete;
- WebGUI::Session::refreshPageInfo($session{page}{parentId});
- return "";
- } else {
- return WebGUI::Privilege::insufficient();
- }
-}
-
-#-------------------------------------------------------------------
-=head2 www_editPage
-
-Displays the properties for a page.
-
-=cut
-sub www_editPage {
- my ($f, $endDate, $output, $subtext, $childCount, %hash, %page);
- $session{page}{useAdminStyle} = 1;
- tie %hash, "Tie::IxHash";
- tie %page, "Tie::CPHash";
- if (WebGUI::Page::canEdit($session{form}{npp})) {
- my %tabs;
- tie %tabs, 'Tie::IxHash';
- %tabs = (
- properties=>{
- label=>WebGUI::International::get(103)
- },
- layout=>{
- label=>WebGUI::International::get(105),
- uiLevel=>5
- },
- privileges=>{
- label=>WebGUI::International::get(107),
- uiLevel=>6
- }
- );
- $f = WebGUI::TabForm->new(\%tabs);
- if ($session{form}{npp} ne "") {
- my $buildFromPage = $session{form}{npp};
- if ($buildFromPage eq "0") {
- $buildFromPage = $session{setting}{defaultPage};
- }
- %page = WebGUI::SQL->quickHash("select * from page where pageId=".quote($buildFromPage));
- $page{templateId} = 1;
- $page{pageId} = "new";
- $page{title} = $page{menuTitle} = $page{urlizedTitle} = $page{synopsis} = '';
- $page{parentId} = $session{form}{npp};
- $page{ownerId} = $session{user}{userId};
- $page{hideFromNavigation} = 0;
- $page{newWindow} = 0;
- $page{encryptPage} = 0;
- $page{redirectURL} = "";
- } else {
- %page = %{$session{page}};
- ($childCount) = WebGUI::SQL->quickArray("select count(*) from page where parentId=".quote($page{pageId}));
- }
- $page{endDate} = (addToDate(time(),10)) if ($page{endDate} < 0);
- $output = helpIcon("page add/edit");
- $output .= ''.WebGUI::International::get(102).'
';
- $f->hidden({name=>"pageId",value=>$page{pageId}});
- $f->hidden({name=>"parentId",value=>$page{parentId}});
- $f->hidden({name=>"op",value=>"editPageSave"});
- $f->getTab("properties")->readOnly(
- -value=>$page{pageId},
- -label=>WebGUI::International::get(500),
- -uiLevel=>3
- );
- $f->getTab("properties")->text(
- -name=>"title",
- -label=>WebGUI::International::get(99),
- -value=>$page{title}
- );
- $f->getTab("properties")->text(
- -name=>"menuTitle",
- -label=>WebGUI::International::get(411),
- -value=>$page{menuTitle},
- -uiLevel=>1
- );
- $f->getTab("properties")->yesNo(
- -name=>"hideFromNavigation",
- -value=>$page{hideFromNavigation},
- -label=>WebGUI::International::get(886),
- -uiLevel=>6
- );
- $f->getTab("properties")->yesNo(
- -name=>"newWindow",
- -value=>$page{newWindow},
- -label=>WebGUI::International::get(940),
- -uiLevel=>6
- );
- $f->getTab("properties")->yesNo(
- -name=>"encryptPage",
- -value=>$page{encryptPage},
- -label=>WebGUI::International::get('encrypt page'),
- -uiLevel=>6
- );
- $f->getTab("properties")->text(
- -name=>"urlizedTitle",
- -label=>WebGUI::International::get(104),
- -value=>$page{urlizedTitle},
- -uiLevel=>3
- );
- $f->getTab("properties")->selectList(
- -name=>"languageId",
- -label=>WebGUI::International::get(304),
- -value=>[$page{languageId}],
- -uiLevel=>1,
- -options=>WebGUI::International::getLanguages()
- );
- $f->getTab("properties")->url(
- -name=>"redirectURL",
- -label=>WebGUI::International::get(715),
- -value=>$page{redirectURL},
- -uiLevel=>9
- );
- $f->getTab("properties")->textarea(
- -name=>"synopsis",
- -label=>WebGUI::International::get(412),
- -value=>$page{synopsis},
- -uiLevel=>3
- );
- $f->getTab("properties")->textarea(
- -name=>"metaTags",
- -label=>WebGUI::International::get(100),
- -value=>$page{metaTags},
- -uiLevel=>7
- );
- $f->getTab("properties")->yesNo(
- -name=>"defaultMetaTags",
- -label=>WebGUI::International::get(307),
- -value=>$page{defaultMetaTags},
- -uiLevel=>5
- );
- my @data = WebGUI::DateTime::secondsToInterval($page{cacheTimeout});
- $f->getTab("properties")->interval(
- -name=>"cacheTimeout",
- -label=>WebGUI::International::get(895),
- -intervalValue=>$data[0],
- -unitsValue=>$data[1],
- -uiLevel=>8
- );
- @data = WebGUI::DateTime::secondsToInterval($page{cacheTimeoutVisitor});
- $f->getTab("properties")->interval(
- -name=>"cacheTimeoutVisitor",
- -label=>WebGUI::International::get(896),
- -intervalValue=>$data[0],
- -unitsValue=>$data[1],
- -uiLevel=>8
- );
- $f->getTab("layout")->template(
- -name=>"styleId",
- -label=>WebGUI::International::get(1073),
- -value=>($page{styleId} || 2),
- -namespace=>'style',
- -afterEdit=>'op=editPage&npp='.$session{form}{npp},
- -uiLevel=>5
- );
- $f->getTab("layout")->template(
- -name=>"printableStyleId",
- -label=>WebGUI::International::get(1079),
- -value=>($page{printableStyleId} || 3),
- -namespace=>'style',
- -afterEdit=>'op=editPage&npp='.$session{form}{npp},
- -uiLevel=>5
- );
- if ($childCount) {
- $f->getTab("layout")->yesNo(
- -name=>"recurseStyle",
- -subtext=>' '.WebGUI::International::get(106),
- -uiLevel=>9
- );
- }
- $f->getTab("layout")->readOnly(
- -value=>_selectPositions($page{templateId}),
- -label=>WebGUI::International::get(829),
- -uiLevel=>5
- );
- $f->getTab("privileges")->dateTime(
- -name=>"startDate",
- -label=>WebGUI::International::get(497),
- -value=>$page{startDate},
- -uiLevel=>6
- );
- $f->getTab("privileges")->dateTime(
- -name=>"endDate",
- -label=>WebGUI::International::get(498),
- -value=>$page{endDate},
- -uiLevel=>6
- );
- if (WebGUI::Grouping::isInGroup(3)) {
- $subtext = manageIcon('op=listUsers');
- } else {
- $subtext = "";
- }
- my $clause;
- if (WebGUI::Grouping::isInGroup(3)) {
- my $contentManagers = WebGUI::Grouping::getUsersInGroup(4,1);
- push (@$contentManagers, $session{user}{userId});
- $clause = "userId in (".quoteAndJoin($contentManagers).")";
- } else {
- $clause = "userId=".quote($page{ownerId});
- }
- my $users = WebGUI::SQL->buildHashRef("select userId,username from users where $clause order by username");
- $f->getTab("privileges")->selectList(
- -name=>"ownerId",
- -options=>$users,
- -label=>WebGUI::International::get(108),
- -value=>[$page{ownerId}],
- -subtext=>$subtext,
- -uiLevel=>6
- );
- $f->getTab("privileges")->group(
- -name=>"groupIdView",
- -label=>WebGUI::International::get(872),
- -value=>[$page{groupIdView}],
- -uiLevel=>6
- );
- $f->getTab("privileges")->group(
- -name=>"groupIdEdit",
- -label=>WebGUI::International::get(871),
- -value=>[$page{groupIdEdit}],
- -excludeGroups=>[1,7],
- -uiLevel=>6
- );
- $f->getTab("privileges")->yesNo(
- -name=>"wobjectPrivileges",
- -label=>WebGUI::International::get(1003),
- -value=>$page{wobjectPrivileges},
- -uiLevel=>9
- );
- if ($childCount) {
- $f->getTab("privileges")->yesNo(
- -name=>"recursePrivs",
- -subtext=>' '.WebGUI::International::get(116),
- -uiLevel=>9
- );
- }
- if ($page{pageId} eq "new") {
- $f->getTab("properties")->whatNext(
- -options=>{
- gotoNewPage=>WebGUI::International::get(823),
- backToPage=>WebGUI::International::get(847)
- },
- -value=>"gotoNewPage",
- -uiLevel=>1
- );
- }
- $output .= $f->print;
- return $output;
- } else {
- return WebGUI::Privilege::insufficient();
- }
-}
-
-#-------------------------------------------------------------------
-=head2 www_editPageSave
-
-Stores the data from www_editPage to the database and tree cache.
-
-=cut
-sub www_editPageSave {
- my ($pageId, $currentPage, $page);
-
- if ($session{form}{pageId} eq "new") {
- $pageId = $session{form}{parentId};
- } else {
- $pageId = $session{form}{pageId};
- }
- return WebGUI::Privilege::insufficient() unless (WebGUI::Page::canEdit($pageId));
-
- if ($session{form}{pageId} eq "new") {
- $currentPage = WebGUI::Page->getPage($session{form}{parentId});
- $page = $currentPage->add;
- $page->set({parentId=>$session{form}{parentId}});
- } else {
- $page = WebGUI::Page->getPage($session{form}{pageId});
- }
- $session{form}{title} = "no title" if ($session{form}{title} eq "");
- $session{form}{menuTitle} = $session{form}{title} if ($session{form}{menuTitle} eq "");
- my $url = $session{form}{urlizedTitle};
- $url = $session{form}{menuTitle} if ($url eq "");
- $url .= ".".$session{setting}{urlExtension} unless ($url =~ /\./ && $session{setting}{urlExtension} ne "");
- $url = WebGUI::Page::makeUnique(WebGUI::URL::urlize($url),$session{form}{pageId});
- $page->set({
- title => $session{form}{title},
- styleId => $session{form}{styleId},
- printableStyleId => $session{form}{printableStyleId},
- ownerId => ($session{form}{ownerId} || 3),
- groupIdView => $session{form}{groupIdView},
- groupIdEdit => $session{form}{groupIdEdit},
- newWindow => $session{form}{newWindow},
- encryptPage => $session{form}{encryptPage},
- wobjectPrivileges => $session{form}{wobjectPrivileges},
- hideFromNavigation => $session{form}{hideFromNavigation},
- startDate => WebGUI::FormProcessor::dateTime("startDate"),
- endDate => WebGUI::FormProcessor::dateTime("endDate"),
- cacheTimeout => WebGUI::FormProcessor::interval("cacheTimeout"),
- cacheTimeoutVisitor => WebGUI::FormProcessor::interval("cacheTimeoutVisitor"),
- metaTags => $session{form}{metaTags},
- urlizedTitle => $url,
- redirectURL => $session{form}{redirectURL},
- languageId => $session{form}{languageId},
- defaultMetaTags => $session{form}{defaultMetaTags},
- templateId => $session{form}{templateId},
- menuTitle => $session{form}{menuTitle},
- synopsis => $session{form}{synopsis}
- });
- unless ($session{form}{pageId} eq 'new') {
- WebGUI::SQL->write("update wobject set templatePosition=1 where pageId=".quote($session{form}{pageId})."
- and templatePosition>".WebGUI::Page::countTemplatePositions($session{form}{templateId}));
- }
- _recursivelyChangeProperties($page) if ($session{form}{recursePrivs} || $session{form}{recurseStyle});
- if ($session{form}{proceed} eq "gotoNewPage") {
- WebGUI::Session::refreshPageInfo($page->get('pageId'));
- } elsif ($session{form}{pageId} eq $session{page}{pageId}) {
- WebGUI::Session::refreshPageInfo($session{page}{pageId});
- }
- return "";
-}
-
-#-------------------------------------------------------------------
-
-=head2 www_exportPage
-
-Displays the export page administrative interface
-
-=cut
-
-sub www_exportPage {
- return WebGUI::Privilege::insufficient unless (WebGUI::Grouping::isInGroup(13));
-
- my $output;
- $output .= helpIcon("page export");
- $output .= ''.WebGUI::International::get('Export Page').'
';
- $output .= _checkExportPath();
-
- my $f = WebGUI::HTMLForm->new;
- $f->hidden("op","exportPageStatus");
- $f->integer(
- -label=>WebGUI::International::get('Depth'),
- -name=>"depth",
- -value=>99,
- );
- $f->selectList(
- -label=>WebGUI::International::get('Export as user'),
- -name=>"userId",
- -options=>WebGUI::SQL->buildHashRef("select userId, username from users"),
- -value=>[1],
- );
- tie my %templates, 'Tie::IxHash';
- %templates = ("", WebGUI::International::get(139), %{WebGUI::Template::getList('style')});
- $f->selectList(
- -label=>WebGUI::International::get('Alternate style'),
- -name=>"styleId",
- -options=>\%templates,
- );
- $f->text(
- -label=>WebGUI::International::get('Extras URL'),
- -name=>"extrasURL",
- -value=>$session{config}{extrasURL}
- );
- $f->text(
- -label=>WebGUI::International::get('Uploads URL'),
- -name=>"uploadsURL",
- -value=>$session{config}{uploadsURL}
- );
- $f->submit;
- $output .= $f->print;
- return $output;
-}
-
-#-------------------------------------------------------------------
-
-=head2 www_exportPageStatus
-
-Displays the export status page
-
-=cut
-
-
-sub www_exportPageStatus {
- return WebGUI::Privilege::insufficient unless (WebGUI::Grouping::isInGroup(13));
-
- my $iframeUrl = WebGUI::URL::page('op=exportPageGenerate');
- $iframeUrl = WebGUI::URL::append($iframeUrl, 'depth='.$session{form}{depth});
- $iframeUrl = WebGUI::URL::append($iframeUrl, 'styleId='.$session{form}{styleId});
- $iframeUrl = WebGUI::URL::append($iframeUrl, 'userId='.$session{form}{userId});
- $iframeUrl = WebGUI::URL::append($iframeUrl, 'pageId='.$session{page}{pageId});
- $iframeUrl = WebGUI::URL::append($iframeUrl, 'extrasURL='.$session{form}{extrasURL});
- $iframeUrl = WebGUI::URL::append($iframeUrl, 'uploadsURL='.$session{form}{uploadsURL});
-
-
- my $output;
- $output .= ''.WebGUI::International::get('Page Export Status').'
';
- $output .= '';
-
- return $output;
-}
-
-#-------------------------------------------------------------------
-
-=head2 www_exportPageGenerate
-
-Executes the export process and displays real time status. This operation is displayed
-by exportPageStatus in an IFRAME.
-
-=cut
-
-
-sub www_exportPageGenerate {
- return WebGUI::Privilege::insufficient unless (WebGUI::Grouping::isInGroup(13));
-
- # This routine is called in an IFRAME and prints status output directly to the browser.
- $|++; # Unbuffered data output
- $session{page}{empty} = 1; # Write directly to the browser
-
- print WebGUI::HTTP::getHeader();
-
- my $startTime = time();
- my $error = _checkExportPath();
- if ($error) {
- print $error;
- return;
- }
- my $userId = $session{form}{userId};
- my $styleId = $session{form}{styleId};
- my $extrasURL = $session{form}{extrasURL};
- my $uploadsURL = $session{form}{uploadsURL};
-
- # Get the pages
- my $p = WebGUI::Page->getPage($session{form}{page});
- my @pages = $p->self_and_descendants(depth=>$session{form}{depth});
- unless (@pages) {
- print "There are no pages to export";
- return;
- }
- foreach my $page (@pages) {
- my ($path, $file);
- print "Exporting page ".$page->{urlizedTitle}."......";
-
- # Create path
- $page->{urlizedTitle} =~ /^(.*)\/(.*)$/;
- $path = $1;
- if($path) {
- $path = $session{config}{exportPath} . $session{os}{slash} . $path;
- eval { mkpath($path) };
- if($@) {
- print "Couldn't create $path because $@
\n";
- print "This most likely means that you have a page with the same name as folder that you're trying to create.
\n";
- return;
- }
- }
- # initiate export object
- my $e = WebGUI::Export->new(
- pageId => $page->{pageId},
- userId => $userId || 1,
- styleId => $styleId,
- relativeUrls => 1,
- extrasURL => $extrasURL,
- uploadsURL => $uploadsURL
- );
- # Open file
- $file = $session{config}{exportPath} . $session{os}{slash} . $page->{urlizedTitle};
- eval { open(FILE, "> $file") or die "$!" };
- if ($@) {
- print "Couldn't open $file because $@
\n";
- print "This most likely means that you have created a page with the same name as an existing folder.
\n";
- return;
- } else {
- print FILE $e->generate;
- close(FILE);
- }
-
- print "DONE
";
- }
- print "Exported ".scalar(@pages)." pages in ".(time()-$startTime)." seconds.
";
- print ''.WebGUI::International::get(493).'';
-
- return;
-
-}
-
-#-------------------------------------------------------------------
-sub _checkExportPath {
- my $error;
- if(defined $session{config}{exportPath}) {
- if(-d $session{config}{exportPath}) {
- unless (-w $session{config}{exportPath}) {
- $error .= 'Error: The export path '.$session{config}{exportPath}.' is not writable.
- Make sure that the webserver has permissions to write to that directory';
- }
- } else {
- $error .= 'Error: The export path '.$session{config}{exportPath}.' does not exists.';
- }
- } else {
- $error.= 'Error: The export path is not configured. Please set the exportPath variable in the WebGUI config file';
- }
- $error = ''.$error.'
' if $error;
- return $error;
-}
-
-#-------------------------------------------------------------------
-=head2 www_movePageDown
-
-Moves page down in the context of it's sisters.
-
-=cut
-sub www_movePageDown {
- if (WebGUI::Page::canEdit($session{page}{pageId})) {
- my $page = WebGUI::Page->getPage;
- $page->moveRight;
- return "";
- } else {
- return WebGUI::Privilege::insufficient();
- }
-}
-
-#-------------------------------------------------------------------
-=head2 www_movePageDown
-
-Moves page up in the context of it's sisters.
-
-=cut
-sub www_movePageUp {
- if (WebGUI::Page::canEdit($session{page}{pageId})) {
- my $page = WebGUI::Page->getPage;
- $page->moveLeft;
- return "";
- } else {
- return WebGUI::Privilege::insufficient();
- }
-}
-
-#-------------------------------------------------------------------
-=head2 www_moveTreePageUp
-
-Same as www_movePageUp wit this difference that this module returns the www_viewPageTree method.
-
-=cut
-sub www_moveTreePageUp {
- if (WebGUI::Page::canEdit($session{form}{pageId})) {
- WebGUI::Page->getPage($session{form}{pageId})->moveLeft;
- return www_viewPageTree();
- } else {
- return WebGUI::Privilege::insufficient();
- }
-}
-
-#-------------------------------------------------------------------
-=head2 www_moveTreePageDown
-
-Same as www_movePageDown with this difference that this module returns the www_viewPageTree method.
-
-=cut
-sub www_moveTreePageDown {
- if (WebGUI::Page::canEdit($session{form}{pageId})) {
- WebGUI::Page->getPage($session{form}{pageId})->moveRight;
- return www_viewPageTree();
- } else {
- return WebGUI::Privilege::insufficient();
- }
-}
-
-#-------------------------------------------------------------------
-=head2 www_moveTreePageLeft
-
-Move the page one level left in the tree. In other words, the page is moved up one place in the hierarchy.
-Another way to look at is that the mother of the current page becomes the elder sister of the current page.
-
-=cut
-sub www_moveTreePageLeft {
- if (WebGUI::Page::canEdit($session{form}{pageId})) {
- WebGUI::Page->getPage($session{form}{pageId})->moveUp;
- return www_viewPageTree();
- } else {
- return WebGUI::Privilege::insufficient();
- }
-}
-
-#-------------------------------------------------------------------
-sub www_moveTreePageRight {
- if (WebGUI::Page::canEdit($session{form}{pageId})) {
- WebGUI::Page->getPage($session{form}{pageId})->moveDown;
- return www_viewPageTree();
- } else {
- return WebGUI::Privilege::insufficient();
- }
-}
-
-#-------------------------------------------------------------------
-sub www_pastePage {
- my ($currentPage, $pageToPaste);
- if (WebGUI::Page::canEdit()) {
- $currentPage = WebGUI::Page->getPage($session{page}{pageId});
- $pageToPaste = WebGUI::Page->getPage($session{form}{pageId});
- $pageToPaste->paste($currentPage);
- return "";
- } else {
- return WebGUI::Privilege::insufficient();
- }
-}
-
-#-------------------------------------------------------------------
-sub www_richEditPageTree {
- my (%var,@bad);
- my $namelessroot = WebGUI::Page->new('0');
- foreach my $page ($namelessroot->descendants) {
- my $skipBadPage = 0;
- foreach my $badPage (@bad) {
- if ($page->{nestedSetLeft} > $badPage->{nestedSetLeft} && $page->{nestedSetRight} < $badPage->{nestedSetRight}) {
- $skipBadPage = 1;
- }
- }
- next if ($skipBadPage); # descendant of a page we threw out
- if ($page->{isSystem}) {
- push(@bad,$page);
- next; # throw out system pages
- }
- unless (WebGUI::Page::canView($page)) {
- push(@bad,$page);
- next; # throw out pages we can't view
- }
- push(@{$var{page_loop}},{
- id=>$page->{pageId},
- url=>$page->{urlizedTitle},
- indent=>" " x $page->{depth},
- title=>$page->{title}
- });
- }
- $session{page}{useEmptyStyle} = 1;
- return WebGUI::Template::process(1,"richEditor/pagetree",\%var);
-}
-
-
-#-------------------------------------------------------------------
-sub www_rearrangeWobjects {
- return WebGUI::Privilege::insufficient() unless (WebGUI::Page::canEdit($session{page}{pageId}));
- $session{page}{styleId} = 2;
- my @contentAreas = split(/\./,$session{form}{map});
- my $templatePosition = 1;
- foreach my $position (@contentAreas) {
- my @sequence = split(",",$position);
- my $sequenceNumber = 1;
- foreach my $wobjectId (@sequence) {
- $wobjectId =~ s/td(\d+|\S+)/$1/;
- WebGUI::SQL->setRow("wobject","wobjectId",{
- wobjectId=>$wobjectId,
- sequenceNumber=>$sequenceNumber,
- templatePosition=>$templatePosition
- });
- $sequenceNumber++;
- }
- $templatePosition++;
- }
- return $session{form}{map};
-}
-
-
-#-------------------------------------------------------------------
-=head2 www_viewPageTree
-
-Returns a HTML formatted indented pagetree complete with edit/delete/cut/move buttons
-
-=cut
-sub www_viewPageTree {
- return WebGUI::Privilege::insufficient() unless (WebGUI::Grouping::isInGroup(4));
- my ($output);
- $session{page}{useAdminStyle} = 1;
- $output = ''.WebGUI::International::get(448).'
';
- $output .= _traversePageTree(0,0);
- return $output;
-}
-
-1;
diff --git a/lib/WebGUI/Page.pm b/lib/WebGUI/Page.pm
deleted file mode 100644
index 6014a09a0..000000000
--- a/lib/WebGUI/Page.pm
+++ /dev/null
@@ -1,1583 +0,0 @@
-package WebGUI::Page;
-
-=head1 LEGAL
-
- -------------------------------------------------------------------
- WebGUI is Copyright 2001-2004 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
- -------------------------------------------------------------------
-
-=cut
-
-use HTML::Template;
-use strict;
-use Tie::IxHash;
-use Tie::CPHash;
-use WebGUI::Cache;
-use WebGUI::DateTime;
-use WebGUI::ErrorHandler;
-use WebGUI::Grouping;
-use WebGUI::HTMLForm;
-use WebGUI::HTTP;
-use WebGUI::Icon;
-use WebGUI::Id;
-use WebGUI::Macro;
-use WebGUI::Session;
-use WebGUI::SQL;
-use WebGUI::Style;
-use WebGUI::Template;
-use WebGUI::Utility;
-use DBIx::Tree::NestedSet;
-use WebGUI::MetaData;
-
-our @ISA = qw(DBIx::Tree::NestedSet);
-
-=head1 NAME
-
-Package WebGUI::Page
-
-=head1 DESCRIPTION
-
-This package provides utility functions for WebGUI's page system. Some of these work in a
-non-object oriented fashion. These are utility functions, not affecting the page tree hiearchy.
-
-The methods that do affect or report on this hiearchy should be called in a object oriented context.
-
-=head1 SYNOPSIS
-
-Non OO functions
-
- use WebGUI::Page;
- $boolean = WebGUI::Page::canEdit();
- $boolean = WebGUI::Page::canView();
- $integer = WebGUI::Page::countTemplatePositions($templateId);
- $html = WebGUI::Page::drawTemplate($templateId);
- $html = WebGUI::Page::generate();
- $hashRef = WebGUI::Page::getTemplateList();
- $template = WebGUI::Page::getTemplate();
- $hashRef = WebGUI::Page::getTemplatePositions($templateId);
- $url = WebGUI::Page::makeUnique($url,$pageId);
-
- WebGUI::Page::deCache();
-
-Some OO style methods
-
- use WebGUI::Page;
- $page = WebGUI::Page->getPage($pageId);
- $page = WebGUI::Page->getAnonymousRoot;
- $page = WebGUI::Page->getFirstDaughter($pageId);
- $page = WebGUI::Page->getGrandmother($pageId);
- $page = WebGUI::Page->getLeftSister($pageId);
- $page = WebGUI::Page->getMother($pageId);
- $page = WebGUI::Page->getRightSister($pageId);
- $page = WebGUI::Page->getTop($pageId);
- $page = WebGUI::Page->getWebGUIRoot($pageId);
- $page = WebGUI::Page->new($pageId); # the default constructor
-
- $page->cut;
- $page->delete;
- $page->paste($newMother);
- $page->move($newMother);
- $page->moveDown;
- $page->moveLeft;
- $page->moveRight;
- $page->moveUp;
- $page->purge;
-
- @array = $page->ancestors;
- @array = $page->daughters;
- @array = $page->descendants;
- @array = $page->generation;
- @array = $page->leaves_under;
- @array = $page->pedigree;
- @array = $page->self_and_ancesters;
- @array = $page->self_and_descendants;
- @array = $page->self_and_sisters;
- @array = $page->self_and_sisters_splitted;
- @array = $page->sisters;
-
- $boolean = $page->canMoveDown;
- $boolean = $page->canMoveLeft;
- $boolean = $page->canMoveRight;
- $boolean = $page->canMoveUp;
- $boolean = $page->hasDaughter;
-
- $page->add($otherPageObject,\%properties);
- $page->get("title");
- $page->set(\%properties); # this automatically recaches the pagetree
- $page->setWithoutRecache;
-
- $page->traversePreOrder(&mappingFunction);
-
- $page->recacheNavigation or WebGUI::Page->recacheNavigation;
-
-=head1 SEE ALSO
-
-This class is a sub-class of DBIx::Tree::NestedSet, which is included in your WebGUI distribution. See that for additional details on the page tree.
-
-=head1 METHODS
-
-These functions are available from this package:
-
-=cut
-
-#-------------------------------------------------------------------
-sub _processWobjectFunctions {
- my ($wobject, $output, $proxyWobjectId, $cmd, $w);
- if (exists $session{form}{func} && exists $session{form}{wid}) {
- if ($session{form}{func} =~ /^[A-Za-z]+$/) {
- if ($session{form}{wid} =~ /^[A-Za-z0-9\_\-]+$/) { #valid wobject id
- if ($session{form}{wid} eq "new") {
- $wobject = {wobjectId=>"new",namespace=>$session{form}{namespace},pageId=>$session{page}{pageId}};
- } else {
- $wobject = WebGUI::SQL->quickHashRef("select * from wobject where wobjectId=".quote($session{form}{wid}),WebGUI::SQL->getSlave);
- if (${$wobject}{namespace} eq "") {
- WebGUI::ErrorHandler::warn("Wobject [$session{form}{wid}] appears to be missing or "
- ."corrupt, but was requested "
- ."by $session{user}{username} [$session{user}{userId}].");
- $wobject = ();
- }
- }
- if ($wobject) {
- if (${$wobject}{pageId} ne $session{page}{pageId}) {
- ($proxyWobjectId) = WebGUI::SQL->quickArray("select wobject.wobjectId from
- wobject,WobjectProxy
- where wobject.wobjectId=WobjectProxy.wobjectId
- and wobject.pageId=".quote($session{page}{pageId})."
- and WobjectProxy.proxiedWobjectId=".quote(${$wobject}{wobjectId}),WebGUI::SQL->getSlave);
- ${$wobject}{_WobjectProxy} = $proxyWobjectId;
- }
- unless (${$wobject}{pageId} eq $session{page}{pageId}
- || ${$wobject}{pageId} eq '2'
- || ${$wobject}{pageId} eq '3'
- || ${$wobject}{_WobjectProxy} ne "") {
- $output .= WebGUI::International::get(417);
- WebGUI::ErrorHandler::security("access wobject [".$session{form}{wid}."] on page '"
- .$session{page}{title}."' [".$session{page}{pageId}."].");
- } else {
- if (WebGUI::Page::canView()) {
- $cmd = "WebGUI::Wobject::".${$wobject}{namespace};
- my $load = "use ".$cmd; # gotta load the wobject before you can use it
- eval($load);
- WebGUI::ErrorHandler::warn("Wobject failed to compile: $cmd.".$@) if($@);
- $w = eval{$cmd->new($wobject)};
- WebGUI::ErrorHandler::fatalError("Couldn't instanciate wobject: ${$wobject}{namespace}. Root Cause: ".$@) if($@);
- if ($session{form}{func} =~ /^[A-Za-z]+$/) {
- $cmd = "www_".$session{form}{func};
- $output = eval{$w->$cmd};
- WebGUI::ErrorHandler::fatalError("Wobject runtime error: ${$wobject}{namespace} / $session{form}{func}. Root cause: ".$@) if($@);
- } else {
- WebGUI::ErrorHandler::security("execute an invalid function: ".$session{form}{func});
- }
- } else {
- $output = WebGUI::Privilege::noAccess();
- }
- }
- }
- } else {
- WebGUI::ErrorHandler::security("instanciate a wobject with an invalid wobjectId [".$session{form}{wid}."]");
- }
- } else {
- WebGUI::ErrorHandler::security("execute an invalid function on wobject "
- .$session{form}{wid}.": ".$session{form}{func});
- }
- }
- return $output;
-}
-
-
-#-------------------------------------------------------------------
-
-=head2 add
-
-Adds page to the right of the children of the object this method is invoked
-on. Returns the new page object.
-
-=head3 page
-
-A WebGUI::Page instance to be added to the children of the current object.
-
-=cut
-
-sub add {
- my ($self, $page, $newPageId);
- $self = shift;
-
- $newPageId = WebGUI::Id::generate();
- $self->add_child_to_right(
- pageId =>$self->get('pageId'),
- provided_primary_key => $newPageId,
- parentId=>$self->get('pageId'),
- depth =>($self->get('depth') + 1),
- );
-
- $self->recacheNavigation;
-
- return WebGUI::Page->new($newPageId);
-}
-
-#-------------------------------------------------------------------
-
-=head2 ancestors
-
-Returns an array of hashes containing the properties of the ancestors of the current node.
-
-=cut
-
-sub ancestors {
- my ($self);
- $self = shift;
- return @{$self->get_parents_flat(
- id => $self->get('pageId')
- )};
-}
-
-#-------------------------------------------------------------------
-
-=head2 canEdit ( [ pageId || pageProperties ] )
-
-Returns a boolean (0|1) value signifying that the user has the required privileges.
-
-=head3 pageId
-
-The unique identifier for the page that you wish to check the privileges on. Defaults to the current page id.
-
-You can alternatively pass a hash reference containing the page's properties. This will save a hit to the database.
-
-=cut
-
-sub canEdit {
- my $pageId = shift || $session{page}{pageId};
- my $page;
- if (ref $pageId eq 'HASH') {
- $page = $pageId;
- } elsif ($pageId ne $session{page}{pageId}) {
- $page = WebGUI::SQL->quickHashRef("select ownerId,groupIdEdit from page where pageId=".quote($pageId));
- } else {
- $page = $session{page};
- }
- if ($session{user}{userId} eq $page->{ownerId}) {
- return 1;
- } else {
- return WebGUI::Grouping::isInGroup($page->{groupIdEdit});
- }
-}
-
-#-------------------------------------------------------------------
-
-=head2 canMoveDown
-
-Returns true if the current node can be moved down the tree. Ie. can be made
-a child of it's left sister.
-
-=cut
-
-sub canMoveDown {
- my ($self) = shift;
- return $self->hasLeftSister;
-}
-
-#-------------------------------------------------------------------
-
-=head2 canMoveLeft
-
-Returns true if the current node can be moved left. Ie. if it can swap places
-with it's left sister.
-
-=cut
-
-sub canMoveLeft {
- my ($self, $mother);
- $self = shift;
- $mother = $self->getMother;
-
- return (($self->get('nestedSetLeft') - $mother->get('nestedSetLeft')) > 1);
-}
-
-#-------------------------------------------------------------------
-
-=head2 canMoveRight
-
-Returns true if the current node can be moved rightt. Ie. if it can swap places
-with it's right sister.
-
-=cut
-
-sub canMoveRight {
- my ($self, $mother);
- $self = shift;
- $mother = $self->getMother;
-
- return (($mother->get('nestedSetRight') - $self->get('nestedSetRight')) > 1);
-}
-
-#-------------------------------------------------------------------
-
-=head2 canMoveUp
-
-Returns true if the current node can be moved up the tree. Ie. if it can be
-made a child of it's grandmother.
-
-=cut
-
-sub canMoveUp {
- my ($self) = shift;
- return ($self->get('depth') > 0);
-}
-
-#-------------------------------------------------------------------
-
-=head2 canView ( [ pageId || $pageProperties ] )
-
-Returns a boolean (0|1) value signifying that the user has the required privileges. Always returns users that have the rights to edit this page.
-
-=head3 pageId
-
-The unique identifier for the page that you wish to check the privileges on. Defaults to the current page id.
-
-You can alternatively pass a hash reference of page properties. This will eliminate a hit to the database.
-
-=cut
-
-sub canView {
- my $pageId = shift || $session{page}{pageId};
- my $page;
- if (ref $pageId eq 'HASH') {
- $page = $pageId;
- } elsif ($pageId eq $session{page}{pageId}) {
- $page = $session{page};
- } else {
- $page = WebGUI::SQL->quickHashRef("select ownerId,groupIdEdit,groupIdView,startDate,endDate from page where pageId=".quote($pageId),WebGUI::SQL->getSlave);
- }
- if ($session{user}{userId} eq $page->{ownerId}) {
- return 1;
- } elsif ($page->{startDate} < WebGUI::DateTime::time() && $page->{endDate} > WebGUI::DateTime::time() && WebGUI::Grouping::isInGroup($page->{groupIdView})) {
- return 1;
- } else {
- return canEdit($page);
- }
-}
-
-#-------------------------------------------------------------------
-
-=head2 countTemplatePositions ( templateId )
-
-Returns the number of template positions in the specified page template.
-
-=head3 templateId
-
-The id of the page template you wish to count.
-
-=cut
-
-sub countTemplatePositions {
- my ($template, $i);
- $template = getTemplate($_[0]);
- $i = 1;
- while ($template =~ m/position$i\_loop/) {
- $i++;
- }
- return $i-1;
-}
-
-#-------------------------------------------------------------------
-
-=head2 cut
-
-Cuts the this page object and places it on the clipboard.
-
-=cut
-
-sub cut {
- my ($self, $clipboard, $parentId);
- $self = shift;
- $parentId = $self->get("parentId");
-
- # Place page in clipboard (pageId 2)
- $clipboard = WebGUI::Page->getPage(2);
- if ($self->move($clipboard)) {
- $self->set({
- bufferUserId => $session{user}{userId},
- bufferDate => time,
- bufferPrevId => $parentId,
- });
- }
-
- return $self;
-}
-
-#-------------------------------------------------------------------
-
-=head2 daughters
-
-Returns an array of hashes containing the properties of the daughters of the current node.
-
-=cut
-
-sub daughters {
- my ($self);
- $self = shift;
- return @{$self->get_children_flat(
- id => $self->get('pageId'),
- depth => 1
- )};
-}
-
-#-------------------------------------------------------------------
-
-=head2 deCache ( [ pageId ] )
-
-Deletes the cached version of a specified page. Note that this is something else than the
-cached page tree. This funtion should be invoked in a non-OO context;
-
-=head3 pageId
-
-The id of the page to decache. Defaults to the current page id.
-
-=cut
-
-sub deCache {
- my $cache = WebGUI::Cache->new;
- my $pageId = $_[0] || $session{page}{pageId};
- $cache->deleteByRegex("m/^page_".$pageId."_\\d+\$/");
-}
-
-#-------------------------------------------------------------------
-
-=head2 delete
-
-Deletes this Page object from the tree and places it in the trash. To physically remove
-pages from the tree and the database you should use the purge method.
-
-=cut
-
-sub delete {
- my ($self, $trash, $parentId);
- $self = shift;
- $parentId = $self->get("parentId");
-
- # Place page in trash (pageId 3)
- $trash = WebGUI::Page->getPage(3);
-
- if ($self->move($trash)) {
- $self->set({
- bufferUserId => $session{user}{userId},
- bufferDate => time,
- bufferPrevId => $parentId,
- });
- }
-
- return $self;
-}
-
-#-------------------------------------------------------------------
-
-=head2 descendants
-
-Returns an array of hashes containing the properties of the descendants of the current node.
-
-=cut
-
-sub descendants {
- my ($self);
- $self = shift;
- return @{$self->get_children_flat(
- id => $self->get('pageId')
- )};
-}
-
-#-------------------------------------------------------------------
-
-=head2 drawTemplate ( templateId )
-
-Returns an HTML string containing a small representation of the page template.
-
-=head3 templateId
-
-The id of the page template you wish to draw.
-
-=cut
-
-sub drawTemplate {
- my $template = getTemplate($_[0]);
- $template =~ s/\n//g;
- $template =~ s/\r//g;
- $template =~ s/\'/\\\'/g;
- $template = WebGUI::Macro::negate($template);
- $template =~ s/\.*?\<\/style\>//gi;
- $template =~ s/\.*?\<\/script\>//gi;
- $template =~ s/\/\/ig;
- $template =~ s/\.*?\<\/tmpl\_loop\>/$1/ig;
- $template =~ s/\.*?\<\/tmpl_if\>//ig;
- $template =~ s/\//ig;
- $template =~ s/\<\/tmpl_if\>//ig;
- $template =~ s/\//ig;
- return $template;
-}
-
-#-------------------------------------------------------------------
-
-=head2 generate ( )
-
-Generates the content of the page.
-
-=cut
-
-sub generate {
- return WebGUI::Privilege::noAccess() unless (canView());
- my $output = _processWobjectFunctions();
- return $output if ($output);
- my %var;
- if ($session{page}{defaultMetaTags}) {
- WebGUI::Style::setMeta({'http-equiv'=>"Keywords", name=>"Keywords", content=>join(",",$session{page}{title},$session{page}{menuTitle})});
- WebGUI::Style::setMeta({'http-equiv'=>"Description", name=>"Description", content=>$session{page}{synopsis}}) if ($session{page}{synopsis});
- }
- WebGUI::Style::setRawHeadTags($session{page}{metaTags});
- if ($session{page}{redirectURL} && !$session{var}{adminOn}) {
- WebGUI::HTTP::setRedirect(WebGUI::Macro::process($session{page}{redirectURL}));
- }
- $var{'page.canEdit'} = canEdit();
- $var{'page.controls'} = pageIcon()
- .deleteIcon('op=deletePageConfirm','',WebGUI::International::get(101))
- .editIcon('op=editPage')
- .moveUpIcon('op=movePageUp')
- .moveDownIcon('op=movePageDown')
- .cutIcon('op=cutPage');
- $var{'page.controls'} .= exportIcon('op=exportPage') if defined ($session{config}{exportPath});
- my $sth = WebGUI::SQL->read("select * from wobject where pageId=".quote($session{page}{pageId})." order by sequenceNumber, wobjectId",WebGUI::SQL->getSlave);
- while (my $wobject = $sth->hashRef) {
- my $wobjectToolbar = wobjectIcon()
- .deleteIcon('func=deleteConfirm&wid='.${$wobject}{wobjectId},'',WebGUI::International::get(43))
- .editIcon('func=edit&wid='.${$wobject}{wobjectId})
- .moveUpIcon('func=moveUp&wid='.${$wobject}{wobjectId})
- .moveDownIcon('func=moveDown&wid='.${$wobject}{wobjectId})
- .moveTopIcon('func=moveTop&wid='.${$wobject}{wobjectId})
- .moveBottomIcon('func=moveBottom&wid='.${$wobject}{wobjectId})
- .cutIcon('func=cut&wid='.${$wobject}{wobjectId})
- .copyIcon('func=copy&wid='.${$wobject}{wobjectId});
- if (${$wobject}{namespace} ne "WobjectProxy" && isIn("WobjectProxy",@{$session{config}{wobjects}})) {
- $wobjectToolbar .= shortcutIcon('func=createShortcut&wid='.${$wobject}{wobjectId});
- }
- if (${$wobject}{namespace} eq "WobjectProxy") {
- my $originalWobject = $wobject;
- my ($wobjectProxy) = WebGUI::SQL->quickHashRef("select * from WobjectProxy where wobjectId=".quote(${$wobject}{wobjectId}),WebGUI::SQL->getSlave);
- if($wobjectProxy->{proxyByCriteria}) {
- $wobjectProxy->{proxiedWobjectId} = WebGUI::MetaData::getWobjectByCriteria($wobjectProxy) || $wobjectProxy->{proxiedWobjectId};
- }
- $wobject = WebGUI::SQL->quickHashRef("select * from wobject where wobject.wobjectId=".quote($wobjectProxy->{proxiedWobjectId}),WebGUI::SQL->getSlave);
- if (${$wobject}{namespace} eq "") {
- $wobject = $originalWobject;
- } else {
- ${$wobject}{startDate} = ${$originalWobject}{startDate};
- ${$wobject}{endDate} = ${$originalWobject}{endDate};
- ${$wobject}{templatePosition} = ${$originalWobject}{templatePosition};
- ${$wobject}{_WobjectProxy} = ${$originalWobject}{wobjectId};
- if ($wobjectProxy->{overrideTitle}) {
- ${$wobject}{title} = ${$originalWobject}{title};
- }
- if ($wobjectProxy->{overrideDisplayTitle}) {
- ${$wobject}{displayTitle} = ${$originalWobject}{displayTitle};
- }
- if ($wobjectProxy->{overrideDescription}) {
- ${$wobject}{description} = ${$originalWobject}{description};
- }
- if ($wobjectProxy->{overrideTemplate}) {
- ${$wobject}{templateId} = $wobjectProxy->{proxiedTemplateId};
- }
- my $originalWobjectPage = WebGUI::Page->new($wobject->{pageId});
- $wobject->{'original.page.url'} = WebGUI::URL::gateway($originalWobjectPage->get("urlizedTitle"));
- }
- }
- my $cmd = "WebGUI::Wobject::".${$wobject}{namespace};
- my $load = 'use '.$cmd;
- eval($load);
- WebGUI::ErrorHandler::warn("Wobject failed to compile: $cmd.".$@) if($@);
- my $w = eval{$cmd->new($wobject)};
- WebGUI::ErrorHandler::fatalError("Couldn't instanciate wobject: ${$wobject}{namespace}. Root cause: ".$@) if($@);
- push(@{$var{'position'.$wobject->{templatePosition}.'_loop'}},{
- 'wobject.canView'=>$w->canView,
- 'wobject.canEdit'=>$w->canEdit,
- 'wobject.controls'=>$wobjectToolbar,
- 'wobject.controls.drag'=>dragIcon(),
- 'wobject.namespace'=>$wobject->{namespace},
- 'wobject.id'=>$wobject->{wobjectId},
- 'wobject.isInDateRange'=>$w->inDateRange,
- 'wobject.content'=>eval{$w->www_view}
- });
- WebGUI::ErrorHandler::fatalError("Wobject runtime error: ${$wobject}{namespace}. Root cause: ".$@) if($@);
- }
- $sth->finish;
- return WebGUI::Template::process($session{page}{templateId},"page",\%var);
-}
-
-#-------------------------------------------------------------------
-
-=head2 generation
-
-Returns an array of hashes containing the properties of the same generation as the current node. The
-current node, being a member of it's own generation, is of course included. A generation consists of
-all nodes with the same depth (or level) in the tree.
-
-=cut
-
-sub generation {
- my ($self, $sth, %row, @result);
- $self = shift;
- $sth = WebGUI::SQL->read(
- "select a.*
- from page as a,
- page as b
- where a.depth = b.depth and
- b.pageId = ".quote($self->get('pageId')).
- " order by nestedSetLeft");
-
- while (%row = $sth->hash) {
- push(@result, {(%row)});
- }
-
- return @result;
-}
-
-#-------------------------------------------------------------------
-
-=head2 get( property )
-
-Returns a hash reference of all the page properties.
-
-=head3 property
-
-Returns a scalar containing the value of the specififed proeprty.
-
-=cut
-
-sub get {
- my ($self, $property) = @_;
- if ($property) {
- return $self->{_pageProperties}->{$property};
- }
- return $self->{_pageProperties};
-}
-
-#-------------------------------------------------------------------
-
-=head2 getAnonymousRoot
-
-Returns the 'ueber'-root, the root with pageId 0, the one that holds all WebGUI roots
-together, the node that brings the balance back into the force ;)
-
-Note that this node is only in the database because of design. You cannot put stuff on
-it. Well actually you can, but you don't want to. Trust me. Use it to add WebGUI roots
-or traverse the whole page tree instead .
-
-=cut
-
-sub getAnonymousRoot {
- return WebGUI::Page->new(0);
-}
-
-#-------------------------------------------------------------------
-
-=head2 getFirstDaughter( pageId )
-
-Return the first (leftmost) daughter of the current node when called in instance context,
-returns the first daughter of 'pageId' when called in class context.
-
-=head3 pageId
-
-Only required if called in class context. The pageId of the page of which you want the
-daughter of. Defaults to the current page.
-
-=cut
-
-sub getFirstDaughter {
- my ($self, $pageId, $daughterId, @daughters);
- ($self, $pageId) = @_;
- unless (ref($self)) {
- $self = WebGUI::Page->new($pageId || $session{page}{pageId});
- }
-
- @daughters = $self->daughters;
- return undef unless (scalar(@daughters));
-
- $daughterId = $daughters[0]->{pageId};
-
- return WebGUI::Page->new($daughterId);
-}
-
-#-------------------------------------------------------------------
-
-=head2 getGrandmother( pageId )
-
-Returns the grandmother of the current node, or, when called in class context, the garndmother
-of 'pageId'.
-
-=head3 pageId
-
-Only required if called in class context. The pageId of the page of which you want the
-grandmother of. Defaults to the current page.
-
-=cut
-
-sub getGrandmother {
- my ($self, $pageId, $grannyId);
- ($self, $pageId) = @_;
- unless (ref($self)) {
- $self = WebGUI::Page->new($pageId || $session{page}{pageId});
- }
-
- return undef if ($self->get('depth') < 1);
-
- # We use self and ancestors here because ancestors strips on the wrong side.
- $grannyId = (reverse $self->self_and_ancestors)[2]->{pageId};
- return WebGUI::Page->new($grannyId);
-}
-
-#-------------------------------------------------------------------
-
-=head2 getLeftSister( pageId )
-
-Returns the left sister of the current node, or, when called in class context, the left sister
-of 'pageId'.
-
-=head3 pageId
-
-Only required if called in class context. The pageId of the page of which you want the
-left sister of. Defaults to the current page.
-
-=cut
-
-sub getLeftSister {
- my ($self, $pageId, $leftSisterId);
- ($self, $pageId) = @_;
- unless (ref($self)) {
- $self = WebGUI::Page->new($pageId || $session{page}{pageId});
- }
-
- ($leftSisterId) = WebGUI::SQL->quickArray("select pageId from page where nestedSetRight=".($self->get('nestedSetLeft') - 1));
- return undef unless($leftSisterId);
-
- return WebGUI::Page->new($leftSisterId);
-}
-
-#-------------------------------------------------------------------
-
-=head2 getMother( pageId )
-
-Returns the mother of the current node, or, when called in class context, the left sister
-of 'pageId'.
-
-=head3 pageId
-
-Only required if called in class context. The pageId of the page of which you want the
-mother of. Defaults to the current page.
-
-=cut
-
-
-sub getMother {
- my ($self, $pageId, $mommyId);
- ($self, $pageId) = @_;
- unless (ref($self)) {
- $self = WebGUI::Page->new($pageId || $session{page}{pageId});
- }
-
- return undef if ($self->get('depth') < 0);
-
- # We use self and ancestors here because ancestors strips on the wrong side.
- $mommyId = (reverse $self->self_and_ancestors)[1]->{pageId};
- return WebGUI::Page->new($mommyId);
-}
-
-#-------------------------------------------------------------------
-
-=head2 getPage( pageId )
-
-Returns the page identified by 'pageId'.
-
-=head3 pageId
-
-The pageId of the page you want. Defaults to the current page.
-
-=cut
-
-sub getPage {
- my ($pageId);
- $pageId = $session{page}{pageId};
- $pageId = $_[1] if (defined $_[1]);
-
- return WebGUI::Page->new($pageId);
-}
-
-#-------------------------------------------------------------------
-
-=head2 getRightSister( pageId )
-
-Returns the right sister of the current node, or, when called in class context, the right sister
-of 'pageId'.
-
-=head3 pageId
-
-Only required if called in class context. The pageId of the page of which you want the
-right sister of. Defaults to the current page.
-
-=cut
-
-
-sub getRightSister {
- my ($self,$pageId, $rightSisterId);
- ($self, $pageId) = @_;
- unless (ref($self)) {
- $self = WebGUI::Page->new($pageId || $session{page}{pageId});
- }
-
- ($rightSisterId) = WebGUI::SQL->quickArray("select pageId from page where nestedSetLeft=".($self->get('nestedSetRight') + 1));
- return undef unless(defined $rightSisterId);
-
- return WebGUI::Page->new($rightSisterId);
-}
-
-#-------------------------------------------------------------------
-
-=head2 getTop( pageId )
-
-Returns the top page (child of a WebGUI root, depth = 1) of the current node, or, when called in class
-context, the top of 'pageId'.
-
-=head3 pageId
-
-Only required if called in class context. The pageId of the page of which you want the
-top page of. Defaults to the current page.
-
-=cut
-
-
-sub getTop {
- my ($self, $pageId, $topId);
- ($self, $pageId) = shift;
- unless (ref($self)) {
- $self= WebGUI::Page->new($pageId || $session{page}{pageId});
- }
-
- if ($self->get('depth') == 1) {
- $topId = $self->get('pageId'); #The current page is a top level page
- } elsif ($self->get('depth') > 1) {
- $topId = ($self->self_and_ancestors)[2]->{pageId};
- } else {
- $topId = ($self->daughters)[0]->{pageId};
- }
- return WebGUI::Page->new($topId);
-}
-
-#-------------------------------------------------------------------
-
-=head2 getTemplateList
-
-Returns a hash reference containing template ids and template titles for all the page templates available in the system.
-
-=cut
-
-sub getTemplateList {
- return WebGUI::Template::getList("page");
-}
-
-#-------------------------------------------------------------------
-
-=head2 getTemplate ( [ templateId ] )
-
-Returns an HTML template.
-
-=head3 templateId
-
-The id of the page template you wish to retrieve. Defaults to the current page's template id.
-
-=cut
-
-sub getTemplate {
- my $templateId = shift || $session{page}{templateId};
- my $template = WebGUI::Template::get($templateId,"page");
- return $template->{template};
-}
-
-#-------------------------------------------------------------------
-
-=head2 getTemplatePositions ( templateId )
-
-Returns a hash reference containing the positions available in the specified page template.
-
-=head3 templateId
-
-The id of the page template you wish to retrieve the positions from.
-
-=cut
-
-sub getTemplatePositions {
- my (%hash, $template, $i);
- tie %hash, "Tie::IxHash";
- for ($i=1; $i<=countTemplatePositions($_[0]); $i++) {
- $hash{$i} = $i;
- }
- return \%hash;
-}
-
-#-------------------------------------------------------------------
-
-=head2 getWebGUIRoot( pageId )
-
-Returns the WebGUI root (depth = 0) of the current node, or, when called in class
-context, the WebGUI root of 'pageId'.
-
-=head3 pageId
-
-Only required if called in class context. The pageId of the page of which you want the
-WebGUI root of. Defaults to the current page.
-
-=cut
-
-sub getWebGUIRoot {
- my ($self, $pageId, $rootId);
- ($self, $pageId) = shift;
- unless (ref($self)) {
- $self= WebGUI::Page->new($pageId || $session{page}{pageId});
- }
-
- if ($self->get('depth') == 0) { #The current page is a WebGUI root
- $rootId = $self->get('pageId');
- } elsif ($self->get('depth') > 0) {
- $rootId = ($self->ancestors)[1]->{pageId};
- } else { #There's no root, your tree is broken
- return undef;
- }
-
- return WebGUI::Page->new($rootId);
-}
-
-#-------------------------------------------------------------------
-
-=head2 hasDaughter
-
-Returns true if the page has one or more daughters
-
-=cut
-
-sub hasDaughter {
- my ($self) = shift;
-
- return ($self->get('nestedSetRight') - $self->get('nestedSetLeft') > 1);
-}
-
-#-------------------------------------------------------------------
-
-=head2 leaves_under
-
-Returns an array of hashes containing the properties of all leaves (pages without children)
-under the page
-
-=cut
-
-sub leaves_under {
- my ($self, $sth, %row, @result);
- $self = shift;
- $sth = WebGUI::SQL->read(
- "select a.*
- from page as a,
- page as b
- where (a.nestedSetLeft between b.nestedSetLeft and b.nestedSetRight) and
- (a.nestedSetRight = a.nestedSetLeft + 1)
- b.pageId = ".quote($self->get('pageId')).
- " order by nestedSetLeft");
-
- while (%row = $sth->hash) {
- push(@result, {(%row)});
- }
-
- return @result;
-}
-
-#-------------------------------------------------------------------
-
-=head2 makeUnique ( pageURL, pageId )
-
-Returns a unique page URL.
-
-=head3 url
-
-The URL you're hoping for.
-
-=head3 pageId
-
-The page id of the page you're creating a URL for.
-
-=cut
-
-sub makeUnique {
- my $url = $_[0] || "_1";
- my $pageId = $_[1] || "new";
- my $where;
- unless ($pageId eq "new") {
- $where .= " and pageId<>".quote($pageId);
- }
- my ($test) = WebGUI::SQL->quickArray("select urlizedTitle from page where urlizedTitle=".quote($url).$where);
- if ($test) {
- my @parts = split(/\./,$url);
- if ($parts[0] =~ /(.*)(\d+$)/) {
- $parts[0] = $1.($2+1);
- } elsif ($test ne "") {
- $parts[0] .= "2";
- }
- $url = join(".",@parts);
- $url = makeUnique($url,$pageId);
- }
- return $url;
-}
-
-#-------------------------------------------------------------------
-
-=head2 move( newMother )
-
-Moves a page to another page (ie. makes the page you execute this method on a child of newMother).
-Returns 1 if the move was succesfull, 0 otherwise.
-
-=head3 newMother
-
-The page under which the current page should be moved. This should be an WebGUI::Page object.
-
-=cut
-
-sub move{
- my ($self, $newMother, $parentId, $diff, $diff2, $sql, $depthDiff, $between, $updateRange, $moveNextToMother);
- ($self, $newMother) = @_;
-
- # Avoid cyclic pages. Not doing this will allow people to freeze your computer, by generating infinite loops.
- return 0 if (isIn($self->get('pageId'), map {$_->{pageId}} $newMother->ancestors));
-
- # Make sure a page is not moved to itself.
- return 0 if ($self->get('pageId') eq $newMother->get("pageId"));
-
- # Make sure a page is not moved to it's own mother
- return 0 if ($self->get('parentId') eq $newMother->get('pageId'));
-
- $parentId = $self->get("parentId");
-
- # We move to the right of the children of $newMother.
- $depthDiff = $self->get('depth') - $newMother->get('depth') - 1;
-
- # It is important if the page moves 'up' or 'down' in nestedSetLeft and nestedSetRight value
- if ($self->get('nestedSetLeft') < $newMother->get('nestedSetLeft')) {
- $between = ($self->get('nestedSetRight') + 1)." and ".($newMother->get('nestedSetRight') - 1);
- $updateRange = $self->get('nestedSetLeft')." and ".$newMother->get('nestedSetRight');
- $diff = $self->get('nestedSetRight') - $self->get('nestedSetLeft') + 1;
- $diff2 = $newMother->get('nestedSetRight') - $self->get('nestedSetRight') - 1;
- } else {
- $between = $newMother->get('nestedSetRight')." and ".($self->get('nestedSetLeft') - 1);
- $updateRange = $newMother->get('nestedSetLeft')." and ".($self->get('nestedSetRight')+1);
- $diff = $self->get('nestedSetLeft') - $self->get('nestedSetRight') - 1;
- $diff2 = $newMother->get('nestedSetRight') - $self->get('nestedSetLeft');
- }
-
-
- # Set the new depth
- WebGUI::SQL->write("update page set depth=depth - $depthDiff where nestedSetLeft between ".$self->get('nestedSetLeft')." and ".$self->get('nestedSetRight'));
-
- # Do the magic: cast move on tree
- $sql = "
- update page set
- nestedSetLeft = case
- when nestedSetLeft between ". $self->get('nestedSetLeft')." and ".$self->get('nestedSetRight')."
- then nestedSetLeft + $diff2
- when nestedSetLeft between ". $between ."
- then nestedSetLeft - $diff
- else
- nestedSetLeft
- end,
- nestedSetRight = case
- when nestedSetRight between ". $self->get('nestedSetLeft') ." and ". $self->get('nestedSetRight') ."
- then nestedSetRight + $diff2
- when nestedSetRight between ". $between ."
- then nestedSetRight - $diff
- else
- nestedSetRight
- end
- where
- nestedSetRight between $updateRange or
- nestedSetLeft between $updateRange";
-
- WebGUI::SQL->write($sql);
-
- # Set the parentId to the right node.
- WebGUI::SQL->write("update page set parentId=".quote($newMother->get('pageId'))." where pageId=".quote($self->get('pageId')));
-
- WebGUI::Page->recacheNavigation;
-
- return 1;
-}
-
-#-------------------------------------------------------------------
-
-=head2 moveDown
-
-Moves the page down the tree. Ie. makes the page a daughter of it's left sister.
-
-=cut
-
-sub moveDown {
- my ($self, $leftSister);
- $self = shift;
-
- $leftSister = $self->getLeftSister;
- return 0 unless (defined $leftSister);
-
- $self->move($leftSister);
- return 1;
-}
-
-#-------------------------------------------------------------------
-
-=head2 moveLeft
-
-Move the page to the left. Ie. swaps places with it's left sister.
-
-=cut
-
-sub moveLeft {
- my ($self, $leftSister);
- $self = shift;
-
- $leftSister = $self->getLeftSister;
- return 0 unless (defined $leftSister);
-
- $self->swap_nodes(
- first_id => $self->get('pageId'),
- second_id => $leftSister->get('pageId')
- );
-
- WebGUI::Page->recacheNavigation;
- return 1;
-}
-
-#-------------------------------------------------------------------
-
-=head2 moveRight
-
-Move the page to the right. Ie. swaps places with it's right sister.
-
-=cut
-
-sub moveRight {
- my ($self, $rightSister);
- $self = shift;
-
- $rightSister = $self->getRightSister;
- return 0 unless (defined $rightSister);
-
- $self->swap_nodes(
- first_id => $self->get('pageId'),
- second_id => $rightSister->get('pageId')
- );
-
- WebGUI::Page->recacheNavigation;
- return 1;
-}
-
-#-------------------------------------------------------------------
-
-=head2 moveUp
-
-Moves the page up the tree. Ie. makes the page the right sister of it's mother.
-
-=cut
-
-sub moveUp {
- my ($self, $mother, $diff, $diff2, $sql);
- $self = shift;
-
- $mother = $self->getMother;
-
- # Don't move to an nonexistent node;
- return 0 if (!defined $mother);
-
- # Don't allow to move up if node is already a webguiroot;
- return 0 if ($mother->get('pageId') eq "0");
-
- # Update depth, we do this before the move because now we know the nestedSetRight range of nodes
- # that change in depth.
- WebGUI::SQL->write("update page set depth=depth-1 where nestedSetRight between ".$self->get('nestedSetLeft')." and ".$self->get('nestedSetRight'));
-
- # Do some movement magic!
- $diff = $self->get('nestedSetRight') - $self->get('nestedSetLeft') + 1;
- $diff2 = $mother->get('nestedSetRight') - $self->get('nestedSetRight');
- $sql = "
- update page set
- nestedSetLeft = case
- when nestedSetLeft between ". $self->get('nestedSetLeft')." and ".$self->get('nestedSetRight')."
- then nestedSetLeft + $diff2
- when nestedSetLeft between ". ($self->get('nestedSetRight') + 1) ." and ". $mother->get('nestedSetRight') ."
- then nestedSetLeft - $diff
- else
- nestedSetLeft
- end,
- nestedSetRight = case
- when nestedSetRight between ". $self->get('nestedSetLeft') ." and ". $self->get('nestedSetRight') ."
- then nestedSetRight + $diff2
- when nestedSetRight between ". ($self->get('nestedSetRight') + 1) ." and ". $mother->get('nestedSetRight') ."
- then nestedSetRight - $diff
- else
- nestedSetRight
- end,
- parentId = case pageId
- when ". quote($self->get('pageId')) ."
- then ". quote($mother->get('parentId'))."
- else
- parentId
- end
- where
- nestedSetRight between ". $self->get('nestedSetLeft') ." and ". $mother->get('nestedSetRight')." or
- nestedSetLeft between ". $self->get('nestedSetLeft') ." and ". $mother->get('nestedSetRight');
-
- WebGUI::SQL->write($sql);
-
- WebGUI::Page->recacheNavigation;
-
- return 1;
-}
-
-#-------------------------------------------------------------------
-
-=head2 new ( pageId || { properties } )
-
-Creates a new page object. You can't create pages in the database with this, though. Use add instead.
-
-If called without arguments it' fetches the current page (the one in $session{page}{pageId}) from the database
-and returns an WebGUI::Page object of it.
-
-You can pass one argument. This can be either a pageId of another page than the current you want, or a hashref
-containing page properties. You can use the latter if you already have page properties (returned by ancestors or
-something like it for example), and save a (redundant) database query. You can of course also use it to fool the
-system with dummy pages and do all kinds of magic that I can't imagine with it.
-
-=head3 pageId || { properties }
-
-You can pass either a pageId or a properties hashref. See above for an explanation
-
-=cut
-
-sub new {
- my ($class, $self, $properties);
- ($class, $properties) = @_;
- $self = $_[0]->SUPER::new(
- table_name => 'page',
- left_column_name => 'nestedSetLeft',
- right_column_name => 'nestedSetRight',
- id_name => 'pageId',
- dbh => $session{dbh},
- no_alter_table => 1,
- no_locking => 1,
- no_id_creation => 1,
- );
- unless (ref($properties)) {
- $properties = WebGUI::SQL->quickHashRef("select * from page where pageId=".quote($_[1]));
- }
-
- return undef unless (defined $properties->{pageId});
- $self->{_pageProperties} = $properties;
- return $self;
-}
-
-#-------------------------------------------------------------------
-
-=head2 paste( newMother )
-
-Pastes a page under newMother.
-
-=head3 newMother
-
-The page under which the current page should be pasted. This should be an WebGUI::Page object.
-
-=cut
-
-sub paste{
- my ($self, $newMother);
- ($self, $newMother) = @_;
-
- # You do not want to paste a page onto itself, believe me.
- return $self if ($self->get("pageId") eq $newMother->get("pageId"));
- return WebGUI::ErrorHandler::fatalError("You cannot paste a page that's not on the clipboard. parentId:".
- $self->get("parentId").", pageId:".$self->get("pageId")) unless ($self->get("parentId") eq "2");
-
- # Place page in clipboard (pageId 2)
- if ($self->move($newMother)) {
- $self->set({
- bufferUserId => 'NULL',
- bufferDate => 'NULL',
- bufferPrevId => 'NULL'
- });
- }
-
- return $self;
-}
-
-#-------------------------------------------------------------------
-
-=head2 pedigree
-
-Ok, this does something funky. It returns an array of hashes containing page properties of the mothers of
-the page and their daughter, the page itself and it's daugthers. It used for the flexmenu.
-
-=cut
-
-sub pedigree {
- my ($self, $leftSisters, $currentPage, $rightSisters, @flexMenu, $node);
- $self = shift;
-
- ($leftSisters, $currentPage, $rightSisters) = $self->self_and_sisters_splitted;
- @flexMenu = (@{$leftSisters}, {%{$currentPage}}, $self->daughters, @{$rightSisters});
- while (defined($self=$self->getMother) && ref($self)) {
- ($leftSisters, $currentPage, $rightSisters) = $self->self_and_sisters_splitted;
- @flexMenu = (@{$leftSisters}, {%{$currentPage}}, @flexMenu, @{$rightSisters});
- }
- return @flexMenu;
-}
-
-#-------------------------------------------------------------------
-
-=head2 purge
-
-This purges this object and all it's children from the tree and the database.
-
-=cut
-
-sub purge {
- my ($self);
- $self = shift;
-
- $self->delete_self_and_children(
- id => $self->get('pageId')
- );
-
- WebGUI::Page->recacheNavigation;
-
- return "";
-}
-
-#-------------------------------------------------------------------
-
-=head2 recacheNavigation
-
-Actually this doesn't recache anything, but it might be in the future. Hence the name. Currently
-it purges all Navigation cache objects. You should call it if you changed the pagetree. Note that
-the methods in this module that modify the tree already call this.
-
-If you only change some navigation properties of a navigation element, you should use a more restricted
-cache purge.
-
-=cut
-
-sub recacheNavigation {
- WebGUI::Cache->new("", "Navigation-".$session{config}{configFile})->deleteByRegex(".*");
- return "";
-}
-
-
-#-------------------------------------------------------------------
-
-=head2 self_and_ancestors
-
-Returns an array of hashrefs containing the page properties of this node and it's ancestors.
-
-=cut
-
-sub self_and_ancestors {
- my ($self);
- $self = shift;
- return @{$self->get_self_and_parents_flat(
- id => $self->get('pageId')
- )};
-}
-
-#-------------------------------------------------------------------
-
-=head2 self_and_descendants
-
-Returns an array of hashrefs containing the page properties of this node and it's descendants.
-
-=cut
-
-
-sub self_and_descendants {
- my ($self);
- $self = shift;
- my @options = @_;
- return @{$self->get_self_and_children_flat(
- id => $self->get('pageId'),
- @options
- )};
-}
-
-#-------------------------------------------------------------------
-
-=head2 self_and_sisters
-
-Returns an array of hashrefs containing the page properties of this node and it's sisters.
-
-=cut
-
-sub self_and_sisters {
- my ($self, $sth, %row, @result);
- $self = shift;
- tie %row,'Tie::CPHash';
- $sth = WebGUI::SQL->read(
- "select a.*
- from page as a,
- page as b
- where a.parentId = b.parentId and
- b.pageId = ".quote($self->get('pageId')).
- " order by nestedSetLeft");
- while (%row = $sth->hash) {
- push(@result, {(%row)});
- }
-
- return @result;
-}
-
-#-------------------------------------------------------------------
-
-=head2 self_and_sisters_splitted
-
-Returns an array with the following contents:
-
- - [ leftSisters ] an arrayref of hashref containing the properties of the left sisters of the page.
- - $currentPage an hashref containing the page properties of this node
- - [ rightsister ] an arrayref of hashref containing the properties of the right sisters of the page.
-
-=cut
-
-sub self_and_sisters_splitted {
- my ($self, $haveAllLeftSisters, $currentPage, @leftSisters, @rightSisters);
- $self = shift;
-
- $haveAllLeftSisters = 0;
- foreach ($self->self_and_sisters) {
- if ($_->{pageId} eq $self->get('pageId')) {
- $currentPage = $_;
- $haveAllLeftSisters = 1;
- } elsif ($haveAllLeftSisters) {
- push (@rightSisters, $_);
- } else {
- push (@leftSisters, $_);
- }
- }
-
- return (\@leftSisters, $currentPage, \@rightSisters);
-}
-
-#-------------------------------------------------------------------
-
-=head2 sisters
-
-Returns an array of hashrefs containing the page properties of this nodes sisters. The node not included.
-
-=cut
-
-sub sisters {
- my ($self, $sth, %row, @result);
- $self = shift;
- $sth = WebGUI::SQL->read(
- "select a.*
- from page as a,
- page as b
- where a.pageId !=".quote($self->get('pageId'))." and
- a.parentId = b.parentId and b.pageId = ".quote($self->get('pageId')).
- " order by nestedSetLeft");
- while (%row = $sth->hash) {
- push(@result, {(%row)});
- }
-
- return @result;
-}
-
-#-------------------------------------------------------------------
-
-=head2 set ( { properties } )
-
-If data is given, invoking this method will set the object to the state given in data. If called without any arguments
-the state of the tree is saved to the database.
-
-This method purges the Navigation cache. Note that if you have to save a lot of properties in row, it's better to use
-setWithoutRecache, and call recacheNavigation manually. This saves some time.
-
-=head3 properties
-
-The properties you want to set. This parameter is optional and should be a hashref of the form {propertyA => valueA, propertyB => valueB, etc...}
-
-=cut
-
-sub set {
- my ($self, $properties);
- ($self, $properties) = @_;
-
- $self->setWithoutRecache($properties);
- WebGUI::Page->recacheNavigation;
-
- return "";
-}
-
-#-------------------------------------------------------------------
-
-=head2 setWithoutRecache ( { properties } )
-
-See set. The only difference with set is that the cached version of the pagetree is not updated. This means that you must
-update it manually by invoking recachePageTree afterwards.
-
-=head3 properties
-
-The properties you want to set. This parameter is optional and should be a hashref of the form {propertyA => valueA, propertyB => valueB, etc...}
-
-=cut
-
-sub setWithoutRecache {
- my ($self, $properties);
- ($self, $properties) = @_;
-
- $properties = $self->{_properties} unless ($properties);
-
- if (scalar(keys(%{$properties}))) {
- WebGUI::SQL->write("update page set ".join(', ', map {"$_=".quote($properties->{$_})} keys %{$properties})." where pageId=".quote($self->get('pageId')));
- }
-
- return "";
-}
-
-#-------------------------------------------------------------------
-
-=head2 traversePreOrder ( &mappingFunction )
-
-Traverses the tree from this node down in pre-order fashion and excutes (maps) the mapping function
-onto each node. Also maps onto this node except if it is the anonymous root. This has some but very limited
-compatibility with the callback property of the walk_down method of Tree::DAG_Node.
-
-=head3 mappingFunction
-
-This should be a coderef pointing to your mapping function. The arguments that are passed to this function are
-a page object and a hashref containing only _depth for now.
-
-=cut
-
-sub traversePreOrder {
- my ($self, $mappingFunction, $initialDepth, $page, @pages);
- ($self, $mappingFunction, $initialDepth) = @_;
-
- @pages = $self->self_and_descendants;
- # The 'ueber'-root contains no data so we do not want to return i!
- shift @pages if ($pages[0]->{'pageId'} eq '0');
- foreach (@pages) {
- $page = WebGUI::Page->new($_->{'pageId'});
- &$mappingFunction($page, {_depth=>$page->get('depth')});
- }
- return @pages;
-}
-
-1;
diff --git a/lib/WebGUI/i18n/English/WebGUI.pm b/lib/WebGUI/i18n/English/WebGUI.pm
index a2f8a4828..cfdb2ca1a 100644
--- a/lib/WebGUI/i18n/English/WebGUI.pm
+++ b/lib/WebGUI/i18n/English/WebGUI.pm
@@ -450,11 +450,6 @@ The URL of the web site for this theme's designer. If you are in the business of
lastUpdated => 1031514049
},
- '101' => {
- message => q|Are you certain that you wish to delete this page, its content, and all items under it?|,
- lastUpdated => 1031514049
- },
-
'340' => {
message => q|Female|,
lastUpdated => 1031514049
@@ -578,11 +573,6 @@ The URL of the web site for this theme's designer. If you are in the business of
lastUpdated => 1031514049
},
- '715' => {
- message => q|Redirect URL|,
- lastUpdated => 1031514049
- },
-
'23' => {
message => q|September|,
lastUpdated => 1031514049
@@ -1343,11 +1333,6 @@ How should this user be notified when they get a new WebGUI message?
lastUpdated => 1031514049
},
- '417' => {
- message => q|Security Violation
You attempted to access a wobject not associated with this page. This incident has been reported.|,
- lastUpdated => 1031514049
- },
-
'12' => {
message => q|Turn admin off.|,
lastUpdated => 1031514049
@@ -1426,11 +1411,6 @@ As with any delete operation, you are prompted to be sure you wish to proceed wi
lastUpdated => 1031514049
},
- '116' => {
- message => q|Select "Yes" to change the privileges of all pages and wobjects under this page to these privileges.|,
- lastUpdated => 1056054674
- },
-
'144' => {
message => q|View statistics.|,
lastUpdated => 1031514049
@@ -1441,11 +1421,6 @@ As with any delete operation, you are prompted to be sure you wish to proceed wi
lastUpdated => 1050232286
},
- '100' => {
- message => q|Meta Tags|,
- lastUpdated => 1031514049
- },
-
'965' => {
message => q|System Trash|,
lastUpdated => 1099050265
@@ -2306,11 +2281,6 @@ will be modified to make it unique.|,
lastUpdated => 1044138730
},
- '500' => {
- message => q|Page ID|,
- lastUpdated => 1031514049
- },
-
'533' => {
message => q|without the words|,
lastUpdated => 1031514049
@@ -2993,11 +2963,6 @@ If this wobject is a shortcut, then this URL will direct you to the original wob
lastUpdated => 1031514049
},
- '102' => {
- message => q|Edit Page|,
- lastUpdated => 1031514049
- },
-
'565' => {
message => q|Who can moderate?|,
lastUpdated => 1031514049
@@ -3656,11 +3621,6 @@ Large sites using external group data will be making many calls to the external
lastUpdated => 1052850265
},
- '307' => {
- message => q|Use default meta tags?|,
- lastUpdated => 1031514049
- },
-
'314' => {
message => q|First Name|,
lastUpdated => 1031514049
@@ -4324,11 +4284,6 @@ div.tabs {
lastUpdated => 1099434667
},
- '103' => {
- message => q|Page Properties|,
- lastUpdated => 1046638742
- },
-
'922' => {
message => q|Created With|,
lastUpdated => 1050262917
@@ -5152,11 +5107,6 @@ Macros always begin with a caret (^) and follow with at least one other char
lastUpdated => 1031514049
},
- '829' => {
- message => q|Page Template|,
- lastUpdated => 1038870260
- },
-
'345' => {
message => q|Not A Member|,
lastUpdated => 1031514049
@@ -5435,11 +5385,6 @@ Privileges and styles assigned to pages in the package will not be copied when t
lastUpdated => 1031514049
},
- '448' => {
- message => q|Page Tree|,
- lastUpdated => 1031514049
- },
-
'357' => {
message => q|News|,
lastUpdated => 1031514049
@@ -5546,11 +5491,6 @@ Privileges and styles assigned to pages in the package will not be copied when t
context => q|Title of the user manager for the admin console.|
},
- '304' => {
- message => q|Language|,
- lastUpdated => 1031514049
- },
-
'406' => {
message => q|Thumbnail Size|,
lastUpdated => 1031514049