public function addAttributes($arrAttributes)
 {
     parent::addAttributes($arrAttributes);
     $arrOptions = array(array('label' => $this->placeholder == '' ? '-' : $this->placeholder, 'value' => ''));
     $arrCountries = $this->getCountries();
     foreach ($arrCountries as $short => $name) {
         $arrOptions[] = array('label' => $name, 'value' => $short);
     }
     $this->arrOptions = $arrOptions;
 }
Exemplo n.º 2
0
 public function __construct($arrAttributes = null)
 {
     parent::__construct($arrAttributes);
     if ($this->anystores_categories === null) {
         return;
     }
     $arrCategories = deserialize($this->anystores_categories);
     $arrOptions = array('order' => 'postal');
     $objLocations = AnyStoresModel::findPublishedByCategory($arrCategories, $arrOptions);
     if ($objLocations) {
         while ($objLocations->next()) {
             $arrLocations[] = array('type' => 'option', 'value' => $objLocations->id, 'label' => $objLocations->postal . ' ' . $objLocations->name);
         }
         $this->arrOptions = $arrLocations;
     }
 }
 /**
  * Parse the template file and return it as string
  * @param array
  * @return string
  */
 public function parse($arrAttributes = null)
 {
     if ($this->formcontrol_template) {
         $this->strTemplate = $this->formcontrol_template;
         $strClass = 'select';
         $blnHasGroups = false;
         if ($this->multiple) {
             $this->strName .= '[]';
             $strClass = 'multiselect';
         } elseif (is_array($this->varValue)) {
             $this->varValue = $this->varValue[0];
         }
         // Add empty option (XHTML) if there are none
         if (empty($this->arrOptions)) {
             $this->arrOptions = array(array('value' => '', 'label' => '-'));
         }
         // Chosen
         if ($this->chosen) {
             $strClass .= ' tl_chosen';
         }
         $this->class = $strClass . (strlen($this->strClass) ? ' ' . $this->strClass : '');
         $arrOptions = array();
         // Generate options
         foreach ($this->arrOptions as $arrOption) {
             if ($arrOption['group']) {
                 if ($blnHasGroups) {
                     $arrOptions[] = array('type' => 'group_end');
                 }
                 $arrOptions[] = array('type' => 'group_start', 'label' => specialchars($arrOption['label']));
                 $blnHasGroups = true;
                 continue;
             }
             $arrOptions[] = array('type' => 'option', 'value' => $arrOption['value'], 'selected' => $this->isSelected($arrOption), 'label' => $arrOption['label']);
         }
         if ($blnHasGroups) {
             $arrOptions[] = array('type' => 'group_end');
         }
         $this->options = $arrOptions;
     }
     return parent::parse($arrAttributes);
 }
 /**
  * Parse the template file and return it as string
  *
  * @param array $arrAttributes An optional attributes array
  *
  * @return string The template markup
  */
 public function parse($arrAttributes = null)
 {
     $this->arrOptions = ConditionalSelectMenu::prepareOptions($this->arrOptions);
     $GLOBALS['TL_JAVASCRIPT']['conditionalselect'] = 'system/modules/conditionalselectmenu/assets/conditionalselect' . ($GLOBALS['TL_CONFIG']['debugMode'] ? '' : '.min') . '.js';
     $strOptions = '';
     $strClass = 'select';
     if ($this->multiple) {
         $this->strName .= '[]';
         $strClass = 'multiselect';
     }
     // Add empty option (XHTML) if there are none
     if (empty($this->arrOptions)) {
         $this->arrOptions = array(array('value' => '', 'label' => strlen($this->blankOptionLabel) ? $this->blankOptionLabel : '-'));
     }
     // Custom class
     if ($this->strClass != '') {
         $strClass .= ' ' . $this->strClass;
     }
     $this->strClass = $strClass;
     // Prepare Javascript
     if ($this->includeBlankOption) {
         $this->classOptions = ", {includeBlankOption: true" . (strlen($this->blankOptionLabel) ? ", blankOptionLabel: '" . $this->blankOptionLabel . "'" : '') . "}";
     }
     return parent::parse($arrAttributes);
 }
 /**
  * Generate the widget and return it as string
  */
 public function generate()
 {
     $this->arrOptions = deserialize($this->protectedOptions, true);
     if (!is_array($this->varValue) && !strlen($this->varValue) && isset($_GET[$this->strName])) {
         $this->varValue = \Input::get($this->strName);
     }
     $arrOptions = $this->arrOptions;
     foreach ($this->arrOptions as $k => $option) {
         $this->arrOptions[$k]['value'] = $option['reference'];
     }
     $strBuffer = parent::generate();
     $this->arrOptions = $arrOptions;
     return $strBuffer;
 }