private function save() { if (!_root::getRequest()->isPost()) { return false; } $oPluginXsrf = new plugin_xsrf(); if (!$oPluginXsrf->checkToken(_root::getParam('token'))) { //on verifie que le token est valide return array('token' => $oPluginXsrf->getMessage()); } $oArticleModel = new model_article(); $iId = _root::getParam('id', null); if ($iId == null) { $oArticle = new row_article(); } else { $oArticle = $oArticleModel->findById(_root::getParam('id', null)); } foreach ($oArticleModel->getListColumn() as $sColumn) { if (_root::getParam($sColumn, null) == null) { continue; } if (in_array($sColumn, $oArticleModel->getIdTab())) { continue; } $oArticle->{$sColumn} = _root::getParam($sColumn, null); } if ($oArticle->save()) { //une fois enregistre on redirige (vers la page de liste) _root::redirect('prive::list'); } else { return $oArticle->getListError(); } }
public function _list() { $oArticleModel = new model_article(); $tArticle = $oArticleModel->findAllOrderBy(module_table::getParam('order', 'titre'), module_table::getParam('side')); $oView = new _view('private/article::slist'); $oView->tArticle = $tArticle; $oView->tColumn = $oArticleModel->getListColumn(); //array('id','titre');// //on recupere un tableau indexe des auteurs pour afficher leur nom a la place de leur id $oView->tJoinAuteur = model_auteur::getInstance()->getSelect(); $this->oLayout->add('main', $oView); }