/** * Method to get the field options. * * @return array The field option objects. * @since 1.6 */ protected function getOptions() { // Initialize variables. JModelLegacy::addIncludePath(JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_mightytouch' . DIRECTORY_SEPARATOR . 'models'); $fieldsModel = JModelLegacy::getInstance('Fields', 'MightyTouchModel'); $options = array(); $fieldsModel->populateAllFieldsState(); $fields = $fieldsModel->getItems(); foreach ($fields as $fld) { $options[] = JHTML::_('select.option', $fld->id, $fld->title); } $options = array_merge(parent::getOptions(), $options); return $options; }
/** * Method to get the field options. * * @return array The field option objects. * @since 1.6 */ protected function getOptions() { // Initialize variables. $options = array(); $_ds = '/'; // path to images directory $path = JPATH_ROOT . $_ds . $this->element['directory']; $path = preg_replace("#([\\\\/]*)\$#", '', $path); if ($path) { $path = realpath($path); $path = str_replace(array('\\', '/'), $_ds, $path); } else { $path = $_ds; } $filter = $this->element['filter']; $exclude = $this->element['exclude']; $levels = $this->element['levels']; $levels = $levels == '' ? -1 : $levels; $relative_path = $this->element['relative_path']; $relative_path_value = $this->element['relative_path_value']; $invite_label = $this->element['invite_label']; $folders = $this->JS_folders($path, $path, $filter, $levels); $options = array(); foreach ($folders as $key => $folder) { $folders[$key] = str_replace(array('\\', '/'), $_ds, $folder); } foreach ($folders as $folder) { if ($relative_path == 1) { $folder_label = str_replace($path . $_ds, '', $folder); } else { $folder_label = str_replace(JPATH_ROOT . $_ds, '', $folder); } if ($relative_path_value == 'root') { $folder = str_replace($path . $_ds, '', $folder); } else { if ($relative_path_value == 'absolute') { //doing nothing } else { $folder = str_replace(JPATH_ROOT . $_ds, '', $folder); } } if ($exclude) { if (preg_match(chr(1) . $exclude . chr(1), $folder_label)) { continue; } } $folder_temp = ''; while ($folder_temp != $folder) { //if in path exist '..' cut this $folder_temp = $folder; $folder = preg_replace('#(\\' . $_ds . '[^\\' . $_ds . ']*\\' . $_ds . '\\.\\.)#', '', $folder); } $options[] = JHTML::_('select.option', $folder, $folder_label); } if (!$this->element['hide_none']) { if (!$invite_label) { $invite_label = 'Do not use'; } array_unshift($options, JHTML::_('select.option', '-1', '- ' . JText::_($invite_label) . ' -')); } if (!$this->element['hide_default']) { array_unshift($options, JHTML::_('select.option', '', '- ' . JText::_('Use default') . ' -')); } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }