Пример #1
0
 /**
  * improved copy from dam_index
  *
  * Returns HTML of a box with a step counter and "back" and "next" buttons
  * Use label "next"/"prev" or "next_[stepnumber]"/"prev_[stepnumber]" for specific step in language file as button text.
  *
  * <code>
  * #set background color
  * plugin.Tx_Formhandler.settings.stepbar_color = #EAEAEA
  * #use default CSS, written to temp file
  * plugin.Tx_Formhandler.settings.useDefaultStepBarStyles = 1
  * </code>
  *
  * @author Johannes Feustel
  * @param    integer $currentStep current step (begins with 1)
  * @param    integer $lastStep last step
  * @param    string $buttonNameBack name attribute of the back button
  * @param    string $buttonNameFwd name attribute of the forward button
  * @return    string    HTML code
  */
 protected function createStepBar($currentStep, $lastStep, $buttonNameBack = '', $buttonNameFwd = '')
 {
     //colors
     $bgcolor = '#EAEAEA';
     $bgcolor = $this->settings['stepbar_color'] ? $this->settings['stepbar_color'] : $bgcolor;
     $nrcolor = \Typoheads\Formhandler\Utility\GeneralUtility::modifyHTMLcolor($bgcolor, 30, 30, 30);
     $errorbgcolor = '#dd7777';
     $errornrcolor = \Typoheads\Formhandler\Utility\GeneralUtility::modifyHTMLcolor($errorbgcolor, 30, 30, 30);
     $classprefix = $this->globals->getFormValuesPrefix() . '_stepbar';
     $css = [];
     $css[] = '.' . $classprefix . ' { background:' . $bgcolor . '; padding:4px;}';
     $css[] = '.' . $classprefix . '_error { background: ' . $errorbgcolor . ';}';
     $css[] = '.' . $classprefix . '_steps { margin-left:50px; margin-right:25px; vertical-align:middle; font-family:Verdana,Arial,Helvetica; font-size:22px; font-weight:bold; }';
     $css[] = '.' . $classprefix . '_steps span { color:' . $nrcolor . '; margin-left:5px; margin-right:5px; }';
     $css[] = '.' . $classprefix . '_error .' . $classprefix . '_steps span { color:' . $errornrcolor . '; margin-left:5px; margin-right:5px; }';
     $css[] = '.' . $classprefix . '_steps .' . $classprefix . '_currentstep { color:  #000;}';
     $css[] = '#stepsFormButtons { margin-left:25px;vertical-align:middle;}';
     $content = '';
     $buttons = '';
     for ($i = 1; $i <= $lastStep; $i++) {
         $class = '';
         if ($i == $currentStep) {
             $class = 'class="' . $classprefix . '_currentstep"';
         }
         $stepName = $this->utilityFuncs->getTranslatedMessage($this->langFiles, 'step-' . $i);
         if (strlen($stepName) === 0) {
             $stepName = $i;
         }
         $content .= '<span ' . $class . ' >' . $stepName . '</span>';
     }
     $content = '<span class="' . $classprefix . '_steps' . '">' . $content . '</span>';
     //if not the first step, show back button
     if ($currentStep > 1) {
         //check if label for specific step
         $message = $this->utilityFuncs->getTranslatedMessage($this->langFiles, 'prev_' . $currentStep);
         if (strlen($message) === 0) {
             $message = $this->utilityFuncs->getTranslatedMessage($this->langFiles, 'prev');
         }
         $buttons .= '<input type="submit" name="' . $buttonNameBack . '" value="' . trim($message) . '" class="button_prev" style="margin-right:10px;" />';
     }
     $message = $this->utilityFuncs->getTranslatedMessage($this->langFiles, 'next_' . $currentStep);
     if (strlen($message) === 0) {
         $message = $this->utilityFuncs->getTranslatedMessage($this->langFiles, 'next');
     }
     $buttons .= '<input type="submit" name="' . $buttonNameFwd . '" value="' . trim($message) . '" class="button_next" />';
     $content .= '<span id="stepsFormButtons">' . $buttons . '</span>';
     //wrap
     $classes = $classprefix;
     if ($this->errors) {
         $classes = $classes . ' ' . $classprefix . '_error';
     }
     $content = '<div class="' . $classes . '" >' . $content . '</div>';
     //add default css to page
     if ($this->settings['useDefaultStepBarStyles']) {
         $css = implode("\n", $css);
         $css = TSpagegen::inline2TempFile($css, 'css');
         if (version_compare(TYPO3_version, '4.3.0') >= 0) {
             $css = '<link rel="stylesheet" type="text/css" href="' . htmlspecialchars($css) . '" />';
         }
         $GLOBALS['TSFE']->additionalHeaderData[$this->extKey . '_' . $classprefix] .= $css;
     }
     return $content;
 }