Example #1
0
 function postForm()
 {
     if ($this->getForm()->validate()) {
         $nyhed = new VIH_News($this->context->name());
         $input = $this->body();
         $input['title'] = vih_handle_microsoft($input['title']);
         $input['tekst'] = vih_handle_microsoft($input['tekst']);
         $input['overskrift'] = vih_handle_microsoft($input['overskrift']);
         $input['date_publish'] = $this->body('date_publish');
         $input['date_publish'] = $input['date_publish']['Y'] . '-' . $input['date_publish']['m'] . '-' . $input['date_publish']['d'];
         $input['date_expire'] = $this->body('date_expire');
         if (!empty($input['date_expire']['Y'])) {
             $input['date_expire'] = $input['date_expire']['Y'] . '-' . $input['date_expire']['m'] . '-' . $input['date_expire']['d'];
         } else {
             $input['date_expire'] = '0000-00-00 00:00:00';
         }
         if ($id = $nyhed->save($input)) {
         }
         // strengen med keywords
         if (!empty($input['keyword'])) {
             $keyword = new Ilib_Keyword_Appender($nyhed);
             // starter keyword objektet
             $appender = new Ilib_Keyword_StringAppender(new Ilib_Keyword($nyhed), $keyword);
             $appender->addKeywordsByString($input['keyword']);
         }
         if ($nyhed->isPublished()) {
             $this->twitter->statuses->update('"' . $input['overskrift'] . '" kan læses på http://vih.dk/nyheder/' . $id);
             $this->twitter->account->end_session();
         }
         if (is_numeric($this->context->name())) {
             return new k_SeeOther($this->url('../'));
         }
         return new k_SeeOther($this->url('../' . $id));
     }
     return $this->render();
 }