bjori Sat Aug 18 23:49:34 2007 UTC
Modified files:
/phd/themes/php phpweb.php
Log:
Cleanup after the refactoring of createNext/createPrev
http://cvs.php.net/viewvc.cgi/phd/themes/php/phpweb.php?r1=1.7&r2=1.8&diff_format=u
Index: phd/themes/php/phpweb.php
diff -u phd/themes/php/phpweb.php:1.7 phd/themes/php/phpweb.php:1.8
--- phd/themes/php/phpweb.php:1.7 Fri Aug 17 09:17:43 2007
+++ phd/themes/php/phpweb.php Sat Aug 18 23:49:34 2007
@@ -1,5 +1,5 @@
<?php
-/* $Id: phpweb.php,v 1.7 2007/08/17 09:17:43 bjori Exp $ */
+/* $Id: phpweb.php,v 1.8 2007/08/18 23:49:34 bjori Exp $ */
class phpweb extends phpdotnet implements PhDTheme {
protected $streams = array();
@@ -107,27 +107,22 @@
}
protected function createPrev($id, $parent, $siblings) {
$ext = '.' .$this->ext;
- $prev = array(null, null);
- // {{{ Create the "previous" link
- do {
- if (!isset($siblings[$id])) {
- break;
- }
+ if (!isset($siblings[$id])) {
+ return array(null, null);
+ }
- // Seek to $id
- in_array($siblings[$id], $siblings, false, true);
- $tmp = prev($siblings);
- if ($tmp) {
- while (!empty($tmp["children"])) {
- $tmp = end($tmp["children"]);
- }
- $prev = array($tmp["filename"].$ext, (empty($tmp["sdesc"]) ?
$tmp["ldesc"] : $tmp["sdesc"]));
- break;
+ // Seek to $id
+ in_array($siblings[$id], $siblings, false, true);
+ $tmp = prev($siblings);
+ if ($tmp) {
+ while (!empty($tmp["children"])) {
+ $tmp = end($tmp["children"]);
}
+ return array($tmp["filename"].$ext, (empty($tmp["sdesc"]) ?
$tmp["ldesc"] : $tmp["sdesc"]));
+ break;
+ }
- $prev = array(PhDHelper::getFilename($parent).$ext,
PhDHelper::getDescription($parent, false));
- } while(false); // }}}
- return $prev;
+ return array(PhDHelper::getFilename($parent).$ext,
PhDHelper::getDescription($parent, false));
}
protected function createNext($id, $parent, $siblings) {
$ext = '.' .$this->ext;
@@ -135,38 +130,33 @@
// {{{ Create the "next" link
if (!empty($siblings[$id]["children"])) {
$tmp = reset($siblings[$id]["children"]);
- $next = array($tmp["filename"].$ext, (empty($tmp["ldesc"]) ?
$tmp["sdesc"] : $tmp["ldesc"]));
- } else {
- // don't overwrite these variables
- $tid = $id;
- $tsiblings = $siblings;
- $tparent = $parent;
- do {
- if (!isset($tsiblings[$tid])) {
- break;
- }
+ return array($tmp["filename"].$ext, (empty($tmp["ldesc"]) ?
$tmp["sdesc"] : $tmp["ldesc"]));
+ }
+ do {
+ if (!isset($siblings[$id])) {
+ break;
+ }
- // Seek to $tid
- in_array($tsiblings[$tid], $tsiblings, false, true) or
die(var_export(debug_backtrace(), true) ."\n$tid\n$tparent"); // This should
*never* happen
- $tmp = next($tsiblings);
- prev($tsiblings); // Reset the internal pointer to previous pos
- if ($tmp) {
- $next = array($tmp["filename"].$ext, (empty($tmp["sdesc"])
? $tmp["ldesc"] : $tmp["sdesc"]));
- break;
- }
+ // Seek to $id
+ in_array($siblings[$id], $siblings, false, true) or
die(var_export(debug_backtrace(), true) ."\n$id\n$parent"); // This should
*never* happen
+ $tmp = next($siblings);
+ prev($siblings); // Reset the internal pointer to previous pos
+ if ($tmp) {
+ $next = array($tmp["filename"].$ext, (empty($tmp["sdesc"]) ?
$tmp["ldesc"] : $tmp["sdesc"]));
+ break;
+ }
- // We are the end element in this chapter
- $tgrandpa = PhDHelper::getParent($tparent);
- if (!$tgrandpa || $tgrandpa == "ROOT") {
- // There is no next relative
- break;
- }
+ // We are the end element in this chapter
+ $grandpa = PhDHelper::getParent($parent);
+ if (!$grandpa || $grandpa == "ROOT") {
+ // There is no next relative
+ break;
+ }
- $tsiblings = PhDHelper::getChildren($tgrandpa);
- $tid = $tparent;
- $tparent = $tgrandpa;
- } while(true);
- } // }}}
+ $siblings = PhDHelper::getChildren($grandpa);
+ $id = $parent;
+ $parent = $grandpa;
+ } while(true);
return $next;
}
public function __destruct() {