本文整理汇总了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.
*/
protected function _getOptions()
{
jimport('joomla.filesystem.folder');
// path to folders directory
$path = JPATH_ROOT . '/' . $this->_element->attributes()->directory;
$filter = (string) $this->_element->attributes()->filter;
$exclude = (string) $this->_element->attributes()->exclude;
$folders = JFolder::folders($path, $filter);
// Prepare return value
$options = array();
// Add basic options
if (!(string) $this->_element->attributes()->hide_none) {
$options[] = JHtml::_('select.option', '-1', JText::_('JOption_Do_Not_Use'));
}
if (!(string) $this->_element->attributes()->hide_default) {
$options[] = JHtml::_('select.option', '', JText::_('JOption_Use_Default'));
}
// Iterate over folders
if (is_array($folders)) {
foreach ($folders as $folder) {
if ($exclude) {
if (preg_match(chr(1) . $exclude . chr(1), $folder)) {
continue;
}
}
$options[] = JHtml::_('select.option', $folder, $folder);
}
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::_getOptions(), $options);
return $options;
}
示例2: _getOptions
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function _getOptions()
{
jimport('joomla.language.helper');
$client = (string) $this->_element->attributes()->client;
$options = array_merge(parent::_getOptions(), JLanguageHelper::createLanguageList($this->value, constant('JPATH_' . strtoupper($client)), true));
return $options;
}
示例3: _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();
$extension = (string) $this->_element->attributes()->extension;
$extension = (string) $this->_element->attributes()->extension ? (string) $this->_element->attributes()->extension : (string) $this->_element->attributes()->scope;
$published = (string) $this->_element->attributes()->published;
$options = array();
if ($published === '') {
$published = null;
}
if (!empty($extension)) {
if ($published) {
$options = JHtml::_('category.options', $extension, array('filter.published' => implode(',', $published)));
} else {
$options = JHtml::_('category.options', $extension);
}
// Verify permissions. If the action attribute is set, then we scan the options.
if ($action = (string) $this->_element->attributes()->action) {
$user = JFactory::getUser();
// TODO: Add a preload method to JAccess so that we can get all the asset rules in one query and cache them.
// eg JAccess::preload('core.create', 'com_content.category')
foreach ($options as $i => $option) {
if (!$user->authorise($action, $extension . '.category.' . $option->value)) {
unset($options[$i]);
}
}
}
} else {
JError::raiseWarning(500, JText::_('JFramework_Form_Fields_Category_Error_extension_empty'));
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::_getOptions(), $options);
return $options;
}
示例4: _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 = new JQuery();
$query->select('a.id AS value, a.title AS text, a.level');
$query->from('#__categories AS a');
$query->join('LEFT', '`#__categories` AS b ON a.lft > b.lft AND a.rgt < b.rgt');
// Filter by the type
if ($extension = $this->_form->getValue('extension')) {
$query->where('(a.extension = ' . $db->quote($extension) . ' OR a.parent_id = 0)');
}
// Prevent parenting to children of this item.
if ($id = $this->_form->getValue('id')) {
$query->join('LEFT', '`#__categories` AS p ON p.id = ' . (int) $id);
$query->where('NOT(a.lft >= p.lft AND a.rgt <= p.rgt)');
}
$query->group('a.id');
$query->order('a.lft ASC');
// Get the options.
$db->setQuery($query);
$options = $db->loadObjectList();
// Check for a database error.
if ($db->getErrorNum()) {
JError::raiseWarning(500, $db->getErrorMsg());
}
// 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;
}
$options = array_merge(parent::_getOptions(), $options);
return $options;
}
示例5: _getOptions
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function _getOptions()
{
// compile list of the editors
$query = 'SELECT element AS value, name AS text' . ' FROM #__extensions' . ' WHERE folder = "editors"' . ' AND enabled = 1' . ' ORDER BY ordering, name';
$db =& JFactory::getDbo();
$db->setQuery($query);
$options = $db->loadObjectList();
// @todo: Check for an error msg.
// Merge any additional options in the XML definition.
$options = array_merge(parent::_getOptions(), $options);
return $options;
}
示例6: _getOptions
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function _getOptions()
{
$first = (int) $this->_element->attributes('first');
$last = (int) $this->_element->attributes('last');
$step = (int) max(1, $this->_element->attributes('step'));
$options = array();
for ($i = $first; $i <= $last; $i += $step) {
$options[] = JHtml::_('select.option', $i);
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::_getOptions(), $options);
return $options;
}
示例7: _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 = new JQuery();
$clientId = (int) $this->_form->getValue('client_id');
$client = JApplicationHelper::getClientInfo($clientId);
jimport('joomla.filesystem.folder');
// template assignment filter
$query = new JQuery();
$query->select('DISTINCT(template)');
$query->from('#__template_styles');
$query->where('client_id = ' . (int) $clientId);
$db->setQuery($query);
$templates = $db->loadResultArray();
if ($error = $db->getErrorMsg()) {
JError::raiseWarning(500, $error);
return false;
}
$query = new JQuery();
$query->select('DISTINCT(position)');
$query->from('#__modules');
$query->where('`client_id` = ' . (int) $clientId);
$db->setQuery($query);
$positions = $db->loadResultArray();
if ($error = $db->getErrorMsg()) {
JError::raiseWarning(500, $error);
return false;
}
// Load the positions from the installed templates.
foreach ($templates as $template) {
$path = JPath::clean($client->path . '/templates/' . $template . '/templateDetails.xml');
if (file_exists($path)) {
$xml = simplexml_load_file($path);
if (isset($xml->positions[0])) {
foreach ($xml->positions[0] as $position) {
$positions[] = (string) $position;
}
}
}
}
$positions = array_unique($positions);
sort($positions);
$options = array();
foreach ($positions as $position) {
$options[] = JHtml::_('select.option', $position, $position);
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::_getOptions(), $options);
return $options;
}
示例8: _getOptions
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function _getOptions()
{
// Get the session handlers.
jimport('joomla.session.session');
$stores = JSession::getStores();
$options = array();
// Convert to name => name array.
foreach ($stores as $store) {
$options[$store] = $store;
}
// Merge the options together.
$options = array_merge(parent::_getOptions(), $options);
return $options;
}
示例9: _getOptions
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function _getOptions()
{
// Initialise variables.
$options = array();
$path1 = null;
$path2 = null;
$module = (string) $this->_element->attributes()->module;
if (empty($module)) {
$module = $this->_form->get('module');
}
$clientId = (string) $this->_element->attributes()->client_id;
if (empty($clientId)) {
$clientId = $this->_form->get('client_id');
}
// Load template entries for each menuid
$db = JFactory::getDBO();
$query = 'SELECT template' . ' FROM #__template_styles' . ' WHERE client_id = ' . (int) $clientId . ' AND home = 1';
$db->setQuery($query);
$template = $db->loadResult();
if ($module) {
$module = preg_replace('#\\W#', '', $module);
$client = JApplicationHelper::getClientInfo($clientId);
$path1 = $client->path . '/modules/' . $module . '/tmpl';
$path2 = $client->path . '/templates/' . $template . '/html/' . $module;
$options[] = JHTML::_('select.option', '', '');
}
if ($path1 && $path2) {
jimport('joomla.filesystem.file');
$path1 = JPath::clean($path1);
$path2 = JPath::clean($path2);
if (is_dir($path1)) {
$files = JFolder::files($path1, '^[^_]*\\.php$');
foreach ($files as $file) {
$options[] = JHTML::_('select.option', JFile::stripExt($file));
}
}
if (is_dir($path2) && ($files = JFolder::files($path2, '^[^_]*\\.php$'))) {
$options[] = JHTML::_('select.optgroup', JText::_('JOption_From_Default'));
foreach ($files as $file) {
$options[] = JHTML::_('select.option', JFile::stripExt($file));
}
}
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::_getOptions(), $options);
return $options;
}
示例10: _getOptions
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function _getOptions()
{
require_once realpath(JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php');
$menuTypes = MenusHelper::getMenuTypes();
// Prepare return value
$options = array();
// Add basic option
// TODO: would be better to put this basic option in the xml file ?
$options[] = JHtml::_('select.option', '', JText::_('JOption_Select_Menu'));
// Iterate over menus
foreach ($menuTypes as $menutype) {
$options[] = JHtml::_('select.option', $menutype, $menutype);
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::_getOptions(), $options);
return $options;
}
示例11: _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 = new JQuery();
$query->select('id As value, name As text');
$query->from('#__newsfeeds AS a');
$query->order('a.name');
// Get the options.
$db->setQuery($query);
$options = $db->loadObjectList();
// Check for a database error.
if ($db->getErrorNum()) {
JError::raiseWarning(500, $db->getErrorMsg());
}
$options = array_merge(parent::_getOptions(), $options);
return $options;
}
示例12: _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 = new JQuery();
$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');
// Get the options.
$db->setQuery($query);
$options = $db->loadObjectList();
// 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;
}
示例13: _getOptions
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function _getOptions()
{
$options = array();
$path1 = null;
$path2 = null;
// Load template entries for each menuid
$db =& JFactory::getDBO();
$query = 'SELECT template' . ' FROM #__template_styles' . ' WHERE client_id = 0 AND home = 1';
$db->setQuery($query);
$template = $db->loadResult();
$extn = (string) $this->_element->attributes()->extension;
if (empty($extn)) {
$extn = $this->_form->getValue('extension');
}
if (($view = (string) $this->_element->attributes()->view) && $extn) {
$view = preg_replace('#\\W#', '', $view);
$extn = preg_replace('#\\W#', '', $extn);
$path1 = JPATH_SITE . DS . 'components' . DS . $extn . DS . 'views' . DS . $view . DS . 'tmpl';
$path2 = JPATH_SITE . DS . 'templates' . DS . $template . DS . 'html' . DS . $extn . DS . $view;
$options[] = JHTML::_('select.option', '', JText::_('JOption_Use_Menu_Request_Setting'));
}
if ($path1 && $path2) {
jimport('joomla.filesystem.file');
$path1 = JPath::clean($path1);
$path2 = JPath::clean($path2);
if (is_dir($path1) && ($files = JFolder::files($path1, '^[^_]*\\.php$'))) {
foreach ($files as $file) {
$options[] = JHTML::_('select.option', JFile::stripExt($file));
}
}
if (is_dir($path2) && ($files = JFolder::files($path2, '^[^_]*\\.php$'))) {
$options[] = JHTML::_('select.optgroup', JText::_('JOption_From_Default_Template'));
foreach ($files as $file) {
$options[] = JHTML::_('select.option', JFile::stripExt($file));
}
}
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::_getOptions(), $options);
return $options;
}
示例14: _getOptions
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function _getOptions()
{
// Initialise variables.
$app =& JFactory::getApplication();
// Detect the native language.
jimport('joomla.language.helper');
$native = JLanguageHelper::detectLanguage();
// Get a forced language if it exists.
$forced = $app->getLocalise();
if (!empty($forced['lang'])) {
$native = $forced['lang'];
}
// Get the list of available languages.
$options = JLanguageHelper::createLanguageList($native);
if (!$options || JError::isError($options)) {
$options = array();
}
// Set the default value from the native language.
$this->value = $native;
// Merge in any explicitly listed options from 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();
$db->setQuery((string) $this->_element->attributes()->query);
$key = (string) $this->_element->attributes()->key_field ? (string) $this->_element->attributes()->key_field : 'value';
$value = (string) $this->_element->attributes()->value_field ? (string) $this->_element->attributes()->value_field : $this->name;
$items = $db->loadObjectlist();
// Check for an error.
if ($db->getErrorNum()) {
JError::raiseWarning(500, $db->getErrorMsg());
return false;
}
// Prepare return value
$options = array();
if (!empty($items)) {
// Iterate over items
foreach ($items as $item) {
$options[] = JHtml::_('select.option', $item->{$key}, $item->{$value});
}
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::_getOptions(), $options);
return $options;
}