You've already forked joomla_test
first commit
This commit is contained in:
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
229
administrator/components/com_modules/helpers/html/modules.php
Normal file
229
administrator/components/com_modules/helpers/html/modules.php
Normal file
@ -0,0 +1,229 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_modules
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_modules
|
||||
* @since 1.6
|
||||
*/
|
||||
abstract class JHtmlModules
|
||||
{
|
||||
/**
|
||||
* Builds an array of template options
|
||||
*
|
||||
* @param integer $clientId The client id
|
||||
* @param string $state The state of the template
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function templates($clientId = 0, $state = '')
|
||||
{
|
||||
$options = array();
|
||||
$templates = ModulesHelper::getTemplates($clientId, $state);
|
||||
|
||||
foreach ($templates as $template)
|
||||
{
|
||||
$options[] = JHtml::_('select.option', $template->element, $template->name);
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds an array of template type options
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function types()
|
||||
{
|
||||
$options = array();
|
||||
$options[] = JHtml::_('select.option', 'user', 'COM_MODULES_OPTION_POSITION_USER_DEFINED');
|
||||
$options[] = JHtml::_('select.option', 'template', 'COM_MODULES_OPTION_POSITION_TEMPLATE_DEFINED');
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds an array of template state options
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function templateStates()
|
||||
{
|
||||
$options = array();
|
||||
$options[] = JHtml::_('select.option', '1', 'JENABLED');
|
||||
$options[] = JHtml::_('select.option', '0', 'JDISABLED');
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a published state on a grid
|
||||
*
|
||||
* @param integer $value The state value.
|
||||
* @param integer $i The row index
|
||||
* @param boolean $enabled An optional setting for access control on the action.
|
||||
* @param string $checkbox An optional prefix for checkboxes.
|
||||
*
|
||||
* @return string The Html code
|
||||
*
|
||||
* @see JHtmlJGrid::state
|
||||
* @since 1.7.1
|
||||
*/
|
||||
public static function state($value, $i, $enabled = true, $checkbox = 'cb')
|
||||
{
|
||||
$states = array(
|
||||
1 => array(
|
||||
'unpublish',
|
||||
'COM_MODULES_EXTENSION_PUBLISHED_ENABLED',
|
||||
'COM_MODULES_HTML_UNPUBLISH_ENABLED',
|
||||
'COM_MODULES_EXTENSION_PUBLISHED_ENABLED',
|
||||
true,
|
||||
'publish',
|
||||
'publish'
|
||||
),
|
||||
0 => array(
|
||||
'publish',
|
||||
'COM_MODULES_EXTENSION_UNPUBLISHED_ENABLED',
|
||||
'COM_MODULES_HTML_PUBLISH_ENABLED',
|
||||
'COM_MODULES_EXTENSION_UNPUBLISHED_ENABLED',
|
||||
true,
|
||||
'unpublish',
|
||||
'unpublish'
|
||||
),
|
||||
-1 => array(
|
||||
'unpublish',
|
||||
'COM_MODULES_EXTENSION_PUBLISHED_DISABLED',
|
||||
'COM_MODULES_HTML_UNPUBLISH_DISABLED',
|
||||
'COM_MODULES_EXTENSION_PUBLISHED_DISABLED',
|
||||
true,
|
||||
'warning',
|
||||
'warning'
|
||||
),
|
||||
-2 => array(
|
||||
'publish',
|
||||
'COM_MODULES_EXTENSION_UNPUBLISHED_DISABLED',
|
||||
'COM_MODULES_HTML_PUBLISH_DISABLED',
|
||||
'COM_MODULES_EXTENSION_UNPUBLISHED_DISABLED',
|
||||
true,
|
||||
'unpublish',
|
||||
'unpublish'
|
||||
),
|
||||
);
|
||||
|
||||
return JHtml::_('jgrid.state', $states, $value, $i, 'modules.', $enabled, true, $checkbox);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a batch widget for the module position selector.
|
||||
*
|
||||
* @param integer $clientId The client ID
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
public static function batchOptions()
|
||||
{
|
||||
// Create the copy/move options.
|
||||
$options = array(
|
||||
JHtml::_('select.option', 'c', JText::_('JLIB_HTML_BATCH_COPY')),
|
||||
JHtml::_('select.option', 'm', JText::_('JLIB_HTML_BATCH_MOVE'))
|
||||
);
|
||||
|
||||
echo JHtml::_('select.radiolist', $options, 'batch[move_copy]', '', 'value', 'text', 'm');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the field options.
|
||||
*
|
||||
* @param integer $clientId The client ID
|
||||
*
|
||||
* @return array The field option objects.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public static function positionList($clientId = 0)
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('DISTINCT(position) as value')
|
||||
->select('position as text')
|
||||
->from($db->quoteName('#__modules'))
|
||||
->where($db->quoteName('client_id') . ' = ' . (int) $clientId)
|
||||
->order('position');
|
||||
|
||||
// Get the options.
|
||||
$db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
$options = $db->loadObjectList();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
JError::raiseWarning(500, $e->getMessage());
|
||||
}
|
||||
|
||||
// Pop the first item off the array if it's blank
|
||||
if (count($options))
|
||||
{
|
||||
if (strlen($options[0]->text) < 1)
|
||||
{
|
||||
array_shift($options);
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
1
administrator/components/com_modules/helpers/index.html
Normal file
1
administrator/components/com_modules/helpers/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
324
administrator/components/com_modules/helpers/modules.php
Normal file
324
administrator/components/com_modules/helpers/modules.php
Normal file
@ -0,0 +1,324 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_modules
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Modules component helper.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_modules
|
||||
* @since 1.6
|
||||
*/
|
||||
abstract class ModulesHelper
|
||||
{
|
||||
/**
|
||||
* Configure the Linkbar.
|
||||
*
|
||||
* @param string $vName The name of the active view.
|
||||
*/
|
||||
public static function addSubmenu($vName)
|
||||
{
|
||||
// Not used in this component.
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of the actions that can be performed.
|
||||
*
|
||||
* @return JObject
|
||||
*/
|
||||
public static function getActions()
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
$result = new JObject;
|
||||
|
||||
$actions = JAccess::getActions('com_modules');
|
||||
|
||||
foreach ($actions as $action)
|
||||
{
|
||||
$result->set($action->name, $user->authorise($action->name, 'com_modules'));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of filter options for the state of a module.
|
||||
*
|
||||
* @return array An array of JHtmlOption elements.
|
||||
*/
|
||||
public static function getStateOptions()
|
||||
{
|
||||
// Build the filter options.
|
||||
$options = array();
|
||||
$options[] = JHtml::_('select.option', '1', JText::_('JPUBLISHED'));
|
||||
$options[] = JHtml::_('select.option', '0', JText::_('JUNPUBLISHED'));
|
||||
$options[] = JHtml::_('select.option', '-2', JText::_('JTRASHED'));
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of filter options for the application clients.
|
||||
*
|
||||
* @return array An array of JHtmlOption elements.
|
||||
*/
|
||||
public static function getClientOptions()
|
||||
{
|
||||
// Build the filter options.
|
||||
$options = array();
|
||||
$options[] = JHtml::_('select.option', '0', JText::_('JSITE'));
|
||||
$options[] = JHtml::_('select.option', '1', JText::_('JADMINISTRATOR'));
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of modules positions
|
||||
*
|
||||
* @param integer $clientId Client ID
|
||||
*
|
||||
* @return array A list of positions
|
||||
*/
|
||||
public static function getPositions($clientId, $editPositions = false)
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('DISTINCT(position)')
|
||||
->from('#__modules')
|
||||
->where($db->quoteName('client_id') . ' = ' . (int) $clientId)
|
||||
->order('position');
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
$positions = $db->loadColumn();
|
||||
$positions = is_array($positions) ? $positions : array();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
JError::raiseWarning(500, $e->getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
// Build the list
|
||||
$options = array();
|
||||
foreach ($positions as $position)
|
||||
{
|
||||
if (!$position && !$editPositions)
|
||||
{
|
||||
$options[] = JHtml::_('select.option', 'none', ':: ' . JText::_('JNONE') . ' ::');
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$options[] = JHtml::_('select.option', $position, $position);
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of templates
|
||||
*
|
||||
* @param integer $clientId Client ID
|
||||
* @param string $state State
|
||||
* @param string $template Template name
|
||||
*
|
||||
* @return array List of templates
|
||||
*/
|
||||
public static function getTemplates($clientId = 0, $state = '', $template = '')
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Get the database object and a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Build the query.
|
||||
$query->select('element, name, enabled')
|
||||
->from('#__extensions')
|
||||
->where('client_id = ' . (int) $clientId)
|
||||
->where('type = ' . $db->quote('template'));
|
||||
if ($state != '')
|
||||
{
|
||||
$query->where('enabled = ' . $db->quote($state));
|
||||
}
|
||||
|
||||
if ($template != '')
|
||||
{
|
||||
$query->where('element = ' . $db->quote($template));
|
||||
}
|
||||
|
||||
// Set the query and load the templates.
|
||||
$db->setQuery($query);
|
||||
$templates = $db->loadObjectList('element');
|
||||
return $templates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of the unique modules installed in the client application.
|
||||
*
|
||||
* @param int $clientId The client id.
|
||||
*
|
||||
* @return array Array of unique modules
|
||||
*/
|
||||
public static function getModules($clientId)
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('element AS value, name AS text')
|
||||
->from('#__extensions as e')
|
||||
->where('e.client_id = ' . (int) $clientId)
|
||||
->where('type = ' . $db->quote('module'))
|
||||
->join('LEFT', '#__modules as m ON m.module=e.element AND m.client_id=e.client_id')
|
||||
->where('m.module IS NOT NULL')
|
||||
->group('element,name');
|
||||
|
||||
$db->setQuery($query);
|
||||
$modules = $db->loadObjectList();
|
||||
$lang = JFactory::getLanguage();
|
||||
|
||||
foreach ($modules as $i => $module)
|
||||
{
|
||||
$extension = $module->value;
|
||||
$path = $clientId ? JPATH_ADMINISTRATOR : JPATH_SITE;
|
||||
$source = $path . "/modules/$extension";
|
||||
$lang->load("$extension.sys", $path, null, false, false)
|
||||
|| $lang->load("$extension.sys", $source, null, false, false)
|
||||
|| $lang->load("$extension.sys", $path, $lang->getDefault(), false, false)
|
||||
|| $lang->load("$extension.sys", $source, $lang->getDefault(), false, false);
|
||||
$modules[$i]->text = JText::_($module->text);
|
||||
}
|
||||
JArrayHelper::sortObjects($modules, 'text', 1, true, true);
|
||||
return $modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of the assignment options for modules to menus.
|
||||
*
|
||||
* @param int $clientId The client id.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getAssignmentOptions($clientId)
|
||||
{
|
||||
$options = array();
|
||||
$options[] = JHtml::_('select.option', '0', 'COM_MODULES_OPTION_MENU_ALL');
|
||||
$options[] = JHtml::_('select.option', '-', 'COM_MODULES_OPTION_MENU_NONE');
|
||||
|
||||
if ($clientId == 0)
|
||||
{
|
||||
$options[] = JHtml::_('select.option', '1', 'COM_MODULES_OPTION_MENU_INCLUDE');
|
||||
$options[] = JHtml::_('select.option', '-1', 'COM_MODULES_OPTION_MENU_EXCLUDE');
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a translated module position name
|
||||
*
|
||||
* @param string $template Template name
|
||||
* @param string $position Position name
|
||||
*
|
||||
* @return string Return a translated position name
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public static function getTranslatedModulePosition($clientId, $template, $position)
|
||||
{
|
||||
// Template translation
|
||||
$lang = JFactory::getLanguage();
|
||||
$path = $clientId ? JPATH_ADMINISTRATOR : JPATH_SITE;
|
||||
|
||||
$lang->load('tpl_'.$template.'.sys', $path, null, false, false)
|
||||
|| $lang->load('tpl_'.$template.'.sys', $path.'/templates/'.$template, null, false, false)
|
||||
|| $lang->load('tpl_'.$template.'.sys', $path, $lang->getDefault(), false, false)
|
||||
|| $lang->load('tpl_'.$template.'.sys', $path.'/templates/'.$template, $lang->getDefault(), false, false);
|
||||
|
||||
$langKey = strtoupper('TPL_' . $template . '_POSITION_' . $position);
|
||||
$text = JText::_($langKey);
|
||||
|
||||
// Avoid untranslated strings
|
||||
if (!self::isTranslatedText($langKey, $text))
|
||||
{
|
||||
// Modules component translation
|
||||
$langKey = strtoupper('COM_MODULES_POSITION_' . $position);
|
||||
$text = JText::_($langKey);
|
||||
|
||||
// Avoid untranslated strings
|
||||
if (!self::isTranslatedText($langKey, $text))
|
||||
{
|
||||
// Try to humanize the position name
|
||||
$text = ucfirst(preg_replace('/^' . $template . '\-/', '', $position));
|
||||
$text = ucwords(str_replace(array('-', '_'), ' ', $text));
|
||||
}
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the string was translated
|
||||
*
|
||||
* @param string $langKey Language file text key
|
||||
* @param string $text The "translated" text to be checked
|
||||
*
|
||||
* @return boolean Return true for translated text
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public static function isTranslatedText($langKey, $text)
|
||||
{
|
||||
return $text !== $langKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and return a new Option
|
||||
*
|
||||
* @param string $value The option value [optional]
|
||||
* @param string $text The option text [optional]
|
||||
*
|
||||
* @return object The option as an object (stdClass instance)
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public static function createOption($value = '', $text = '')
|
||||
{
|
||||
if (empty($text))
|
||||
{
|
||||
$text = $value;
|
||||
}
|
||||
|
||||
$option = new stdClass;
|
||||
$option->value = $value;
|
||||
$option->text = $text;
|
||||
|
||||
return $option;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and return a new Option Group
|
||||
*
|
||||
* @param string $label Value and label for group [optional]
|
||||
* @param array $options Array of options to insert into group [optional]
|
||||
*
|
||||
* @return array Return the new group as an array
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public static function createOptionGroup($label = '', $options = array())
|
||||
{
|
||||
$group = array();
|
||||
$group['value'] = $label;
|
||||
$group['text'] = $label;
|
||||
$group['items'] = $options;
|
||||
|
||||
return $group;
|
||||
}
|
||||
}
|
46
administrator/components/com_modules/helpers/xml.php
Normal file
46
administrator/components/com_modules/helpers/xml.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_modules
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Helper for parse XML module files
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_modules
|
||||
* @since 1.5
|
||||
*/
|
||||
class ModulesHelperXML
|
||||
{
|
||||
/**
|
||||
* @since 1.5
|
||||
*/
|
||||
public function parseXMLModuleFile(&$rows)
|
||||
{
|
||||
foreach ($rows as $i => $row)
|
||||
{
|
||||
if ($row->module == '')
|
||||
{
|
||||
$rows[$i]->name = 'custom';
|
||||
$rows[$i]->module = 'custom';
|
||||
$rows[$i]->descrip = 'Custom created module, using Module Manager New function';
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = JInstaller::parseXMLInstallFile($row->path . '/' . $row->file);
|
||||
|
||||
if ($data['type'] == 'module')
|
||||
{
|
||||
$rows[$i]->name = $data['name'];
|
||||
$rows[$i]->descrip = $data['description'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user