protected function getOptions() { MLog::add('MFormFieldEditors is deprecated. Use MFormFieldPlugins instead (with folder="editors").', MLog::WARNING, 'deprecated'); // Get the database object and a new query object. $db = MFactory::getDBO(); $query = $db->getQuery(true); // Build the query. $query->select('element AS value, name AS text'); $query->from('#__extensions'); $query->where('folder = ' . $db->quote('editors')); $query->where('enabled = 1'); $query->order('ordering, name'); // Set the query and load the options. $db->setQuery($query); $options = $db->loadObjectList(); $lang = MFactory::getLanguage(); foreach ($options as $i => $option) { $lang->load('plg_editors_' . $option->value, MPATH_ADMINISTRATOR, null, false, false) || $lang->load('plg_editors_' . $option->value, MPATH_PLUGINS . '/editors/' . $option->value, null, false, false) || $lang->load('plg_editors_' . $option->value, MPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load('plg_editors_' . $option->value, MPATH_PLUGINS . '/editors/' . $option->value, $lang->getDefault(), false, false); $options[$i]->text = MText::_($option->text); } // Check for a database error. if ($db->getErrorNum()) { MError::raiseWarning(500, $db->getErrorMsg()); } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
protected function getOptions() { // Initialise variables $folder = $this->element['folder']; if (!empty($folder)) { // Get list of plugins $db = MFactory::getDbo(); $query = $db->getQuery(true); $query->select('element AS value, name AS text'); $query->from('#__extensions'); $query->where('folder = ' . $db->q($folder)); $query->where('enabled = 1'); $query->order('ordering, name'); $db->setQuery($query); $options = $db->loadObjectList(); $lang = MFactory::getLanguage(); foreach ($options as $i => $item) { $source = MPATH_PLUGINS . '/' . $folder . '/' . $item->value; $extension = 'plg_' . $folder . '_' . $item->value; $lang->load($extension . '.sys', MPATH_ADMINISTRATOR, null, false, false) || $lang->load($extension . '.sys', $source, null, false, false) || $lang->load($extension . '.sys', MPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false); $options[$i]->text = MText::_($item->text); } if ($db->getErrorMsg()) { MError::raiseWarning(500, MText::_('MFRAMEWORK_FORM_FIELDS_PLUGINS_ERROR_FOLDER_EMPTY')); return ''; } } else { MError::raiseWarning(500, MText::_('MFRAMEWORK_FORM_FIELDS_PLUGINS_ERROR_FOLDER_EMPTY')); } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
protected function getOptions() { // Initialize variables. $options = array(); // Initialize some field attributes. $key = $this->element['key_field'] ? (string) $this->element['key_field'] : 'value'; $value = $this->element['value_field'] ? (string) $this->element['value_field'] : (string) $this->element['name']; $translate = $this->element['translate'] ? (string) $this->element['translate'] : false; $query = (string) $this->element['query']; // Get the database object. $db = MFactory::getDBO(); // Set the query and get the result list. $db->setQuery($query); $items = $db->loadObjectlist(); // Check for an error. if ($db->getErrorNum()) { MError::raiseWarning(500, $db->getErrorMsg()); return $options; } // Build the field options. if (!empty($items)) { foreach ($items as $item) { if ($translate == true) { $options[] = MHtml::_('select.option', $item->{$key}, MText::_($item->{$value})); } else { $options[] = MHtml::_('select.option', $item->{$key}, $item->{$value}); } } } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
protected function getOptions() { // Initialize variables. $options = array(); // Initialize some field attributes. $first = (int) $this->element['first']; $last = (int) $this->element['last']; $step = (int) $this->element['step']; // Sanity checks. if ($step == 0) { // Step of 0 will create an endless loop. return $options; } elseif ($first < $last && $step < 0) { // A negative step will never reach the last number. return $options; } elseif ($first > $last && $step > 0) { // A position step will never reach the last number. return $options; } // Build the options array. for ($i = $first; $i <= $last; $i += $step) { $options[] = MHtml::_('select.option', $i); } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
protected function getOptions() { // Initialise variables. $options = array(); $extension = $this->element['extension'] ? (string) $this->element['extension'] : (string) $this->element['scope']; $published = (string) $this->element['published']; $name = (string) $this->element['name']; // Load the category options for a given extension. if (!empty($extension)) { // Filter over published state or not depending upon if it is present. if ($published) { $options = MHtml::_('category.options', $extension, array('filter.published' => explode(',', $published))); } else { $options = MHtml::_('category.options', $extension); } // Verify permissions. If the action attribute is set, then we scan the options. if ((string) $this->element['action']) { // Get the current user object. $user = MFactory::getUser(); // For new items we want a list of categories you are allowed to create in. if (!$this->form->getValue($name)) { foreach ($options as $i => $option) { // To take save or create in a category you need to have create rights for that category // unless the item is already in that category. // Unset the option if the user isn't authorised for it. In this field assets are always categories. if ($user->authorise('core.create', $extension . '.category.' . $option->value) != true) { unset($options[$i]); } } } else { $categoryOld = $this->form->getValue($name); foreach ($options as $i => $option) { // If you are only allowed to edit in this category but not edit.state, you should not get any // option to change the category. if ($user->authorise('core.edit.state', $extension . '.category.' . $categoryOld) != true) { if ($option->value != $categoryOld) { unset($options[$i]); } } elseif ($user->authorise('core.create', $extension . '.category.' . $option->value) != true && $option->value != $categoryOld) { unset($options[$i]); } } } } if (isset($this->element['show_root'])) { array_unshift($options, MHtml::_('select.option', '0', MText::_('MGLOBAL_ROOT'))); } } else { MError::raiseWarning(500, MText::_('MLIB_FORM_ERROR_FIELDS_CATEGORY_ERROR_EXTENSION_EMPTY')); } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
protected function getOptions() { // Initialize some field attributes. $client = (string) $this->element['client']; if ($client != 'site' && $client != 'administrator') { $client = 'site'; } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), MLanguageHelper::createLanguageList($this->value, constant('MPATH_' . strtoupper($client)), true, true)); return $options; }
protected function getOptions() { // Initialize variables. $options = array(); // Convert to name => name array. foreach (MCache::getStores() as $store) { $options[] = MHtml::_('select.option', $store, MText::_('MLIB_FORM_VALUE_CACHE_' . $store), 'value', 'text'); } $options = array_merge(parent::getOptions(), $options); return $options; }
protected function getOptions() { // Initialize variables. $options = array(); // Get the options from MSession. foreach (MSession::getStores() as $store) { $options[] = MHtml::_('select.option', $store, MText::_('MLIB_FORM_VALUE_SESSION_' . $store), 'value', 'text'); } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
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 = MPATH_ROOT . '/' . $path; } // Prepend some default options based on field attributes. if (!$hideNone) { $options[] = MHtml::_('select.option', '-1', MText::alt('MOPTION_DO_NOT_USE', preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname))); } if (!$hideDefault) { $options[] = MHtml::_('select.option', '', MText::alt('MOPTION_USE_DEFAULT', preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname))); } // Get a list of files in the search path with the given filter. $files = MFolder::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 = MFile::stripExt($file); } $options[] = MHtml::_('select.option', $file, $file); } } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
protected function getOptions() { // Merge any additional options in the XML definition. return array_merge(parent::getOptions(), MHtml::_('contentlanguage.existing')); }