Skip to content

Commit

Permalink
[BUGFIX] Fix Bug #72776 Links to record edit module do not work in TY…
Browse files Browse the repository at this point in the history
…PO3 CMS 7 LTS
  • Loading branch information
daniellienert committed Jan 17, 2016
1 parent 6e29a9d commit 5b1ada7
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 49 deletions.
86 changes: 86 additions & 0 deletions Classes/ViewHelpers/Backend/EditRecordUrlViewHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php
namespace DL\Yag\ViewHelpers\Backend;

/***************************************************************
* Copyright notice
*
* (c) 2015 Daniel Lienert
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\FormProtection\FormProtectionFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;

class EditRecordUrlViewHelper extends AbstractViewHelper
{

/**
* Returns a URL to record rditor
*
* @param AbstractEntity $entity to link to
* @param string $returnUrl
* @return string link to record editor
*/
public function render(AbstractEntity $entity, $returnUrl)
{
return static::renderStatic(['parameters' => $this->buildParameters($entity), 'returnUrl' => $returnUrl],
$this->buildRenderChildrenClosure(),
$this->renderingContext
);
}

/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return string
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$parameters = GeneralUtility::explodeUrl2Array($arguments['parameters']);
$parameters['returnUrl'] = $arguments['returnUrl'];

return BackendUtility::getModuleUrl('record_edit', $parameters);
}



protected function buildParameters(AbstractEntity $entity)
{

$className = get_class($entity);

$classToTableMap = [
'Tx_Yag_Domain_Model_Gallery' => 'tx_yag_domain_model_gallery',
'Tx_Yag_Domain_Model_Album' => 'tx_yag_domain_model_album',
'Tx_Yag_Domain_Model_Item' => 'tx_yag_domain_model_item',
];

$tableName = $classToTableMap[$className];

$parameters = sprintf('edit[%s][%s]=edit', $tableName, $entity->getUid());

return $parameters;
}
}
3 changes: 2 additions & 1 deletion Resources/Private/Partials/Album/AlbumAdminEdit.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{namespace yag=Tx_Yag_ViewHelpers}
{namespace yagns=DL\Yag\ViewHelpers}
{namespace extlist=Tx_PtExtlist_ViewHelpers}
{namespace ptx=Tx_PtExtbase_ViewHelpers}
{namespace rbac=Tx_Rbac_ViewHelpers}
Expand Down Expand Up @@ -48,7 +49,7 @@
<f:form.select property="album.{album.uid}.gallery" optionValueField="uid" optionLabelField="name" options="{galleries}" value="{album.gallery}"/>
</div>
<div class="yag-albumedit-commands">
<a href="alt_doc.php?returnUrl={f:uri.action(action:'index', additionalParams:'{id:currentPid}', arguments:'{extlist:namespace.GPArray(object: yagContext arguments:\'albumUid:{album.uid}\')}')->ptx:format.urlencode()}&edit[tx_yag_domain_model_album][{album.uid}]=edit" >
<a href="{yagns:Backend.editRecordUrl(entity:album, returnUrl: '{f:uri.action(action:\'index\', additionalParams:\'{id:currentPid}\', arguments:\'{extlist:namespace.GPArray(object: yagContext arguments:\\'albumUid:{album.uid}\\')}\')}')}">
<core:icon identifier="actions-document-open" />
<f:translate key="tx_yag_controller_item.editAlbumInListModule"/>
</a>
Expand Down
85 changes: 44 additions & 41 deletions Resources/Private/Partials/Album/FormFields.html
Original file line number Diff line number Diff line change
@@ -1,70 +1,73 @@
{namespace yag=Tx_Yag_ViewHelpers}
{namespace yag=DL\Yag\ViewHelpers}
{namespace ptx=Tx_PtExtbase_ViewHelpers}
{namespace extlist=Tx_PtExtlist_ViewHelpers}
{namespace core=TYPO3\CMS\Core\ViewHelpers}

<div class="outer-wrapper">
<label for="tx-yag-album-name" >
<f:translate key="tx_yag_domain_model_album.name" /> <span class="required"><f:translate key="tx_yag_general.required" default="(required)"/></span>
</label>
<div class="outer-field-wrapper">
<div class="field-wrapper type-text">
<f:form.textfield property="name" id="tx-yag-album-name"/>
</div>
</div>
<label for="tx-yag-album-name">
<f:translate key="tx_yag_domain_model_album.name"/>
<span class="required"><f:translate key="tx_yag_general.required" default="(required)"/></span>
</label>
<div class="outer-field-wrapper">
<div class="field-wrapper type-text">
<f:form.textfield property="name" id="tx-yag-album-name"/>
</div>
</div>
</div>


