From 87aef8eaac47307f6d5ad51f72504b0f55fe2422 Mon Sep 17 00:00:00 2001
From: JT Smith
+
'
);
-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.
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.
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
@@ -117,27 +113,27 @@ loop variables:
A conditional indicating whether this page is a hidden page.
(Note: This variable is only visible if "Show hidden pages" is switched on.)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.