public function _list() { //cache if (_root::getCache()->isCached('sidebar_categories')) { $oView = _root::getCache()->getCached('sidebar_categories'); return $oView; } $tCategories = model_categories::getInstance()->findAll(); $oView = new _view('categories::list'); $oView->tCategories = $tCategories; _root::getCache()->setCache('sidebar_categories', $oView); return $oView; }
public function _lastList() { //cache if (_root::getCache()->isCached('sidebar_lastpost')) { $oView = _root::getCache()->getCached('sidebar_lastpost'); return $oView; } $tPosts = model_posts::getInstance()->findLast(); $oView = new _view('posts::smalllist'); $oView->tPosts = $tPosts; $oView->tJoinmodel_categories = model_categories::getInstance()->getSelect(); $oView->tJoinmodel_users = model_users::getInstance()->getSelect(); _root::getCache()->setCache('sidebar_lastpost', $oView); return $oView; }
private function processSave() { if (!_root::getRequest()->isPost()) { //si ce n'est pas une requete POST on ne soumet pas return null; } $oPluginXsrf = new plugin_xsrf(); if (!$oPluginXsrf->checkToken(_root::getParam('token'))) { //on verifie que le token est valide return array('token' => $oPluginXsrf->getMessage()); } $iId = _root::getParam('id', null); if ($iId == null) { $oPosts = new row_posts(); } else { $oPosts = model_posts::getInstance()->findById(_root::getParam('id', null)); } $tColumn = array('category_id', 'user_id', 'name', 'slug', 'content'); foreach ($tColumn as $sColumn) { $oPosts->{$sColumn} = _root::getParam($sColumn, null); } if ($oPosts->save()) { if (_root::getCache()->isCached('sidebar_lastpost')) { _root::getCache()->clearCache('sidebar_lastpost'); } if (_root::getCache()->isCached('sidebar_categories')) { _root::getCache()->clearCache('sidebar_categories'); } //une fois enregistre on redirige (vers la page liste) _root::redirect('privatePosts::list'); } else { return $oPosts->getListError(); } }