<div class="outer-wrapper">
<label for="tx-yag-album-galleries" >
<f:translate key="tx_yag_domain_model_gallery" />
</label>
<div class="outer-field-wrapper">
<div class="field-wrapper type-text">
<f:form.select id="tx-yag-album-galleries" property="gallery" options="{selectableGalleries}" optionValueField="uid" optionLabelField="name" value="{selectedGallery}" />
</div>
</div>
<label for="tx-yag-album-galleries">
<f:translate key="tx_yag_domain_model_gallery"/>
</label>
<div class="outer-field-wrapper">
<div class="field-wrapper type-text">
<f:form.select id="tx-yag-album-galleries" property="gallery" options="{selectableGalleries}"
optionValueField="uid" optionLabelField="name" value="{selectedGallery}"/>
</div>
</div>
</div>


<div class="outer-wrapper">
<label for="tx-yag-album-description" >
<f:translate key="tx_yag_domain_model_album.description" />
<label for="tx-yag-album-description">
<f:translate key="tx_yag_domain_model_album.description"/>
</label>
<div class="outer-field-wrapper">
<div class="field-wrapper type-text">
<f:form.textarea id="tx-yag-album-description" property="description" cols="40" rows="15" /><br />
</div>
</div>
<div class="outer-field-wrapper">
<div class="field-wrapper type-text">
<f:form.textarea id="tx-yag-album-description" property="description" cols="40" rows="15"/>
<br/>
</div>
</div>
</div>

<div class="outer-wrapper">
<label for="tx-yag-album-date" >
<f:translate key="tx_yag_domain_model_album.date" />
<label for="tx-yag-album-date">
<f:translate key="tx_yag_domain_model_album.date"/>
</label>
<div class="outer-field-wrapper">
<div class="field-wrapper type-text">
<div class="outer-field-wrapper">
<div class="field-wrapper type-text">
<f:form.textfield name="album[date][date]" value="{f:format.date(date:album.date)}" id="tx-yag-album-date"/>
<f:form.hidden name="album[date][dateFormat]" value="{config.extensionConfig.sysDateFormat}"/>
</div>
</div>
</div>
</div>
</div>

<div class="outer-wrapper">
<label for="tx-yag-album-hide" >
<f:translate key="tx_yag_domain_model_album.hide" />
<label for="tx-yag-album-hide">
<f:translate key="tx_yag_domain_model_album.hide"/>
</label>
<div class="outer-field-wrapper">
<div class="field-wrapper type-text">
<f:form.checkbox id="tx-yag-album-hide" property="hidden" value="1" checked="{album.hidden}" />
</div>
</div>
<div class="outer-field-wrapper">
<div class="field-wrapper type-text">
<f:form.checkbox id="tx-yag-album-hide" property="hidden" value="1" checked="{album.hidden}"/>
</div>
</div>
</div>

<div class="yag-albumedit-commands">
<a href="alt_doc.php?returnUrl={f:uri.action(action:'submitFilter', additionalParams:'{id:currentPid}', arguments:'{extlist:namespace.GPArray(object: yagContext arguments:\'albumUid:{album.uid}\')}')->ptx:format.urlencode()}&edit[tx_yag_domain_model_album][{album.uid}]=edit" >
<core:icon identifier="actions-document-open" />
<f:translate key="tx_yag_controller_item.editAlbumInListModule"/>
</a>
<a href="{yag:Backend.editRecordUrl(entity:album, returnUrl: '{f:uri.action(action:\'submitFilter\', additionalParams:\'{id:currentPid}\', arguments:\'{extlist:namespace.GPArray(object: yagContext arguments:\\'albumUid:{album.uid}\\')}\')}')}">
<core:icon identifier="actions-document-open"/>
<f:translate key="tx_yag_controller_item.editAlbumInListModule"/>
</a>
</div>

