function delete($id, $entry) { $key = entry_idtokey($id); if (!$this->_lock_acquire()) { return false; } // we're DOOMED! $main =& $this->get_index(); $main->delitem($key); if (isset($entry['categories']) && is_array($entry['categories'])) { foreach ($entry['categories'] as $cat) { if (!is_numeric($cat)) { continue; } $this_index =& $this->get_index($cat); if ($this_index->has_key($key)) { $this_index->delitem($key); } } } return $this->_lock_release(); }
function &peekEntry() { global $post; $qp =& $this->params; $return = array(false, false); if ($this->counter < 0) { $this->prepare(); } if ($this->pointer == $this->params->start + $this->params->count) { return $return; } if ($qp->id) { $idx = $this->main_idx; $key = entry_idtokey($qp->id); $v = $idx->getitem($key); if ($qp->fullparse) { $entry = isset($this->localcache[$qp->id]) ? $this->localcache[$qp->id] : entry_parse($qp->id); if ($entry && $qp->comments) { $this->comments = new FPDB_CommentList($qp->id, comment_getlist($qp->id)); $entry['comments'] = $this->comments->getCount(); } $post = $entry; if (!$entry) { return $return; } } else { $entry = array('subject' => $v); $post = $entry; } $return = array($this->params->id, $entry); return $return; } if (!$this->walker) { $false = array(false, false); return $false; } // search first eligible post while ($this->walker->valid && $this->pointer < $qp->start) { $this->previd = $this->currentid; $key = $this->walker->current_key(); $id = $this->currentid = entry_keytoid($key); if ($this->single) { $this->preventry = array('subject' => $this->walker->current_value()); } $this->walker->next(); $this->pointer++; } // if there is a secondary (not) idx if ($this->secondary_idx) { // skips posts until we find one which is not in the secondary idx while ($this->walker->valid && ($key = $this->walker->current_key()) && $this->secondary_idx->has_key($key)) { $this->walker->next(); //$qp->count--; } } if (!$this->walker->valid) { $cont = false; return $cont; } // pointer == start $prevcurr = $this->currentid; $id = $this->currentid = entry_keytoid($this->walker->current_key()); if ($id != $prevcurr) { $this->previd = $prevcurr; } if ($qp->fullparse && $this->counter <= 0) { // full parse: reads the whole array from file $cont = array(); $cont = isset($this->localcache[$id]) ? $this->localcache[$id] : entry_parse($id); } else { // only title $cont = array('subject' => $this->walker->current_value(), 'date' => entry_idtotime($id)); } if (!$cont) { $cont = false; return $cont; } if ($qp->comments) { $this->comments = new FPDB_CommentList($id, comment_getlist($id)); $cont['comments'] = $this->comments->getCount(); } $post = $cont; $post['id'] = $id; $var = array(&$id, &$cont); return $var; }