[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/layouts/joomla/edit/ -> frontediting_modules.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Site
   5   * @subpackage  Layout
   6   *
   7   * @copyright   (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  defined('_JEXEC') or die;
  12  
  13  use Joomla\CMS\Component\ComponentHelper;
  14  use Joomla\CMS\Factory;
  15  use Joomla\CMS\Language\Text;
  16  use Joomla\CMS\Uri\Uri;
  17  
  18  // JLayout for standard handling of the edit modules:
  19  
  20  $moduleHtml   = &$displayData['moduleHtml'];
  21  $mod          = $displayData['module'];
  22  $position     = $displayData['position'];
  23  $menusEditing = $displayData['menusediting'];
  24  $parameters   = ComponentHelper::getParams('com_modules');
  25  $redirectUri  = '&return=' . urlencode(base64_encode(Uri::getInstance()->toString()));
  26  $target       = '_blank';
  27  $itemid       = Factory::getApplication()->input->get('Itemid', '0', 'int');
  28  $editUrl      = Uri::base() . 'administrator/index.php?option=com_modules&task=module.edit&id=' . (int) $mod->id;
  29  
  30  // If Module editing site
  31  if ($parameters->get('redirect_edit', 'site') === 'site') {
  32      $editUrl = Uri::base() . 'index.php?option=com_config&view=modules&id=' . (int) $mod->id . '&Itemid=' . $itemid . $redirectUri;
  33      $target  = '_self';
  34  }
  35  
  36  // Add link for editing the module
  37  $count = 0;
  38  $moduleHtml = preg_replace(
  39      // Find first tag of module
  40      '/^(\s*<(?:div|span|nav|ul|ol|h\d|section|aside|address|article|form) [^>]*>)/',
  41      // Create and add the edit link and tooltip
  42      '\\1 <a class="btn btn-link jmodedit" href="' . $editUrl . '" target="' . $target . '" aria-describedby="tip-' . (int) $mod->id . '">
  43      <span class="icon-edit" aria-hidden="true"></span><span class="visually-hidden">' . Text::_('JGLOBAL_EDIT') . '</span></a>
  44      <div role="tooltip" id="tip-' . (int) $mod->id . '">' . Text::_('JLIB_HTML_EDIT_MODULE') . '<br>' . htmlspecialchars($mod->title, ENT_COMPAT, 'UTF-8') . '<br>' . sprintf(Text::_('JLIB_HTML_EDIT_MODULE_IN_POSITION'), htmlspecialchars($position, ENT_COMPAT, 'UTF-8')) . '</div>',
  45      $moduleHtml,
  46      1,
  47      $count
  48  );
  49  
  50  // If menu editing is enabled and allowed and it's a menu module add link for editing
  51  if ($menusEditing && $mod->module === 'mod_menu') {
  52      // find the menu item id
  53      $regex = '/\bitem-(\d+)\b/';
  54  
  55      preg_match_all($regex, $moduleHtml, $menuItemids);
  56      if ($menuItemids) {
  57          foreach ($menuItemids[1] as $menuItemid) {
  58                  $menuitemEditUrl = Uri::base() . 'administrator/index.php?option=com_menus&view=item&client_id=0&layout=edit&id=' . (int) $menuItemid;
  59                  $moduleHtml = preg_replace(
  60                      // Find the link
  61                      '/(<li.*?\bitem-' . $menuItemid . '.*?>)/',
  62                      // Create and add the edit link
  63                      '\\1 <a class="jmenuedit small" href="' . $menuitemEditUrl . '" target="' . $target . '" title="' . Text::_('JLIB_HTML_EDIT_MENU_ITEM') . ' ' . sprintf(Text::_('JLIB_HTML_EDIT_MENU_ITEM_ID'), (int) $menuItemid) . '">
  64                      <span class="icon-edit" aria-hidden="true"></span></a>',
  65                      $moduleHtml
  66                  );
  67          }
  68      }
  69  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer