Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions administrator/components/com_config/models/forms/application.xml
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,19 @@
label="COM_CONFIG_FIELD_OFFLINE_IMAGE_LABEL"
description="COM_CONFIG_FIELD_OFFLINE_IMAGE_DESC" />

<field
name="frontediting"
type="list"
default="1"
label="COM_CONFIG_FRONTEDITING_LABEL"
description="COM_CONFIG_FRONTEDITING_DESC"
filter="integer">
<!-- <option value="3">COM_CONFIG_FRONTEDITING_MENUSANDMODULES_ADMIN_TOO</option> -->
<option value="2">COM_CONFIG_FRONTEDITING_MENUSANDMODULES</option>
<option value="1">COM_CONFIG_FRONTEDITING_MODULES</option>
<option value="0">JNONE</option>
</field>

<field
name="editor"
type="plugins"
Expand Down
26 changes: 3 additions & 23 deletions administrator/components/com_menus/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class MenusController extends JControllerLegacy
/**
* Method to display a view.
*
* @param boolean If true, the view output will be cached
* @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
* @param boolean $cachable If true, the view output will be cached
* @param array|boolean $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return JController This object to support chaining.
* @return JController This object to support chaining.
* @since 1.5
*/
public function display($cachable = false, $urlparams = false)
Expand All @@ -35,26 +35,6 @@ public function display($cachable = false, $urlparams = false)
$layout = $this->input->get('layout', 'default');
$id = $this->input->getInt('id');

// Check for edit form.
if ($view == 'menu' && $layout == 'edit' && !$this->checkEditId('com_menus.edit.menu', $id)) {

// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option=com_menus&view=menus', false));

return false;
}
elseif ($view == 'item' && $layout == 'edit' && !$this->checkEditId('com_menus.edit.item', $id)) {

// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option=com_menus&view=items', false));

return false;
}

parent::display();

return $this;
Expand Down
10 changes: 0 additions & 10 deletions administrator/components/com_menus/controllers/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,6 @@ public function save($key = null, $urlVar = null)
$context = 'com_menus.edit.item';
$recordId = $this->input->getInt('id');

if (!$this->checkEditId($context, $recordId))
{
// Somehow the person just went to the form and saved it - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $recordId));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option=com_menus&view=items' . $this->getRedirectToListAppend(), false));

return false;
}

// Populate the row id from the session.
$data['id'] = $recordId;

Expand Down
10 changes: 0 additions & 10 deletions administrator/components/com_menus/controllers/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@ public function save($key = null, $urlVar = null)
$task = $this->getTask();
$recordId = $this->input->getInt('id');

if (!$this->checkEditId($context, $recordId))
{
// Somehow the person just went to the form and saved it - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $recordId));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option='.$this->option.'&view='.$this->view_list.$this->getRedirectToListAppend(), false));

return false;
}

