roxcoder

Untitled

Jan 5th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. <?php
  2. /**
  3. * @package Joomla.Site
  4. * @subpackage Layout
  5. *
  6. * @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
  7. * @license GNU General Public License version 2 or later; see LICENSE.txt
  8. */
  9.  
  10. defined('_JEXEC') or die;
  11.  
  12. // JLayout for standard handling of the edit modules:
  13.  
  14. $moduleHtml =& $displayData['moduleHtml'];
  15. $mod = $displayData['module'];
  16. $position = $displayData['position'];
  17. $menusEditing = $displayData['menusediting'];
  18. $redirectUri = '&return='. urlencode(base64_encode(JUri::getInstance()->toString()));
  19.  
  20. if (preg_match('/<(?:div|span|nav|ul|ol|h\d) [^>]*class="[^"]* jmoddiv"/', $moduleHtml))
  21. {
  22. // Module has already module edit button:
  23. return;
  24. }
  25.  
  26. // Add css class jmoddiv and data attributes for module-editing URL and for the tooltip:
  27. $editUrl = JUri::base() . 'index.php?option=com_config&controller=config.display.modules&id=' . (int) $mod->id . $redirectUri;
  28. $target = '_self';
  29.  
  30. // Add class, editing URL and tooltip, and if module of type menu, also the tooltip for editing the menu item:
  31. $count = 0;
  32. $moduleHtml = preg_replace(
  33. // Replace first tag of module with a class
  34. '/^(\s*<(?:div|span|nav|ul|ol|h\d) [^>]*class="[^"]*)"/',
  35. // By itself, adding class jmoddiv and data attributes for the url and tooltip:
  36. '\\1 jmoddiv" data-jmodediturl="' . $editUrl . '" data-target="' . $target . '" data-jmodtip="'
  37. . JHtml::tooltipText(
  38. JText::_('JLIB_HTML_EDIT_MODULE'),
  39. htmlspecialchars($mod->title) . '<br />' . sprintf(JText::_('JLIB_HTML_EDIT_MODULE_IN_POSITION'), htmlspecialchars($position)),
  40. 0
  41. )
  42. . '"'
  43. // And if menu editing is enabled and allowed and it's a menu module, add data attributes for menu editing:
  44. . ($menusEditing && $mod->module == 'mod_menu' ?
  45. '" data-jmenuedittip="' . JHtml::tooltipText('JLIB_HTML_EDIT_MENU_ITEM', 'JLIB_HTML_EDIT_MENU_ITEM_ID') . '"'
  46. :
  47. ''
  48. ),
  49. $moduleHtml,
  50. 1,
  51. $count
  52. );
  53.  
  54. if ($count)
  55. {
  56. // Load once booststrap tooltip and add stylesheet and javascript to head:
  57. //JHtml::_('bootstrap.tooltip');
  58. //JHtml::_('bootstrap.popover');
  59.  
  60. JHtml::_('stylesheet', 'system/frontediting.css', array(), true);
  61. JHtml::_('script', 'system/frontediting.js', false, true);
  62.  
  63. //Helix3
  64. helix3::addLess('frontend-edit', 'frontend-edit');
  65. helix3::addJS('frontend-edit.js');
  66. }
Advertisement
Add Comment
Please, Sign In to add comment