Esempio n. 1
0
 /**
  * Method to get the field input markup for a generic list.
  * Use the multiple attribute to enable multiselect.
  *
  * @return  string  The field input markup.
  *
  * @since   11.1
  */
 public function getInput()
 {
     // Initialize variables.
     $html = array();
     $attr = '';
     // Initialize some field attributes.
     $attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . ' chzn-done"' : ' class="chzn-done"';
     // To avoid user's confusion, readonly="true" should imply disabled="true".
     if ((string) $this->element['readonly'] == 'true' || (string) $this->element['disabled'] == 'true') {
         $attr .= ' disabled="disabled"';
     }
     $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
     $attr .= $this->multiple ? ' multiple="multiple"' : '';
     // Initialize JavaScript field attributes.
     $attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
     // Get the field options.
     $options = (array) $this->getOptions();
     /** @var $list_renderer RokCommon_HTML_ISelect */
     $list_renderer = $this->container->getService('html.renderer.select');
     // Create a read-only list (no name) with a hidden input to store the value.
     if ((string) $this->element['readonly'] == 'true') {
         $html[] = RokCommon_HTML_SelectList::genericlist($options, '', trim($attr), 'value', 'text', $this->value, $this->id);
         $html[] = '<input type="hidden" name="' . $this->name . '" value="' . $this->value . '"/>';
     } else {
         $html[] = RokCommon_HTML_SelectList::genericlist($options, $this->name, trim($attr), 'value', 'text', $this->value, $this->id);
     }
     return implode($html);
 }
Esempio n. 2
0
 public function getInput()
 {
     $fieldname = $this->element['name'];
     $js = "RokSprocket.dynamicfields.add('" . $this->id . "', '" . $fieldname . "');";
     // Initialize variables.
     $html = array();
     $attr = '';
     $css_classes = explode(' ', (string) $this->element['class']);
     $css_classes = array_merge($css_classes, $this->getProviderClasses());
     $css_classes[] = strtolower($this->type);
     $css_classes[] = 'chzn-done';
     $css_classes = array_unique($css_classes);
     $attr .= ' class="' . implode(' ', $css_classes) . '"';
     // Initialize some field attributes.
     //		$this->element['class'] = $this->element['class'] ? (string)$this->element['class'] . " " . strtolower($this->type) : strtolower($this->type);
     //		$attr .= $this->element['class'] ? ' class="' . (string)$this->element['class'] . ' chzn-done"' : ' class="chzn-done"';
     // To avoid user's confusion, readonly="true" should imply disabled="true".
     if ((string) $this->element['readonly'] == 'true' || (string) $this->element['disabled'] == 'true') {
         $attr .= ' disabled="disabled"';
     }
     $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
     $attr .= $this->multiple ? ' multiple="multiple"' : '';
     $attr .= $this->element['refresher'] ? ' data-refresher="true" ' : "";
     // Initialize JavaScript field attributes.
     $attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
     if ($this->element['attrs']) {
         $additional_attrs = explode(',', (string) $this->element['attrs']);
         foreach ($additional_attrs as $additional_attr) {
             $additional_attr = strtolower(trim($additional_attr));
             $attr .= $this->element[$additional_attr] ? sprintf(' %s="', $additional_attr) . (string) $this->element[$additional_attr] . '"' : '';
         }
     }
     // Get the field options.
     $options = (array) $this->getOptions();
     RokCommon_Header::addInlineScript($js);
     if ((string) $this->element['readonly'] == 'true') {
         $html[] = rc__('select.genericlist', $options, '', trim($attr), 'value', 'text', $this->value, $this->id);
         $html[] = '<input type="hidden" name="' . $this->name . '" value="' . $this->value . '"/>';
     } else {
         if (count($options) == 1) {
             $icon = isset($options[0]->icon) ? $options[0]->icon : "";
             if (strlen($icon)) {
                 $icon_html = '<i data-dynamic="false" class="icon ' . $this->element['name'] . " " . $options[0]->value . '"></i>';
             } else {
                 $icon_html = "";
             }
             $html[] = '<div class="single-layout">' . $icon_html . ' ' . $options[0]->text . "</div>\n";
             $attr .= ' style="display: none;" ';
         }
         $listattr = array('list.attr' => $attr, 'id' => $this->id, 'list.select' => $this->value, 'option.text' => 'text', 'option.value' => 'value', 'option.attr' => 'attr');
         $list = RokCommon_HTML_SelectList::genericlist($options, $this->name, $listattr);
         $html[] = $list;
     }
     return implode('', $html);
 }