// Make sure we are not trying to modify an administrator menu.
if (isset($data['client_id']) && $data['client_id'] == 1){
JError::raiseNotice(0, JText::_('COM_MENUS_MENU_TYPE_NOT_ALLOWED'));
Expand Down
20 changes: 5 additions & 15 deletions administrator/components/com_modules/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ class ModulesController extends JControllerLegacy
/**
* Method to display a view.
*
* @param boolean If true, the view output will be cached
* @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
* @param boolean $cachable If true, the view output will be cached
* @param array|boolean $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}
.
*
* @return JController This object to support chaining.
* @return JController This object to support chaining.
* @since 1.5
*/
public function display($cachable = false, $urlparams = false)
Expand All @@ -38,17 +39,6 @@ public function display($cachable = false, $urlparams = false)
$layout = $this->input->get('layout', 'default');
$id = $this->input->getInt('id');

// Check for edit form.
if ($view == 'module' && $layout == 'edit' && !$this->checkEditId('com_modules.edit.module', $id))
{
// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option=com_modules&view=modules', false));

return false;
}

parent::display();
return parent::display();
}
}
5 changes: 5 additions & 0 deletions administrator/language/en-GB/en-GB.com_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ COM_CONFIG_FIELD_FILTERS_CUSTOM_BLACK_LIST="Custom Black List"
COM_CONFIG_FIELD_FILTERS_NO_HTML="No HTML"
COM_CONFIG_FIELD_FILTERS_NO_FILTER="No Filtering"
COM_CONFIG_FIELD_FILTERS_WHITE_LIST="White List"
COM_CONFIG_FRONTEDITING_DESC="Select if you want mouse-over edit icons for modules and menu items (support may depend on your template)"
COM_CONFIG_FRONTEDITING_LABEL="Mouse-over edit icons for"
COM_CONFIG_FRONTEDITING_MENUSANDMODULES="Modules & Menus"
COM_CONFIG_FRONTEDITING_MENUSANDMODULES_ADMIN_TOO="Modules & Menus (admin too)"
COM_CONFIG_FRONTEDITING_MODULES="Modules"
COM_CONFIG_FIELD_FORCE_SSL_DESC="Force site access to always occur under SSL (https) for selected areas. You will not be able to access selected areas under non-ssl. Note, you must have SSL enabled on your server to utilise this option."
COM_CONFIG_FIELD_FORCE_SSL_LABEL="Force SSL"
COM_CONFIG_FIELD_FTP_ENABLE_DESC="Enable the built in FTP (File Transfer Protocol) functionality which is needed in some server environments to be used instead of the normal upload functionality of Joomla!"
Expand Down
4 changes: 4 additions & 0 deletions administrator/language/en-GB/en-GB.lib_joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,10 @@ JLIB_HTML_DATE_RELATIVE_MINUTES_0="%s minutes ago"
JLIB_HTML_DATE_RELATIVE_WEEKS="%s weeks ago"
JLIB_HTML_DATE_RELATIVE_WEEKS_1="%s week ago"
JLIB_HTML_DATE_RELATIVE_WEEKS_0="%s weeks ago"
JLIB_HTML_EDIT_MENU_ITEM="Edit menu item"
JLIB_HTML_EDIT_MENU_ITEM_ID="Item id: %s"
JLIB_HTML_EDIT_MODULE="Edit module"
JLIB_HTML_EDIT_MODULE_IN_POSITION="Position: %s"
JLIB_HTML_EDITOR_CANNOT_LOAD="Cannot load the editor"
JLIB_HTML_END="End"
JLIB_HTML_ERROR_FUNCTION_NOT_SUPPORTED="Function not supported."
Expand Down
4 changes: 4 additions & 0 deletions language/en-GB/en-GB.lib_joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ JLIB_HTML_DATE_RELATIVE_MINUTES_0="%s minutes ago"
JLIB_HTML_DATE_RELATIVE_WEEKS="%s weeks ago"
JLIB_HTML_DATE_RELATIVE_WEEKS_1="%s week ago"
JLIB_HTML_DATE_RELATIVE_WEEKS_0="%s weeks ago"
JLIB_HTML_EDIT_MENU_ITEM="Edit menu item"
JLIB_HTML_EDIT_MENU_ITEM_ID="Item id: %s"
JLIB_HTML_EDIT_MODULE="Edit module"
JLIB_HTML_EDIT_MODULE_IN_POSITION="Position: %s"
JLIB_HTML_EDITOR_CANNOT_LOAD="Cannot load the editor"
JLIB_HTML_END="End"
JLIB_HTML_ERROR_FUNCTION_NOT_SUPPORTED="Function not supported."
Expand Down
62 changes: 62 additions & 0 deletions layouts/joomla/edit/frontediting_modules.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @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;

// JLayout for standard handling of the edit modules:

$moduleHtml =& $displayData['moduleHtml'];
$mod = $displayData['module'];
$position = $displayData['position'];
$menusEditing = $displayData['menusediting'];


if (preg_match('/<(?:div|span|nav|ul|ol|h\d) [^>]*class="[^"]* jmoddiv"/', $moduleHtml))
{
// Module has already module edit button:
return;
}

// Add css class jmoddiv and data attributes for module-editing URL and for the tooltip:
$editUrl = JURI::base() . 'administrator/index.php?option=com_modules&view=module&layout=edit&id=' . (int) $mod->id;

