*/ class SectionWizard extends Widget { /** * Submit user input * @var boolean */ protected $blnSubmitInput = true; /** * Template * @var string */ protected $strTemplate = 'be_widget'; /** * Standardize the ID * * @param mixed $varInput * * @return mixed */ protected function validator($varInput) { $arrTitles = array(); $arrIds = array(); $arrSections = array(); foreach ($varInput as $arrSection) { // Title and ID are required if ((!empty($arrSection['title']) && empty($arrSection['id'])) || (empty($arrSection['title']) && !empty($arrSection['id']))) { $this->addError($GLOBALS['TL_LANG']['ERR']['emptyTitleOrId']); } // Check for duplicate section titles if (\in_array($arrSection['title'], $arrTitles)) { $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['duplicateSectionTitle'], $arrSection['title'])); } $arrSection['id'] = StringUtil::standardize($arrSection['id'], true); // Add a suffix to reserved names (see #301) if (\in_array($arrSection['id'], array('top', 'wrapper', 'header', 'container', 'main', 'left', 'right', 'footer'))) { $arrSection['id'] .= '-custom'; } // Check for duplicate section IDs if (\in_array($arrSection['id'], $arrIds)) { $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['duplicateSectionId'], $arrSection['id'])); } $arrTitles[] = $arrSection['title']; $arrIds[] = $arrSection['id']; $arrSections[] = $arrSection; } return $arrSections; } /** * Generate the widget and return it as string * * @return string */ public function generate() { $arrButtons = array('copy', 'delete', 'drag'); // Make sure there is at least an empty array if (!\is_array($this->varValue) || !$this->varValue[0]) { $this->varValue = array(array('')); } // Add the label and the return wizard $return = ''; // Add the input fields for ($i=0, $c=\count($this->varValue); $i<$c; $i++) { $return .= ' '; $options = ''; // Add the template foreach (Template::getTemplateGroup('block_section') as $k=>$v) { $options .= ''; } $return .= ' '; $options = ''; // Add the positions foreach (array('top', 'before', 'main', 'after', 'bottom', 'manual') as $v) { $options .= ''; } $return .= ' '; } return $return.'
'.$GLOBALS['TL_LANG']['MSC']['sw_title'].' '.$GLOBALS['TL_LANG']['MSC']['sw_id'].' '.$GLOBALS['TL_LANG']['MSC']['sw_template'].' '.$GLOBALS['TL_LANG']['MSC']['sw_position'].'
'; // Add the buttons foreach ($arrButtons as $button) { if ($button == 'drag') { $return .= ' '; } else { $return .= ' '; } } $return .= '
'; } } class_alias(SectionWizard::class, 'SectionWizard');