本文整理汇总了PHP中ModulesHelper类的典型用法代码示例。如果您正苦于以下问题:PHP ModulesHelper类的具体用法?PHP ModulesHelper怎么用?PHP ModulesHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ModulesHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
/**
* Method to display a view.
*
* @param boolean $cachable If true, the view output will be cached
* @param array|boolean $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}
*
* @return JController This object to support chaining.
*
* @since 1.5
*/
public function display($cachable = false, $urlparams = false)
{
$id = $this->input->getInt('id');
$document = JFactory::getDocument();
// For JSON requests
if ($document->getType() == 'json') {
$view = new ModulesViewModule();
// Get/Create the model
if ($model = new ModulesModelModule()) {
// Checkin table entry
if (!$model->checkout($id)) {
JFactory::getApplication()->enqueueMessage(JText::_('JLIB_APPLICATION_ERROR_CHECKIN_USER_MISMATCH'), 'error');
return false;
}
// Push the model into the view (as default)
$view->setModel($model, true);
}
$view->document = $document;
return $view->display();
}
JLoader::register('ModulesHelper', JPATH_ADMINISTRATOR . '/components/com_modules/helpers/modules.php');
$layout = $this->input->get('layout', 'edit');
$id = $this->input->getInt('id');
// Check for edit form.
if ($layout == 'edit' && !$this->checkEditId('com_modules.edit.module', $id)) {
// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option=com_modules&view=modules', false));
return false;
}
// Load the submenu.
ModulesHelper::addSubmenu($this->input->get('view', 'modules'));
return parent::display();
}
示例2: display
/**
* Method to display a view.
*
* @param boolean $cachable If true, the view output will be cached
* @param array|boolean $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}
*
* @return JController This object to support chaining.
*
* @since 1.5
*/
public function display($cachable = false, $urlparams = false)
{
$view = $this->input->get('view', 'modules');
$layout = $this->input->get('layout', 'default');
$id = $this->input->getInt('id');
$document = JFactory::getDocument();
// For JSON requests
if ($document->getType() == 'json') {
$view = new ModulesViewModule();
// Get/Create the model
if ($model = new ModulesModelModule()) {
// Checkin table entry
if (!$model->checkout($id)) {
JFactory::getApplication()->enqueueMessage(JText::_('JLIB_APPLICATION_ERROR_CHECKIN_USER_MISMATCH'), 'error');
return false;
}
// Push the model into the view (as default)
$view->setModel($model, true);
}
$view->document = $document;
return $view->display();
}
require_once JPATH_COMPONENT . '/helpers/modules.php';
// Load the submenu.
ModulesHelper::addSubmenu($this->input->get('view', 'modules'));
return parent::display();
}
示例3: _setToolbar
/**
* Setup the Toolbar
*
* @since 1.6
*/
protected function _setToolbar()
{
JRequest::setVar('hidemainmenu', true);
$user = JFactory::getUser();
$isNew = $this->item->id == 0;
$checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
$canDo = ModulesHelper::getActions($this->state->get('filter.category_id'), $this->item->id);
$client = $this->get('client');
JToolBarHelper::title(JText::_('Modules_Manager_Module'));
if ($this->item->module == 'mod_custom') {
JToolBarHelper::Preview('index.php?option=com_modules&tmpl=component&client=' . $client->id . '&pollid=' . $this->item->id);
}
// If not checked out, can save the item.
if (!$checkedOut && $canDo->get('core.edit')) {
JToolBarHelper::apply('module.apply', 'JToolbar_Apply');
JToolBarHelper::save('module.save', 'JToolbar_Save');
JToolBarHelper::addNew('module.save2new', 'JToolbar_Save_and_new');
}
// If an existing item, can save to a copy.
if (!$isNew && $canDo->get('core.create')) {
JToolBarHelper::custom('module.save2copy', 'copy.png', 'copy_f2.png', 'JToolbar_Save_as_Copy', false);
}
if (empty($this->item->id)) {
JToolBarHelper::cancel('module.cancel', 'JToolbar_Cancel');
} else {
JToolBarHelper::cancel('module.cancel', 'JToolbar_Close');
}
JToolBarHelper::help('screen.module.edit');
}
示例4: addToolbar
/**
* Add the page title and toolbar.
*
* @since 1.6
*/
protected function addToolbar()
{
$state = $this->get('State');
$canDo = ModulesHelper::getActions();
Toolbar::title(Lang::txt('COM_MODULES_MANAGER_MODULES'), 'module.png');
if ($canDo->get('core.create')) {
//Toolbar::addNew('module.add');
Toolbar::appendButton('Popup', 'new', 'JTOOLBAR_NEW', 'index.php?option=com_modules&view=select&tmpl=component', 850, 400);
}
if ($canDo->get('core.edit')) {
Toolbar::editList('module.edit');
}
if ($canDo->get('core.create')) {
Toolbar::custom('modules.duplicate', 'copy.png', 'copy_f2.png', 'JTOOLBAR_DUPLICATE', true);
}
if ($canDo->get('core.edit.state')) {
Toolbar::divider();
Toolbar::publish('modules.publish', 'JTOOLBAR_PUBLISH', true);
Toolbar::unpublish('modules.unpublish', 'JTOOLBAR_UNPUBLISH', true);
Toolbar::divider();
Toolbar::checkin('modules.checkin');
}
if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) {
Toolbar::deleteList('', 'modules.delete', 'JTOOLBAR_EMPTY_TRASH');
Toolbar::divider();
} elseif ($canDo->get('core.edit.state')) {
Toolbar::trash('modules.trash');
Toolbar::divider();
}
if ($canDo->get('core.admin')) {
Toolbar::preferences('com_modules');
Toolbar::divider();
}
Toolbar::help('modules');
}
示例5: display
/**
* Method to display a view.
*
* @param boolean If true, the view output will be cached
* @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return JController This object to support chaining.
* @since 1.5
*/
public function display($cachable = false, $urlparams = false)
{
require_once JPATH_COMPONENT . '/helpers/modules.php';
// Load the submenu.
ModulesHelper::addSubmenu($this->input->get('view', 'modules'));
$view = $this->input->get('view', 'modules');
$layout = $this->input->get('layout', 'default');
$id = $this->input->getInt('id');
// Check for edit form.
if ($view == 'module' && $layout == 'edit') {
if (!$this->checkEditId('com_advancedmodules.edit.module', $id)) {
// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option=com_advancedmodules&view=modules', false));
return false;
}
// Check general edit permission first.
if (!JFactory::getUser()->authorise('core.edit', 'com_advancedmodules.module.' . $id)) {
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option=com_advancedmodules&view=modules', false));
return false;
}
}
parent::display();
}
示例6: templates
/**
* @param int $clientId The client id
* @param string $state The state of the template
*/
public static function templates($clientId = 0, $state = '')
{
$templates = ModulesHelper::getTemplates($clientId, $state);
foreach ($templates as $template) {
$options[] = JHtml::_('select.option', $template->element, $template->name);
}
return $options;
}
示例7: display
/**
* Method to display a view.
*
* @param boolean $cachable If true, the view output will be cached
* @param array|boolean $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}
.
*
* @return JController This object to support chaining.
* @since 1.5
*/
public function display($cachable = false, $urlparams = false)
{
require_once JPATH_COMPONENT . '/helpers/modules.php';
// Load the submenu.
ModulesHelper::addSubmenu($this->input->get('view', 'modules'));
$view = $this->input->get('view', 'modules');
$layout = $this->input->get('layout', 'default');
$id = $this->input->getInt('id');
return parent::display();
}
示例8: addToolbar
/**
* Add the page title and toolbar.
*
* @since 1.6
*/
protected function addToolbar()
{
JFactory::getApplication()->input->set('hidemainmenu', true);
$user = JFactory::getUser();
$isNew = $this->item->id == 0;
$checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
$canDo = ModulesHelper::getActions($this->item->id);
JToolbarHelper::title(JText::sprintf('COM_MODULES_MANAGER_MODULE', JText::_($this->item->module)), 'cube module');
// For new records, check the create permission.
if ($isNew && $canDo->get('core.create')) {
JToolbarHelper::apply('module.apply');
JToolbarHelper::save('module.save');
JToolbarHelper::save2new('module.save2new');
JToolbarHelper::cancel('module.cancel');
} else {
// Can't save the record if it's checked out.
if (!$checkedOut) {
// Since it's an existing record, check the edit permission.
if ($canDo->get('core.edit')) {
JToolbarHelper::apply('module.apply');
JToolbarHelper::save('module.save');
// We can save this record, but check the create permission to see if we can return to make a new one.
if ($canDo->get('core.create')) {
JToolbarHelper::save2new('module.save2new');
}
}
}
// If checked out, we can still save
if ($canDo->get('core.create')) {
JToolbarHelper::save2copy('module.save2copy');
}
JToolbarHelper::cancel('module.cancel', 'JTOOLBAR_CLOSE');
}
// Get the help information for the menu item.
$lang = JFactory::getLanguage();
$help = $this->get('Help');
if ($lang->hasKey($help->url)) {
$debug = $lang->setDebug(false);
$url = JText::_($help->url);
$lang->setDebug($debug);
} else {
$url = null;
}
JToolbarHelper::help($help->key, false, $url);
}
示例9: display
/**
* Method to display a view.
*
* @param boolean If true, the view output will be cached
* @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return JController This object to support chaining.
* @since 1.5
*/
public function display($cachable = false, $urlparams = false)
{
require_once JPATH_COMPONENT . '/helpers/modules.php';
// Load the submenu.
ModulesHelper::addSubmenu(JRequest::getCmd('view', 'modules'));
$view = JRequest::getCmd('view', 'modules');
$layout = JRequest::getCmd('layout', 'default');
$id = JRequest::getInt('id');
// Check for edit form.
if ($view == 'module' && $layout == 'edit' && !$this->checkEditId('com_modules.edit.module', $id)) {
// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option=com_modules&view=modules', false));
return false;
}
parent::display();
}
示例10: getTemplateModuleStyles
/**
* Method to get the templates module styles.
*
* @return array The array of styles, grouped by templates.
*
* @since 3.0
*/
protected function getTemplateModuleStyles()
{
$moduleStyles = array();
$templates = array($this->getSystemTemplate());
$templates = array_merge($templates, ModulesHelper::getTemplates('site'));
foreach ($templates as $template) {
$modulesFilePath = JPATH_SITE . '/templates/' . $template->element . '/html/modules.php';
// Is there modules.php for that template?
if (file_exists($modulesFilePath)) {
$modulesFileData = file_get_contents($modulesFilePath);
preg_match_all('/function[\\s\\t]*modChrome\\_([a-z0-9\\-\\_]*)[\\s\\t]*\\(/i', $modulesFileData, $styles);
if (!array_key_exists($template->element, $moduleStyles)) {
$moduleStyles[$template->element] = array();
}
$moduleStyles[$template->element] = $styles[1];
}
}
return $moduleStyles;
}
示例11: display
/**
* Method to display a view.
*
* @param bool $cachable
* @param bool $urlparams
*
* @internal param \If $boolean true, the view output will be cached
* @internal param \An $array array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return JController This object to support chaining.
* @since 1.5
*/
public function display($cachable = false, $urlparams = false)
{
require_once JPATH_ADMINISTRATOR . '/components/com_modules/helpers/modules.php';
// Load the submenu.
ModulesHelper::addSubmenu(JFactory::getApplication()->input->getCmd('view', 'modules'));
$view = JFactory::getApplication()->input->getCmd('view', 'modules');
$layout = JFactory::getApplication()->input->getCmd('layout', 'default');
$id = JFactory::getApplication()->input->getInt('id', null);
// Check for edit form.
if ($view == 'module' && $layout == 'edit' && !$this->checkEditId('com_roksprocket.edit.module', $id)) {
// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_(sprintf('index.php?option=%s&view=modules', RokSprocket_Helper::getRedirectionOption()), false));
return false;
}
if (RokCommon_Session::get('roksprocket.' . $id, false)) {
RokCommon_Session::clear('roksprocket.' . $id);
}
parent::display();
}
示例12: addToolbar
/**
* Add the page title and toolbar.
*
* @since 1.6
*/
protected function addToolbar()
{
$state = $this->get('State');
$canDo = ModulesHelper::getActions();
JToolBarHelper::title(JText::_('COM_MODULES_MANAGER_MODULES'), 'module.png');
if ($canDo->get('core.create')) {
//JToolBarHelper::addNew('module.add');
$bar = JToolBar::getInstance('toolbar');
$bar->appendButton('Popup', 'new', 'JTOOLBAR_NEW', 'index.php?option=com_modules&view=select&tmpl=component', 850, 400);
}
if ($canDo->get('core.edit')) {
JToolBarHelper::editList('module.edit', 'JTOOLBAR_EDIT');
}
if ($canDo->get('core.create')) {
JToolBarHelper::custom('modules.duplicate', 'copy.png', 'copy_f2.png', 'JTOOLBAR_DUPLICATE', true);
}
if ($canDo->get('core.edit.state')) {
JToolBarHelper::divider();
JToolBarHelper::custom('modules.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true);
JToolBarHelper::custom('modules.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true);
JToolBarHelper::divider();
JToolBarHelper::custom('modules.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true);
}
if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) {
JToolBarHelper::deleteList('', 'modules.delete', 'JTOOLBAR_EMPTY_TRASH');
JToolBarHelper::divider();
} else {
if ($canDo->get('core.edit.state')) {
JToolBarHelper::trash('modules.trash', 'JTOOLBAR_TRASH');
JToolBarHelper::divider();
}
}
if ($canDo->get('core.admin')) {
JToolBarHelper::preferences('com_modules');
JToolBarHelper::divider();
}
JToolBarHelper::help('JHELP_EXTENSIONS_MODULE_MANAGER');
}
示例13: addToolbar
/**
* Add the page title and toolbar.
*
* @since 1.6
*/
protected function addToolbar()
{
JRequest::setVar('hidemainmenu', true);
$user = JFactory::getUser();
$isNew = $this->item->id == 0;
$checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
$canDo = ModulesHelper::getActions($this->state->get('filter.category_id'), $this->item->id);
$item = $this->get('Item');
JToolBarHelper::title(JText::sprintf('COM_MODULES_MANAGER_MODULE', JText::_($this->item->module)), 'module.png');
// If not checked out, can save the item.
if (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.create'))) {
JToolBarHelper::apply('module.apply');
JToolBarHelper::save('module.save');
}
if (!$checkedOut && $canDo->get('core.create')) {
JToolBarHelper::save2new('module.save2new');
}
// If an existing item, can save to a copy.
if (!$isNew && $canDo->get('core.create')) {
JToolBarHelper::save2copy('module.save2copy');
}
if (empty($this->item->id)) {
JToolBarHelper::cancel('module.cancel');
} else {
JToolBarHelper::cancel('module.cancel', 'JTOOLBAR_CLOSE');
}
// Get the help information for the menu item.
$lang = JFactory::getLanguage();
$help = $this->get('Help');
if ($lang->hasKey($help->url)) {
$debug = $lang->setDebug(false);
$url = JText::_($help->url);
$lang->setDebug($debug);
} else {
$url = null;
}
JToolBarHelper::help($help->key, false, $url);
}
示例14: display
/**
* Method to display a view.
*/
public function display()
{
require_once JPATH_COMPONENT . '/helpers/modules.php';
// Get the document object.
$document = JFactory::getDocument();
// Set the default view name and format from the Request.
$vName = JRequest::getWord('view', 'modules');
$vFormat = $document->getType();
$lName = JRequest::getWord('layout', 'default');
// Get and render the view.
if ($view =& $this->getView($vName, $vFormat)) {
// Get the model for the view.
$model =& $this->getModel($vName);
// Push the model into the view (as default).
$view->setModel($model, true);
$view->setLayout($lName);
// Push document object into the view.
$view->assignRef('document', $document);
$view->display();
// Load the submenu.
ModulesHelper::addSubmenu($vName);
}
}
示例15: 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;
}