_getDataObj()->getCategories(); $this->_idCategory = (int)Qs_Request::getRequestValue('idCategory', key($categories)); // дефолтна категорія $dataObj = new App_Settings_Obj(array( 'idCategory' => $this->_idCategory, 'suMode' => $this->_doc->getAuth()->getSuMode() )); $this->setDataObj($dataObj); parent::_init(); $this->_setMessage('%itemsName% have been updated', static::MSG_UPDATED); $message = 'This category is currently being edited by "%firstName% %lastName%" %userRoleTitle%. ' . 'Please try again later.'; $this->_setMessage($message, static::MSG_LOCKED); return $this; } protected function _getEditForm(array $options = array()) { $options['cancelUrl'] = Qs_Constant::get('BASE_URL_LANGUAGE') . '/' . Qs_Constant::get('CURRENT_PAGE') . '?action=cancel&idCategory=' . $this->_idCategory; $options['enctype'] = Qs_Form::ENCTYPE_MULTIPART; $options['idCategory'] = $this->_idCategory; return parent::_getEditForm($options); } protected function _getBackUrl($sessionName = null, $defaultUrl = null) { $options = array('idCategory' => $this->_idCategory); return $this->url($options); } protected function _doEdit() { if (null === ($data = $this->_getData4Form())) { $this->_setBackError(static::MSG_DATA_UNAVAILABLE); $this->_doBack(); } if (App_Admin_Auth::getInstance()->getSuMode()) { $this->_addLinksItem(); } $this->_setPageHeader(); $this->_addCategoriesTabs(); if (!$this->_lock()) { $item = array( 'tpl' => $this->getTemplate('message-locked.tpl'), 'link' => $this->_getBackUrl(), 'message' => $this->_createMessage(static::MSG_LOCKED, $this->_getLocker()), ); $this->_addItem($item); return $this; } $form = $this->_getEditForm(array('defaults' => $data)); $form->setDefaults(); $this->_addFormItem($form); $this->_postEdit(); return $this; } protected function _doUpdate() { $this->_setPageHeader(); $this->_addCategoriesTabs(); return parent::_doUpdate(); } protected function _addCategoriesTabs() { $categories = $this->_getDataObj()->getCategories(); if (is_array($categories) && count($categories) > 1) { $buttons = array(); foreach ($categories as $id => $label) { $click = "try {" . "document.location='" . BASE_URL . '/' . CURRENT_PAGE . '?idCategory=' . ((int) $id) . "'" . "} catch(e) {};" . "return false;"; $active = ($this->_idCategory == $id) ? true : false; $label = $this->_translate($label); $link = '' . htmlspecialchars($label) . ''; $buttons[] = array('html' => $link, 'active' => $active); } $item = array('tpl' => $this->getTemplate('categories.tpl'), 'categories' => $buttons); $this->_addItem($item); } return $this; } protected function _setPageHeader() { $categories = $this->_getDataObj()->getCategories(); $categoryId = $this->_getDataObj()->getPrimaryKey(); $this->_doc->setHeader($this->translate('Edit ' . $categories[$categoryId])); return $this; } protected function _log() { if ($this->_hasLog && Qs_ViewController_Log::getEnabled()) { $options = array( 'categoryTitle' => Qs_Array::get($this->_getDataObj()->getCategories(), (string)$this->_idCategory) ); $this->_getLog()->write($this->_action, $options); } return $this; } protected function _getDefaultLinks() { $url = Qs_SiteMap::findFirst(null, array('type' => 'Settings\Field\Admin\\'), null, 'url'); $links = array(array( 'url' => $url . '?idCategory=' . $this->_idCategory, 'title' => 'Manage Fields' )); return $links; } }