public function getExtrasearchconds($search, $cond) { $baseset = $this->get($cond); $extracond = array(); foreach ($baseset as $row) { $newcond = array(); $tmp = array(); $idcond = array('articleid' => array('mode' => '=', 'value' => $row->getId())); $model = new myarticleversionModel(); $columns = $model->getColumns(); foreach ($columns as $col) { $tmp[] = array($col => array('mode' => '=', 'value' => '*' . $search . '*')); } $newcond = array('AND' => array($idcond, array('OR' => $tmp))); $res = $model->get($newcond); if (count($res) > 0) { $extracond[] = array('id' => array('mode' => '=', 'value' => $row->getId())); } } return $extracond; }
public function wikieditversion($parameters = array()) { $view = new ui($this); $articlemodel = new myarticleModel(); $versionmodel = new myarticleversionModel(); $version = $versionmodel->getfromId($parameters['id']); if (count($version) == 1) { $version = $version[0]; $form = new mygridform($parameters, $parameters['-gridid-'], 'edit'); $form->addField(new textField('title', 'Titel', $version->getTitle(), array('required'))); $form->addField(new hiddenField('start', time())); $form->addField(new hiddenField('alias', $parameters['alias'])); $form->addField(new hiddenField('limit', '')); $form->addField(new hiddenField('stop', -1)); $form->addField(new hiddenField('section', $parameters['section'])); $form->addField(new rteField('content', 'Inhoud', $version->getContent(), 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('articleid', $parameters['articleid'])); $form->addField(new hiddenField('id', $parameters['id'])); if ($form->validate()) { $newversion = new myarticleversionObject(); $newversion->setArticleid($parameters['articleid']); $newversion->setAuthor(myauth::getCurrentuser()->getId()); $newversion->setAuthorname(myauth::getCurrentuser()->getName()); $newversion->setCreationdate(time()); $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 { if ($form->getFieldvalue('state') == 'Actief') { $articleidcond = array('articleid' => array('mode' => '=', 'value' => $parameters['articleid'])); $statecond = array('state' => array('mode' => '=', 'value' => 'Actief')); $prevactive = $versionmodel->get(array('AND' => array($articleidcond, $statecond))); foreach ($prevactive as $prev) { // This could have been if equal to 1 and just do the one, but this method is "self-healing" if multiple versions get flagged active $prev->setState('Gearchiveerd'); $versionmodel->save($prev); } } $versionmodel->save($newversion); } catch (Exception $e) { $flash = new popupController(); $flash->createflash(array('name' => 'erroredit', 'type' => 'error', 'content' => 'De gegevens werden niet aangepast! Raadpleeg de informaticadienst.')); return false; } $flash = new popupController(); $flash->createflash(array('name' => 'flash_add_' . $parameters['-gridid-'], 'type' => 'success', 'content' => 'De gegevens zijn goed aangepast.')); $this->response->assign('gridextra_' . $parameters['-gridid-'], 'innerHTML', ''); return true; } elseif (!$form->isSent()) { $view->assign('form', $form); return $view->fetch('myarticle_editversion.tpl'); } else { return false; } } 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; } }