9 changes: 7 additions & 2 deletions Resources/Private/Partials/Image/FormFields.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{namespace yag=Tx_Yag_ViewHelpers}
{namespace yagns=DL\Yag\ViewHelpers}
{namespace ptx=Tx_PtExtbase_ViewHelpers}
{namespace extlist=Tx_PtExtlist_ViewHelpers}
{namespace core=TYPO3\CMS\Core\ViewHelpers}
Expand Down Expand Up @@ -32,8 +33,12 @@
</table>
</div>
<div class="yag-itemedit-commands">
<ptx:be.buttons.Icon uri="alt_doc.php?returnUrl={f:uri.action(action:'submitFilter', additionalParams:'{id:currentPid}', arguments:'{extlist:namespace.GPArray(object: yagContext arguments:\'albumUid:{item.album.uid}\')}')->ptx:format.urlencode()}&edit[tx_yag_domain_model_item][{item.uid}]=edit" icon='actions-document-open' title="Open"/>
<a href="alt_doc.php?returnUrl={f:uri.action(action:'submitFilter', additionalParams:'{id:currentPid}', arguments:'{extlist:namespace.GPArray(object: yagContext arguments:\'albumUid:{item.album.uid}\')}')->ptx:format.urlencode()}&edit[tx_yag_domain_model_item][{item.uid}]=edit" ><f:translate key="tx_yag_controller_item.editItemInListModule"/></a>

<a href="{yagns:Backend.editRecordUrl(entity:item, returnUrl: '{f:uri.action(action:\'submitFilter\', additionalParams:\'{id:currentPid}\', arguments:\'{extlist:namespace.GPArray(object: yagContext arguments:\\'albumUid:{item.album.uid}\\')}\')}')}">
<core:icon identifier="actions-document-open" />
<f:translate key="tx_yag_controller_item.editItemInListModule"/>
</a>

</div>
</td>
</tr>
Expand Down
3 changes: 2 additions & 1 deletion Resources/Private/Partials/Image/ImageAdminEdit.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{namespace yag=Tx_Yag_ViewHelpers}
{namespace yagns=DL\Yag\ViewHelpers}
{namespace ptx=Tx_PtExtbase_ViewHelpers}
{namespace extlist=Tx_PtExtlist_ViewHelpers}
{namespace core=TYPO3\CMS\Core\ViewHelpers}
Expand Down Expand Up @@ -44,7 +45,7 @@
</div>

<div style="padding-top: 3px;">
<a href="alt_doc.php?returnUrl={f:uri.action(action:'submitFilter', additionalParams:'{id:currentPid}', arguments:'{extlist:namespace.GPArray(object: yagContext arguments:\'albumUid:{item.album.uid}\')}')->ptx:format.urlencode()}&edit[tx_yag_domain_model_item][{item.uid}]=edit" >
<a href="{yagns:Backend.editRecordUrl(entity:item, returnUrl: '{f:uri.action(action:\'submitFilter\', additionalParams:\'{id:currentPid}\', arguments:\'{extlist:namespace.GPArray(object: yagContext arguments:\\'albumUid:{item.album.uid}\\')}\')}')}">
<core:icon identifier="actions-document-open" />
<f:translate key="tx_yag_controller_item.editItemInListModule"/>
</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{namespace yag=Tx_Yag_ViewHelpers}
{namespace yag=DL\Yag\ViewHelpers}
{namespace extlist=Tx_PtExtlist_ViewHelpers}
{namespace ptx=Tx_PtExtbase_ViewHelpers}
{namespace core=TYPO3\CMS\Core\ViewHelpers}
Expand All @@ -23,9 +23,8 @@ <h3>
</f:form>

<div class="yag-galleryedit-commands">
<a href="alt_doc.php?returnUrl={f:uri.action(action:'index', additionalParams:'{id:currentPid}', arguments:'{extlist:namespace.GPArray(object: yagContext arguments:\'albumUid:{gallery.uid}\')}')->ptx:format.urlencode()}&edit[tx_yag_domain_model_gallery][{gallery.uid}]=edit">
<a href="{yag:Backend.editRecordUrl(entity:gallery, returnUrl: '{f:uri.action(action:\'index\', additionalParams:\'{id:currentPid}\', arguments:\'{extlist:namespace.GPArray(object: yagContext arguments:\\'galleryUid:{gallery.uid}\\')}\')}')}">
<core:icon identifier="actions-document-open"/>
<f:translate key="tx_yag_controller_item.editGalleryInListModule"/>
<f:translate key="tx_yag_controller_item.editAlbumInListModule"/>
</a>

</div>

0 comments on commit 5b1ada7

Please sign in to comment.