/** * Return list of MultiColumnWizard columns * * @param \MultiColumnWizard|object $objWidget * * @return array */ public function getColumns(\MultiColumnWizard $objWidget) { $this->loadDataContainer(Product::getTable()); $arrValues = $objWidget->value; $blnVariants = $objWidget->name != 'attributes'; if (!empty($arrValues) && is_array($arrValues)) { $arrFixed = $blnVariants ? Attribute::getVariantFixedFields() : Attribute::getFixedFields(); foreach ($arrValues as $i => $attribute) { if (in_array($attribute['name'], $arrFixed)) { $objWidget->addDataToFieldAtIndex($i, 'enabled', array('eval' => array('disabled' => true))); } /** @type IsotopeAttribute|IsotopeAttributeForVariants $objAttribute */ $objAttribute = $GLOBALS['TL_DCA']['tl_iso_product']['attributes'][$attribute['name']]; if (null !== $objAttribute && $objAttribute->isVariantOption()) { $objWidget->addDataToFieldAtIndex($i, 'mandatory', array('eval' => array('hideBody' => true))); } } } return array('enabled' => array('inputType' => 'checkbox', 'eval' => array('hideHead' => true)), 'name' => array('input_field_callback' => array('Isotope\\Backend\\ProductType\\AttributeWizard', 'getNextName'), 'eval' => array('hideHead' => true, 'tl_class' => 'mcwUpdateFields')), 'legend' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_producttype']['attributes']['legend'], 'inputType' => 'select', 'options_callback' => array('Isotope\\Backend\\ProductType\\AttributeWizard', 'getLegends'), 'eval' => array('style' => 'width:150px', 'class' => 'extendable')), 'tl_class' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_producttype']['attributes']['tl_class'], 'inputType' => 'text', 'eval' => array('style' => 'width:80px')), 'mandatory' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_producttype']['attributes']['mandatory'], 'inputType' => 'select', 'options' => array('yes', 'no'), 'reference' => &$GLOBALS['TL_LANG']['MSC'], 'eval' => array('style' => 'width:80px', 'includeBlankOption' => true, 'blankOptionLabel' => &$GLOBALS['TL_LANG']['tl_iso_producttype']['attributes']['default']))); }
/** * Initialize widget * * Based on DataContainer::row() from Contao 2.10.1 * * @param array * @param int * @param string * @param mixed * @return Widget|null */ protected function initializeWidget(&$arrField, $intRow, $strKey, $varValue) { $xlabel = ''; $strContaoPrefix = 'contao/'; // YACE support for leo unglaub :) if (defined('YACE')) { $strContaoPrefix = ''; } //pass activeRecord to widget $arrField['activeRecord'] = $this->activeRecord; // Toggle line wrap (textarea) if ($arrField['inputType'] == 'textarea' && $arrField['eval']['rte'] == '') { $xlabel .= ' ' . $this->generateImage('wrap.gif', $GLOBALS['TL_LANG']['MSC']['wordWrap'], 'title="' . specialchars($GLOBALS['TL_LANG']['MSC']['wordWrap']) . '" class="toggleWrap" onclick="Backend.toggleWrap(\'ctrl_' . $this->strId . '_row' . $intRow . '_' . $strKey . '\');"'); } // Add the help wizard if ($arrField['eval']['helpwizard']) { if (version_compare(VERSION, '3.1', '<')) { $xlabel .= ' <a href="contao/help.php?table=' . $this->strTable . '&field=' . $this->strField . '" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['helpWizard']) . '" data-lightbox="help 610 80%">' . $this->generateImage('about.gif', $GLOBALS['TL_LANG']['MSC']['helpWizard'], 'style="vertical-align:text-bottom"') . '</a>'; } else { $xlabel .= ' <a href="contao/help.php?table=' . $this->strTable . '&field=' . $this->strField . '" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['helpWizard']) . '" onclick="Backend.openModalIframe({\'width\':735,\'height\':405,\'title\':\'' . specialchars(str_replace("'", "\\'", $arrField['label'][0])) . '\',\'url\':this.href});return false">' . \Image::getHtml('about.gif', $GLOBALS['TL_LANG']['MSC']['helpWizard'], 'style="vertical-align:text-bottom"') . '</a>'; } } // Add the popup file manager if ($arrField['inputType'] == 'fileTree' || $arrField['inputType'] == 'pageTree') { $path = ''; if (isset($arrField['eval']['path'])) { $path = '?node=' . $arrField['eval']['path']; } $xlabel .= ' <a href="' . $strContaoPrefix . 'files.php' . $path . '" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['fileManager']) . '" rel="lightbox[files 765 80%]">' . $this->generateImage('filemanager.gif', $GLOBALS['TL_LANG']['MSC']['fileManager'], 'style="vertical-align:text-bottom;"') . '</a>'; $arrField['strField'] = $this->strField . '__' . $strKey; } elseif ($arrField['inputType'] == 'tableWizard') { $xlabel .= ' <a href="' . $this->addToUrl('key=table') . '" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['tw_import'][1]) . '" onclick="Backend.getScrollOffset();">' . $this->generateImage('tablewizard.gif', $GLOBALS['TL_LANG']['MSC']['tw_import'][0], 'style="vertical-align:text-bottom;"') . '</a>'; $xlabel .= ' ' . $this->generateImage('demagnify.gif', '', 'title="' . specialchars($GLOBALS['TL_LANG']['MSC']['tw_shrink']) . '" style="vertical-align:text-bottom; cursor:pointer;" onclick="Backend.tableWizardResize(0.9);"') . $this->generateImage('magnify.gif', '', 'title="' . specialchars($GLOBALS['TL_LANG']['MSC']['tw_expand']) . '" style="vertical-align:text-bottom; cursor:pointer;" onclick="Backend.tableWizardResize(1.1);"'); } elseif ($arrField['inputType'] == 'listWizard') { $xlabel .= ' <a href="' . $this->addToUrl('key=list') . '" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['lw_import'][1]) . '" onclick="Backend.getScrollOffset();">' . $this->generateImage('tablewizard.gif', $GLOBALS['TL_LANG']['MSC']['tw_import'][0], 'style="vertical-align:text-bottom;"') . '</a>'; } // Input field callback if (is_array($arrField['input_field_callback'])) { if (!is_object($this->{$arrField}['input_field_callback'][0])) { $this->import($arrField['input_field_callback'][0]); } return $this->{$arrField}['input_field_callback'][0]->{$arrField}['input_field_callback'][1]($this, $xlabel); } $strClass = $GLOBALS[TL_MODE == 'BE' ? 'BE_FFL' : 'TL_FFL'][$arrField['inputType']]; if ($strClass == '' || !$this->classFileExists($strClass)) { return null; } $arrField['eval']['required'] = false; // Use strlen() here (see #3277) if ($arrField['eval']['mandatory']) { if (is_array($this->varValue[$intRow][$strKey])) { if (empty($this->varValue[$intRow][$strKey])) { $arrField['eval']['required'] = true; } } else { if (!strlen($this->varValue[$intRow][$strKey])) { $arrField['eval']['required'] = true; } } } // Hide label except if multiple widgets are in one column if ($arrField['eval']['columnPos'] == '') { $arrField['eval']['tl_class'] = trim($arrField['eval']['tl_class'] . ' hidelabel'); } // add class to enable easy updating of "name" attributes etc. $arrField['eval']['tl_class'] = trim($arrField['eval']['tl_class'] . ' mcwUpdateFields'); // if we have a row class, add that one aswell. if (isset($arrField['eval']['rowClasses'][$intRow])) { $arrField['eval']['tl_class'] = trim($arrField['eval']['tl_class'] . ' ' . $arrField['eval']['rowClasses'][$intRow]); } // load callback if (is_array($arrField['load_callback'])) { foreach ($arrField['load_callback'] as $callback) { $this->import($callback[0]); $varValue = $this->{$callback}[0]->{$callback}[1]($varValue, $this); } } // Convert date formats into timestamps (check the eval setting first -> #3063) $rgxp = $arrField['eval']['rgxp']; if (($rgxp == 'date' || $rgxp == 'time' || $rgxp == 'datim') && $varValue != '') { $objDate = new Date($varValue, $GLOBALS['TL_CONFIG'][$rgxp . 'Format']); $varValue = $objDate->tstamp; } $arrField['activeRow'] = $intRow; $arrField['name'] = $this->strName . '[' . $intRow . '][' . $strKey . ']'; $arrField['id'] = $this->strId . '_row' . $intRow . '_' . $strKey; $arrField['value'] = $varValue !== '' ? $varValue : $arrField['default']; $arrField['eval']['tableless'] = true; $arrData = $this->handleDcGeneral($arrField, $strKey); if (version_compare(VERSION, '3.1', '<')) { $objWidget = new $strClass($this->prepareForWidget($arrData, $arrField['name'], $arrField['value'], $arrField['strField'], $this->strTable)); } else { $objWidget = new $strClass(\MultiColumnWizard::getAttributesFromDca($arrData, $arrField['name'], $arrField['value'], $arrField['strField'], $this->strTable, $this)); } $objWidget->strId = $arrField['id']; $objWidget->storeValues = true; $objWidget->xlabel = $xlabel; $objWidget->currentRecord = $this->currentRecord; return $objWidget; }