protected function fillObject($data) { $object = parent::fillObject($data); $sectionmodel = new myarticlesectionModel(); $articlemodel = new myarticleModel(); $section = $sectionmodel->getfromId($object->getSectionid()); if (count($section) == 1) { $object->setSectionname($section[0]->getName()); } $article = $articlemodel->getfromId($object->getArticleid()); if (count($article) == 1) { $object->setAlias($article[0]->getAlias()); $object->setArticleauthorname($article[0]->getAuthorname()); $object->setArticlecreationdate($article[0]->getCreationdate()); } return $object; }
public function addsectionlink($parameters = array()) { if (isset($parameters['sectionid'])) { $newlink = new myarticlesectionlinkObject(); $newlink->setArticleid($parameters['articleid']); $newlink->setSectionid($parameters['sectionid']); $model = new myarticlesectionlinkModel(); $newlink->setOrder($model->getmax('order', array('sectionid' => array('mode' => '=', 'value' => $parameters['sectionid']))) + 1); $flash = new popupController(); $testcond = array('AND' => array(array('sectionid' => array('mode' => '=', 'value' => $parameters['sectionid'])), array('articleid' => array('mode' => '=', 'value' => $parameters['articleid'])))); if (count($model->get($testcond)) > 0) { $flash->createflash(array('name' => 'warning', 'type' => 'warning', 'content' => 'Deze sectie was reeds gelinked')); return false; } try { $model->save($newlink); } catch (Exception $e) { $flash->createflash(array('name' => 'error', 'type' => 'error', 'content' => 'De aanpassing werd niet doorgevoerd! Contacteer de informaticadienst.')); return false; } $flash->createflash(array('name' => 'error', 'type' => 'success', 'content' => 'De aanpassing werd goed doorgevoerd.')); $gridcontr = new mygridController(); $gridcontr->reloadgrid($parameters['oldgrid']); return true; } else { $view = new ui($this); $grid = new mygrid('sections'); $grid->setModel(new myarticlesectionModel()); $grid->registerRequest('name', 'myarticle', 'addsectionlink', array('sectionid' => '{id}', 'articleid' => $parameters['articleid'], 'oldgrid' => $parameters['-gridid-'], 'myacl' => array('target' => '{this}', 'right' => 'manage_articlelinks', 'default' => false))); $view->assign('grid', $grid); return $view->fetch('myarticle_addsectionlink.tpl'); } }
public function deletemodulepagelink($parameters = array()) { if ($parameters['sure'] == 'sure') { $model = new myarticlesectionlinkModel(); $flash = new popupController(); $curlink = $model->getfromId($parameters['id']); if (count($curlink) == 1) { try { $model->deletebyId($parameters['id']); } catch (Exception $e) { $flash->createflash(array('name' => 'error', 'type' => 'error', 'content' => 'De aanpassing werd niet doorgevoerd! Contacteer de informaticadienst.')); return false; } } else { $flash->createflash(array('name' => 'warning', 'type' => 'warning', 'content' => 'De aanpassing werd niet doorgevoerd omdat deze link reeds verwijderd was!')); return false; } $flash->createflash(array('name' => 'error', 'type' => 'success', 'content' => 'De aanpassing werd goed doorgevoerd.')); return true; } else { $model = new processedmodulepageModel(); $link = $model->getfromId($parameters['id']); if (count($link) == 1) { $view = new ui($this); $view->assign('link', $link[0]); return $view->fetch('mypageadmin_deletemodulepagelink.tpl'); } } }
public function addpromotext($parameters = array()) { $view = new ui($this); $form = new mygridform($parameters, $parameters['-gridid-'], 'edit'); $form->addField(new textField('title', 'Titel', '', array('required'))); $form->addField(new textField('alias', 'Werktitel', '')); $form->addField(new datepickerField('start', 'Gepubliceerd van', true, '', array('required'))); $form->addField(new hiddenField('limit', 'limit')); $form->addField(new datepickerField('stop', 'Gepubliceerd tot', true, '', array('required'))); $form->addField(new rteField('content', 'Inhoud', '', array('required'))); $draft = new selectField('state', 'Bewaar als', array('required')); $draft->addOption(new selectoptionField('Actieve versie', 'Actief', true)); $draft->addOption(new selectoptionField('Draft', 'Draft', false)); $form->addField($draft); $form->addField(new hiddenField('sectionid', $parameters['sectionid'])); if ($form->validate()) { $newarticle = new myarticleObject(); $newarticle->setAuthor(myauth::getCurrentuser()->getId()); $newarticle->setAuthorname(myauth::getCurrentuser()->getName()); $newarticle->setCreationdate(time()); if ($form->getFieldvalue('alias') != '') { $newarticle->setAlias($form->getFieldvalue('alias')); } else { $newarticle->setAlias($form->getFieldvalue('title')); } $newversion = new myarticleversionObject(); $newversion->setAuthor($newarticle->getAuthor()); $newversion->setAuthorname($newarticle->getAuthorname()); $newversion->setCreationdate($newarticle->getCreationdate()); $newversion->setTitle($form->getFieldvalue('title')); $newversion->setState($form->getFieldvalue('state')); $newversion->setStartpublishdate($form->getFieldvalue('start')); $newversion->setContent($form->getFieldvalue('content')); if ($form->getFieldvalue('limit') == 'limit') { $newversion->setStoppublishdate($form->getFieldvalue('stop')); } else { $newversion->setStoppublishdate(-1); } try { $articlemodel = new myarticleModel(); $versionmodel = new myarticleversionModel(); $linkmodel = new myarticlesectionlinkModel(); $articlemodel->save($newarticle); $newversion->setArticleid($newarticle->getId()); $versionmodel->save($newversion); $newlink = new myarticlesectionlinkObject(); $newlink->setArticleid($newarticle->getId()); $newlink->setSectionid($parameters['sectionid']); $newlink->setOrder($linkmodel->getmax('order', array('sectionid' => array('mode' => '=', 'value' => $parameters['sectionid']))) + 1); $linkmodel->save($newlink); } catch (Exception $e) { $flash = new popupController(); $flash->createflash(array('name' => 'erroredit', 'type' => 'error', 'content' => 'De gegevens werden niet toegevoegd! Raadpleeg de informaticadienst.')); return false; } $flash = new popupController(); $flash->createflash(array('name' => 'flash_add_' . $parameters['-gridid-'], 'type' => 'success', 'content' => 'De gegevens zijn goed toegevoegd.')); $this->response->assign('gridextra_' . $parameters['-gridid-'], 'innerHTML', ''); return true; } elseif (!$form->isSent()) { $view->assign('form', $form); return $view->fetch('myarticle_addarticle.tpl'); } else { return false; } }