bplustree: making a message more explicit (walker)

fpdb:      fixed problem with single post navigation (new method)
This commit is contained in:
real_nowhereman 2009-12-03 10:41:54 +00:00
parent c601593a59
commit 345ad28d5f
2 changed files with 58 additions and 31 deletions

View File

@ -2455,12 +2455,12 @@ class BPlusWalker {
function current_key() { function current_key() {
if ($this->valid) return $this->node->keys[$this->node_index]; if ($this->valid) return $this->node->keys[$this->node_index];
else trigger_error("Not a valid index ({$this->node_index})"); else trigger_error("WALKER: Not a valid index ({$this->node_index})");
} }
function current_value() { function current_value() {
if ($this->valid) return $this->node->indices[$this->node_index]; if ($this->valid) return $this->node->indices[$this->node_index];
else trigger_error("Not a valid index ({$this->node_index})"); else trigger_error("WALKER: Not a valid index ({$this->node_index})");
} }
function current() { function current() {
@ -2470,7 +2470,7 @@ class BPlusWalker {
$this->node->indices[$this->node_index] $this->node->indices[$this->node_index]
); );
} else { } else {
trigger_error("Not a valid index ({$this->node_index})"); trigger_error("WALKER: Not a valid index ({$this->node_index})");
} }
} }

View File

@ -246,15 +246,29 @@
// in the sequence, if $prevkey becomes equal to $key then it means // in the sequence, if $prevkey becomes equal to $key then it means
// $key is the first post (the last in time) // $key is the first post (the last in time)
if ($prevkey == $key) $qp->start = 0;
$qp->start = 0;
else
$qp->start = 1;
$qp->count = 1; $qp->count = 1;
$this->pointer = 0; $this->pointer = 0;
if ($prevkey == $key) {
$this->prevkey = null;
if ($this->walker->valid) {
$this->walker->next();
$this->nextkey = $this->walker->current_key();
}
} else {
$this->prevkey = $prevkey;
if ($this->walker->valid) {
$this->walker->next();
if ($this->walker->valid) {
$this->walker->next();
$this->nextkey = $this->walker->valid? $this->walker->current_key() : null;
}
}
}
} }
function _prepare_list(&$entry_index) { function _prepare_list(&$entry_index) {
@ -348,17 +362,30 @@
global $post; global $post;
/*if (!$this->hasMore()) {
$false = array(false, false);
return $false;
}*/
$qp =& $this->params; $qp =& $this->params;
$return = array(false, false);
if ($this->counter < 0) if ($this->counter < 0)
$this->prepare(); $this->prepare();
if ($qp->id) {
$idx = $this->main_idx;
$key = entry_idtokey($qp->id);
$v = $idx->getitem($key);
if ($qp->fullparse) {
$entry = entry_parse($qp->id);
if (!$entry) return $return;
} else {
$entry = array('subject' => $v);
}
$return = array($this->params->id, $entry);
return $return;
}
if (!$this->walker) { if (!$this->walker) {
$false = array(false, false); $false = array(false, false);
return $false; return $false;
@ -504,17 +531,15 @@
function getNextPage() { function getNextPage() {
if ($this->single){ if ($this->single){
#return false; $key = $this->nextkey;
#$id = $this->_getOffsetId(1, $this->params->start); if (!$key)
$id = $this->walker->valid ? entry_keytoid($this->walker->current_key()) : false; return array(null, null);
else {
if ($id) { $val = $this->main_idx->getitem($key);
$label = $this->walker->current_value(); return array($val, entry_keytoid($key));
} else {
return false;
} }
return array($label, $id);
} }
@ -530,12 +555,14 @@
function getPrevPage() { function getPrevPage() {
if ($this->single) { if ($this->single){
$key = $this->prevkey;
$id = $this->previd; if (!$key)
$label = $this->preventry['subject']; return array(null, null);
else {
return array($label, $id); $val = $this->main_idx->getitem($key);
return array($val, entry_keytoid($key));
}
} }