diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index be50a8f71..024a6fa24 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -1,7 +1,7 @@ 6.3.0 - Migrated all wobjects to assets. - Migrated pages to the layout and redirect assets. - - Converted site maps to navigation macros. + - Converted site maps to navigation assets. - Converted file managers to layout assets with file and image assets attached. - Converted page templates to use CSS-based layouts instead of tables. diff --git a/docs/gotcha.txt b/docs/gotcha.txt index 0c276ac64..b857215e5 100644 --- a/docs/gotcha.txt +++ b/docs/gotcha.txt @@ -22,14 +22,15 @@ save you many hours of grief. need to download and upgrade to 5.5.x before you can upgrade to 6.3 or higher. - * All Site Map wobjects will be migrated to Navigation macros in - Articles during the upgrade. All the site map templates will + * All Site Map wobjects will be migrated to Navigation assets + during the upgrade. All the site map templates will be lost. If you want them, save them before the upgrade. Also check your site after the upgrade for all site maps to make sure that they look the way you want them to look. * All File Manager wobjects have been migrated to File Folder Layout - assets. + assets. The File Manager templates will be deleted during the + upgrade, so if you want to keep yours, get them before upgrading. * If you have any SQL reports querying internal WebGUI database tables, you'll need to update them after the upgrade. Most of WebGUI's diff --git a/docs/upgrades/upgrade_6.2.9-6.3.0.pl b/docs/upgrades/upgrade_6.2.9-6.3.0.pl index 76fdc0d5d..aabe3b09a 100644 --- a/docs/upgrades/upgrade_6.2.9-6.3.0.pl +++ b/docs/upgrades/upgrade_6.2.9-6.3.0.pl @@ -92,17 +92,17 @@ while (my ($namespace) = $sth->array) { $sth->finish; walkTree('0','PBasset000000000000001','000001','1'); print "\t\tMaking second round of table structure changes\n" unless ($quiet); -WebGUI::SQL->write("drop table SiteMap"); -WebGUI::SQL->write("delete from template where namespace in ('SiteMap')"); my $sth = WebGUI::SQL->read("select distinct(namespace) from wobject where namespace is not null"); while (my ($namespace) = $sth->array) { if (isIn($namespace, qw(Article DataForm EventsCalendar HttpProxy IndexedSearch MessageBoard Poll Product SQLReport Survey SyndicatedContent USS WobjectProxy WSClient))) { WebGUI::SQL->write("alter table ".$namespace." drop column wobjectId"); + WebGUI::SQL->write("alter table ".$namespace." add primary key (assetId)"); + } elsif (isIn($namespace, qw(Navigation Layout))) { + # do nothing } else { WebGUI::SQL->write("alter table ".$namespace." drop primary key"); + WebGUI::SQL->write("alter table ".$namespace." add primary key (assetId)"); } - - WebGUI::SQL->write("alter table ".$namespace." add primary key (assetId)"); } $sth->finish; WebGUI::SQL->write("alter table wobject drop column wobjectId"); @@ -132,10 +132,14 @@ WebGUI::SQL->write("alter table wobject drop column editedBy"); WebGUI::SQL->write("alter table wobject drop column lastEdited"); WebGUI::SQL->write("alter table wobject drop column allowDiscussion"); WebGUI::SQL->write("drop table page"); +WebGUI::SQL->write("drop table FileManager"); +WebGUI::SQL->write("drop table FileManager_file"); +WebGUI::SQL->write("delete from template where namespace in ('FileManager')"); +WebGUI::SQL->write("drop table SiteMap"); +WebGUI::SQL->write("delete from template where namespace in ('SiteMap')"); WebGUI::SQL->write("alter table Article drop column image"); WebGUI::SQL->write("alter table Article drop column attachment"); - my %migration; print "\tConverting navigation system to asset tree\n" unless ($quiet); @@ -259,6 +263,39 @@ WebGUI::SQL->write("update Navigation set startPoint='root' where startPoint='na WebGUI::SQL->write("drop table tempoldnav"); +print "\tConverting navigation templates\n" unless ($quiet); +my $sth = WebGUI::SQL->read("select templateId, template from template where namespace='Navigation'"); +while (my ($id, $template) = $sth->array) { + $template =~ s/isBasePage/isCurrent/isg; + $template =~ s/basePage/currentPage/isg; + $template =~ s/isRoot/isBranchRoot/isg; + $template =~ s/inRoot/inBranchRoot/isg; + $template =~ s/urlizedTitle/url/isg; + $template =~ s/ownerId/ownerUserId/isg; + $template =~ s/isTop/isTopOfBranch/isg; + $template =~ s/isDaughter/isChild/isg; + $template =~ s/isMother/isParent/isg; + $template =~ s/isSister/isSibling/isg; + $template =~ s/isLeftMost/isRankedFirst/isg; + $template =~ s/isRightMost/isRankedLast/isg; + $template =~ s/hasDaughter/hasChild/isg; + $template =~ s/mother/parent/isg; + $template =~ s/config\.button/controls/isg; + $template =~ s/pageId/assetId/isg; + $template = ' + +

+
+ +

+
+ '.$template; + WebGUI::SQL->write("update template set template=".quote($template)." where templateId=".quote($id)." and namespace='Navigation'"); +} +$sth->finish; + + + print "\tDeleting files which are no longer used.\n" unless ($quiet); #unlink("../../lib/WebGUI/Page.pm"); #unlink("../../lib/WebGUI/Operation/Page.pm"); @@ -310,10 +347,10 @@ sub walkTree { WebGUI::SQL->write("insert into redirect (assetId, redirectUrl) values (".quote($pageId).",".quote($page->{redirectURL}).")"); } else { WebGUI::SQL->write("insert into wobject (assetId, styleTemplateId, templateId, printableStyleTemplateId, - cacheTimeout, cacheTimeoutVisitor, displayTitle) values ( + cacheTimeout, cacheTimeoutVisitor, displayTitle, namespace) values ( ".quote($pageId).", ".quote($page->{styleId}).", ".quote($page->{templateId}).", ".quote($page->{printableStyleId}).", ".quote($page->{cacheTimeout}).",".quote($page->{cacheTimeoutVisitor}).", - 0)"); + 0,'Layout')"); WebGUI::SQL->write("insert into layout (assetId) values (".quote($pageId).")"); } my $rank = 1; @@ -399,7 +436,7 @@ sub walkTree { print "\t\t\tConverting File Manager ".$wobject->{wobjectId}." into File Folder Layout\n" unless ($quiet); WebGUI::SQL->write("update asset set className='WebGUI::Asset::Layout' where assetId=".quote($wobjectId)); WebGUI::SQL->write("insert into layout (assetId) values (".quote($wobjectId).")"); - WebGUI::SQL->write("update wobject set templateId='15' where wobjectId=".quote($wobjectId)); + WebGUI::SQL->write("update wobject set templateId='15', namespace='Layout' where wobjectId=".quote($wobjectId)); print "\t\t\tMigrating attachments for File Manager ".$wobject->{wobjectId}."\n" unless ($quiet); my $sth = WebGUI::SQL->read("select * from FileManager_file where wobjectId=".quote($wobjectId)." order by sequenceNumber"); my $rank = 1; @@ -556,10 +593,6 @@ sub getNewId { 'MessageBoard' => { '1' => 'PBtmpl0000000000000047' }, - 'FileManager' => { - '1' => 'PBtmpl0000000000000025', - '2' => 'PBtmpl0000000000000087' - }, 'Operation/Profile/View' => { '1' => 'PBtmpl0000000000000052' }, @@ -820,7 +853,6 @@ sub getNewId { } }, 'nav' => { - '1002' => 'PBnav00000000000000005', '11' => 'PBnav00000000000000006', '7' => 'PBnav00000000000000019', '2' => 'PBnav00000000000000014', @@ -829,18 +861,14 @@ sub getNewId { '18' => 'PBnav00000000000000013', '16' => 'PBnav00000000000000011', '13' => 'PBnav00000000000000008', - 'iBkcoHUb-z4vzYPyX0oS5A' => 'PBnav00000000000000023', '6' => 'PBnav00000000000000018', - 'b3XBaWXeMXS39HPDfV2y5Q' => 'PBnav00000000000000022', '3' => 'PBnav00000000000000015', '9' => 'PBnav00000000000000021', '12' => 'PBnav00000000000000007', '14' => 'PBnav00000000000000009', '15' => 'PBnav00000000000000010', '8' => 'PBnav00000000000000020', - '1001' => 'PBnav00000000000000004', '4' => 'PBnav00000000000000016', - '1000' => 'PBnav00000000000000003', '10' => 'PBnav00000000000000002', '5' => 'PBnav00000000000000017' } diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 54351b6e5..56b80f45d 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -26,6 +26,7 @@ sub addChild { my $properties = shift; my $id = WebGUI::Id::generate(); my $lineage = $self->get("lineage").$self->getNextChildRank; + $self->{_hasChildren} = 1; WebGUI::SQL->beginTransaction; WebGUI::SQL->write("insert into asset (assetId, parentId, lineage, state, className, url, startDate, endDate) values (".quote($id).",".quote($self->getId).", ".quote($lineage).", @@ -148,6 +149,14 @@ sub demote { } } +sub DESTROY { + my $self = shift; + $self->{_parent}->DESTROY if (exists $self->{_parent}); + $self->{_firstChild}->DESTROY if (exists $self->{_firstChild}); + $self->{_lastChild}->DESTROY if (exists $self->{_lastChild}); + $self = undef; +} + sub duplicate { my $self = shift; my $newAsset = $self->addChild($self->get); @@ -357,10 +366,13 @@ sub getEditForm { } -sub getFirstDescendant { +sub getFirstChild { my $self = shift; - $self->{_firstDescendant} = WebGUI::Asset->newByLineage($self->get("lineage").$self->formatRank(1)) unless (exists $self->{_firstDescendant}); - return $self->{_firstDescendant}; + unless (exists $self->{_firstChild}) { + my ($lineage) = WebGUI::SQL->quickArray("select min(lineage) from asset where parentId=".quote($self->getId)); + $self->{_firstChild} = WebGUI::Asset->newByLineage($lineage); + } + return $self->{_firstChild}; } sub getIcon { @@ -389,11 +401,21 @@ sub getIndexerParams { } +sub getLastChild { + my $self = shift; + unless (exists $self->{_lastChild}) { + my ($lineage) = WebGUI::SQL->quickArray("select max(lineage) from asset where parentId=".quote($self->getId)); + $self->{_lastChild} = WebGUI::Asset->newByLineage($lineage); + } + return $self->{_lastChild}; +} + sub getLineage { my $self = shift; my $relatives = shift; my $rules = shift; my $lineage = $self->get("lineage"); + # deal with exclusions my $whereExclusion = " and state='published'"; if (exists $rules->{excludeClasses}) { my @set; @@ -402,10 +424,12 @@ sub getLineage { } $whereExclusion .= 'and ('.join(" and ",@set).')'; } + # let's get those siblings my $whereSiblings; if (isIn("siblings",@{$relatives})) { $whereSiblings = "(parentId=".quote($self->get("parentId"))." and assetId<>".quote($self->getId).")"; } + # ancestors too my @specificFamilyMembers = (); if (isIn("ancestors",@{$relatives})) { my @familyTree = ($lineage =~ /(.{6})/g); @@ -413,6 +437,7 @@ sub getLineage { push(@specificFamilyMembers,join("",@familyTree)) if (scalar(@familyTree)); } } + # let's add ourself to the list if (isIn("self",@{$relatives})) { push(@specificFamilyMembers,$self->get("lineage")); } @@ -425,6 +450,7 @@ sub getLineage { $whereExact .= quoteAndJoin(\@specificFamilyMembers); $whereExact .= ")"; } + # we need to include descendants my $whereDescendants; if (isIn("descendants",@{$relatives})) { if ($whereSiblings ne "" || $whereExact ne "") { @@ -435,19 +461,32 @@ sub getLineage { $whereDescendants .= " and length(lineage) <= ".($rules->{endingLineageLength}*6); } } - my $columns = "assetId, className"; + # based upon all available criteria, let's get some assets + my $columns = "assetId, className, parentId"; $columns = "*" if ($rules->{returnQuickReadObjects}); my $sql = "select $columns from asset where $whereSiblings $whereExact $whereDescendants $whereExclusion order by lineage"; my @lineage; + my %relativeCache; my $sth = WebGUI::SQL->read($sql); while (my $properties = $sth->hashRef) { + # create whatever type of object was requested + my $asset; if ($rules->{returnObjects}) { - push(@lineage,WebGUI::Asset->newByDynamicClass($properties->{assetId}, $properties->{className})); + $asset = WebGUI::Asset->newByDynamicClass($properties->{assetId}, $properties->{className}); } elsif ($rules->{returnQuickReadObjects}) { - push(@lineage,WebGUI::Asset->newByPropertyHashRef($properties)); + $asset = WebGUI::Asset->newByPropertyHashRef($properties); } else { - push(@lineage,$properties->{assetId}); + $asset = $properties->{assetId}; } + # since we have the relatives info now, why not cache it + if ($rules->{returnObjects} || $rules->{returnQuickReadObjects}) { + my $parent = $relativeCache{$properties->{parentId}}; + $relativeCache{$properties->{assetId}} = $asset; + $asset->{_parent} = $parent; + $parent->{_firstChild} = $asset unless(exists $parent->{_firstChild}); + $parent->{_lastChild} = $asset; + } + push(@lineage,$asset); } $sth->finish; return \@lineage; @@ -525,8 +564,17 @@ sub getValue { sub hasChildren { my $self = shift; - my ($hasChildren) = WebGUI::SQL->read("select count(*) from asset where parentId=".quote($self->getId)); - return $hasChildren; + unless (exists $self->{_hasChildren}) { + if (exists $self->{_firstChild}) { + $self->{_hasChildren} = 1; + } elsif (exists $self->{_lastChild}) { + $self->{_hasChildren} = 1; + } else { + my ($hasChildren) = WebGUI::SQL->read("select count(*) from asset where parentId=".quote($self->getId)); + $self->{_hasChildren} = $hasChildren; + } + } + return $self->{_hasChildren}; } sub new { diff --git a/lib/WebGUI/Asset/Wobject/Navigation.pm b/lib/WebGUI/Asset/Wobject/Navigation.pm index 26e39b2df..39fe4a56c 100644 --- a/lib/WebGUI/Asset/Wobject/Navigation.pm +++ b/lib/WebGUI/Asset/Wobject/Navigation.pm @@ -101,7 +101,7 @@ sub getEditForm { -value=>'' ); $tabform->getTab("properties")->readOnly( - -label=>"Assets to Include", + -label=>"Relatives to Include", -value=>WebGUI::Form::checkbox({ checked=>$selfChecked, name=>"assetsToInclude", @@ -124,7 +124,6 @@ sub getEditForm { value=>"pedigree" }).'Pedigree
' ); -WebGUI::ErrorHandler::warn($self->getValue("startType")); my %options; tie %options, 'Tie::IxHash'; %options = ( @@ -182,13 +181,13 @@ WebGUI::ErrorHandler::warn($self->getValue("startType")); changeStartPoint(); toggleEndPoint(); "); - my $previewButton = qq{ - }; + my $previewButton;# = qq{ + # }; my $saveButton = ' getByUrl($self->get("startPoint")); } elsif ($self->get("startType") eq "relativeToRoot") { @@ -229,190 +229,108 @@ sub view { $start = WebGUI::Asset->newByLineage($lineage); } } + $current = $session{asset} unless (defined $current); $start = $session{asset} unless (defined $start); # if none of the above results in a start point, then the current page must be it - my @assets = $start->getLineage(); - - -my $config; -my $base; - - my (@relatives, %rules); - foreach my $relative ("ancestors","self","siblings","descendants") { - push(@relatives,$relative) if ($config->{relative}); - } + my @includedRelationships = split("\n",$self->get("assetsToInclude")); + my %rules; $rules{returnQuickReadObjects} = 1; - $base->getLineage(\@relatives,\%rules); - - my @interestingPageProperties = ('pageId', 'parentId', 'title', 'ownerId', 'urlizedTitle', - 'synopsis', 'newWindow', 'menuTitle', 'encryptLogin'); + $rules{endingLineageLength} = $start->getLineageLength+$self->get("endPoint"); + my @assets = $start->getLineage(\@includedRelationships,\%rules); my $var = {'page_loop' => []}; - my $p = $self->_getStartPageObject(); - my $method = $self->_methods()->{$self->{_method}}{method}; - - my $cache = WebGUI::Cache->new($self->{_identifier}.'-'.$session{page}{pageId}, "Navigation-".$session{config}{configFile}); - my $cacheContent = $cache->get unless $session{var}{adminOn}; - my (@page_loop, $lastPage, %unfolded); - tie %unfolded, "Tie::IxHash"; - - # Store current page properties in template var - my $currentPage = WebGUI::Page->getPage(); - my $currentRoot = $currentPage->getWebGUIRoot(); - foreach my $property (@interestingPageProperties) { - $var->{'basepage.'.$property} = $currentPage->get($property); - } - unless (defined $cacheContent && - ! $session{url}{siteURL}) { # Never use cache if an alternate site url is specified. - # The loop was not cached - my @pages = eval $method; - if ($@) { - WebGUI::ErrorHandler::warn("Error in WebGUI::Navigation::build while trying to execute $method".$@); + my @interestingProperties = ('assetId', 'parentId', 'title', 'ownerUserId', 'synopsis', 'newWindow', 'menuTitle'); + foreach my $property (@interestingProperties) { + $var->{'currentPage.'.$property} = $current->get($property); + } + $var->{'currentPage.isHome'} = ($current->getId eq $session{setting}{defaultPage}); + $var->{'currentPage.url'} = $current->getUrl; + $var->{'currentPage.hasChild'} = $current->hasChildren; + my $currentLineage = $current->get("lineage"); + my @linesToSkip; + my $absoluteDepthOfLastPage; + foreach my $asset (@assets) { + # skip pages we shouldn't see + my $skip = 0; + my $pageLineage = $asset->get("lineage"); + foreach my $lineage (@linesToSkip) { + $skip = 1 if ($lineage =~ m/^$pageLineage/); } - if (@pages) { - my $startPageDepth = $p->get("depth")+1; - my $maxDepth = $startPageDepth + $self->{_depth}; - my $minDepth = $startPageDepth - $self->{_depth}; - - foreach my $page (@pages) { - my $pageData = {}; - $pageData->{"page.absDepth"} = $page->{'depth'} + 1; - $pageData->{"page.isSystem"} = $page->{isSystem}; - - # Check if in depth range - next if ($pageData->{"page.absDepth"} > $maxDepth || $pageData->{"page.absDepth"} < $minDepth); - - # Check stopAtLevel - next if ($pageData->{"page.absDepth"} < $self->{_stopAtLevel}); - - # Check showSystemPages - next if (! $self->{_showSystemPages} && $pageData->{"page.isSystem"}); - - # Deal with hidden pages, don't ever hide pages if admin mode is on - next if(($page->{'hideFromNavigation'} && ! $self->{_showHiddenPages}) && (! $session{var}{adminOn})); - - # Initial page info - $pageData->{"page.url"} = WebGUI::URL::gateway($page->{'urlizedTitle'}); - if ($page->{'encryptPage'}) { - $pageData->{"page.url"} =~ s/http:/https:/; - } - $pageData->{"page.relDepth"} = $pageData->{"page.absDepth"} - $startPageDepth; - $pageData->{"page.isBasepage"} = ($page->{'pageId'} eq $session{page}{pageId}); - $pageData->{"page.isHidden"} = $page->{'hideFromNavigation'}; - - # indent - my $indent = 0; - if ($self->{_method} eq 'pedigree' # reverse traversing - || $self->{_method} eq 'ancestors' # needs another way to calculate - || $self->{_method} eq 'self_and_ancestors') { # the indent - if ($self->{_stopAtLevel} <= $startPageDepth && $self->{_stopAtLevel} > 0) { - $indent = $pageData->{"page.absDepth"} - ($self->{_stopAtLevel} - 1) - 1; - } elsif ($self->{_stopAtLevel} > $startPageDepth && $self->{_stopAtLevel} > 0) { - $indent = 0; - } else { - $indent = $pageData->{"page.absDepth"} - 1; - } - } else { - $indent = $pageData->{"page.absDepth"} - $startPageDepth - 1; - } - $pageData->{"page.indent_loop"} = []; - push(@{$pageData->{"page.indent_loop"}},{'indent'=>$_}) for(1..$indent); - $pageData->{"page.indent"} = "   " x $indent; - - # Put page properties in $pageData hashref - foreach my $property (@interestingPageProperties) { - $pageData->{"page.".$property} = $page->{$property}; - } - $pageData->{"page.isRoot"} = (! $page->{'parentId'}); - $pageData->{"page.isTop"} = ($pageData->{"page.absDepth"} == 2); - $pageData->{"page.hasDaughter"} = ($page->{'nestedSetRight'} - $page->{'nestedSetLeft'} > 1); - $pageData->{"page.isDaughter"} = ($page->{'parentId'} eq $currentPage->get('pageId')); - $pageData->{"page.isMother"} = ($page->{'pageId'} eq $currentPage->get('parentId')); - - $pageData->{"page.isAncestor"} - = (($page->{'nestedSetLeft'} < $currentPage->get('nestedSetLeft')) - && ($page->{'nestedSetRight'} > $currentPage->get('nestedSetRight'))); - $pageData->{"page.isDescendent"} - = (($page->{'nestedSetLeft'} > $currentPage->get('nestedSetLeft')) - && ($page->{'nestedSetRight'} < $currentPage->get('nestedSetRight'))); - - $pageData->{"page.inRoot"} - = (($page->{'nestedSetLeft'} > $currentRoot->get('nestedSetLeft')) - && ($page->{'nestedSetRight'} < $currentRoot->get('nestedSetRight'))); - - # Some information about my mother - my $mother = WebGUI::Page->getPage($page->{parentId}); - if ($page->{parentId} ne "0") { - foreach (qw(title urlizedTitle parentId pageId)) { - $pageData->{"page.mother.$_"} = $mother->get($_); - } - $pageData->{"page.isSister"} - = (($mother->get("pageId") eq $currentPage->get("parentId")) - && !$pageData->{"page.isBasepage"}); - } - - $pageData->{"page.inBranch"} - = ($pageData->{"page.isAncestor"} - || $pageData->{"page.isDescendent"} - || $pageData->{"page.isSister"} - || $pageData->{"page.isBasepage"}); - - $pageData->{"page.isLeftMost"} = (($page->{'nestedSetLeft'} - 1) == $mother->get('nestedSetLeft')); - $pageData->{"page.isRightMost"} = (($page->{'nestedSetRight'} + 1) == $mother->get('nestedSetRight')); - my $depthDiff = ($lastPage) ? ($lastPage->{'page.absDepth'} - $pageData->{'page.absDepth'}) : 0; - if ($depthDiff > 0) { - $pageData->{"page.depthDiff"} = $depthDiff if ($depthDiff > 0); - $pageData->{"page.depthDiffIs".$depthDiff} = 1; - push(@{$pageData->{"page.depthDiff_loop"}},{}) for(1..$depthDiff); - } - - # Some information about my depth - $pageData->{"page.depthIs".$pageData->{"page.absDepth"}} = 1; - $pageData->{"page.relativeDepthIs".$pageData->{"page.relDepth"}} = 1; - - # We need a copy of the last page for the depthDiffLoop - $lastPage = $pageData; - - # Store $pageData in page_loop. Mind the order. - if ($self->{_reverse}) { - unshift(@page_loop, $pageData); - } else { - push(@page_loop, $pageData); - } + next if ($skip); + if ($asset->get("isHidden") && !$self->get("showHiddenPages")) { + push (@linesToSkip,$asset->getId); + next; + } + if ($asset->get("isSystem") && !$self->get("showSystemPages")) { + push (@linesToSkip,$asset->getId); + next; + } + unless ($self->get("showUnprivilegedPages") || $asset->canView) { + push (@linesToSkip,$asset->getId); + next; + } + my $pageData = {}; + foreach my $property (@interestingProperties) { + $pageData->{"page.".$property} = $asset->get($property); + } + # build nav variables + $pageData->{"page.absDepth"} = $asset->getLineageLength; + $pageData->{"page.relDepth"} = $asset->getLineageLength - $start->getLineageLength; + $pageData->{"page.isSystem"} = $asset->get("isSystem"); + $pageData->{"page.isHidden"} = $asset->get("isHidden"); + $pageData->{"page.isViewable"} = $asset->canView; + $pageData->{"page.url"} = $asset->getUrl; + my $indent = $pageData->{"page.relDepth"}; + $pageData->{"page.indent_loop"} = []; + push(@{$pageData->{"page.indent_loop"}},{'indent'=>$_}) for(1..$indent); + $pageData->{"page.indent"} = "   " x $indent; + $pageData->{"page.isBranchRoot"} = ($pageData->{"page.absDepth"} == 1); + $pageData->{"page.isTopOfBranch"} = ($pageData->{"page.absDepth"} == 2); + $pageData->{"page.isChild"} = ($asset->get("parentId") eq $current->getId); + $pageData->{"page.isParent"} = ($asset->getId eq $current->get("parentId")); + $pageData->{"page.isCurrent"} = ($asset->getId eq $current->getId); + $pageData->{"page.isDescendant"} = ( $currentLineage =~ m/^$pageLineage/ && !$pageData->{"page.isCurrent"}); + $pageData->{"page.isAnscestor"} = ( $pageLineage =~ m/^$currentLineage/ && !$pageData->{"page.isCurrent"}); + $pageData->{"page.isSibling"} = ( + $pageData->{"page.inBranchRoot"} && + $asset->getLineageLength == $current->getLineageLength && + !$pageData->{"page.isCurrent"} + ); + my $currentBranchLineage = substr($currentLineage,0,12); + $pageData->{"page.inBranchRoot"} = ($currentBranchLineage =~ m/^$pageLineage/); + $pageData->{"page.inBranch"} = ( + $pageData->{"page.isCurrent"} || + $pageData->{"page.isAncestor"} || + $pageData->{"page.isSibling"} || + $pageData->{"page.isDescendant"} + ); + $pageData->{"page.depthIs".$pageData->{"page.absDepth"}} = 1; + $pageData->{"page.relativeDepthIs".$pageData->{"page.relDepth"}} = 1; + my $depthDiff = ($absoluteDepthOfLastPage) ? ($absoluteDepthOfLastPage - $pageData->{'page.absDepth'}) : 0; + if ($depthDiff > 0) { + $pageData->{"page.depthDiff"} = $depthDiff if ($depthDiff > 0); + $pageData->{"page.depthDiffIs".$depthDiff} = 1; + push(@{$pageData->{"page.depthDiff_loop"}},{}) for(1..$depthDiff); + } + $absoluteDepthOfLastPage = $pageData->{"page.absDepth"}; + my $parent = $self->getParent; + if (defined $parent) { + foreach my $property (@interestingProperties) { + $pageData->{"page.parent.".$property} = $parent->get($property); } + $pageData->{"page.parent.url"} = $parent->getUrl; } - - # We had a cache miss, so let's put the data in cache - $cache->set(\@page_loop, 3600*24) unless $session{var}{adminOn}; - } else { - # We had a cache hit - @page_loop = @{$cacheContent}; - } - - # Do the user-dependent checks (which cannot be cached globally) - foreach my $pageData (@page_loop) { - $pageData->{"page.isViewable"} = WebGUI::Page::canView($pageData->{'page.pageId'}); - # Check privileges - if ($pageData->{"page.isViewable"} || $self->{_showUnprivilegedPages}) { - push (@{$var->{page_loop}}, $pageData); - push (@{$unfolded{$pageData->{"page.parentId"}}}, $pageData); + $pageData->{"page.hasChild"} = $asset->hasChildren; + # these next two variables can be very inefficient, consider getting rid of them + my $parentsFirstChild = $parent->getFirstChild; + if (defined $parentsFirstChild) { + $pageData->{"page.isRankedFirst"} = ($asset->getId == $parentsFirstChild->getId); } + my $parentsLastChild = $parent->getLastChild; + if (defined $parentsLastChild) { + $pageData->{"page.isRankedLast"} = ($asset->getId == $parentsLastChild->getId); + } + push(@{$var->{page_loop}}, $pageData); } - - foreach (values %unfolded) { - push(@{$var->{unfolded_page_loop}}, @{$_}); - } - - # Configure button - $var->{'config.button'} = $self->_getEditButton(); - - # Some properties of the page the user's viewing. - $var->{'basepage.hasDaughter'} = $currentPage->hasDaughter(); - $var->{"basepage.isHome"} = ($currentPage->get('pageId') eq '1'); - - if ($self->{_template}) { - return WebGUI::Template::processRaw($self->{_template}, $var); - } else { - return WebGUI::Template::process($self->{_templateId}, "Navigation", $var); - } + return $self->processTemplate($var,"Navigation",$self->get("templateId")); } @@ -425,6 +343,7 @@ sub www_edit { #------------------------------------------------------------------- +# we eventually should reaadd this sub www_preview { my $self = shift; $session{var}{adminOn} = 0; diff --git a/lib/WebGUI/Form.pm b/lib/WebGUI/Form.pm index fceeb927f..c03a9f33d 100644 --- a/lib/WebGUI/Form.pm +++ b/lib/WebGUI/Form.pm @@ -241,7 +241,7 @@ sub checkList { sub codearea { my $params = shift; WebGUI::Style::setScript($session{config}{extrasURL}.'/TabFix.js',{type=>"text/javascript"}); - $params->{extras} = 'style="width: 99%; min-width: 440px; height: 400px" onkeypress="TabFix_keyPress(event.type)" onkeydown="TabFix_keyDown(event.type)"'; + $params->{extras} = 'style="width: 99%; min-width: 440px; height: 400px" onkeypress="return TabFix_keyPress(event)" onkeydown="return TabFix_keyDown(event)"'; my $output = textarea($params); return $output; } diff --git a/lib/WebGUI/i18n/English/Navigation.pm b/lib/WebGUI/i18n/English/Navigation.pm index 87b4ee209..ed3cd0453 100644 --- a/lib/WebGUI/i18n/English/Navigation.pm +++ b/lib/WebGUI/i18n/English/Navigation.pm @@ -82,17 +82,15 @@ the Navigation Template to determine who can see them in the menu.

}, '1097' => { - message => q|config.button 
A "Edit / Manage" button for this navigation item.
-

basepage.menuTitle
The pageId of the base page.

-

basepage.title
The title of the base page.

-

basepage.urlizedTitle
The URL of the base page.

-

basepage.pageId
The pageId of the base page.

-

basepage.parentId
The parentId of the base page.

-

basepage.ownerId
The ownerId of the base page.

-

basepage.synopsis
The synopsis of the base page.

-

basepage.newWindow
A conditional indicating whether the base page should be opened in a new window.

-

basepage.encryptLogin
A conditional indicating whether the base page should be served over SSL.

-

basepage.hasDaughter
A conditional indicating whether the base page has daughters.

+ message => q|

currentPage.menuTitle
The pageId of the base page.

+

currentPage.title
The title of the base page.

+

currentPage.url
The URL of the base page.

+

currentPage.assetId
The pageId of the base page.

+

currentPage.parentId
The parentId of the base page.

+

currentPage.ownerUserId
The ownerId of the base page.

+

currentPage.synopsis
The synopsis of the base page.

+

currentPage.newWindow
A conditional indicating whether the base page should be opened in a new window.

+

currentPage.hasChild
A conditional indicating whether the base page has daughters.

page_loop
A loop containing page information in nested, hierarchical order.

unfolded_page_loop
This loop contains the same data as page_loop but the order is different. unfolded_page_loop returns it's pages in an unfolded manner; grouped by parent id. You'll probably need page_loop, but there are (CSS) menus that need unfolded_page_loop to work properly.

Both page_loop and unfolded_page_loop have the following @@ -100,14 +98,12 @@ loop variables:

page.menuTitle
The menu title of this page.

page.title
The title of this page.

-

page.urlizedTitle
The urlizedTitle of this page.

page.url
The complete URL to this page.

-

page.pageId
The pageId of this page.

+

page.assetId
The pageId of this page.

page.parentId
The parentId of this page.

-

page.ownerId
The ownerId of this page.

+

page.ownerUserId
The ownerId of this page.

page.synopsis
The synopsis of this page.

page.newWindow
A conditional indicating whether this page should be opened in a new window.

-

page.encryptLogin
A conditional indicating whether this page should be served over SSL.

page.absDepth
The absolute depth of this page (relative to nameless root).

page.relDepth
The relative depth of this page (relative to starting point).

page.isHidden
A conditional indicating whether this page is a hidden page.
(Note: This variable is only visible if "Show hidden pages" is switched on.)

@@ -117,27 +113,27 @@ loop variables:

page.indent_loop
A loop that runs page.relDepth times.

indent
A number representing the loop count.

-

page.isRoot
A conditional indicating whether this page is a root page.

-

page.isTop
A conditional indicating whether this page is a top page (daughter of root).

-

page.inRoot
This conditional is true if this page is a descendant of the root page of the base page.

-

page.hasDaughter
A conditional indicating whether this page has a daughter. In other words: It evaluates to true if this page is a mother.

-

page.isBasepage
A conditional indicating whether this page is the base page.

+

page.isBranchRoot
A conditional indicating whether this page is a root page.

+

page.isTopOfBranch
A conditional indicating whether this page is a top page (daughter of root).

+

page.inBranchRoot
This conditional is true if this page is a descendant of the root page of the base page.

+

page.hasChild
A conditional indicating whether this page has a daughter. In other words: It evaluates to true if this page is a mother.

+

page.isCurrent
A conditional indicating whether this page is the base page.

page.isAncestor
A conditional indicating whether this page is an ancestor of the base page.

page.isDescendent
A conditional indicating whether this page is a descendant of the base page.

-

page.isDaughter
A conditional indicating whether this page is a daughter of the base page.

-

page.isMother
A conditional indicating whether this page is the mother of the base page.

-

page.isSister
A conditional indicating whether this page is the sister of the base page.

+

page.isChild
A conditional indicating whether this page is a daughter of the base page.

+

page.isParent
A conditional indicating whether this page is the mother of the base page.

+

page.isSibling
A conditional indicating whether this page is the sister of the base page.

page.inBranch
A conditional that is the logical OR of isAncestor, isSister, isBasepage and isDescendent.

-

page.mother.*
These variables will be undefined if the page is a root.

-

page.mother.title
The title of the mother of this page.

-

page.mother.urlizedTitle
The urlized title of the mother of this page.

-

page.mother.pageId
The pageId of the mother of this page.

-

page.mother.parentId
The parentId of the mother of this page.

+

page.parent.*
These variables will be undefined if the page is a root.

+

page.parent.title
The title of the mother of this page.

+

page.parent.url
The urlized title of the mother of this page.

+

page.parent.assetId
The pageId of the mother of this page.

+

page.parent.parentId
The parentId of the mother of this page.

page.depthIs1 , page.depthIs2 , page.depthIs3 , page.depthIs4 , page.depthIsN
A conditional indicating whether the depth of this page is N. This variable is useful if you want to style a certain level.

<tmpl_if page.depthIs1>
   <img src="level1.gif">
<tmpl_else>
   <img src="defaultBullet.gif">
</tmpl_if>

page.relativeDepthIs1 , page.relativeDepthIs2 , page.relativeDepthIs3 , page.relativeDepthIsN
A conditional indicating whether the relative depth of this page is N.

-

page.isLeftMost
This property is true if this page is the first within this level. Ie. has no left sister.

-

page.isRightMost
This property is true if this page is the last within this level. Ie. has no right sister.

+

page.isRankedFirst
This property is true if this page is the first within this level. Ie. has no left sister.

+

page.isRankedLast
This property is true if this page is the last within this level. Ie. has no right sister.

page.depthDiff
The difference in depth of this page and the page processed before it. This only has a value when you go up in depth. If you go down, this would be always 1 and going down a level can be detected with page.isLeftMost.

page.depthDiffIs1, page.depthDiffIs2, page.depthDiffIs3, page.depthDiffIsN
True if the page.depthDiff variable is N.

page.depthDiff_loop
A loop that runs page.depthDiff times. This loop contains no loop variables.