// Add class, editing URL and tooltip, and if module of type menu, also the tooltip for editing the menu item:
$count = 0;
$moduleHtml = preg_replace(
// Replace first tag of module with a class
'/^(\s*<(?:div|span|nav|ul|ol|h\d) [^>]*class="[^"]*)"/',
// By itself, adding class jmoddiv and data attributes for the url and tooltip:
'\\1 jmoddiv" data-jmodediturl="' . $editUrl . '" data-jmodtip="'
. JHtml::tooltipText(
JText::_('JLIB_HTML_EDIT_MODULE'),
htmlspecialchars($mod->title) . '<br />' . sprintf(JText::_('JLIB_HTML_EDIT_MODULE_IN_POSITION'), htmlspecialchars($position)),
0
)
. '"'
// And if menu editing is enabled and allowed and it's a menu module, add data attributes for menu editing:
. ($menusEditing && $mod->module == 'mod_menu' ?
'" data-jmenuedittip="' . JHtml::tooltipText('JLIB_HTML_EDIT_MENU_ITEM', 'JLIB_HTML_EDIT_MENU_ITEM_ID') . '"'
:
''
),
$moduleHtml,
1,
$count
);

if ($count)
{
// Load once booststrap tooltip and add stylesheet and javascript to head:
JHtml::_('bootstrap.loadCss', true, JFactory::getDocument()->getDirection());
JHtml::_('bootstrap.tooltip');
JHtml::_('bootstrap.popover');

JFactory::getDocument()->addStyleSheet('media/system/css/frontediting.css')
->addScript('media/system/js/frontediting.js');
}
18 changes: 17 additions & 1 deletion libraries/joomla/document/html/renderer/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,26 @@ public function render($position, $params = array(), $content = null)
$renderer = $this->_doc->loadRenderer('module');
$buffer = '';

$app = JFactory::getApplication();
$frontediting = $app->get('frontediting', 1);
$user = JFactory::getUser();

$canEdit = $user->id && $frontediting && !($app->isAdmin() && $frontediting < 2) && $user->authorise('core.edit', 'com_modules');
$menusEditing = ($frontediting == 2) && $user->authorise('core.edit', 'com_menus');

foreach (JModuleHelper::getModules($position) as $mod)
{
$buffer .= $renderer->render($mod, $params, $content);
$moduleHtml = $renderer->render($mod, $params, $content);

if ($canEdit && trim($moduleHtml) != '' && $user->authorise('core.edit', 'com_modules.module.' . $mod->id))
{
$displayData = array('moduleHtml' => &$moduleHtml, 'module' => $mod, 'position' => $position, 'menusediting' => $menusEditing);
JLayoutHelper::render('joomla.edit.frontediting_modules', $displayData);
}

$buffer .= $moduleHtml;
}

return $buffer;
}
}
33 changes: 0 additions & 33 deletions libraries/legacy/controller/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,23 +311,6 @@ public function cancel($key = null)
// Attempt to check-in the current record.
if ($recordId)
{
// Check we are holding the id in the edit list.
if (!$this->checkEditId($context, $recordId))
{
// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $recordId));
$this->setMessage($this->getError(), 'error');

$this->setRedirect(
JRoute::_(
'index.php?option=' . $this->option . '&view=' . $this->view_list
. $this->getRedirectToListAppend(), false
)
);

return false;
}

if ($checkin)
{
if ($model->checkin($recordId) === false)
Expand Down Expand Up @@ -650,22 +633,6 @@ public function save($key = null, $urlVar = null)

$recordId = $this->input->getInt($urlVar);

if (!$this->checkEditId($context, $recordId))
{
// Somehow the person just went to the form and tried to save it. We don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $recordId));
$this->setMessage($this->getError(), 'error');

$this->setRedirect(
JRoute::_(
'index.php?option=' . $this->option . '&view=' . $this->view_list
. $this->getRedirectToListAppend(), false
)
);

return false;
}

// Populate the row id from the session.
$data[$key] = $recordId;

Expand Down
33 changes: 33 additions & 0 deletions media/system/css/frontediting.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

/* Module edit in front-end */

.jmoddiv.jmodinside {
position: relative;
top: 0;
left: 0;
}
.btn.jmodedit
{
z-index: 1001;
display: block;
position: absolute;
top: 0;
right: 0;
}
html[dir=rtl] .btn.jmodedit
{
right: auto;
left: 0;
}

/* Menu edit in front-end */

.btn.jfedit-menu
{
z-index: 1002;
display: block;
}
Loading