本文整理汇总了PHP中JFormFieldList::getOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP JFormFieldList::getOptions方法的具体用法?PHP JFormFieldList::getOptions怎么用?PHP JFormFieldList::getOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFormFieldList
的用法示例。
在下文中一共展示了JFormFieldList::getOptions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOptions
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*
* @since 11.4
*/
protected function getOptions()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select('c.id, c.country, c.country_jtext');
$query->from('`#__tj_country` AS c');
$query->where('c.com_quick2cart = 1');
$query->order($db->escape('c.ordering ASC'));
$db->setQuery($query);
// Get all countries.
$countries = $db->loadObjectList();
$options = array();
// Load lang file for countries
$lang = JFactory::getLanguage();
$lang->load('tjgeo.countries', JPATH_SITE, null, false, true);
foreach ($countries as $c) {
if ($lang->hasKey(strtoupper($c->country_jtext))) {
$c->country = JText::_($c->country_jtext);
}
$options[] = JHtml::_('select.option', $c->id, $c->country);
}
if (!$this->loadExternally) {
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
}
return $options;
}
示例2: getOptions
/**
* Method to get the list of siblings in a menu.
* The method requires that parent be set.
*
* @return array The field option objects or false if the parent field has not been set
* @since 1.7
*/
protected function getOptions()
{
// Initialize variables.
$options = array();
// Get the parent
$parent_id = $this->form->getValue('parent_id', 0);
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('a.id AS value, a.title AS text');
$query->from('#__menu AS a');
$query->where('a.published >= 0');
$query->where('a.parent_id =' . (int) $parent_id);
$query->where('a.client_id = 1');
$query->where('a.menutype = ' . $db->quote('admin'));
$query->order('a.lft ASC');
// Get the options.
$db->setQuery($query);
$options = $db->loadObjectList();
// Translate the items
for ($i = 0, $n = count($options); $i < $n; $i++) {
$options[$i]->text = JText::_($options[$i]->text);
}
// Check for a database error.
if ($db->getErrorNum()) {
JError::raiseWarning(500, $db->getErrorMsg());
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
示例3: getOptions
/**
* Method to get the field options.
*
* @since 2.0
*
* @return array The field option objects.
*/
protected function getOptions()
{
$options = parent::getOptions();
if (!empty($options)) {
return $options;
}
// If no custom options were defined let's figure out which ones of the
// defaults we shall use...
$config = array('published' => 1, 'unpublished' => 1, 'archived' => 0, 'trash' => 0, 'all' => 0);
$stack = array();
// We are no longer using jgrid.publishedOptions as it's returning
// untranslated strings, unsuitable for our purposes.
if ($this->element['show_published'] == 'false') {
$stack[] = JHtml::_('select.option', '1', JText::_('JPUBLISHED'));
}
if ($this->element['show_unpublished'] == 'false') {
$stack[] = JHtml::_('select.option', '0', JText::_('JUNPUBLISHED'));
}
if ($this->element['show_archived'] == 'true') {
$stack[] = JHtml::_('select.option', '2', JText::_('JARCHIVED'));
}
if ($this->element['show_trash'] == 'true') {
$stack[] = JHtml::_('select.option', '-2', JText::_('JTRASHED'));
}
if ($this->element['show_all'] == 'true') {
$stack[] = JHtml::_('select.option', '*', JText::_('JALL'));
}
return $stack;
}
示例4: getOptions
/**
* Method to get the custom field options.
* Use the query attribute to supply a query to generate the list.
*
* @return array The field option objects.
*
* @since 11.1
*/
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 = JFactory::getDBO();
// Set the query and get the result list.
$db->setQuery($query);
$items = $db->loadObjectlist();
// Check for an error.
if ($db->getErrorNum()) {
JError::raiseWarning(500, $db->getErrorMsg());
return $options;
}
// Build the field options.
if (!empty($items)) {
foreach ($items as $item) {
if ($translate == true) {
$options[] = JHtml::_('select.option', $item->{$key}, JText::_($item->{$value}));
} else {
$options[] = JHtml::_('select.option', $item->{$key}, $item->{$value});
}
}
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
示例5: getOptions
public function getOptions()
{
# The options available are based on what type was selected
$options = array();
$type = $this->form->getField('entity_type')->value;
return array_merge(parent::getOptions(), JFormFieldParentEntity::getParents($type));
}
示例6: getOptions
/**
* Method to get the field options for the list of installed editors.
*
* @return array The field option objects.
* @since 11.1
*/
protected function getOptions()
{
// Get the database object and a new query object.
$db = JFactory::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 = JFactory::getLanguage();
foreach ($options as $i=>$option) {
$lang->load('plg_editors_'.$option->value, JPATH_ADMINISTRATOR, null, false, false)
|| $lang->load('plg_editors_'.$option->value, JPATH_PLUGINS .'/editors/'.$option->value, null, false, false)
|| $lang->load('plg_editors_'.$option->value, JPATH_ADMINISTRATOR, $lang->getDefault(), false, false)
|| $lang->load('plg_editors_'.$option->value, JPATH_PLUGINS .'/editors/'.$option->value, $lang->getDefault(), false, false);
$options[$i]->text = JText::_($option->text);
}
// Check for a database error.
if ($db->getErrorNum()) {
JError::raiseWarning(500, $db->getErrorMsg());
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
示例7: getOptions
protected function getOptions()
{
$session = JFactory::getSession();
$attr = '';
// 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'] . '"' : '';
$db = JFactory::getDBO();
$db->setQuery("SELECT t.name AS name, t.id AS id FROM #__k2_tags AS t WHERE published = 1 ORDER BY t.name ASC");
$results = $db->loadObjectList();
$tags = array();
if (count($results)) {
foreach ($results as $tag) {
$tags[] = JHtml::_('select.option', $tag->id, $tag->name);
}
$tags = array_merge(parent::getOptions(), $tags);
return $tags;
} else {
$tags = array();
return $tags;
}
}
示例8: getOptions
/**
* Method to get the field options.
*
* @return array The field option objects.
* @since 1.6
*/
protected function getOptions()
{
$options = array();
$db = JFactory::getDbo();
$query = $db->getQuery(true)->select('a.id AS value, a.title AS text, a.level')->from('#__menu AS a')->join('LEFT', $db->quoteName('#__menu') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt');
if ($menuType = $this->form->getValue('menutype')) {
$query->where('a.menutype = ' . $db->quote($menuType));
} else {
$query->where('a.menutype != ' . $db->quote(''));
}
// Prevent parenting to children of this item.
if ($id = $this->form->getValue('id')) {
$query->join('LEFT', $db->quoteName('#__menu') . ' AS p ON p.id = ' . (int) $id)->where('NOT(a.lft >= p.lft AND a.rgt <= p.rgt)');
}
$query->where('a.published != -2')->group('a.id, a.title, a.level, a.lft, a.rgt, a.menutype, a.parent_id, a.published')->order('a.lft ASC');
// Get the options.
$db->setQuery($query);
try {
$options = $db->loadObjectList();
} catch (RuntimeException $e) {
JError::raiseWarning(500, $e->getMessage());
}
// Pad the option text with spaces using depth level as a multiplier.
for ($i = 0, $n = count($options); $i < $n; $i++) {
$options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->text;
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
示例9: getOptions
/**
* Method to get the field options.
*
* @return array The field option objects.
* @since 1.6
*/
protected function getOptions()
{
$options = array();
$db = JFactory::getDbo();
$query = $db->getQuery(true)->select('a.id AS value, a.name AS text, a.level')->from('#__jdeveloper_forms AS a')->join('LEFT', $db->quoteName('#__jdeveloper_forms') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt')->where('a.parent_id > 0');
// Prevent parenting to children of this item.
if ($id = $this->form->getValue('id')) {
$query->join('LEFT', $db->quoteName('#__jdeveloper_forms') . ' AS p ON p.id = ' . (int) $id)->where('NOT(a.lft >= p.lft AND a.rgt <= p.rgt)');
}
$query->group('a.id, a.name, a.level, a.lft, a.rgt, a.parent_id');
$query->order('a.lft ASC');
// Get the options.
$db->setQuery($query);
try {
$root = new JObject(array("value" => 1, "text" => JText::_("JGLOBAL_ROOT_PARENT"), "level" => 0));
$options = array_merge(array($root), $db->loadObjectList());
} catch (RuntimeException $e) {
throw new Exception($e->getMessage());
}
// Pad the option text with spaces using depth level as a multiplier.
for ($i = 0, $n = count($options); $i < $n; $i++) {
$options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->text;
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
示例10: getOptions
/**
* Method to get the options to populate list
*
* @return array The field option objects.
*
* @since 3.2
*/
protected function getOptions()
{
// Hash for caching
$hash = md5($this->element);
if (!isset(static::$options[$hash])) {
static::$options[$hash] = parent::getOptions();
$options = array();
$db = JFactory::getDbo();
$user = JFactory::getUser();
$query = $db->getQuery(true)->select('a.id AS value')->select('a.title AS text')->select('COUNT(DISTINCT b.id) AS level')->from('#__categories as a')->where('a.extension = "' . $this->extension . '"')->join('LEFT', '#__categories AS b ON a.lft > b.lft AND a.rgt < b.rgt')->group('a.id, a.title, a.lft, a.rgt')->order('a.lft ASC');
$isRoot = $user->authorise('core.admin');
if (!$isRoot) {
require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/imc.php';
$allowed_catids = ImcHelper::getCategoriesByUserGroups();
$allowed_catids = implode(',', $allowed_catids);
if (!empty($allowed_catids)) {
$query->where('a.id IN (' . $allowed_catids . ')');
}
}
$db->setQuery($query);
if ($options = $db->loadObjectList()) {
foreach ($options as &$option) {
$option->text = str_repeat('- ', $option->level) . $option->text;
}
static::$options[$hash] = array_merge(static::$options[$hash], $options);
}
}
return static::$options[$hash];
}
示例11: getOptions
function getOptions()
{
// Base name of the HTML control.
// $ctrl = $control_name .'['. $name .']';
$courses = JoomdleHelperContent::getCourseList(0);
// Construct an array of the HTML OPTION statements.
$options = array();
$c = array();
foreach ($courses as $course) {
$val = $course['remoteid'];
$text = $course['fullname'];
$options[] = JHtml::_('select.option', $val, $text);
// $op->id = $course['remoteid'];
// $op->text = $course['fullname'];
// $c[] = $op;
}
$options = array_merge(parent::getOptions(), $options);
return $options;
// Construct the various argument calls that are supported.
$attribs = ' ';
if ($v = $node->attributes('size')) {
$attribs .= 'size="' . $v . '"';
}
if ($v = $node->attributes('class')) {
$attribs .= 'class="' . $v . '"';
} else {
$attribs .= 'class="inputbox"';
}
if ($m = $node->attributes('multiple')) {
$attribs .= ' multiple="multiple"';
$ctrl .= '[]';
}
// Render the HTML SELECT list.
return JHTML::_('select.genericlist', $options, $ctrl, $attribs, 'value', 'text', $value, $control_name . $name);
}
示例12: getOptions
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 11.1
*/
public function getOptions()
{
$options = array();
$db = JFactory::getDbo();
$query = $db->getQuery(true)->select('code As value, title As `text`, print_title')->from('#__sibdiet_countries')->order('title')->where('published = 1');
$db->setQuery($query);
try {
$options = $db->loadObjectList();
} catch (RuntimeException $e) {
JError::raiseWarning(500, $e->getMessage());
}
$lang_tag = JFactory::getLanguage()->get('tag');
foreach ($options as $option) {
// Convert the print_title field to an array.
$registry = new JRegistry();
$registry->loadString($option->print_title);
$print_title = $registry->toArray();
if (array_key_exists($lang_tag, $print_title)) {
$option->text = $print_title[$lang_tag];
}
}
// Sort Options
usort($options, function ($a, $b) {
return strcmp($a->text, $b->text);
});
return array_merge(parent::getOptions(), $options);
}
示例13: getOptions
/**
* Method to get the field options.
*
* @return array The field option objects.
* @since 1.6
*/
protected function getOptions()
{
// Get the database object and a new query object.
$path = str_replace('administrator', '', JPATH_BASE);
$path = $path . 'components' . DS . 'com_awdwall' . DS . 'images' . DS;
$ldirs = listdirs($path);
//print_r($ldirs);
foreach ($ldirs as $ldir) {
$folders[] = str_replace($path . '/', '', $ldir);
}
$dir = str_replace('administrator', '', JPATH_BASE);
$dir = $dir . 'components' . DS . 'com_awdwall' . DS . 'css';
$needle = 'style_';
$length = strlen($needle);
$dh = opendir($dir);
while (false !== ($filename = readdir($dh))) {
if ($filename != "." && $filename != "..") {
if (substr($filename, 0, $length) === $needle) {
$order = '';
$newstr = '';
$order = array("style_", ".css");
$replace = '';
$newstr = str_replace($order, $replace, $filename);
if (in_array($newstr, $folders)) {
$files[] = $newstr;
$options[] = array('value' => $newstr, 'text' => $newstr);
}
}
}
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
示例14: getOptions
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 11.1
*/
protected function getOptions()
{
// Initialize variables.
$options = array();
//echo 'this->element<br /><pre>~' . print_r($this->element,true) . '~</pre><br />';
$varname = (string) $this->element['varname'];
$vartable = (string) $this->element['targettable'];
$select_id = JRequest::getVar($varname);
if (is_array($select_id)) {
$select_id = $select_id[0];
}
if ($select_id) {
$db =& JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('t.id AS value, t.name AS text');
$query->from('#__joomleague_associations AS t');
$query->join('inner', '#__joomleague_' . $vartable . ' AS wt ON wt.country = t.country ');
$query->where('wt.id = ' . $select_id);
$query->order('t.name');
$db->setQuery($query);
$options = $db->loadObjectList();
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
示例15: getOptions
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName('car.id') . ', ' . $db->quoteName('car.name'));
$query->from($db->quoteName('#__agendadirigentes_cargos', 'car'));
if ($this->getAttribute('includecategory', false) == true) {
$query->select($db->quoteName('cat.title', 'category_name'));
$query->join('INNER', $db->quoteName('#__categories', 'cat') . ' ON ' . $db->quoteName('car.catid') . ' = ' . $db->quoteName('cat.id'));
$query->order($db->quoteName('cat.title') . 'ASC, ' . $db->quoteName('car.name') . ' ASC');
} else {
$query->order($db->quoteName('car.name') . ' ASC');
}
$db->setQuery((string) $query);
$cargos = $db->loadObjectList();
$options = array();
$options[] = JHtml::_('select.option', '', JText::_('COM_AGENDADIRIGENTES_SELECT_CARGO'));
if ($cargos) {
foreach ($cargos as $cargo) {
if ($this->getAttribute('includecategory', false)) {
$options[] = JHtml::_('select.option', $cargo->id, $cargo->category_name . ' - ' . $cargo->name);
} else {
$options[] = JHtml::_('select.option', $cargo->id, $cargo->name);
}
}
}
$options = array_merge(parent::getOptions(), $options);
return $options;
}