'', 'include_self' => 0, 'noheader' => 0, 'page' => '[pagename]', 'description' => $this->getDescription(), 'reclimit' => 4, 'info' => false, 'direction' => 'back', 'firstreversed' => false, 'excludeunknown' => true, 'includepages' => '' // to be used only from the IncludeSiteMap plugin ); } // info arg allows multiple columns // info=mtime,hits,summary,version,author,locked,minor // exclude arg allows multiple pagenames // exclude=HomePage,RecentChanges // Fixme: overcome limitation if two SiteMap plugins are in the same page! // static $VisitedPages still holds it //Funktion von Stefan Schorn überarbeitet da preg_match falsch angewendet wurde function recursivelyGetBackLinks($startpage, $pagearr, $level = '*', $reclimit = '***') { static $VisitedPages = array(); echo $reclimit.'
'; $startpagename = $startpage->getName(); //trigger_error("DEBUG: recursivelyGetBackLinks( $startpagename , $level )"); if ($level == $reclimit) return $pagearr; if (in_array($startpagename, $VisitedPages)) return $pagearr; array_push($VisitedPages, $startpagename); $pagelinks = $startpage->getLinks(); while ($link = $pagelinks->next()) { $linkpagename = $link->getName(); if ($linkpagename != $startpagename) { $expages = explode('|', $this->ExcludedPages); $leavit = 0; foreach ( $expages as $expage ) { $expos = strpos(trim($expage), $linkpagename); if (!($expos === false)){ $leavit = 1; break; } } if ($leavit == 0) { $pagearr[$level . " [$linkpagename]"] = $link; $pagearr = $this->recursivelyGetBackLinks($link, $pagearr, $level . '*', $reclimit); } } } return $pagearr; } //Funktion von Stefan Schorn überarbeitet da preg_match falsch angewendet wurde function recursivelyGetLinks($startpage, $pagearr, $level = '*', $reclimit = '***') { static $VisitedPages = array(); $startpagename = $startpage->getName(); //trigger_error("DEBUG: recursivelyGetLinks( $startpagename , $level )"); if ($level == $reclimit) return $pagearr; if (in_array($startpagename, $VisitedPages)) return $pagearr; array_push($VisitedPages, $startpagename); $reversed = (($this->firstreversed) && ($startpagename == $this->initialpage)); //trigger_error("DEBUG: \$reversed = $reversed"); $pagelinks = $startpage->getLinks($reversed); while ($link = $pagelinks->next()) { $linkpagename = $link->getName(); if ($linkpagename != $startpagename) { $expages = explode('|', $this->ExcludedPages); $leavit = 0; foreach ( $expages as $expage ) { $expos = strpos(trim($expage), $linkpagename); if (!($expos === false)){ $leavit = 1; break; } } if ($leavit == 0) { if (!$this->excludeunknown || $this->dbi->isWikiPage($linkpagename)) { $pagearr[$level . " [$linkpagename]"] = $link; $pagearr = $this->recursivelyGetLinks($link, $pagearr, $level . '*', $reclimit); } } } } return $pagearr; } function run($dbi, $argstr, &$request, $basepage) { include_once('lib/BlockParser.php'); $args = $this->getArgs($argstr, $request, false); extract($args); if (!$page) return ''; $this->_pagename = $page; $out = ''; // get rid of this $html = HTML(); if (empty($exclude)) $exclude = array(); if (!$include_self) $exclude[] = $page; $this->ExcludedPages = "" . join("|", $exclude); $this->_default_limit = str_pad('', 3, '*'); if (is_numeric($reclimit)) { if ($reclimit < 0) $reclimit = 0; if ($reclimit > 10) $reclimit = 10; $limit = str_pad('', $reclimit + 2, '*'); } else { $limit = '***'; } //Fixme: override given arg $description = $this->getDescription(); if (! $noheader) { $out = $this->getDescription() ." ". sprintf(_("(max. recursion level: %d)"), $reclimit) . ":\n\n"; $html->pushContent(TransformText($out, 1.0, $page)); } $pagelist = new PageList($info, $exclude); $p = $dbi->getPage($page); $pagearr = array(); if ($direction == 'back') { $pagearr = $this->recursivelyGetBackLinks($p, $pagearr, "*", $limit); } else { $this->dbi = $dbi; $this->initialpage = $page; $this->firstreversed = $firstreversed; $this->excludeunknown = $excludeunknown; $pagearr = $this->recursivelyGetLinks($p, $pagearr, "*", $limit); } reset($pagearr); if (!empty($includepages)) { // disallow direct usage, only via child class IncludeSiteMap if (!isa($this,"WikiPlugin_IncludeSiteMap")) $includepages = ''; if (!is_string($includepages)) $includepages = ' '; // avoid plugin loader problems $loader = new WikiPluginLoader(); $plugin = $loader->getPlugin('IncludePage',false); $nothing = ''; } while (list($key, $link) = each($pagearr)) { if (!empty($includepages)) { $a = substr_count($key, '*'); $indenter = str_pad($nothing, $a); //$request->setArg('IncludePage', 1); //geändert von Stefan Schorn Anführungsezeichen eingefügt für Seiten mit Leerzeichen $plugin_args = 'page=' . '\''.$link->getName().'\''. ' ' . $includepages; //$plugin_args = 'page=' . $link->getName() . ' ' . $includepages; $pagehtml = $plugin->run($dbi, $plugin_args, $request, $basepage); $html->pushContent($pagehtml); //$html->pushContent( HTML(TransformText($indenter, 1.0, $page), $pagehtml)); //$out .= $indenter . $pagehtml . "\n"; } else { $out .= $key . "\n"; } } if (empty($includepages)) { return TransformText($out, 2.0, $page); } else { return $html; } } }; // $Log: SiteMap.php,v $ // Revision 1.13 2004/12/14 21:36:06 rurban // exclude is already handled by getArgs // // Revision 1.12 2004/11/01 09:14:25 rurban // avoid ConvertOldMarkup step, using markup=2 (memory problems) // // Revision 1.11 2004/03/24 19:39:03 rurban // php5 workaround code (plus some interim debugging code in XmlElement) // php5 doesn't work yet with the current XmlElement class constructors, // WikiUserNew does work better than php4. // rewrote WikiUserNew user upgrading to ease php5 update // fixed pref handling in WikiUserNew // added Email Notification // added simple Email verification // removed emailVerify userpref subclass: just a email property // changed pref binary storage layout: numarray => hash of non default values // print optimize message only if really done. // forced new cookie policy: delete pref cookies, use only WIKI_ID as plain string. // prefs should be stored in db or homepage, besides the current session. // // Revision 1.10 2004/02/17 12:11:36 rurban // added missing 4th basepage arg at plugin->run() to almost all plugins. This caused no harm so far, because it was silently dropped on normal usage. However on plugin internal ->run invocations it failed. (InterWikiSearch, IncludeSiteMap, ...) // // Revision 1.9 2004/02/12 13:05:50 rurban // Rename functional for PearDB backend // some other minor changes // SiteMap comes with a not yet functional feature request: includepages (tbd) // // Revision 1.8 2004/01/24 23:24:07 rurban // Patch by Alec Thomas, allows Perl regular expressions in SiteMap exclude lists. // exclude=WikiWikiWeb,(?:Category|Topic).* // It is backwards compatible unless old exclude lists, and therefore Wiki // page names, contain regular expression characters. // // Revision 1.7 2003/02/21 04:12:06 dairiki // Minor fixes for new cached markup. // // Revision 1.6 2003/01/18 22:08:01 carstenklapp // Code cleanup: // Reformatting & tabs to spaces; // Added copyleft, getVersion, getDescription, rcs_id. // // For emacs users // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil // End: ?>