- md5
- ef0af3c64a45a13efcf06cbe4ce41916
- sha1
- f435b2fce2e3bab1d551b5e0903c31ba29174217
- sha256
- 7e3e9304a1c8ccfab5a270933e5b5b2bd1011b831659051b23af3bb2da29a3ac
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
<?php
/**
* @package Joomla.Administrator
* @subpackage com_menus
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Menus\Administrator\Service\HTML;
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Router\Route;
use Joomla\Component\Menus\Administrator\Helper\MenusHelper;
use Joomla\Registry\Registry;
/**
* Menus HTML helper class.
*
* @package Joomla.Administrator
* @subpackage com_menus
* @since 1.7
*/
class Menus
{
/**
* Generate the markup to display the item associations
*
* @param int $itemid The menu item id
*
* @return string
*
* @since 3.0
*
* @throws \Exception If there is an error on the query
*/
public function association($itemid)
{
// Defaults
$html = '';
// Get the associations
if ($associations = MenusHelper::getAssociations($itemid))
{
// Get the associated menu items
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select('m.id, m.title')
->select('l.sef as lang_sef, l.lang_code')
->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)) . ')')
->where('m.id != ' . $itemid)
->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 = Route::_('index.php?option=com_menus&task=item.edit&id=' . (int) $item->id);
$tooltip = '<strong>' . htmlspecialchars($item->language_title, ENT_QUOTES, 'UTF-8') . '</strong><br>'
. htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8') . '<br>' . Text::sprintf('COM_MENUS_MENU_SPRINTF', $item->menu_title);
$classes = 'badge badge-secondary';
$item->link = '<a href="' . $url . '" title="' . $item->language_title . '" class="' . $classes . '">' . $text . '</a>'
. '<div role="tooltip" id="tip' . (int) $item->id . '">' . $tooltip . '</div>';
}
}
$html = LayoutHelper::render('joomla.content.associations', $items);
}
return $html;
}
/**
* Returns a visibility state on a grid
*
* @param integer $params Params of item.
*
* @return string The Html code
*
* @since 3.7.0
*/
public function visibility($params)
{
$registry = new Registry;
try
{
$registry->loadString($params);
}
catch (\Exception $e)
{
// Invalid JSON
}
$show_menu = $registry->get('menu_show');
return ($show_menu === 0) ? '<span class="badge badge-secondary">' . Text::_('COM_MENUS_LABEL_HIDDEN') . '</span>' : '';
}
}
The same content is in 3 releases, Joomla 4.0.0-alpha10 to 4.0.0-alpha12. See them all, or every version of this file.