コード例 #1
0
ファイル: radio.php プロジェクト: densem-2013/exikom
 /**
  * Method to get the radio button field input markup.
  *
  * @return  string  The field input markup.
  *
  * @since   11.1
  */
 public function getInput()
 {
     // Initialize variables.
     $html = array();
     // Initialize some field attributes.
     $class = $this->element['class'] ? ' class="radio ' . (string) $this->element['class'] . '"' : ' class="radio"';
     // Start the radio field output.
     $html[] = '<fieldset id="' . $this->id . '"' . $class . '>';
     // Get the field options.
     $options = $this->getOptions();
     // Build the radio field output.
     foreach ($options as $i => $option) {
         // Initialize some option attributes.
         $checked = (string) $option->value == (string) $this->value ? ' checked="checked"' : '';
         $class = !empty($option->class) ? ' class="' . $option->class . '"' : '';
         $disabled = !empty($option->disable) ? ' disabled="disabled"' : '';
         // Initialize some JavaScript option attributes.
         $onclick = !empty($option->onclick) ? ' onclick="' . $option->onclick . '"' : '';
         $html[] = '<input type="radio" id="' . $this->id . $i . '" name="' . $this->name . '"' . ' value="' . htmlspecialchars($option->value, ENT_COMPAT, 'UTF-8') . '"' . $checked . $class . $onclick . $disabled . '/>';
         $html[] = '<label for="' . $this->id . $i . '"' . $class . '>' . rc_alt($option->text, preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)) . '</label>';
     }
     // End the radio field output.
     $html[] = '</fieldset>';
     return implode($html);
 }
コード例 #2
0
ファイル: multiselect.php プロジェクト: TeamCodeStudio/fpmoz
 protected function getOptions()
 {
     $options = array();
     foreach ($this->element->children() as $option) {
         if ($option->getName() != 'option') {
             continue;
         }
         $tmp = RokCommon_HTML_SelectList::option((string) $option['value'], rc_alt(trim((string) $option), preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)), 'value', 'text', (string) $option['disabled'] == 'true');
         $tmp->class = (string) $option['class'];
         $options[] = $tmp;
     }
     reset($options);
     return $options;
 }
コード例 #3
0
ファイル: filelist.php プロジェクト: densem-2013/exikom
 /**
  * Method to get the list of files for the field options.
  * Specify the target directory with a directory attribute
  * Attributes allow an exclude mask and stripping of extensions from file name.
  * Default attribute may optionally be set to null (no file) or -1 (use a default).
  *
  * @return  array  The field option objects.
  *
  * @since   11.1
  */
 protected function getOptions()
 {
     // Initialize variables.
     $options = array();
     // Initialize some field attributes.
     $filter = (string) $this->element['filter'];
     $exclude = (string) $this->element['exclude'];
     $stripExt = (string) $this->element['stripext'];
     $hideNone = (string) $this->element['hide_none'];
     $hideDefault = (string) $this->element['hide_default'];
     // Get the path in which to search for file options.
     $path = (string) $this->element['directory'];
     if (!is_dir($path)) {
         $path = JPATH_ROOT . '/' . $path;
     }
     // Prepend some default options based on field attributes.
     if (!$hideNone) {
         $options[] = RokCommon_HTML_SelectList::option('-1', rc_alt('JOPTION_DO_NOT_USE', preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)));
     }
     if (!$hideDefault) {
         $options[] = RokCommon_HTML_SelectList::option('', rc_alt('JOPTION_USE_DEFAULT', preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)));
     }
     // Get a list of files in the search path with the given filter.
     $files = JFolder::files($path, $filter);
     // Build the options list from the list of files.
     if (is_array($files)) {
         foreach ($files as $file) {
             // Check to see if the file is in the exclude mask.
             if ($exclude) {
                 if (preg_match(chr(1) . $exclude . chr(1), $file)) {
                     continue;
                 }
             }
             // If the extension is to be stripped, do it.
             if ($stripExt) {
                 $file = JFile::stripExt($file);
             }
             $options[] = RokCommon_HTML_SelectList::option($file, $file);
         }
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
コード例 #4
0
 /**
  *
  * @return array;
  */
 public function getPicklistOptions()
 {
     $options = array();
     // Get the database object and a new query object.
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     // Build the query.
     $query->select('a.lang_code AS value, a.title AS text, a.title_native');
     $query->from('#__languages AS a');
     $query->where('a.published >= 0');
     $query->order('a.title');
     // Set the query and load the options.
     $db->setQuery($query);
     $items = $db->loadObjectList();
     $options['*'] = rc_alt('JALL', 'language');
     foreach ($items as $item) {
         $options[$item->value] = $item->text;
     }
     return $options;
 }
コード例 #5
0
ファイル: list.php プロジェクト: densem-2013/exikom
 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  *
  * @since   11.1
  */
 protected function getOptions()
 {
     // Initialize variables.
     $options = array();
     foreach ($this->element->children() as $option) {
         // Only add <option /> elements.
         if ($option->getName() != 'option') {
             continue;
         }
         // Create a new option object based on the <option /> element.
         $tmp = RokCommon_HTML_SelectList::option((string) $option['value'], rc_alt(trim((string) $option), preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)), 'value', 'text', (string) $option['disabled'] == 'true');
         // Set some option attributes.
         $tmp->class = (string) $option['class'];
         // Set some JavaScript option attributes.
         $tmp->onclick = (string) $option['onclick'];
         // Add the option object to the result set.
         $options[] = $tmp;
     }
     reset($options);
     return $options;
 }
