本文整理汇总了PHP中TemplatesHelper::getPositions方法的典型用法代码示例。如果您正苦于以下问题:PHP TemplatesHelper::getPositions方法的具体用法?PHP TemplatesHelper::getPositions怎么用?PHP TemplatesHelper::getPositions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TemplatesHelper
的用法示例。
在下文中一共展示了TemplatesHelper::getPositions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Construct method
*
* @param JDocumentHTML $template Template object
*
* @throws Exception
*/
public function __construct(JDocumentHTML $template)
{
if (!$template instanceof JDocumentHTML) {
return;
}
$this->tmpl_params = $template->params;
$menu = JFactory::getApplication()->getMenu();
$activeMenu = $menu->getActive();
// Merge menu params with template params
jimport('joomla.utilities.arrayhelper');
$params = array_merge($activeMenu->params->toArray(), $this->tmpl_params->toArray());
$this->params = JArrayHelper::toObject($params, 'JRegistry');
require_once JPATH_ADMINISTRATOR . '/components/com_templates/helpers/templates.php';
$positions = TemplatesHelper::getPositions(false, 'blank_j3');
// Check for positions
foreach ($positions as $position) {
$this->{'show_' . $position} = $template->countModules($position);
}
$this->show_msg = $template->countModules('message');
}
示例2: positions
/**
* Display a batch widget for the module position selector.
*
* @param integer $clientId The client ID.
* @param integer $state The state of the module (enabled, unenabled, trashed).
* @param string $selectedPosition The currently selected position for the module.
*
* @return string The necessary positions for the widget.
*
* @since 2.5
*/
public static function positions($clientId, $state = 1, $selectedPosition = '')
{
require_once JPATH_ADMINISTRATOR . '/components/com_templates/helpers/templates.php';
$templates = array_keys(ModulesHelper::getTemplates($clientId, $state));
$templateGroups = array();
// Add an empty value to be able to deselect a module position
$option = ModulesHelper::createOption();
$templateGroups[''] = ModulesHelper::createOptionGroup('', array($option));
// Add positions from templates
$isTemplatePosition = false;
foreach ($templates as $template) {
$options = array();
$positions = TemplatesHelper::getPositions($clientId, $template);
if (is_array($positions)) {
foreach ($positions as $position) {
$text = ModulesHelper::getTranslatedModulePosition($clientId, $template, $position) . ' [' . $position . ']';
$options[] = ModulesHelper::createOption($position, $text);
if (!$isTemplatePosition && $selectedPosition === $position) {
$isTemplatePosition = true;
}
}
}
$templateGroups[$template] = ModulesHelper::createOptionGroup(ucfirst($template), $options);
}
// Add custom position to options
$customGroupText = JText::_('COM_MODULES_CUSTOM_POSITION');
$editPositions = true;
$customPositions = ModulesHelper::getPositions($clientId, $editPositions);
$templateGroups[$customGroupText] = ModulesHelper::createOptionGroup($customGroupText, $customPositions);
return $templateGroups;
}
示例3: getPositions
protected function getPositions($active)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('element, name, enabled');
$query->from('#__extensions');
$query->where('client_id = 0');
$query->where('type = ' . $db->quote('template'));
$query->where('enabled = 1');
$db->setQuery($query);
$templates = $db->loadObjectList();
require_once JPATH_ADMINISTRATOR . '/components/com_templates/helpers/templates.php';
$options = array();
$group = array();
$group['value'] = '';
$group['text'] = '';
$group['items'] = array();
$option = new stdClass();
$option->value = '';
$option->text = JText::_('COM_SIGPRO___NONE_SELECTED__');
$group['items'][] = $option;
$options[] = $group;
foreach ($templates as $template) {
$group = array();
$group['value'] = $template->name;
$group['text'] = $template->name;
$group['items'] = array();
$positions = TemplatesHelper::getPositions(0, $template->element);
foreach ($positions as $position) {
$option = new stdClass();
$option->value = $position;
$option->text = $position;
$group['items'][] = $option;
}
$options[] = $group;
}
// Build field
$attributes = array('list.select' => $active, 'list.attr' => 'class="chzn-custom-value input-xlarge"');
return JHtml::_('select.groupedlist', $options, $this->name, $attributes);
}
示例4: defined
*/
defined('_JEXEC') or die;
require_once JPATH_ADMINISTRATOR . '/components/com_templates/helpers/templates.php';
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
$clientId = $this->item->client_id;
$state = $this->state->get('filter.state');
$templates = array_keys(ModulesHelper::getTemplates($clientId, $state));
$templateGroups = array();
// Add an empty value to be able to deselect a module position
$option = ModulesHelper::createOption();
$templateGroups[''] = ModulesHelper::createOptionGroup('', array($option));
// Add positions from templates
$isTemplatePosition = false;
foreach ($templates as $template) {
$options = array();
$positions = TemplatesHelper::getPositions($clientId, $template);
foreach ($positions as $position) {
$text = ModulesHelper::getTranslatedModulePosition($clientId, $template, $position) . ' [' . $position . ']';
$options[] = ModulesHelper::createOption($position, $text);
if (!$isTemplatePosition && $this->item->position === $position) {
$isTemplatePosition = true;
}
}
$templateGroups[$template] = ModulesHelper::createOptionGroup(ucfirst($template), $options);
}
// Add custom position to options
$customGroupText = JText::_('COM_MODULES_CUSTOM_POSITION');
$editPositions = true;
$customPositions = ModulesHelper::getPositions($clientId, $editPositions);
$templateGroups[$customGroupText] = ModulesHelper::createOptionGroup($customGroupText, $customPositions);
// Build field