Exemplo n.º 1
0
 /**
  * Задание контента страницы с добавлением полей прогресса и кнопок навигации по шагам
  * '<%PROGRESS_BAR%>' - строка, отображающая последовательность шагов
  * '<%NAVIGATION_BAR%>' - панель, отображающая кнопки для переключения между шагами
  *
  * @param string $content контент страницы
  */
 public function _set_content($content)
 {
     $buttons_html = '';
     $steps_count = count($this->_steps);
     if (!$this->review_mode) {
         $steps_html = '';
         $steps_spacer = $this->load->view('common/campaign_wizard/steps_spacer.html', '', TRUE);
         for ($i = 0; $i < $steps_count; $i++) {
             if ($i > 0) {
                 $steps_html .= $steps_spacer;
             }
             if ($i < $this->_currentStep->getStep()) {
                 $steps_html .= $this->parser->parse('common/campaign_wizard/completed_step.html', array('STEP_TITLE' => __($this->_steps[$i]->getTitle())), TRUE);
             }
             if ($i == $this->_currentStep->getStep()) {
                 $steps_html .= $this->parser->parse('common/campaign_wizard/current_step.html', array('STEP_TITLE' => __($this->_steps[$i]->getTitle())), TRUE);
             }
             if ($i > $this->_currentStep->getStep()) {
                 $steps_html .= $this->parser->parse('common/campaign_wizard/not_completed_step.html', array('STEP_TITLE' => __($this->_steps[$i]->getTitle())), TRUE);
             }
         }
         //Back
         if (!is_null($this->_currentStep) && !$this->_currentStep->isFirstStep()) {
             $buttons_html .= $this->parser->parse('common/campaign_wizard/button.html', array('BUTTON_ICON' => 'ico-back', 'BUTTON_TITLE' => __('Back'), 'ON_CLICK' => 'onclick=\'top.document.location="<%SITEURL%>' . $this->_currentStep->getPreviousStep()->getController() . '"\''), TRUE);
         }
         //Next/Create
         if (!is_null($this->_currentStep) && !$this->_currentStep->isLastStep()) {
             $button_title = __('Next');
             $button_icon = 'ico-next';
         } else {
             $button_title = __($this->create_save_button);
             $button_icon = 'ico-confirm';
         }
         $buttons_html .= $this->parser->parse('common/campaign_wizard/button.html', array('BUTTON_ICON' => $button_icon, 'BUTTON_TITLE' => $button_title, 'ON_CLICK' => 'onclick="' . $this->on_submit . '"'), TRUE);
         //Cancel
         $cancel_func = 'go("<%SITEURL%><%INDEXPAGE%>' . $this->cancel_creation_controller . '")';
         if ('' != $this->cancel_confirmation) {
             $cancel_func = 'if(confirm("' . __($this->cancel_confirmation) . '")) {' . $cancel_func . '}';
         }
         $buttons_html .= "&nbsp;&nbsp;&nbsp;" . $this->parser->parse('common/campaign_wizard/button.html', array('BUTTON_ICON' => 'ico-cancel', 'BUTTON_TITLE' => __('Cancel'), 'ON_CLICK' => 'onclick=\'' . $cancel_func . '\''), TRUE);
         $progress_bar = '';
         if ($this->progressbar) {
             $progress_bar = $this->parser->parse('common/campaign_wizard/progress_bar.html', array('STEPS' => $steps_html), TRUE);
         }
         $content = str_replace('<%PROGRESS_BAR%>', $progress_bar, $content);
     } else {
         //открытие страницы в режиме review
         if (!is_null($this->_currentStep->getReviewNextStep())) {
             $button_title = __('Next');
             $button_icon = 'ico-next';
         } else {
             if (!is_null($this->_currentStep->getConfirmationButtonTitle())) {
                 $button_title = __($this->_currentStep->getConfirmationButtonTitle());
             } else {
                 $button_title = __('Apply');
             }
             $button_icon = 'ico-confirm';
         }
         $buttons_html .= $this->parser->parse('common/campaign_wizard/button.html', array('BUTTON_ICON' => $button_icon, 'BUTTON_TITLE' => $button_title, 'ON_CLICK' => 'onclick="' . $this->on_submit . '"'), TRUE);
         if (!is_null($this->_currentStep->getReviewPreviousStep())) {
             $back_cotnroller_path = $this->_currentStep->getReviewPreviousStep();
             $buttons_html .= $this->parser->parse('common/campaign_wizard/back_button.html', array('PATH_TO_PREV_CONTROLLER' => '<%SITEURL%><%INDEXPAGE%>' . $back_cotnroller_path), TRUE);
         } else {
             $lastStep = count($this->_steps) - 1;
             $back_cotnroller_path = $this->_steps[$lastStep]->getController();
             $buttons_html .= $this->parser->parse('common/campaign_wizard/button.html', array('BUTTON_ICON' => 'ico-back', 'BUTTON_TITLE' => __('Back'), 'ON_CLICK' => 'onclick=\'go("<%SITEURL%><%INDEXPAGE%>' . $back_cotnroller_path . '")\''), TRUE);
         }
         if (!is_null($this->_currentStep->getReviewTitle())) {
             $content = str_replace('<%PROGRESS_BAR%>', '<h1>' . __($this->_currentStep->getReviewTitle()) . '</h1>', $content);
         } else {
             $content = str_replace('<%PROGRESS_BAR%>', '', $content);
         }
     }
     $content = str_replace('<%FORM_TITLE%>', $this->form_title, $content);
     $navigation_bar = $this->parser->parse('common/campaign_wizard/navigation_bar.html', array('BUTTONS' => $buttons_html), TRUE);
     $content = str_replace('<%NAVIGATION_BAR%>', $navigation_bar, $content);
     parent::_set_content($content);
 }