コード例 #6
0
ファイル: groupedlist.php プロジェクト: densem-2013/exikom
 /**
  * Method to get the field option groups.
  *
  * @return  array  The field option objects as a nested array in groups.
  *
  * @since   11.1
  */
 protected function getGroups()
 {
     // Initialize variables.
     $groups = array();
     $label = 0;
     foreach ($this->element->children() as $element) {
         switch ($element->getName()) {
             // The element is an <option />
             case 'option':
                 // Initialize the group if necessary.
                 if (!isset($groups[$label])) {
                     $groups[$label] = array();
                 }
                 // Create a new option object based on the <option /> element.
                 $tmp = RokCommon_HTML_SelectList::option($element['value'] ? (string) $element['value'] : trim((string) $element), rc_alt(trim((string) $element), preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)), 'value', 'text', (string) $element['disabled'] == 'true');
                 // Set some option attributes.
                 $tmp->class = (string) $element['class'];
                 // Set some JavaScript option attributes.
                 $tmp->onclick = (string) $element['onclick'];
                 // Add the option.
                 $groups[$label][] = $tmp;
                 break;
                 // The element is a <group />
             // The element is a <group />
             case 'group':
                 // Get the group label.
                 if ($groupLabel = (string) $element['label']) {
                     $label = rc__($groupLabel);
                 }
                 // Initialize the group if necessary.
                 if (!isset($groups[$label])) {
                     $groups[$label] = array();
                 }
                 // Iterate through the children and build an array of options.
                 foreach ($element->children() as $option) {
                     // Only add <option /> elements.
                     if ($option->getName() != 'option') {
                         continue;
                     }
                     // Create a new option object based on the <option /> element.
                     $tmp = RokCommon_HTML_SelectList::option($option['value'] ? (string) $option['value'] : rc__(trim((string) $option)), rc__(trim((string) $option)), 'value', 'text', (string) $option['disabled'] == 'true');
                     // Set some option attributes.
                     $tmp->class = (string) $option['class'];
                     // Set some JavaScript option attributes.
                     $tmp->onclick = (string) $option['onclick'];
                     // Add the option.
                     $groups[$label][] = $tmp;
                 }
                 if ($groupLabel) {
                     $label = count($groups);
                 }
                 break;
                 // Unknown element type.
             // Unknown element type.
             default:
                 JError::raiseError(500, rc__('JLIB_FORM_ERROR_FIELDS_GROUPEDLIST_ELEMENT_NAME', $element->getName()));
                 break;
         }
     }
     reset($groups);
     return $groups;
 }