/** * @return Zend_Db_Table_Row */ protected function _getErrorRow() { $row = self::$_model->fetchRow(array('sid=?' => 'error')); if (!$row) { $configError = new Z_Config('error_text'); $errtext = $configError->getValue(); $row = self::$_model->createRow(array('sid' => 'error', 'title' => 'Ошибка', 'text' => $errtext ? $errtext : 'Страница не найдена')); } return $row; }
public function reorderAction() { $this->setViewPathes(); $this->disableRenderView(); $ids = $this->_getParam('ids'); $id = $this->_getParam('id'); $direction = $this->_getParam('direction'); if ($ids && !empty($ids)) { $items = $this->z_model->find($ids); $orderids = array(); foreach ($items as $item) { $orderids[] = $item->orderid; } sort($orderids); $array_edit = array_combine($ids, $orderids); foreach ($items as $item) { if ($item->orderid != $array_edit[$item->id]) { $item->orderid = $array_edit[$item->id]; $item->save(); } } } elseif ($id) { if ($direction != 'up' && $direction != 'down' && $direction != 'top' && $direction != 'bottom') { return; } $item = $this->z_model->fetchRow(array('id=?' => $id)); if (!$item) { return; } if ($direction == 'up') { $item2 = $this->z_model->fetchRow(array('orderid<?' => $item->orderid), 'orderid desc'); } elseif ($direction == 'down') { $item2 = $this->z_model->fetchRow(array('orderid>?' => $item->orderid), 'orderid asc'); } elseif ($direction == 'top') { $item2 = $this->z_model->fetchRow(NULL, 'orderid asc'); } elseif ($direction == 'bottom') { $item2 = $this->z_model->fetchRow(NULL, 'orderid desc'); } if (!$item2) { return; } if ($direction == 'up' || $direction == 'down') { $tmp = $item->orderid; $tmp2 = $item2->orderid; $item->orderid = $tmp2; $item2->orderid = $tmp; $item->save(); $item2->save(); } elseif ($direction == 'top' || $direction == 'bottom') { $newOrderId = $direction == 'top' ? $item2->orderid - 1 : $item2->orderid + 1; $item->orderid = $newOrderId; $item->save(); } $this->ajaxGo($this->view->url(array('action' => $resource->actionId, 'direction' => NULL, 'id' => NULL))); } }