first commit

This commit is contained in:
alazhar
2020-01-02 22:20:31 +07:00
commit 10eb3340ad
5753 changed files with 631345 additions and 0 deletions

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,209 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_menus
*
* @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;
JLoader::register('MenusHelper', JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php');
/**
* @package Joomla.Administrator
* @subpackage com_menus
*/
abstract class MenusHtmlMenus
{
/**
* @param int $itemid The menu item id
*/
public static function association($itemid)
{
// Defaults
$html = '';
// Get the associations
if ($associations = MenusHelper::getAssociations($itemid))
{
// Get the associated menu items
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('m.id, m.title')
->select('l.sef as lang_sef')
->select('mt.title as menu_title')
->from('#__menu as m')
->join('LEFT', '#__menu_types as mt ON mt.menutype=m.menutype')
->where('m.id IN (' . implode(',', array_values($associations)) . ')')
->join('LEFT', '#__languages as l ON m.language=l.lang_code')
->select('l.image')
->select('l.title as language_title');
$db->setQuery($query);
try
{
$items = $db->loadObjectList('id');
}
catch (runtimeException $e)
{
throw new Exception($e->getMessage(), 500);
}
// Construct html
if ($items)
{
foreach ($items as &$item)
{
$text = strtoupper($item->lang_sef);
$url = JRoute::_('index.php?option=com_menus&task=item.edit&id=' . (int) $item->id);
$tooltipParts = array(
JHtml::_('image', 'mod_languages/' . $item->image . '.gif',
$item->language_title,
array('title' => $item->language_title),
true
),
$item->title,
'(' . $item->menu_title . ')'
);
$item->link = JHtml::_('tooltip', implode(' ', $tooltipParts), null, null, $text, $url, null, 'hasTooltip label label-association label-' . $item->lang_sef);
}
}
$html = JLayoutHelper::render('joomla.content.associations', $items);
}
return $html;
}
/**
* 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(
9 => array(
'unpublish',
'',
'COM_MENUS_HTML_UNPUBLISH_HEADING',
'',
false,
'publish',
'publish'
),
8 => array(
'publish',
'',
'COM_MENUS_HTML_PUBLISH_HEADING',
'',
false,
'unpublish',
'unpublish'
),
7 => array(
'unpublish',
'',
'COM_MENUS_HTML_UNPUBLISH_SEPARATOR',
'',
false,
'publish',
'publish'
),
6 => array(
'publish',
'',
'COM_MENUS_HTML_PUBLISH_SEPARATOR',
'',
false,
'unpublish',
'unpublish'
),
5 => array(
'unpublish',
'',
'COM_MENUS_HTML_UNPUBLISH_ALIAS',
'',
false,
'publish',
'publish'
),
4 => array(
'publish',
'',
'COM_MENUS_HTML_PUBLISH_ALIAS',
'',
false,
'unpublish',
'unpublish'
),
3 => array(
'unpublish',
'',
'COM_MENUS_HTML_UNPUBLISH_URL',
'',
false,
'publish',
'publish'
),
2 => array(
'publish',
'',
'COM_MENUS_HTML_PUBLISH_URL',
'',
false,
'unpublish',
'unpublish'
),
1 => array(
'unpublish',
'COM_MENUS_EXTENSION_PUBLISHED_ENABLED',
'COM_MENUS_HTML_UNPUBLISH_ENABLED',
'COM_MENUS_EXTENSION_PUBLISHED_ENABLED',
true,
'publish',
'publish'
),
0 => array(
'publish',
'COM_MENUS_EXTENSION_UNPUBLISHED_ENABLED',
'COM_MENUS_HTML_PUBLISH_ENABLED',
'COM_MENUS_EXTENSION_UNPUBLISHED_ENABLED',
true,
'unpublish',
'unpublish'
),
-1 => array(
'unpublish',
'COM_MENUS_EXTENSION_PUBLISHED_DISABLED',
'COM_MENUS_HTML_UNPUBLISH_DISABLED',
'COM_MENUS_EXTENSION_PUBLISHED_DISABLED',
true,
'warning',
'warning'
),
-2 => array(
'publish',
'COM_MENUS_EXTENSION_UNPUBLISHED_DISABLED',
'COM_MENUS_HTML_PUBLISH_DISABLED',
'COM_MENUS_EXTENSION_UNPUBLISHED_DISABLED',
true,
'unpublish',
'unpublish'
),
);
return JHtml::_('jgrid.state', $states, $value, $i, 'items.', $enabled, true, $checkbox);
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,285 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_menus
*
* @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;
/**
* Menus component helper.
*
* @package Joomla.Administrator
* @subpackage com_menus
* @since 1.6
*/
class MenusHelper
{
/**
* Defines the valid request variables for the reverse lookup.
*/
protected static $_filter = array('option', 'view', 'layout');
/**
* Configure the Linkbar.
*
* @param string The name of the active view.
*/
public static function addSubmenu($vName)
{
JHtmlSidebar::addEntry(
JText::_('COM_MENUS_SUBMENU_MENUS'),
'index.php?option=com_menus&view=menus',
$vName == 'menus'
);
JHtmlSidebar::addEntry(
JText::_('COM_MENUS_SUBMENU_ITEMS'),
'index.php?option=com_menus&view=items',
$vName == 'items'
);
}
/**
* Gets a list of the actions that can be performed.
*
* @param integer The menu ID.
*
* @return JObject
* @since 1.6
*/
public static function getActions($parentId = 0)
{
$user = JFactory::getUser();
$result = new JObject;
if (empty($parentId))
{
$assetName = 'com_menus';
}
else
{
$assetName = 'com_menus.item.' . (int) $parentId;
}
$actions = JAccess::getActions('com_menus');
foreach ($actions as $action)
{
$result->set($action->name, $user->authorise($action->name, $assetName));
}
return $result;
}
/**
* Gets a standard form of a link for lookups.
*
* @param mixed A link string or array of request variables.
*
* @return mixed A link in standard option-view-layout form, or false if the supplied response is invalid.
*/
public static function getLinkKey($request)
{
if (empty($request))
{
return false;
}
// Check if the link is in the form of index.php?...
if (is_string($request))
{
$args = array();
if (strpos($request, 'index.php') === 0)
{
parse_str(parse_url(htmlspecialchars_decode($request), PHP_URL_QUERY), $args);
}
else
{
parse_str($request, $args);
}
$request = $args;
}
// Only take the option, view and layout parts.
foreach ($request as $name => $value)
{
if ((!in_array($name, self::$_filter)) && (!($name == 'task' && !array_key_exists('view', $request))))
{
// Remove the variables we want to ignore.
unset($request[$name]);
}
}
ksort($request);
return 'index.php?' . http_build_query($request, '', '&');
}
/**
* Get the menu list for create a menu module
*
* @return array The menu array list
* @since 1.6
*/
public static function getMenuTypes()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('a.menutype')
->from('#__menu_types AS a');
$db->setQuery($query);
return $db->loadColumn();
}
/**
* Get a list of menu links for one or all menus.
*
* @param string An option menu to filter the list on, otherwise all menu links are returned as a grouped array.
* @param integer An optional parent ID to pivot results around.
* @param integer An optional mode. If parent ID is set and mode=2, the parent and children are excluded from the list.
* @param array An optional array of states
*/
public static function getMenuLinks($menuType = null, $parentId = 0, $mode = 0, $published = array(), $languages = array())
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('a.id AS value, a.title AS text, a.alias, a.level, a.menutype, a.type, a.template_style_id, a.checked_out')
->from('#__menu AS a')
->join('LEFT', $db->quoteName('#__menu') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt');
// Filter by the type
if ($menuType)
{
$query->where('(a.menutype = ' . $db->quote($menuType) . ' OR a.parent_id = 0)');
}
if ($parentId)
{
if ($mode == 2)
{
// Prevent the parent and children from showing.
$query->join('LEFT', '#__menu AS p ON p.id = ' . (int) $parentId)
->where('(a.lft <= p.lft OR a.rgt >= p.rgt)');
}
}
if (!empty($languages))
{
if (is_array($languages))
{
$languages = '(' . implode(',', array_map(array($db, 'quote'), $languages)) . ')';
}
$query->where('a.language IN ' . $languages);
}
if (!empty($published))
{
if (is_array($published))
{
$published = '(' . implode(',', $published) . ')';
}
$query->where('a.published IN ' . $published);
}
$query->where('a.published != -2')
->group('a.id, a.title, a.level, a.menutype, a.type, a.template_style_id, a.checked_out, a.lft')
->order('a.lft ASC');
// Get the options.
$db->setQuery($query);
try
{
$links = $db->loadObjectList();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
return false;
}
if (empty($menuType))
{
// If the menutype is empty, group the items by menutype.
$query->clear()
->select('*')
->from('#__menu_types')
->where('menutype <> ' . $db->quote(''))
->order('title, menutype');
$db->setQuery($query);
try
{
$menuTypes = $db->loadObjectList();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
return false;
}
// Create a reverse lookup and aggregate the links.
$rlu = array();
foreach ($menuTypes as &$type)
{
$rlu[$type->menutype] = & $type;
$type->links = array();
}
// Loop through the list of menu links.
foreach ($links as &$link)
{
if (isset($rlu[$link->menutype]))
{
$rlu[$link->menutype]->links[] = & $link;
// Cleanup garbage.
unset($link->menutype);
}
}
return $menuTypes;
}
else
{
return $links;
}
}
static public function getAssociations($pk)
{
$associations = array();
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->from('#__menu as m')
->join('INNER', '#__associations as a ON a.id=m.id AND a.context=' . $db->quote('com_menus.item'))
->join('INNER', '#__associations as a2 ON a.key=a2.key')
->join('INNER', '#__menu as m2 ON a2.id=m2.id')
->where('m.id=' . (int) $pk)
->select('m2.language, m2.id');
$db->setQuery($query);
try
{
$menuitems = $db->loadObjectList('language');
}
catch (RuntimeException $e)
{
throw new Exception($e->getMessage(), 500);
}
foreach ($menuitems as $tag => $item)
{
// Do not return itself as result
if ((int) $item->id != $pk)
{
$associations[$tag] = $item->id;
}
}
return $associations;
}
}