From fdd2e2ddc742dc33eb63bc11884bf49c771506ca Mon Sep 17 00:00:00 2001 From: JT Smith Date: Sat, 14 Dec 2002 23:09:12 +0000 Subject: [PATCH] Fixed sitemap so it will display roots properly --- docs/upgrades/upgrade_4.9.2-4.9.3.sql | 19 +++++++++++++++++- lib/WebGUI/Wobject/SiteMap.pm | 28 +++++++++++++++++---------- lib/WebGUI/Wobject/Survey.pm | 2 +- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/docs/upgrades/upgrade_4.9.2-4.9.3.sql b/docs/upgrades/upgrade_4.9.2-4.9.3.sql index d8ac10a0e..652cd4564 100644 --- a/docs/upgrades/upgrade_4.9.2-4.9.3.sql +++ b/docs/upgrades/upgrade_4.9.2-4.9.3.sql @@ -40,7 +40,7 @@ INSERT INTO template VALUES (1,'Default Link List','\r\n INSERT INTO template VALUES (2,'Unordered List','\r\n

\r\n
\r\n\r\n\r\n

\r\n\r\n\r\n\r\n \">

\r\n\r\n\r\n

    \r\n\r\n
  • \r\n \r\n \r\n \r\n \r\n \"\r\n \r\n target=\"_blank\"\r\n \r\n >\r\n\r\n \r\n - \r\n \r\n
  • \r\n
    \r\n','LinkList'); INSERT INTO template VALUES (3,'Ordered List','\r\n

    \r\n
    \r\n\r\n\r\n

    \r\n\r\n\r\n\r\n \">

    \r\n\r\n\r\n

      \r\n\r\n
    1. \r\n \r\n \r\n \r\n\r\n \"\r\n \r\n target=\"_blank\"\r\n \r\n >\r\n\r\n \r\n - \r\n \r\n
    2. \r\n
      \r\n
    ','LinkList'); INSERT INTO template VALUES (4,'Descriptive','\r\n

    \r\n
    \r\n\r\n\r\n

    \r\n\r\n\r\n\r\n \">

    \r\n\r\n\r\n\r\n \r\n
    \r\n
    \r\n\r\n \"\r\n \r\n target=\"_blank\"\r\n \r\n >\r\n\r\n \r\n - \r\n \r\n

    \r\n\r\n','LinkList'); -INSERT INTO template VALUES (1,'Default Site Map','\r\n

    \r\n
    \r\n\r\n\r\n

    \r\n\r\n\r\n\r\n ·\">
    \r\n
    ','SiteMap'); +INSERT INTO template VALUES (1,'Default Site Map','\r\n

    \r\n
    \r\n\r\n\r\n

    \r\n\r\n\r\n\r\n

    \r\n ·\">
    \r\n','SiteMap'); INSERT INTO template VALUES (2,'Descriptive Site Map','\r\n

    \r\n
    \r\n\r\n\r\n

    \r\n\r\n\r\n\r\n \"> \r\n \r\n - \r\n \r\n

    \r\n','SiteMap'); INSERT INTO template VALUES (6,'Guest Book','\r\n

    \r\n
    \r\n\r\n\r\n

    \r\n\r\n\r\n\r\n \">

    \r\n\r\n\r\n\r\n\r\n\r\n\r\n

    \r\n\r\n\r\nOn \"> from \">the department wrote, \r\n\r\n\r\n
    \r\n
    \r\n\r\n

    \r\n\r\n\r\n\r\n\r\n

    \r\n · \r\n
    \r\n
    \r\n','USS'); insert into international (internationalId,languageId,namespace,message,lastUpdated) values (848,1,'WebGUI','There is a syntax error in this template. Please correct.', 1039892202); @@ -2519,6 +2519,23 @@ delete from international where languageId=4 and namespace='Article' and interna insert into international (internationalId,languageId,namespace,message,lastUpdated) values (22,4,'Article','Autor', 1039564293); delete from international where languageId=4 and namespace='EventsCalendar' and internationalId=20; insert into international (internationalId,languageId,namespace,message,lastUpdated) values (20,4,'EventsCalendar','Agregar un Evento', 1039564281); +delete from international where languageId=1 and namespace='SiteMap' and internationalId=75; +insert into international (internationalId,languageId,namespace,message,lastUpdated) values (75,1,'SiteMap','All Roots', 1039908572); +delete from international where languageId=1 and namespace='SiteMap' and internationalId=74; +insert into international (internationalId,languageId,namespace,message,lastUpdated) values (74,1,'SiteMap','This Page', 1039908565); +delete from international where languageId=1 and namespace='SiteMap' and internationalId=71; +insert into international (internationalId,languageId,namespace,message,lastUpdated) values (71,1,'SiteMap','Site maps are used to provide additional navigation in WebGUI. You could set up a traditional site map that would display a hierarchical view of all the pages in the site. On the other hand, you could use site maps to provide extra navigation at certain levels in your site.\r\n

    \r\n\r\nTemplate
    \r\nChoose a layout for this site map.\r\n

    \r\n\r\nStart With
    \r\nSelect the page that this site map should start from.\r\n

    \r\n\r\nDepth To Traverse
    \r\nHow many levels deep of navigation should the Site Map show? If 0 (zero) is specified, it will show as many levels as there are.\r\n

    \r\n\r\nIndent\r\nHow many characters should indent each level?\r\n

    \r\n\r\n', 1039908464); +delete from international where languageId=1 and namespace='SiteMap' and internationalId=3; +insert into international (internationalId,languageId,namespace,message,lastUpdated) values (3,1,'SiteMap','Start With', 1039908390); +create table SiteMap2 (wobjectId int not null primary key,startAtThisLevel int not null default 0, depth int not null default 0, indent int not null default 5, templateId int not null default 1); +insert into SiteMap2 select wobject.wobjectId,wobject.pageId,SiteMap.depth,SiteMap.indent,SiteMap.templateId from wobject,SiteMap where wobject.wobjectId=SiteMap.wobjectId and SiteMap.startAtThisLevel=1; +insert into SiteMap2 select wobject.wobjectId,1,SiteMap.depth,SiteMap.indent,SiteMap.templateId from wobject,SiteMap where wobject.wobjectId=SiteMap.wobjectId and SiteMap.startAtThisLevel=0; +drop table SiteMap; +alter table SiteMap2 rename SiteMap; +delete from international where languageId=1 and namespace='SiteMap' and internationalId=73; +insert into international (internationalId,languageId,namespace,message,lastUpdated) values (73,1,'SiteMap','This is the list of template variables available for site map templates.\r\n

    \r\n\r\npage_loop
    \r\nThis loop contains all of the pages in the site map.\r\n

    \r\n\r\npage.indent
    \r\nThe indent spacer for this page indicating the depth of the page in the tree.\r\n

    \r\n\r\npage.url
    \r\nThe URL to the page.\r\n

    \r\n\r\npage.id
    \r\nThe unique identifier for this page that WebGUI uses internally.\r\n

    \r\n\r\npage.title
    \r\nThe title of this page.\r\n

    \r\n\r\npage.menutitle
    \r\nThe title of this page that appears in navigation.\r\n

    \r\n\r\npage.synopsis
    \r\nThe description of the contents of this page (if any).\r\n

    \r\n\r\npage.isRoot
    \r\nA condition indicating whether or not this page is a root.\r\n

    \r\n\r\n

    \r\n

    ', 1039910987); + + diff --git a/lib/WebGUI/Wobject/SiteMap.pm b/lib/WebGUI/Wobject/SiteMap.pm index 113b1e595..599b2cfda 100644 --- a/lib/WebGUI/Wobject/SiteMap.pm +++ b/lib/WebGUI/Wobject/SiteMap.pm @@ -39,14 +39,15 @@ sub _traversePageTree { $sth = WebGUI::SQL->read("select urlizedTitle, title, pageId, synopsis from page where parentId='$parent' order by sequenceNumber"); while ($data = $sth->hashRef) { - if (WebGUI::Privilege::canViewPage($data->{pageId})) { + if (($data->{pageId}>999 || $data->{pageId}==1) && WebGUI::Privilege::canViewPage($data->{pageId})) { push(@pages,{ "page.indent" => $indentString, "page.url" => WebGUI::URL::gateway($data->{urlizedTitle}), "page.id" => $data->{pageId}, "page.title" => $data->{title}, "page.menuTitle" => $data->{menuTitle}, - "page.synopsis" => $data->{synopsis} + "page.synopsis" => $data->{synopsis}, + "page.isRoot" => ($parent == 0) }); push(@pages,@{_traversePageTree($data->{pageId},($currentDepth+1),$depth,$indent)}); } @@ -78,6 +79,9 @@ sub set { sub www_edit { return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage()); my ($output, $f, $indent); + my $startLevel = $_[0]->get("startAtThisLevel") || 1; + my $options = WebGUI::SQL->buildHashRef("select pageId,title from page where parentId=0 + and (pageId=1 or pageId>999) order by title"); $indent = $_[0]->get("indent") || 5; $output = helpIcon(1,$_[0]->get("namespace")); $output .= '

    '.WebGUI::International::get(5,$namespace).'

    '; @@ -88,7 +92,16 @@ sub www_edit { -namespace=>$namespace, -afterEdit=>'func=edit&wid='.$_[0]->get("wobjectId") ); - $f->yesNo("startAtThisLevel",WebGUI::International::get(3,$namespace),$_[0]->get("startAtThisLevel")); + $f->select( + -name=>"startAtThisLevel", + -label=>WebGUI::International::get(3,$namespace), + -value=>[$startLevel], + -options=>{ + 0=>WebGUI::International::get(75,$namespace), + $session{page}{pageId}=>WebGUI::International::get(74,$namespace), + %{$options} + } + ); $f->integer("depth",WebGUI::International::get(4,$namespace),$_[0]->get("depth")); $f->integer("indent",WebGUI::International::get(6,$namespace),$indent); $output .= $_[0]->SUPER::www_edit($f->printRowsOnly); @@ -109,13 +122,8 @@ sub www_editSave { #------------------------------------------------------------------- sub www_view { - my (%var, $parent); - if ($_[0]->get("startAtThisLevel")) { - $parent = $session{page}{pageId}; - } else { - $parent = 1; - } - $var{page_loop} = _traversePageTree($parent,0,$_[0]->get("depth"),$_[0]->get("indent")); + my (%var); + $var{page_loop} = _traversePageTree($_[0]->get("startAtThisLevel"),0,$_[0]->get("depth"),$_[0]->get("indent")); return $_[0]->processMacros($_[0]->processTemplate($_[0]->get("templateId"),\%var)); } diff --git a/lib/WebGUI/Wobject/Survey.pm b/lib/WebGUI/Wobject/Survey.pm index 8ff7b35ef..1d1d8c4ff 100644 --- a/lib/WebGUI/Wobject/Survey.pm +++ b/lib/WebGUI/Wobject/Survey.pm @@ -348,7 +348,7 @@ sub www_editAnswerSave { $session{form}{qid} = "new"; } elsif ($session{form}{proceed} eq "addAnswer") { $session{form}{aid} = "new"; - $_[0]->www_editAnswer(); + return $_[0]->www_editAnswer(); } elsif ($session{form}{proceed} eq "backToPage") { return ""; }