/** * @before _secured, _admin */ public function edit($id) { $view = $this->getActionView(); $content = App_Model_PageContent::first(array('id = ?' => (int) $id)); if (NULL === $content) { $view->warningMessage('Obsah nenalezen'); $this->_willRenderActionView = false; self::redirect('/admin/content/'); } $view->set('content', $content); if (RequestMethods::post('submitEditContent')) { if ($this->checkCSRFToken() !== true) { self::redirect('/admin/content/'); } $cache = Registry::get('cache'); $errors = array(); $urlKey = $this->_createUrlKey(RequestMethods::post('page')); if ($content->getUrlKey() !== $urlKey && !$this->_checkUrlKey($urlKey)) { $errors['title'] = array('Stránka s tímto názvem již existuje'); } $content->pageName = RequestMethods::post('page'); $content->urlKey = $urlKey; $content->body = RequestMethods::post('text'); $content->bodyEn = RequestMethods::post('texten'); $content->metaTitle = RequestMethods::post('metatitle'); $content->metaDescription = RequestMethods::post('metadescription'); $content->active = RequestMethods::post('active'); if (empty($errors) && $content->validate()) { $content->save(); Event::fire('admin.log', array('success', 'Content id: ' . $id)); $view->successMessage(self::SUCCESS_MESSAGE_2); $cache->erase($content->getUrlKey()); self::redirect('/admin/content/'); } else { Event::fire('admin.log', array('fail', 'Content id: ' . $id)); $view->set('errors', $content->getErrors())->set('content', $content); } } }
/** * */ public function actions() { $view = $this->getActionView(); $layoutView = $this->getLayoutView(); $content = $this->getCache()->get('akce'); if (NULL !== $content) { $content = $content; } else { $content = App_Model_PageContent::first(array('active = ?' => true, 'urlKey = ?' => 'akce')); $this->getCache()->set('akce', $content); } $canonical = 'http://' . $this->getServerHost() . '/akce'; $view->set('content', $content); $this->_checkMetaData($layoutView, $content); $layoutView->set('canonical', $canonical)->set('metatitle', 'ZKO - Akce'); }