Commit 0f73b6ab authored by Helmut Hummel's avatar Helmut Hummel Committed by Anja Leichsenring
Browse files

[TASK] Make browse_links.php a wizard

Resolves: #56470
Releases: 6.2
Change-Id: I7bf8c20ab7e084efca352840f88007a574f7e270
Reviewed-on: https://review.typo3.org/27981
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
parent a3deacc1
......@@ -34,9 +34,7 @@ require_once 'init.php';
// Make instance if it is not an AJAX call
if (!(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX)) {
$fileSystemNavigationFrameController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
'TYPO3\\CMS\\Backend\\Controller\\FileSystemNavigationFrameController'
);
$fileSystemNavigationFrameController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Controller\\FileSystemNavigationFrameController');
$fileSystemNavigationFrameController->initPage();
$fileSystemNavigationFrameController->main();
$fileSystemNavigationFrameController->printContent();
......
......@@ -20,7 +20,7 @@ class localPageTree extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
* @todo Define visibility
*/
public function __construct() {
$this->thisScript = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('SCRIPT_NAME');
$this->determineScriptUrl();
$this->init();
$this->clause = ' AND doktype!=' . \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_RECYCLER . $this->clause;
}
......@@ -66,7 +66,7 @@ class localPageTree extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
} else {
$arrCol = '<td></td>';
}
$aOnClick = 'return jumpToUrl(\'' . $this->thisScript . '?act=' . $GLOBALS['SOBE']->browser->act . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&expandPage=' . $v['row']['uid'] . '\');';
$aOnClick = 'return jumpToUrl(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=' . $GLOBALS['SOBE']->browser->act . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&expandPage=' . $v['row']['uid']) . ');';
$cEbullet = $this->ext_isLinkable($v['row']['doktype'], $v['row']['uid']) ? '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '"><img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/ol/arrowbullet.gif', 'width="18" height="16"') . ' alt="" /></a>' : '';
$out .= '
<tr class="' . $bgColorClass . '">
......@@ -109,12 +109,13 @@ class localPageTree extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
* @todo Define visibility
*/
public function PM_ATagWrap($icon, $cmd, $bMark = '') {
$name = '';
if ($bMark) {
$anchor = '#' . $bMark;
$name = ' name="' . $bMark . '"';
}
$aOnClick = 'return jumpToUrl(\'' . $this->thisScript . '?PM=' . $cmd . '\',\'' . $anchor . '\');';
return '<a href="#"' . $name . ' onclick="' . htmlspecialchars($aOnClick) . '">' . $icon . '</a>';
$aOnClick = 'return jumpToUrl(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($this->getThisScript() . 'PM=' . $cmd) . ',' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($anchor) . ');';
return '<a href="#"' . htmlspecialchars($name) . ' onclick="' . htmlspecialchars($aOnClick) . '">' . $icon . '</a>';
}
/**
......@@ -168,9 +169,9 @@ class TBE_PageTree extends localPageTree {
$ficon = \TYPO3\CMS\Backend\Utility\IconUtility::getIcon('pages', $v);
$onClick = 'return insertElement(\'pages\', \'' . $v['uid'] . '\', \'db\', ' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($v['title']) . ', \'\', \'\', \'' . $ficon . '\',\'\',1);';
} else {
$onClick = htmlspecialchars('return jumpToUrl(\'' . $this->thisScript . '?act=' . $GLOBALS['SOBE']->browser->act . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&expandPage=' . $v['uid'] . '\');');
$onClick = 'return jumpToUrl(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=' . $GLOBALS['SOBE']->browser->act . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&expandPage=' . $v['uid']) . ');';
}
return '<a href="#" onclick="' . $onClick . '">' . $title . '</a>';
return '<a href="#" onclick="' . htmlspecialchars($onClick) . '">' . $title . '</a>';
}
}
......@@ -195,7 +196,7 @@ class localFolderTree extends \TYPO3\CMS\Backend\Tree\View\FolderTreeView {
* @todo Define visibility
*/
public function __construct() {
$this->thisScript = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('SCRIPT_NAME');
$this->determineScriptUrl();
parent::__construct();
}
......@@ -209,7 +210,7 @@ class localFolderTree extends \TYPO3\CMS\Backend\Tree\View\FolderTreeView {
*/
public function wrapTitle($title, \TYPO3\CMS\Core\Resource\Folder $folderObject) {
if ($this->ext_isLinkable($folderObject)) {
$aOnClick = 'return jumpToUrl(\'' . $this->thisScript . '?act=' . $GLOBALS['SOBE']->browser->act . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier()) . '\');';
$aOnClick = 'return jumpToUrl(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=' . $GLOBALS['SOBE']->browser->act . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier())) . ');';
return '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $title . '</a>';
} else {
return '<span class="typo3-dimmed">' . $title . '</span>';
......@@ -242,12 +243,13 @@ class localFolderTree extends \TYPO3\CMS\Backend\Tree\View\FolderTreeView {
* @todo Define visibility
*/
public function PM_ATagWrap($icon, $cmd, $bMark = '') {
$name = $anchor = '';
if ($bMark) {
$anchor = '#' . $bMark;
$name = ' name="' . $bMark . '"';
}
$aOnClick = 'return jumpToUrl(\'' . $this->thisScript . '?PM=' . $cmd . '\',\'' . $anchor . '\');';
return '<a href="#"' . $name . ' onclick="' . htmlspecialchars($aOnClick) . '">' . $icon . '</a>';
$aOnClick = 'return jumpToUrl(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($this->getThisScript() . 'PM=' . $cmd) . ',' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($anchor) . ');';
return '<a href="#"' . htmlspecialchars($name) . ' onclick="' . htmlspecialchars($aOnClick) . '">' . $icon . '</a>';
}
}
......@@ -290,7 +292,7 @@ class TBE_FolderTree extends localFolderTree {
*/
public function wrapTitle($title, $folderObject) {
if ($this->ext_isLinkable($folderObject)) {
$aOnClick = 'return jumpToUrl(\'' . $this->thisScript . '?act=' . $GLOBALS['SOBE']->browser->act . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier()) . '\');';
$aOnClick = 'return jumpToUrl(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=' . $GLOBALS['SOBE']->browser->act . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier())) . ');';
return '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $title . '</a>';
} else {
return '<span class="typo3-dimmed">' . $title . '</span>';
......
......@@ -709,7 +709,7 @@ class PageLayoutController {
// Return-url for JavaScript:
$retUrlStr = $this->returnUrl ? '+\'&returnUrl=\'+\'' . rawurlencode($this->returnUrl) . '\'' : '';
// Drawing the edit record selectbox
$this->editSelect = '<select name="edit_record" onchange="' . htmlspecialchars(('jumpToUrl(\'db_layout.php?id=' . $this->id . '&edit_record=\'+escape(this.options[this.selectedIndex].value)' . $retUrlStr . ',this);')) . '">' . implode('', $opt) . '</select>';
$this->editSelect = '<select name="edit_record" onchange="' . htmlspecialchars(('jumpToUrl(' . GeneralUtility::quoteJSvalue('db_layout.php?id=' . $this->id . '&edit_record=') . '+escape(this.options[this.selectedIndex].value)' . $retUrlStr . ',this);')) . '">' . implode('', $opt) . '</select>';
// Creating editing form:
if ($GLOBALS['BE_USER']->check('tables_modify', $this->eRParts[0]) && $edit_record && ($this->eRParts[0] !== 'pages' && $this->EDIT_CONTENT || $this->eRParts[0] === 'pages' && $this->CALC_PERMS & 1)) {
// Splitting uid parts for special features, if new:
......@@ -1107,7 +1107,7 @@ class PageLayoutController {
onclick="' . htmlspecialchars(('window.location.href=\'' . $GLOBALS['BACK_PATH'] . 'show_rechis.php?element=' . rawurlencode(($this->eRParts[0] . ':' . $this->eRParts[1])) . '&revert=ALL_FIELDS&sumUp=-1&returnUrl=' . rawurlencode($this->R_URI) . '\'; return false;')) . '"
title="' . htmlspecialchars(sprintf($GLOBALS['LANG']->getLL('undoLastChange'), BackendUtility::calcAge(($GLOBALS['EXEC_TIME'] - $this->undoButtonR['tstamp']), $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.minutesHoursDaysYears')))) . '">' . IconUtility::getSpriteIcon('actions-edit-undo') . '</a>';
// History button
$buttons['history_record'] = '<a href="#" onclick="' . htmlspecialchars(('jumpToUrl(\'' . $GLOBALS['BACK_PATH'] . 'show_rechis.php?element=' . rawurlencode(($this->eRParts[0] . ':' . $this->eRParts[1])) . '&returnUrl=' . rawurlencode($this->R_URI) . '#latest\');return false;')) . '" title="' . $GLOBALS['LANG']->getLL('recordHistory', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-history-open') . '</a>';
$buttons['history_record'] = '<a href="#" onclick="' . htmlspecialchars(('jumpToUrl(' . GeneralUtility::quoteJSvalue($GLOBALS['BACK_PATH'] . 'show_rechis.php?element=' . rawurlencode(($this->eRParts[0] . ':' . $this->eRParts[1])) . '&returnUrl=' . rawurlencode($this->R_URI) . '#latest') . ');return false;')) . '" title="' . $GLOBALS['LANG']->getLL('recordHistory', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-history-open') . '</a>';
}
}
}
......@@ -1123,7 +1123,7 @@ class PageLayoutController {
* Returns the number of hidden elements (including those hidden by start/end times)
* on the current page (for the current sys_language)
*
* @return void
* @return int
* @todo Define visibility
*/
public function getNumberOfHiddenElements() {
......
......@@ -4157,6 +4157,8 @@ TBE_EDITOR.customEvalFunctions[\'' . $evalData . '\'] = function(value) {
$params['flexFormPath'] = $flexFormPath;
$params['md5ID'] = $md5ID;
$params['returnUrl'] = $this->thisReturnUrl();
$wScript = '';
// Resolving script filename and setting URL.
if (isset($wConf['module']['name'])) {
$urlParameters = array();
......@@ -4179,6 +4181,8 @@ TBE_EDITOR.customEvalFunctions[\'' . $evalData . '\'] = function(value) {
break;
}
} else {
// Compatibility layer
// @deprecated since 6.2, will be removed 2 versions later
$parsedWizardUrl = parse_url($wConf['script']);
if (in_array($parsedWizardUrl['path'], array(
'wizard_add.php',
......@@ -4188,13 +4192,18 @@ TBE_EDITOR.customEvalFunctions[\'' . $evalData . '\'] = function(value) {
'wizard_list.php',
'wizard_rte.php',
'wizard_table.php',
'browse_links.php',
))
) {
$urlParameters = array();
if (isset($parsedWizardUrl['query'])) {
parse_str($parsedWizardUrl['query'], $urlParameters);
}
$moduleName = str_replace('.php', '', $parsedWizardUrl['path']);
$moduleName = str_replace(
array('.php', 'browse_links'),
array('', 'wizard_element_browser'),
$parsedWizardUrl['path']
);
$wScript = BackendUtility::getModuleUrl($moduleName, $urlParameters);
unset($moduleName, $urlParameters, $parsedWizardUrl);
} else {
......@@ -4202,7 +4211,7 @@ TBE_EDITOR.customEvalFunctions[\'' . $evalData . '\'] = function(value) {
}
}
} elseif (in_array($wConf['type'], array('script', 'colorbox', 'popup'), TRUE)) {
// Illeagal configuration, fail silently
// Illegal configuration, fail silently
break;
}
......
......@@ -103,9 +103,9 @@ abstract class AbstractRecordList {
public $fixedL = 30;
/**
* @todo Define visibility
* Script URL
*/
public $script = '';
public $thisScript = '';
// Set to zero, if you don't want a left-margin with addElement function
/**
......@@ -170,6 +170,24 @@ abstract class AbstractRecordList {
$this->getTranslateTools();
}
/**
* Sets the script url depending on being a module or script request
*/
protected function determineScriptUrl() {
if ($moduleName = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('M')) {
$this->thisScript = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl($moduleName);
} else {
$this->thisScript = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('SCRIPT_NAME');
}
}
/**
* @return string
*/
protected function getThisScript() {
return strpos($this->thisScript, '?') === FALSE ? $this->thisScript . '?' : $this->thisScript . '&';
}
/**
* Returns a table-row with the content from the fields in the input data array.
* OBS: $this->fieldArray MUST be set! (represents the list of fields to display)
......@@ -340,7 +358,7 @@ abstract class AbstractRecordList {
* @todo Define visibility
*/
public function listURL($altId = '') {
return $this->script . '?id=' . ($altId !== '' ? $altId : $this->id);
return $this->getThisScript() . 'id=' . ($altId !== '' ? $altId : $this->id);
}
/**
......
......@@ -39,12 +39,6 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
* @author Kasper Skårhøj <kasperYYYY@typo3.com>
*/
class ElementBrowserRecordList extends \TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList {
/**
* @todo Define visibility
*/
public $thisScript = 'browse_links.php';
/**
* Table name of the field pointing to this element browser
*
......@@ -67,7 +61,7 @@ class ElementBrowserRecordList extends \TYPO3\CMS\Recordlist\RecordList\Database
*/
public function __construct() {
parent::__construct();
$this->thisScript = GeneralUtility::getIndpEnv('SCRIPT_NAME');
$this->determineScriptUrl();
}
/**
......@@ -80,7 +74,7 @@ class ElementBrowserRecordList extends \TYPO3\CMS\Recordlist\RecordList\Database
* @todo Define visibility
*/
public function listURL($altId = '', $table = -1, $exclList = '') {
return $this->thisScript . '?id=' . ($altId !== '' ? $altId : $this->id) . '&table=' . rawurlencode(($table == -1 ? $this->table : $table)) . ($this->thumbs ? '&imagemode=' . $this->thumbs : '') . ($this->searchString ? '&search_field=' . rawurlencode($this->searchString) : '') . ($this->searchLevels ? '&search_levels=' . rawurlencode($this->searchLevels) : '') . ((!$exclList || !GeneralUtility::inList($exclList, 'sortField')) && $this->sortField ? '&sortField=' . rawurlencode($this->sortField) : '') . ((!$exclList || !GeneralUtility::inList($exclList, 'sortRev')) && $this->sortRev ? '&sortRev=' . rawurlencode($this->sortRev) : '') . $this->ext_addP();
return $this->getThisScript() . 'id=' . ($altId !== '' ? $altId : $this->id) . '&table=' . rawurlencode(($table == -1 ? $this->table : $table)) . ($this->thumbs ? '&imagemode=' . $this->thumbs : '') . ($this->searchString ? '&search_field=' . rawurlencode($this->searchString) : '') . ($this->searchLevels ? '&search_levels=' . rawurlencode($this->searchLevels) : '') . ((!$exclList || !GeneralUtility::inList($exclList, 'sortField')) && $this->sortField ? '&sortField=' . rawurlencode($this->sortField) : '') . ((!$exclList || !GeneralUtility::inList($exclList, 'sortRev')) && $this->sortRev ? '&sortRev=' . rawurlencode($this->sortRev) : '') . $this->ext_addP();
}
/**
......
......@@ -307,6 +307,24 @@ abstract class AbstractTreeView {
*/
public $recs = array();
/**
* Sets the script url depending on being a module or script request
*/
protected function determineScriptUrl() {
if ($moduleName = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('M')) {
$this->thisScript = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl($moduleName);
} else {
$this->thisScript = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('SCRIPT_NAME');
}
}
/**
* @return string
*/
protected function getThisScript() {
return strpos($this->thisScript, '?') === FALSE ? $this->thisScript . '?' : $this->thisScript . '&';
}
/**
* Initialize the tree class. Needs to be overwritten
* Will set ->fieldsArray, ->backPath and ->clause
......@@ -526,7 +544,7 @@ abstract class AbstractTreeView {
$anchor = '#' . $bMark;
$name = ' name="' . $bMark . '"';
}
$aUrl = $this->thisScript . '?PM=' . $cmd . $anchor;
$aUrl = $this->getThisScript() . 'PM=' . $cmd . $anchor;
return '<a href="' . htmlspecialchars($aUrl) . '"' . $name . '>' . $icon . '</a>';
} else {
return $icon;
......
......@@ -127,7 +127,7 @@ class FolderTreeView extends \TYPO3\CMS\Backend\Tree\View\AbstractTreeView {
// Activates dynamic AJAX based tree
$scopeData = serialize($this->scope);
$scopeHash = GeneralUtility::hmac($scopeData);
$js = htmlspecialchars('Tree.load(\'' . $cmd . '\', ' . (int)$isExpand . ', this, \'' . $scopeData . '\', \'' . $scopeHash . '\');');
$js = htmlspecialchars('Tree.load(' . GeneralUtility::quoteJSvalue($cmd) . ', ' . (int)$isExpand . ', this, ' . GeneralUtility::quoteJSvalue($scopeData) . ', ' . GeneralUtility::quoteJSvalue($scopeHash) . ');');
return '<a class="pm" onclick="' . $js . '">' . $icon . '</a>';
} else {
return $icon;
......
......@@ -228,7 +228,13 @@
<type>popup</type>
<title>LLL:EXT:cms/locallang_ttc.xml:media.browseUrlTitle</title>
<icon>link_popup.gif</icon>
<script>browse_links.php?mode=wizard&amp;act=file|url</script>
<module type="array">
<name>wizard_element_browser</name>
<urlParameters type="array">
<mode>wizard</mode>
<act>file|url</act>
</urlParameters>
</module>
<params type="array">
<blindLinkOptions>page,folder,mail,spec</blindLinkOptions>
<allowedExtensions>class,swa,dcr,wav,avi,au,mov,asf,mpg,wmv,mp3,mp4,m4v,m4a,flv,ogg,ogv,swf,webm</allowedExtensions>
......@@ -273,7 +279,13 @@
<type>popup</type>
<title>LLL:EXT:cms/locallang_ttc.xml:media.browseUrlTitle</title>
<icon>link_popup.gif</icon>
<script>browse_links.php?mode=wizard&amp;act=file|url</script>
<module type="array">
<name>wizard_element_browser</name>
<urlParameters type="array">
<mode>wizard</mode>
<act>file|url</act>
</urlParameters>
</module>
<params type="array">
<blindLinkOptions>page,folder,mail,spec</blindLinkOptions>
<allowedExtensions>mov,mpg,mp4,m4a,m4v,ogg,ogv,swf,webm</allowedExtensions>
......@@ -302,7 +314,13 @@
<type>popup</type>
<title>LLL:EXT:cms/locallang_ttc.xml:media.browseUrlTitle</title>
<icon>link_popup.gif</icon>
<script>browse_links.php?mode=wizard&amp;act=file|url</script>
<module type="array">
<name>wizard_element_browser</name>
<urlParameters type="array">
<mode>wizard</mode>
<act>file|url</act>
</urlParameters>
</module>
<params type="array">
<blindLinkOptions>page,folder,mail,spec</blindLinkOptions>
<allowedExtensions>srt</allowedExtensions>
......@@ -336,7 +354,13 @@
<type>popup</type>
<title>LLL:EXT:cms/locallang_ttc.xml:media.browseUrlTitle</title>
<icon>link_popup.gif</icon>
<script>browse_links.php?mode=wizard&amp;act=file|url</script>
<module type="array">
<name>wizard_element_browser</name>
<urlParameters type="array">
<mode>wizard</mode>
<act>file|url</act>
</urlParameters>
</module>
<params type="array">
<blindLinkOptions>page,folder,mail,spec</blindLinkOptions>
<allowedExtensions>au,asf,mp3,m4a,oga,ogg, wav,webm,wmv</allowedExtensions>
......@@ -377,7 +401,13 @@
<type>popup</type>
<title>LLL:EXT:cms/locallang_ttc.xml:media.browseUrlTitle</title>
<icon>link_popup.gif</icon>
<script>browse_links.php?mode=wizard&amp;act=file|url</script>
<module type="array">
<name>wizard_element_browser</name>
<urlParameters type="array">
<mode>wizard</mode>
<act>file|url</act>
</urlParameters>
</module>
<params type="array">
<blindLinkOptions>page,folder,mail,spec</blindLinkOptions>
<allowedExtensions>au,asf,mp3,m4a,oga,swa,wav,webm,wmv</allowedExtensions>
......@@ -411,7 +441,13 @@
<type>popup</type>
<title>LLL:EXT:cms/locallang_ttc.xml:media.browseUrlTitle</title>
<icon>link_popup.gif</icon>
<script>browse_links.php?mode=wizard&amp;act=file|url</script>
<module type="array">
<name>wizard_element_browser</name>
<urlParameters type="array">
<mode>wizard</mode>
<act>file|url</act>
</urlParameters>
</module>
<params type="array">
<blindLinkOptions>page,folder,mail,spec</blindLinkOptions>
<allowedExtensions>au,asf,mp3,m4a,oga,ogg, wav,webm,wmv</allowedExtensions>
......
......@@ -68,7 +68,7 @@ class ext_posMap extends \TYPO3\CMS\Backend\Tree\View\PagePositionMap {
* @todo Define visibility
*/
public function wrapRecordTitle($str, $row) {
$aOnClick = 'jumpToUrl(\'' . $GLOBALS['SOBE']->local_linkThisScript(array('edit_record' => ('tt_content:' . $row['uid']))) . '\');return false;';
$aOnClick = 'jumpToUrl(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($GLOBALS['SOBE']->local_linkThisScript(array('edit_record' => ('tt_content:' . $row['uid'])))) . ');return false;';
return '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $str . '</a>';
}
......@@ -82,7 +82,7 @@ class ext_posMap extends \TYPO3\CMS\Backend\Tree\View\PagePositionMap {
* @todo Define visibility
*/
public function wrapColumnHeader($str, $vv) {
$aOnClick = 'jumpToUrl(\'' . $GLOBALS['SOBE']->local_linkThisScript(array('edit_record' => ('_EDIT_COL:' . $vv))) . '\');return false;';
$aOnClick = 'jumpToUrl(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($GLOBALS['SOBE']->local_linkThisScript(array('edit_record' => ('_EDIT_COL:' . $vv)))) . ');return false;';
return '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $str . '</a>';
}
......@@ -103,7 +103,7 @@ class ext_posMap extends \TYPO3\CMS\Backend\Tree\View\PagePositionMap {
} else {
$location = $GLOBALS['SOBE']->local_linkThisScript(array('edit_record' => 'tt_content:new/' . $pid . '/' . $vv));
}
return 'jumpToUrl(\'' . $location . '\');return false;';
return 'jumpToUrl(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($location) . ');return false;';
}
/**
......
......@@ -173,7 +173,12 @@ return array(
'type' => 'popup',
'title' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.link',
'icon' => 'link_popup.gif',
'script' => 'browse_links.php?mode=wizard',
'module' => array(
'name' => 'wizard_element_browser',
'urlParameters' => array(
'mode' => 'wizard'
)
),
'JSopenParams' => 'height=300,width=500,status=0,menubar=0,scrollbars=1'
)
)
......
......@@ -403,7 +403,12 @@ return array(
'type' => 'popup',
'title' => 'LLL:EXT:cms/locallang_ttc.xlf:header_link_formlabel',
'icon' => 'link_popup.gif',
'script' => 'browse_links.php?mode=wizard',
'module' => array(
'name' => 'wizard_element_browser',
'urlParameters' => array(
'mode' => 'wizard'
)
),
'JSopenParams' => 'height=300,width=500,status=0,menubar=0,scrollbars=1'
)
),
......@@ -690,7 +695,12 @@ return array(
'type' => 'popup',
'title' => 'LLL:EXT:cms/locallang_ttc.xlf:image_link_formlabel',
'icon' => 'link_popup.gif',
'script' => 'browse_links.php?mode=wizard',
'module' => array(
'name' => 'wizard_element_browser',
'urlParameters' => array(
'mode' => 'wizard'
)
),
'JSopenParams' => 'height=300,width=500,status=0,menubar=0,scrollbars=1'
)
),
......@@ -1000,7 +1010,12 @@ return array(
'type' => 'popup',
'title' => 'LLL:EXT:cms/locallang_ttc.xlf:image_link_formlabel',
'icon' => 'link_popup.gif',
'script' => 'browse_links.php?mode=wizard',
'module' => array(
'name' => 'wizard_element_browser',
'urlParameters' => array(
'mode' => 'wizard'
)
),
'params' => array(
'blindLinkOptions' => 'folder,file,mail,spec',
'blindLinkFields' => 'target,title,class,params'
......
......@@ -250,6 +250,24 @@ class ElementBrowser {
*/
public $fileProcessor;
/**
* Sets the script url depending on being a module or script request
*/
protected function determineScriptUrl() {
if ($moduleName = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('M')) {
$this->thisScript = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl($moduleName);
} else {
$this->thisScript = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('SCRIPT_NAME');
}
}
/**
* @return string
*/
protected function getThisScript() {
return strpos($this->thisScript, '?') === FALSE ? $this->thisScript . '?' : $this->thisScript . '&';
}
/**
* Constructor:
* Initializes a lot of variables, setting JavaScript functions in header etc.
......@@ -274,6 +292,7 @@ class ElementBrowser {
}
// Creating backend template object:
$this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
$this->doc->bodyTagId = 'typo3-browse-links-php';
$this->doc->backPath = $GLOBALS['BACK_PATH'];
// Load the Prototype library and browse_links.js
$this->doc->getPageRenderer()->loadPrototype();
......@@ -297,8 +316,7 @@ class ElementBrowser {
// Site URL
// Current site url
$this->siteURL = GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
// The script to link to
$this->thisScript = GeneralUtility::getIndpEnv('SCRIPT_NAME');
$this->determineScriptUrl();
// Init fileProcessor
$this->fileProcessor = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Utility\\File\\BasicFileUtility');
$this->fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
......@@ -799,37 +817,37 @@ class ElementBrowser {
$menuDef['page']['isActive'] = $this->act == 'page';
$menuDef['page']['label'] = $GLOBALS['LANG']->getLL('page', TRUE);
$menuDef['page']['url'] = '#';
$menuDef['page']['addParams'] = 'onclick="jumpToUrl(\'?act=page\');return false;"';
$menuDef['page']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=page') . ');return false;"';
}
if (in_array('file', $allowedItems)) {
$menuDef['file']['isActive'] = $this->act == 'file';
$menuDef['file']['label'] = $GLOBALS['LANG']->getLL('file', TRUE);
$menuDef['file']['url'] = '#';
$menuDef['file']['addParams'] = 'onclick="jumpToUrl(\'?act=file\');return false;"';
$menuDef['file']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=file') . ');return false;"';
}
if (in_array('folder', $allowedItems)) {
$menuDef['folder']['isActive'] = $this->act == 'folder';
$menuDef['folder']['label'] = $GLOBALS['LANG']->getLL('folder', TRUE);
$menuDef['folder']['url'] = '#';
$menuDef['folder']['addParams'] = 'onclick="jumpToUrl(\'?act=folder\');return false;"';
$menuDef['folder']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=folder') . ');return false;"';
}
if (in_array('url', $allowedItems)) {
$menuDef['url']['isActive'] = $this->act == 'url';
$menuDef['url']['label'] = $GLOBALS['LANG']->getLL('extUrl', TRUE);
$menuDef['url']['url'] = '#';
$menuDef['url']['addParams'] = 'onclick="jumpToUrl(\'?act=url\');return false;"';
$menuDef['url']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=url') . ');return false;"';
}
if (in_array('mail', $allowedItems)) {
$menuDef['mail']['isActive'] = $this->act == 'mail';
$menuDef['mail']['label'] = $GLOBALS['LANG']->getLL('email', TRUE);
$menuDef['mail']['url'] = '#';
$menuDef['mail']['addParams'] = 'onclick="jumpToUrl(\'?act=mail\');return false;"';
$menuDef['mail']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=mail') . ');return false;"';
}
if (is_array($this->thisConfig['userLinks.']) && in_array('spec', $allowedItems)) {
$menuDef['spec']['isActive'] = $this->act == 'spec';
$menuDef['spec']['label'] = $GLOBALS['LANG']->getLL('special', TRUE);
$menuDef['spec']['url'] = '#';
$menuDef['spec']['addParams'] = 'onclick="jumpToUrl(\'?act=spec\');return false;"';
$menuDef['spec']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=spec') . ');return false;"';
}
// Call hook for extra options
foreach ($this->hookObjects as $hookObject) {
......@@ -931,7 +949,8 @@ class ElementBrowser {
// Render the filelist if there is a folder selected
if ($selectedFolder) {
$files = $this->expandFolder($selectedFolder, $this->P['params']['allowedExtensions']);
$allowedExtensions = isset($this->P['params']['allowedExtensions']) ? $this->P['params']['allowedExtensions'] : '';
$files = $this->expandFolder($selectedFolder, $allowedExtensions);
}
$this->doc->JScode .= $this->doc->wrapScriptTags('
Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
......@@ -2362,7 +2381,7 @@ class ElementBrowser {
<input type="hidden" name="file[upload][' . $a . '][data]" value="' . $a . '" /><br />';
}
// Make footer of upload form, including the submit button: