public static function load() { // Set Path Path::load(); // Set Link Link::load(); // Set URL Url::load(); // Set Language Language::load(); // Set parameters self::_setParameters(); // Set Controller self::_setController(); // Set Headers self::_setDefaultHeader(); }
/** * Edit blog post * * @uses ACL::post * @uses Gleez_Config::load * @uses Request::query * @uses Request::redirect * @uses Route::get * @uses Route::uri * @uses URL::query * @uses Tags::implode * @uses Date::date_time * @uses Path::load * @uses Message::success * @uses Log::add * @throws HTTP_Exception_403 */ public function action_edit() { $id = (int) $this->request->param('id', 0); $post = ORM::factory('blog', $id); if (!ACL::post('edit', $post)) { // If the post was not loaded, we return access denied. throw HTTP_Exception::factory(403, 'Access denied!'); } $this->title = $post->title; $config = Config::load('blog'); // Set form destination $destination = !is_null($this->request->query('destination')) ? array('destination' => $this->request->query('destination')) : array(); // Set form action $action = Route::get('blog')->uri(array('id' => $id, 'action' => 'edit')) . URL::query($destination); $view = View::factory('blog/form')->set('destination', $destination)->set('action', $action)->set('config', $config)->set('path', FALSE)->set('created', $post->created)->set('author', $post->user->name)->set('tags', Tags::implode($post->tags_form))->set('image', FALSE)->bind('errors', $this->_errors)->bind('terms', $terms)->bind('blog', $post); if ($config->get('use_captcha', FALSE)) { $captcha = Captcha::instance(); $view->set('captcha', $captcha); } if ($path = Path::load($post->rawurl)) { $view->set('path', $path['alias']); } if ($config->get('use_category', FALSE)) { $terms = ORM::factory('term', array('type' => 'blog', 'lvl' => 1))->select_list('id', 'name', '--'); } if ($config->get('primary_image', FALSE)) { $image = $post->image; } if ($this->valid_post('blog')) { try { $post->values($_POST)->save(); Log::info('Blog :title updated.', array(':title' => $post->title)); Message::success(__('Blog %title updated', array('%title' => $post->title))); $this->request->redirect(empty($destination) ? $post->url : $this->request->query('destination')); } catch (ORM_Validation_Exception $e) { // @todo Add messages $this->_errors = $e->errors('models', TRUE); } } $this->_tabs = array(array('link' => $post->url, 'text' => __('View')), array('link' => $post->edit_url, 'text' => __('Edit'))); if (ACL::post('delete', $post)) { $this->_tabs[] = array('link' => $post->delete_url, 'text' => __('Delete')); } $this->response->body($view); }
/** * Reading data from inaccessible properties * * @param string $field * @return mixed * * @uses Text::plain * @uses Text::markup * @uses HTML::links * @uses Path::load * @uses Route::get * @uses Route::uri */ public function __get($field) { switch ($field) { case 'title': return Text::plain(parent::__get('title')); break; case 'teaser': return Text::markup($this->rawteaser, $this->format); break; case 'body': return Text::markup($this->rawbody, $this->format); break; case 'terms_form': return $this->terms->find()->id; break; case 'tags_form': return $this->tags->find_all()->as_array('id', 'name'); break; case 'taxonomy': return HTML::links($this->terms->find_all(), array('class' => 'nav nav-pills pull-right')); break; case 'tagcloud': return HTML::links($this->tags->find_all(), array('class' => 'nav nav-pills')); break; case 'links': return HTML::links($this->links(), array('class' => 'links inline')); break; case 'rawtitle': // Raw fields without markup. Usage: during edit or etc! return parent::__get('title'); break; case 'rawteaser': // Raw fields without markup. Usage: during edit or etc! return parent::__get('teaser'); break; case 'rawbody': // Raw fields without markup. Usage: during edit or etc! return parent::__get('body'); break; case 'rawurl': return Route::get($this->type)->uri(array('id' => $this->id, 'action' => 'view')); break; case 'rawimage': // Raw fields without path. Usage: during edit or etc! return parent::__get('image'); break; case 'url': // Model specific links; view, edit, delete url's return ($path = Path::load($this->rawurl)) ? $path['alias'] : $this->rawurl; break; case 'edit_url': return Route::get($this->type)->uri(array('id' => $this->id, 'action' => 'edit')); break; case 'delete_url': return Route::get($this->type)->uri(array('id' => $this->id, 'action' => 'delete')); break; case 'image': return $this->rawimage ? $this->_image_url . $this->rawimage : NULL; break; case 'count_comments': return (int) DB::select(array(DB::expr('COUNT(*)'), 'mycount'))->from('comments')->where('status', '=', 'publish')->where('post_id', '=', $this->id)->execute()->get('mycount'); break; } return parent::__get($field); }
/** * Reading data from inaccessible properties * * @param string $field * @return mixed * * @uses HTML::chars * @uses Route::get * @uses Route::uri * @uses Path::load */ public function __get($field) { $nick = parent::__get('nick'); switch ($field) { case 'name': case 'mail': return HTML::chars(parent::__get($field)); break; case 'nick': // Return the best version of the user's name. // Either their specified nick name, or fall back to the user name. return empty($nick) ? HTML::chars($this->name) : HTML::chars($nick); break; case 'rawurl': return Route::get('user')->uri(array('id' => $this->id)); break; case 'url': // Model specific links; view, edit, delete url's. return ($path = Path::load($this->rawurl)) ? $path['alias'] : $this->rawurl; break; case 'edit_url': // Model specific links; view, edit, delete url's. return Route::get('user')->uri(array('id' => $this->id, 'action' => 'edit')); break; case 'delete_url': // Model specific links; view, edit, delete url's. return Route::get('admin/user')->uri(array('id' => $this->id, 'action' => 'delete')); break; } return parent::__get($field); }
/** * Reading data from inaccessible properties * * @param string $field * @return mixed * * @uses HTML::chars * @uses Route::get * @uses Route::uri * @uses Path::load */ public function __get($field) { switch ($field) { case 'name': return HTML::chars(parent::__get('name')); break; case 'image': return is_null(parent::__get('image')) ? 'media/images/camera.png' : parent::__get('image'); break; case 'rawname': // Raw fields without markup. Usage: during edit or etc! return parent::__get('name'); break; case 'rawurl': // Raw fields without markup. Usage: during edit or etc! return Route::get($this->type)->uri(array('action' => 'term', 'id' => $this->id)); break; case 'url': case 'link': // Model specific links; view, edit, delete url's. return ($path = Path::load($this->rawurl)) ? $path['alias'] : $this->rawurl; break; case 'edit_url': // Model specific links; view, edit, delete url's. return Route::get('admin/term')->uri(array('id' => $this->id, 'action' => 'edit')); break; case 'delete_url': // Model specific links; view, edit, delete url's. return Route::get('admin/term')->uri(array('id' => $this->id, 'action' => 'delete')); break; } return parent::__get($field); }