Esempio n. 1
0
 public function wikiaddArticle($parameters = array())
 {
     $view = new ui($this);
     $closerequest = new ajaxrequest('myarticle', 'followwikibreadcrumb', array('id' => $parameters['id'], 'section' => $parameters['section']));
     $view->assign('closerequest', $closerequest);
     $form = new form($parameters);
     $form->addField(new textField('title', 'Titel', $parameters['title'], array('required')));
     $form->addField(new hiddenField('alias', $parameters['alias']));
     $form->addField(new hiddenField('start', time()));
     $form->addField(new hiddenField('limit', ''));
     $form->addField(new hiddenField('stop', -1));
     $form->addField(new rteField('content', 'Inhoud', '', array('required')));
     $form->addField(new hiddenField('state', 'Actief'));
     $form->addField(new hiddenField('section', $parameters['section']));
     $form->addField(new hiddenField('id', $parameters['id']));
     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();
             $articlemodel->save($newarticle);
             $newversion->setArticleid($newarticle->getId());
             $versionmodel->save($newversion);
             $linkmodel = new myarticlesectionlinkModel();
             $newlink = new myarticlesectionlinkObject();
             $newlink->setArticleid($newarticle->getId());
             $newlink->setSectionid($parameters['section']);
             $newlink->setOrder($linkmodel->getmax('order', array('sectionid' => array('mode' => '=', 'value' => $parameters['section']))) + 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', 'type' => 'success', 'content' => 'De gegevens zijn goed toegevoegd.'));
         $this->followwikilink(array('name' => $newarticle->getAlias(), 'section' => $parameters['section'], 'id' => $parameters['id']));
         return true;
     } elseif (!$form->isSent()) {
         $view->assign('form', $form);
         $this->response->assign('wiki_' . $parameters['section'], 'innerHTML', $view->fetch('myarticle_wiki_addarticle.tpl'));
     } else {
         return false;
     }
 }
 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;
     }
 }