Skip to content

Commit

Permalink
[TASK] Improve URL generation code for BE buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
liayn committed Jul 20, 2016
1 parent fd63e12 commit 2be0ebe
Showing 1 changed file with 34 additions and 32 deletions.
66 changes: 34 additions & 32 deletions Classes/Hooks/AbstractBeButtons.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
***************************************************************/

use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException;
use TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException;
use TYPO3\CMS\Core\Resource\Folder;
Expand Down Expand Up @@ -118,18 +117,13 @@ protected function getIcon($name)
*/
protected function buildEditUrl($uid)
{
if (!GeneralUtility::compat_version('7.4')) {
return 'alt_doc.php?edit[tx_falsecuredownload_folder][' . $uid . ']=edit';
} else {
return BackendUtility::getModuleUrl('record_edit', array(
'edit' => array(
'tx_falsecuredownload_folder' => array(
$uid => 'edit'
)
),
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
));
}
return $this->buildUrl(array(
'edit' => array(
'tx_falsecuredownload_folder' => array(
$uid => 'edit'
)
)
));
}

/**
Expand All @@ -139,28 +133,36 @@ protected function buildEditUrl($uid)
* @return string
*/
protected function buildAddUrl(Folder $folder)
{
return $this->buildUrl(array(
'edit' => array(
'tx_falsecuredownload_folder' => array(
0 => 'new'
)
),
'defVals' => array(
'tx_falsecuredownload_folder' => array(
'storage' => $folder->getStorage()->getUid(),
'folder' => $folder->getIdentifier(),
'folder_hash' => $folder->getHashedIdentifier(),
)
)
));
}

/**
* Build record edit url
*
* @param array $parameters URL parameters
* @return string
*/
protected function buildUrl(array $parameters)
{
if (!GeneralUtility::compat_version('7.4')) {
return 'alt_doc.php?edit[tx_falsecuredownload_folder][0]=new&' .
'defVals[tx_falsecuredownload_folder][folder_hash]=' . $folder->getHashedIdentifier() .
'&defVals[tx_falsecuredownload_folder][storage]=' . $folder->getStorage()->getUid() .
'&defVals[tx_falsecuredownload_folder][folder]=' . $folder->getIdentifier();
return 'alt_doc.php?' . ltrim(GeneralUtility::implodeArrayForUrl('', $parameters), '&');
} else {
return BackendUtility::getModuleUrl('record_edit', array(
'edit' => array(
'tx_falsecuredownload_folder' => array(
0 => 'new'
)
),
'defVals' => array(
'tx_falsecuredownload_folder' => array(
'storage' => $folder->getStorage()->getUid(),
'folder' => $folder->getIdentifier(),
'folder_hash' => $folder->getHashedIdentifier(),
)
),
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
));
$parameters['returnUrl'] = GeneralUtility::getIndpEnv('REQUEST_URI');
return BackendUtility::getModuleUrl('record_edit', $parameters);
}
}

Expand Down

0 comments on commit 2be0ebe

Please sign in to comment.