Esempio n. 3
0
 public function getInput()
 {
     $fieldname = $this->element['name'];
     // Initialize variables.
     $html = array();
     $attr = '';
     // Initialize some field attributes.
     $this->element['class'] = $this->element['class'] ? (string) $this->element['class'] . " " . strtolower($this->type) : strtolower($this->type);
     $attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
     // To avoid user's confusion, readonly="true" should imply disabled="true".
     if ((string) $this->element['readonly'] == 'true' || (string) $this->element['disabled'] == 'true') {
         $attr .= ' disabled="disabled"';
     }
     $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
     $attr .= $this->multiple ? ' multiple="multiple"' : '';
     // Initialize JavaScript field attributes.
     $attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
     if ($this->element['attrs']) {
         $additional_attrs = explode(',', (string) $this->element['attrs']);
         foreach ($additional_attrs as $additional_attr) {
             $additional_attr = strtolower(trim($additional_attr));
             $attr .= $this->element[$additional_attr] ? sprintf(' %s="', $additional_attr) . (string) $this->element[$additional_attr] . '"' : '';
         }
     }
     // Get the field options.
     $options = (array) $this->getOptions();
     if ((string) $this->element['readonly'] == 'true') {
         $html[] = JHtml::_('select.genericlist', $options, '', trim($attr), 'value', 'text', $this->value, $this->id);
         $html[] = '<input type="hidden" name="' . $this->name . '" value="' . $this->value . '"/>';
     } else {
         if (count($options) == 1) {
             $html[] = '<div class="single-layout"> ' . $options[0]->text . "</div>\n";
             $attr .= ' style="display: none;" ';
         }
         $listattr = array('list.attr' => $attr, 'id' => $this->id, 'list.select' => $this->value, 'option.text' => 'text', 'option.value' => 'value', 'option.attr' => 'attr');
         $list = RokCommon_HTML_SelectList::genericlist($options, $this->name, $listattr);
         $html[] = $list;
     }
     return implode('', $html);
 }
Esempio n. 4
0
 /**
  * Method to get the field input markup for a generic list.
  * Use the multiple attribute to enable multiselect.
  *
  * @return  string  The field input markup.
  *
  * @since   11.1
  */
 public function getInput()
 {
     // Initialize variables.
     $html = array();
     $attr = '';
     if (!self::$js_loaded) {
         RokCommon_Header::addInlineScript($this->attachJavaScript());
         self::$js_loaded = true;
     }
     // Initialize some field attributes.
     $attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
     // To avoid user's confusion, readonly="true" should imply disabled="true".
     if ((string) $this->element['readonly'] == 'true' || (string) $this->element['disabled'] == 'true') {
         $attr .= ' disabled="disabled"';
     }
     $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
     $attr .= $this->multiple ? ' multiple="multiple"' : '';
     // Initialize JavaScript field attributes.
     $attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
     if ($this->element['attrs']) {
         $additional_attrs = explode(',', (string) $this->element['attrs']);
         foreach ($additional_attrs as $additional_attr) {
             $additional_attr = strtolower(trim($additional_attr));
             $attr .= $this->element[$additional_attr] ? sprintf(' %s="', $additional_attr) . (string) $this->element[$additional_attr] . '"' : '';
         }
     }
     // Get the field options.
     $options = (array) $this->getOptions();
     // Create a read-only list (no name) with a hidden input to store the value.
     if ((string) $this->element['readonly'] == 'true' || $this->element['disabled'] == true) {
         $html[] = RokCommon_HTML_SelectList::genericlist($options, '', trim($attr), 'value', 'text', $this->value, $this->id);
         $html[] = '<input type="hidden" name="' . $this->name . '" value="' . htmlspecialchars($this->value) . '"/>';
     } else {
         $list = RokCommon_HTML_SelectList::genericlist($options, $this->name, trim($attr), 'value', 'text', $this->value, $this->id);
         $html[] = $list;
     }
     return implode($html);
 }