Futher improved the redirect option to use return and stack the return path to take the user back to the original area from where they clicked away.

This commit is contained in:
2018-08-18 14:09:17 +02:00
parent 70e198abf3
commit 103457eef7
37 changed files with 455 additions and 70 deletions

View File

@ -1868,7 +1868,7 @@ class Get
}
}
// add_php
$addArrayP = array('php_getitem', 'php_before_save', 'php_save', 'php_getform', 'php_postsavehook', 'php_getitems', 'php_getitems_after_all', 'php_getlistquery', 'php_allowedit', 'php_before_delete', 'php_after_delete', 'php_before_publish', 'php_after_publish', 'php_batchcopy', 'php_batchmove', 'php_document');
$addArrayP = array('php_getitem', 'php_before_save', 'php_save', 'php_getform', 'php_postsavehook', 'php_getitems', 'php_getitems_after_all', 'php_getlistquery', 'php_allowadd', 'php_allowedit', 'php_before_delete', 'php_after_delete', 'php_before_publish', 'php_after_publish', 'php_batchcopy', 'php_batchmove', 'php_document');
foreach ($addArrayP as $scripter)
{
if (isset($view->{'add_' . $scripter}) && $view->{'add_' . $scripter} == 1)

View File

@ -2927,7 +2927,8 @@ class Fields extends Structure
$addButton[] = $this->_t(3) . "//" . $this->setLine(__LINE__) . " get the view name & id";
$addButton[] = $this->_t(3) . "\$values = \$jinput->getArray(array(";
$addButton[] = $this->_t(4) . "'id' => 'int',";
$addButton[] = $this->_t(4) . "'view' => 'word'";
$addButton[] = $this->_t(4) . "'view' => 'word',";
$addButton[] = $this->_t(4) . "'return' => 'base64'";
$addButton[] = $this->_t(3) . "));";
$addButton[] = $this->_t(3) . "//" . $this->setLine(__LINE__) . " check if new item";
$addButton[] = $this->_t(3) . "\$ref = '';";
@ -2939,6 +2940,12 @@ class Fields extends Structure
$addButton[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " only load referal if not new item.";
$addButton[] = $this->_t(4) . "\$ref = '&ref=' . \$values['view'] . '&refid=' . \$values['id'];";
$addButton[] = $this->_t(4) . "\$refJ = '&ref=' . \$values['view'] . '&refid=' . \$values['id'];";
$addButton[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " get the return value.";
$addButton[] = $this->_t(4) . "\$_uri = (string) JUri::getInstance();";
$addButton[] = $this->_t(4) . "\$_return = urlencode(base64_encode(\$_uri));";
$addButton[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " load return value.";
$addButton[] = $this->_t(4) . "\$ref .= '&return=' . \$_return;";
$addButton[] = $this->_t(4) . "\$refJ .= '&return=' . \$_return;";
$addButton[] = $this->_t(3) . "}";
}
else

View File

@ -7740,20 +7740,33 @@ class Interpretation extends Fields
// LAYOUTITEMSTABLE <<<DYNAMIC>>>
$this->fileContentDynamic[$viewName_single . '_' . $layoutCodeName][$this->hhh . 'LAYOUTITEMSTABLE' . $this->hhh] = $head . $body;
// LAYOUTITEMSHEADER <<<DYNAMIC>>>
$headerscript = '$edit = "index.php?option=com_' . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . '&view=' . $list . '&task=' . $single . '.edit";';
$headerscript .= '//' . $this->setLine(__LINE__) . ' set the edit URL';
$headerscript .= PHP_EOL . '$edit = "index.php?option=com_' . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . '&view=' . $list . '&task=' . $single . '.edit";';
$headerscript .= PHP_EOL . '//' . $this->setLine(__LINE__) . ' set a return value';
$headerscript .= PHP_EOL . '$return = ($id) ? "index.php?option=com_' . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . '&view=' . $viewName_single . '&layout=edit&id=" . $id : "";';
$headerscript .= PHP_EOL . '//' . $this->setLine(__LINE__) . ' check for a return value';
$headerscript .= PHP_EOL . '$jinput = JFactory::getApplication()->input;';
$headerscript .= PHP_EOL . "if (\$_return = \$jinput->get('return', null, 'base64'))";
$headerscript .= PHP_EOL . '{';
$headerscript .= PHP_EOL . $this->_t(1) . '$return .= "&return=" . $_return;';
$headerscript .= PHP_EOL . '}';
$headerscript .= PHP_EOL . '//' . $this->setLine(__LINE__) . ' set the referral values';
$headerscript .= PHP_EOL . '$ref = ($id) ? "&ref=' . $viewName_single . '&refid=" . $id . "&return=" . urlencode(base64_encode($return)) : "";';
if ($addNewButon > 0)
{
// add the link for new
if ($addNewButon == 1 || $addNewButon == 2)
{
$headerscript .= PHP_EOL . '$ref = ($id) ? "&ref=' . $viewName_single . '&refid=".$id : "";';
$headerscript .= PHP_EOL . '//' . $this->setLine(__LINE__) . ' set the create new URL';
$headerscript .= PHP_EOL . '$new = "index.php?option=com_' . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . '&view=' . $single . '&layout=edit".$ref;';
}
// and the link for close and new
if ($addNewButon == 2 || $addNewButon == 3)
{
$headerscript .= PHP_EOL . '//' . $this->setLine(__LINE__) . ' set the create new and close URL';
$headerscript .= PHP_EOL . '$close_new = "index.php?option=com_' . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . '&view=' . $single . '&layout=edit";';
}
$headerscript .= PHP_EOL . '//' . $this->setLine(__LINE__) . ' load the action object';
$headerscript .= PHP_EOL . '$can = ' . $this->fileContentStatic[$this->hhh . 'Component' . $this->hhh] . 'Helper::getActions(' . "'" . $single . "'" . ');';
}
$this->fileContentDynamic[$viewName_single . '_' . $layoutCodeName][$this->hhh . 'LAYOUTITEMSHEADER' . $this->hhh] = $headerscript;
@ -7906,7 +7919,7 @@ class Interpretation extends Fields
foreach ($this->listBuilder[$viewName_list] as $item)
{
// set the ref
$ref = '&ref=' . $refview . '&refid=<?php echo $id; ?>';
$ref = '<?php echo $ref; ?>';
// set some defaults
$customAdminViewButtons = '';
// set the item row

View File

@ -3546,6 +3546,108 @@ abstract class ComponentbuilderHelper
return false;
}
/**
* Get the edit button
*
* @param int $item The item to edit
* @param string $view The type of item to edit
* @param string $views The list view controller name
* @param string $ref The return path
* @param string $headsup The message to show on click of button
*
* @return string On success the full html edit button
*
*/
public static function getEditButton(&$item, $view, $views, $ref = '', $component = 'com_componentbuilder', $headsup = 'COM_COMPONENTBUILDER_ALL_UNSAVED_WORK_ON_THIS_PAGE_WILL_BE_LOST_ARE_YOU_SURE_YOU_WANT_TO_CONTINUE')
{
// get URL
$url = self::getEditURL($item, $view, $views, $ref, $component);
// check if we found any
if (self::checkString($url))
{
// check that we have the ID
if (self::checkObject($item) && isset($item->id))
{
// check if the checked_out is available
if (isset($item->checked_out))
{
$checked_out = (int) $item->checked_out;
}
}
elseif (self::checkArray($item) && isset($item['id']))
{
// check if the checked_out is available
if (isset($item['checked_out']))
{
$checked_out = (int) $item['checked_out'];
}
}
// set the link title
$title = self::safeString(JText::_('COM_COMPONENTBUILDER_EDIT') . ' ' . $view, 'W');
// check that there is a check message
if (self::checkString($headsup))
{
$href = 'onclick="UIkit.modal.confirm(\''.JText::_($headsup).'\', function(){ window.location.href = \'' . $url . '\' })" href="javascript:void(0)"';
}
else
{
$href = 'href="' . $url . '"';
}
// check if it is checked out
if (isset($checked_out) && $checked_out > 0)
{
// is this user the one who checked it out
if ($checked_out == JFactory::getUser()->id)
{
return ' <a ' . $href . ' class="uk-icon-lock" title="' . $title . '"></a>';
}
return ' <a href="#" disabled class="uk-icon-lock" title="' . JText::sprintf('COM_COMPONENTBUILDER__HAS_BEEN_CHECKED_OUT_BY_S', self::safeString($view, 'W'), JFactory::getUser($checked_out)->name) . '"></a>';
}
// return normal edit link
return ' <a ' . $href . ' class="uk-icon-pencil" title="' . $title . '"></a>';
}
return '';
}
/**
* Get the edit URL
*
* @param int $item The item to edit
* @param string $view The type of item to edit
* @param string $ref The return path
*
* @return string On success the edit url
*
*/
public static function getEditURL(&$item, $view, $views, $ref = '', $component = 'com_componentbuilder')
{
// check that we have the ID
if (self::checkObject($item) && isset($item->id))
{
$id = (int) $item->id;
}
elseif (self::checkArray($item) && isset($item['id']))
{
$id = (int) $item['id'];
}
elseif (is_numeric($item))
{
$id = (int) $item;
}
// check ID
if (isset($id) && $id > 0)
{
// can edit
if (JFactory::getUser()->authorise($view . '.edit', $component . '.' . $view . '.' . (int) $id))
{
// set the edit link
return JRoute::_("index.php?option=" . $component . "&view=" . $views . "&task=" . $view . ".edit&id=" . $id . $ref);
}
}
return false;
}
/**
* the Crypt objects
**/