示例#1
0
 /**
  *
  * @param int $id
  * @return Zend_Db_Statement_Interface
  */
 public function deleteItem($id)
 {
     $row = $this->find($id)->current();
     if (!$row) {
         return false;
     }
     /*
      * select cid array
      * delete from this where id in cid array
      * delete from description where cat_id in cid array
      * update tree index
      */
     $childrenIds = $this->select('id')->where("lft BETWEEN {$row->lft} AND {$row->rgt}")->where('site_id = ?', $row->site_id)->fetchCol();
     if (!sizeof($childrenIds)) {
         return false;
     }
     Axis::single('catalog/hurl')->delete(array($this->getAdapter()->quoteInto('key_id IN(?)', $childrenIds), "key_type = 'c'"));
     $nstreeTable = new Axis_NSTree_Table();
     return $nstreeTable->deleteNode($id, true);
 }
 public function moveAction()
 {
     $moveType = $this->_getParam('moveType');
     $newParentId = $this->_getParam('newParentId');
     $categoryId = $this->_getParam('catId');
     $model = new Axis_NSTree_Table();
     switch ($moveType) {
         case 'moveTo':
             $success = $model->replaceNode($categoryId, $newParentId);
             break;
         case 'moveBefore':
             $success = $model->replaceBefore($categoryId, $newParentId);
             break;
     }
     if (!$success) {
         return $this->_helper->json->sendFailure();
     }
     return $this->_helper->json->sendSuccess();
 }
示例#3
0
 /**
  * Проверяет, имеются ли другие узлы, ссылающиеся на данные
  * предоставленного узла. Имеет смысл только для деревьев NETWORK
  *
  * @param Axis_NSTree_Node $node
  * @param Axis_NSTree_Node $root если задан узел root,
  *                                  то ссылки внутри этого узла будут игнорироваться
  * @return bool
  */
 private function _hasSymlinks($node, $root = null)
 {
     $struct = $node->getStructure();
     $where = $this->_table->getAdapter()->quoteInto("{$this->_dataForeign} = ?", $struct['dataForeign']);
     if (null !== $root) {
         $rootStruct = $root->getStructure();
         $where .= $this->_table->getAdapter()->quoteInto(" AND ({$this->_left} NOT BETWEEN ? AND ?)", $rootStruct['left'], $rootStruct['right']);
     }
     $rowset = $this->_table->fetchAll($where);
     return count($rowset) > 1;
 }