예제 #1
0
 public function newStatementAction()
 {
     /*
     if (!$this->_user->user_id)
         return $this->_msg('Нужна авторизация', 'Чтобы создавать новые идеи вы должны быть авторизованы');
     */
     require_once ST_DIR . '/Form/Statement.php';
     $form = new FormStatement($this->_user);
     $form->bindRequest($this->_request);
     $this->eventManager->notify('statement.new.start', $this, $form);
     if ($this->_request->isMethod('post') && $this->_request->has('send') && $form->isValid()) {
         $statement = $form->getModel();
         $statement->setDate(time());
         $text = $statement->getText();
         $text = strip_tags($text);
         if (mb_strlen($text) > $this->_config['teaser_length']) {
             $count = $this->_config['teaser_length'];
             while (isset($text[$count - 1]) && $text[$count - 1] != '.') {
                 $count++;
             }
             $statement->setTeaser(mb_substr($text, 0, $count));
         } else {
             $statement->setTeaser($statement->getText());
         }
         $this->eventManager->notify('statement.new.presave', $this, $statement);
         $statement->save();
         $this->eventManager->notify('statement.new.completed', $this, $statement);
         return $this->_redirect('@view', array('id' => $statement->getId()));
     }
     $view = $this->getViews();
     $vars = $form->getVars();
     $vars['bbcode'] = $view->getBBCodes('st_text', 'statement_form');
     $vars['ulogin'] = $view->getBaseURL() . "engine/modules/Statement/Resources/addition/ulogin_xd.html";
     $this->eventManager->notify('statement.new.render', $this, $vars);
     $view->returnContent($view->render('newStatement', $vars));
     $this->setPgeTitle($this->t('Добавить своё предложение'));
     $this->addToBreadcrumbs($this->t('Предложения'), self::getURLByRoute('index'));
     $this->addToBreadcrumbs($this->t('Добавить своё предложение'));
 }
예제 #2
0
 protected function _getVars()
 {
     $vars = parent::_getVars();
     $status = '<select name="status"><option value=""></option>';
     foreach (Statement::$statues as $key => $value) {
         if ($key == $this->_original_data['status']) {
             $selected = " selected='selected'";
         } else {
             $selected = '';
         }
         $status .= "<option value='{$key}'{$selected}>{$value}</option>";
     }
     $status .= '</select>';
     return array_merge($vars, array('status' => $status));
 }