public function admin_index() { // ajax? if ($this->is_ajax) { // page? $page = $this->assign('page', (int) Url::GetRequest('page', 1)); // limit $limit = 10; $offset = ($page - 1) * $limit; // page count $page_count = $this->assign('page_count', ceil(count(AppModel::FindAllSearched(Url::$data['modelName'], Url::GetRequest('search', null), false, $this->filter->where)) / $limit)); // items $this->assign('items', AppModel::FindAllSearched(Url::$data['modelName'], Url::GetRequest('search', null), false, $this->filter->where, null, $limit, $offset)); } else { // items $this->assign('items', AppModel::FindAll(Url::$data['modelName'], false, $this->filter->where, '`' . $this->Model->name_fields[0] . '` ASC')); } // options $this->assign('is_publishable', $this->Model->is_publishable()); }
private function _handle_attachments() { if (!$this->do_handle_attachments) { return true; } // cycle Associations foreach ($this->get_attached as $class) { // save passed $tmp = isset($this->{$class}) ? $this->{$class} : array(); // get all objects $Objects = AppModel::FindAll($class, false); // only one query // detach foreach ($this->find_attached($class) as $Object) { $this->detach($Object); } // attach if (!empty($tmp)) { foreach ($tmp as $objectOrId) { $Object = is_numeric($objectOrId) ? $Objects[$objectOrId] : $objectOrId; $this->attach($Object); } } else { $this->{$class} = array(); } } return true; }