Commit 941eb5dc authored by Markus Klein's avatar Markus Klein Committed by Stefan Neufeind
Browse files

[CLEANUP] ElementBrowser classes

Next step in cleanup and separation of concerns.
Removal of unused or redundant code.

Resolves: #69136
Releases: master
Change-Id: I4a81c6856bf44cf15ceea1cad9e41f00ba43f70a
Reviewed-on: http://review.typo3.org/42689


Reviewed-by: Mathias Schreiber's avatarMathias Schreiber <mathias.schreiber@wmdb.de>
Tested-by: Mathias Schreiber's avatarMathias Schreiber <mathias.schreiber@wmdb.de>
Reviewed-by: default avatarStefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: default avatarStefan Neufeind <typo3.neufeind@speedpartner.de>
parent 3b5400e6
......@@ -730,8 +730,11 @@ class EditDocumentController {
// Info view:
function launchView(table,uid,bP) { //
var backPath= bP ? bP : "";
var thePreviewWindow="";
thePreviewWindow = window.open(backPath+' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('show_item', array(), '') . '&table=') . '+encodeURIComponent(table)+"&uid="+encodeURIComponent(uid),"ShowItem"+TS.uniqueID,"height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
var thePreviewWindow = window.open(
backPath+' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('show_item') . '&table=') . ' + encodeURIComponent(table) + "&uid=" + encodeURIComponent(uid),
"ShowItem" + TS.uniqueID,
"height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0"
);
if (thePreviewWindow && thePreviewWindow.focus) {
thePreviewWindow.focus();
}
......
......@@ -55,11 +55,6 @@ class BrowseLinks extends ElementBrowser {
*/
public $buttonConfig = array();
/**
* @var array
*/
public $RTEProperties = array();
/**
* @var array
*/
......@@ -96,41 +91,18 @@ class BrowseLinks extends ElementBrowser {
protected $defaultLinkTarget;
/**
* @var
* @var string
*/
public $allowedItems;
protected $hookName = 'ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php';
/**
* Constructor:
* Initializes a lot of variables, setting JavaScript functions in header etc.
*
* @return void
* Constructor
*/
public function init() {
$this->initVariables();
public function __construct() {
parent::__construct();
// Create content language service
$this->contentLanguageService = GeneralUtility::makeInstance(LanguageService::class);
$this->contentLanguageService->init($this->contentTypo3Language);
$this->initConfiguration();
$this->initDocumentTemplate();
// Initializing hooking browsers
$this->initHookObjects('ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php');
$this->allowedItems = $this->getAllowedItems('page,file,folder,url,mail');
$this->initCurrentUrl();
// Determine nature of current url:
$this->act = GeneralUtility::_GP('act');
if (!$this->act) {
$this->act = $this->curUrlInfo['act'];
}
// Setting initial values for link attributes
$this->initLinkAttributes();
// Adding RTE JS code
// also unset the default jumpToUrl() function before
unset($this->doc->JScodeArray['jumpToUrl']);
$this->doc->JScodeArray['rtehtmlarea'] = $this->getJSCode();
}
/**
......@@ -155,15 +127,9 @@ class BrowseLinks extends ElementBrowser {
$pArr[1] = implode(':', array($this->editorNo, $this->contentTypo3Language));
$pArr[2] = $this->RTEtsConfigParams;
$this->bparams = implode('|', $pArr);
}
/**
* Initializes the configuration variables
*
* @return void
*/
public function initConfiguration() {
$this->thisConfig = $this->getRTEConfig();
$this->contentLanguageService->init($this->contentTypo3Language);
$this->buttonConfig = $this->getButtonConfig('link');
}
......@@ -174,48 +140,17 @@ class BrowseLinks extends ElementBrowser {
*/
protected function initDocumentTemplate() {
parent::initDocumentTemplate();
$this->doc->getContextMenuCode();
// Apply the same styles as those of the base script
$this->getPageRenderer()->addCssFile(ExtensionManagementUtility::extRelPath('t3skin') . 'rtehtmlarea/htmlarea.css');
// Add attributes to body tag. Note: getBodyTagAdditions will invoke the hooks
$this->doc->bodyTagAdditions = $this->getBodyTagAdditions();
$this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/LegacyTree', 'function(Tree) {
$pageRenderer = $this->getPageRenderer();
$pageRenderer->addCssFile(ExtensionManagementUtility::extRelPath('t3skin') . 'rtehtmlarea/htmlarea.css');
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/LegacyTree', 'function(Tree) {
Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
}');
}
/**
* Initialize $this->curUrlArray and $this->curUrlInfo based on script parameters
*
* @return void
*/
protected function initCurrentUrl() {
// CurrentUrl - the current link url must be passed around if it exists
$this->curUrlArray = GeneralUtility::_GP('curUrl');
if ($this->curUrlArray['all']) {
$this->curUrlArray = GeneralUtility::get_tag_attributes($this->curUrlArray['all']);
$this->curUrlArray['href'] = htmlspecialchars_decode($this->curUrlArray['href']);
}
// Note: parseCurUrl will invoke the hooks
$this->curUrlInfo = $this->parseCurUrl($this->curUrlArray['href'], $this->siteURL);
if (isset($this->curUrlArray['data-htmlarea-external']) && $this->curUrlArray['data-htmlarea-external'] === '1' && $this->curUrlInfo['act'] != 'mail') {
$this->curUrlInfo['act'] = 'url';
$this->curUrlInfo['info'] = $this->curUrlArray['href'];
}
}
/**
* Get the RTE configuration from Page TSConfig
*
* @return array RTE configuration array
*/
protected function getRTEConfig() {
$RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
$RTEsetup = $this->getBackendUser()->getTSConfig('RTE', BackendUtility::getPagesTSconfig($RTEtsConfigParts[5]));
$this->RTEProperties = $RTEsetup['properties'];
return BackendUtility::RTEsetup($this->RTEProperties, $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
}
/**
* Get the configuration of the button
*
......@@ -223,8 +158,8 @@ class BrowseLinks extends ElementBrowser {
* @return array the configuration array of the image button
*/
protected function getButtonConfig($buttonName) {
return is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.'][$buttonName . '.'])
? $this->thisConfig['buttons.'][$buttonName . '.']
return isset($this->RTEProperties['default.']['buttons.'][$buttonName . '.'])
? $this->RTEProperties['default.']['buttons.'][$buttonName . '.']
: array();
}
......@@ -237,8 +172,7 @@ class BrowseLinks extends ElementBrowser {
// Initializing the class value
$this->setClass = isset($this->curUrlArray['class']) ? $this->curUrlArray['class'] : '';
// Processing the classes configuration
$classSelected = array();
if ($this->buttonConfig['properties.']['class.']['allowedClasses']) {
if (!empty($this->buttonConfig['properties.']['class.']['allowedClasses'])) {
$classesAnchorArray = GeneralUtility::trimExplode(',', $this->buttonConfig['properties.']['class.']['allowedClasses'], TRUE);
// Collecting allowed classes and configured default values
$classesAnchor = array();
......@@ -275,10 +209,13 @@ class BrowseLinks extends ElementBrowser {
$selected = '';
if ($currentClass == $class || !$currentClass && $this->classesAnchorDefault[$anchorType] == $class) {
$selected = 'selected="selected"';
$classSelected[$anchorType] = TRUE;
}
$classLabel = is_array($this->RTEProperties['classes.']) && is_array($this->RTEProperties['classes.'][$class . '.']) && $this->RTEProperties['classes.'][$class . '.']['name'] ? $this->getPageConfigLabel($this->RTEProperties['classes.'][$class . '.']['name'], 0) : $class;
$classStyle = is_array($this->RTEProperties['classes.']) && is_array($this->RTEProperties['classes.'][$class . '.']) && $this->RTEProperties['classes.'][$class . '.']['value'] ? $this->RTEProperties['classes.'][$class . '.']['value'] : '';
$classLabel = !empty($this->RTEProperties['classes.'][$class . '.']['name'])
? $this->getPageConfigLabel($this->RTEProperties['classes.'][$class . '.']['name'], 0)
: $class;
$classStyle = !empty($this->RTEProperties['classes.'][$class . '.']['value'])
? $this->RTEProperties['classes.'][$class . '.']['value']
: '';
$this->classesAnchorJSOptions[$anchorType] .= '<option ' . $selected . ' value="' . $class . '"' . ($classStyle ? ' style="' . $classStyle . '"' : '') . '>' . $classLabel . '</option>';
}
}
......@@ -417,10 +354,10 @@ class BrowseLinks extends ElementBrowser {
if (URL.charAt(0) === \'?\') {
URL = ' . GeneralUtility::quoteJSvalue($this->getThisScript()) . ' + URL.substring(1);
}
var add_editorNo = URL.indexOf("editorNo=")==-1 ? "&editorNo=' . $this->editorNo . '" : "";
var add_contentTypo3Language = URL.indexOf("contentTypo3Language=")==-1 ? "&contentTypo3Language=' . $this->contentTypo3Language . '" : "";
var add_act = URL.indexOf("act=")==-1 ? "&act=' . $this->act . '" : "";
var add_mode = URL.indexOf("mode=")==-1 ? "&mode=' . $this->mode . '" : "";
var add_editorNo = URL.indexOf("editorNo=")==-1 ? "&editorNo=' . $this->editorNo . '" : "";
var add_contentTypo3Language = URL.indexOf("contentTypo3Language=")==-1 ? "&contentTypo3Language=' . $this->contentTypo3Language . '" : "";
var add_additionalValues = "";
if (plugin.pageTSConfiguration && plugin.pageTSConfiguration.additionalAttributes) {
var additionalAttributes = plugin.pageTSConfiguration.additionalAttributes.split(",");
......@@ -430,28 +367,19 @@ class BrowseLinks extends ElementBrowser {
}
}
}
var theLocation = URL+add_act+add_editorNo+add_contentTypo3Language+add_mode+add_href+add_target+add_class+add_title+add_additionalValues+add_params+(anchor?anchor:"");
window.location.href = theLocation;
window.location.href = URL + add_act + add_mode + add_editorNo + add_contentTypo3Language + add_href + add_target + add_class + add_title + add_additionalValues + add_params + (typeof(anchor) === "string" ? anchor : "");
return false;
}
function launchView(url) {
var thePreviewWindow="";
thePreviewWindow = window.open(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('show_item') . '&table=') . '+url,"ShowItem","height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
if (thePreviewWindow && thePreviewWindow.focus) {
thePreviewWindow.focus();
}
}
';
// Hook to overwrite or extend javascript functions
if (
isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']['extendJScode'])
&& is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']['extendJScode'])
isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][$this->hookName]['extendJScode'])
&& is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][$this->hookName]['extendJScode'])
) {
$conf = array();
$_params = array(
'conf' => &$conf
'conf' => []
);
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']['extendJScode'] as $objRef) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][$this->hookName]['extendJScode'] as $objRef) {
$processor =& GeneralUtility::getUserObj($objRef);
$JScode .= $processor->extendJScode($_params, $this);
}
......@@ -476,7 +404,7 @@ class BrowseLinks extends ElementBrowser {
// Starting content:
$content = $this->doc->startPage($this->getLanguageService()->getLL('Insert/Modify Link', TRUE));
// Making menu in top:
$content .= $this->doc->getTabMenuRaw($this->buildMenuArray($wiz, $this->allowedItems));
$content .= $this->doc->getTabMenuRaw($this->buildMenuArray($wiz, $this->getAllowedItems('page,file,folder,url,mail')));
// Adding the menu and header to the top of page:
$content .= $this->printCurrentUrl($this->curUrlInfo['info']) . '<br />';
// Depending on the current action we will create the actual module content for selecting a link:
......@@ -510,59 +438,6 @@ class BrowseLinks extends ElementBrowser {
return $content;
}
/**
* Returns an array definition of the top menu
*
* @param $wiz
* @param $allowedItems
* @return array
*/
protected function buildMenuArray($wiz, $allowedItems) {
$menuDef = array();
$lang = $this->getLanguageService();
if (!$wiz && $this->curUrlArray['href']) {
$menuDef['removeLink']['isActive'] = $this->act == 'removeLink';
$menuDef['removeLink']['label'] = $lang->getLL('removeLink', TRUE);
$menuDef['removeLink']['url'] = '#';
$menuDef['removeLink']['addParams'] = 'onclick="plugin.unLink();return false;"';
}
if (in_array('page', $this->allowedItems)) {
$menuDef['page']['isActive'] = $this->act == 'page';
$menuDef['page']['label'] = $lang->getLL('page', TRUE);
$menuDef['page']['url'] = '#';
$menuDef['page']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=page&mode=' . $this->mode . '&bparams=' . $this->bparams) . ');return false;"';
}
if (in_array('file', $this->allowedItems)) {
$menuDef['file']['isActive'] = $this->act == 'file';
$menuDef['file']['label'] = $lang->sL('LLL:EXT:lang/locallang_browse_links.xlf:file', TRUE);
$menuDef['file']['url'] = '#';
$menuDef['file']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=file&mode=' . $this->mode . '&bparams=' . $this->bparams) . ');return false;"';
}
if (in_array('folder', $this->allowedItems)) {
$menuDef['folder']['isActive'] = $this->act == 'folder';
$menuDef['folder']['label'] = $lang->sL('LLL:EXT:lang/locallang_browse_links.xlf:folder', TRUE);
$menuDef['folder']['url'] = '#';
$menuDef['folder']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=folder&mode=' . $this->mode . '&bparams=' . $this->bparams) . ');return false;"';
}
if (in_array('url', $this->allowedItems)) {
$menuDef['url']['isActive'] = $this->act == 'url';
$menuDef['url']['label'] = $lang->getLL('extUrl', TRUE);
$menuDef['url']['url'] = '#';
$menuDef['url']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=url&mode=' . $this->mode . '&bparams=' . $this->bparams) . ');return false;"';
}
if (in_array('mail', $this->allowedItems)) {
$menuDef['mail']['isActive'] = $this->act == 'mail';
$menuDef['mail']['label'] = $lang->getLL('email', TRUE);
$menuDef['mail']['url'] = '#';
$menuDef['mail']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=mail&mode=' . $this->mode . '&bparams=' . $this->bparams) . ');return false;"';
}
// call hook for extra options
foreach ($this->hookObjects as $hookObject) {
$menuDef = $hookObject->modifyMenuDefinition($menuDef);
}
return $menuDef;
}
/**
* Returns HTML of the email link from
*
......@@ -632,10 +507,12 @@ class BrowseLinks extends ElementBrowser {
foreach ($this->hookObjects as $hookObject) {
$allowedItems = $hookObject->addAllowedItems($allowedItems);
}
// Removing items as per configuration
if (is_array($this->buttonConfig['options.']) && $this->buttonConfig['options.']['removeItems']) {
$allowedItems = array_diff($allowedItems, GeneralUtility::trimExplode(',', $this->buttonConfig['options.']['removeItems'], TRUE));
}
reset($allowedItems);
if (!in_array($this->act, $allowedItems)) {
$this->act = current($allowedItems);
......@@ -653,14 +530,14 @@ class BrowseLinks extends ElementBrowser {
// additional fields for links
$additionalAttributeFields = '';
if (
isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']['addAttributeFields'])
&& is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']['addAttributeFields'])
isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][$this->hookName]['addAttributeFields'])
&& is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][$this->hookName]['addAttributeFields'])
) {
$conf = array();
$_params = array(
'conf' => &$conf
);
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']['addAttributeFields'] as $objRef) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][$this->hookName]['addAttributeFields'] as $objRef) {
$processor =& GeneralUtility::getUserObj($objRef);
$additionalAttributeFields .= $processor->getAttributefields($_params, $this);
}
......@@ -694,7 +571,7 @@ class BrowseLinks extends ElementBrowser {
-->
<form action="" name="ltargetform" id="ltargetform">
<table id="typo3-linkTarget" class="htmlarea-window-table">' . $string;
if ($this->act == $this->curUrlInfo['act'] && $this->act != 'mail' && $this->curUrlArray['href']) {
if ($this->act === $this->curUrlInfo['act'] && $this->act != 'mail' && $this->curUrlArray['href']) {
$form .= '
<tr>
<td>
......@@ -718,7 +595,7 @@ class BrowseLinks extends ElementBrowser {
* @return string
*/
public function addPageIdSelector() {
if ($this->act == 'page' && isset($this->buttonConfig['pageIdSelector.']['enabled'])
if ($this->act === 'page' && isset($this->buttonConfig['pageIdSelector.']['enabled'])
&& $this->buttonConfig['pageIdSelector.']['enabled']
) {
return '
......@@ -745,7 +622,7 @@ class BrowseLinks extends ElementBrowser {
public function addRelField() {
// Unset rel attribute if we changed tab
$currentRel = $this->curUrlInfo['act'] === $this->act && isset($this->curUrlArray['rel']) ? $this->curUrlArray['rel'] : '';
if (($this->act == 'page' || $this->act == 'url' || $this->act == 'file')
if (($this->act === 'page' || $this->act === 'url' || $this->act === 'file')
&& isset($this->buttonConfig['relAttribute.']['enabled']) && $this->buttonConfig['relAttribute.']['enabled']
) {
return '
......@@ -766,7 +643,7 @@ class BrowseLinks extends ElementBrowser {
* @return string
*/
public function addQueryParametersSelector() {
if ($this->act == 'page' && isset($this->buttonConfig['queryParametersSelector.']['enabled'])
if ($this->act === 'page' && isset($this->buttonConfig['queryParametersSelector.']['enabled'])
&& $this->buttonConfig['queryParametersSelector.']['enabled']
) {
return '
......
......@@ -94,11 +94,6 @@ class SelectImage extends ElementBrowser {
*/
public $sys_language_content;
/**
* @var array
*/
public $thisConfig;
/**
* @var array
*/
......@@ -109,6 +104,11 @@ class SelectImage extends ElementBrowser {
*/
public $addModifyTab;
/**
* @var string
*/
protected $hookName = 'ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php';
/**
* Initialisation
*
......@@ -116,8 +116,8 @@ class SelectImage extends ElementBrowser {
*/
public function init() {
$this->initVariables();
$this->initConfiguration();
$this->initHookObjects('ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php');
$this->initHookObjects();
$this->allowedItems = $this->getAllowedItems('magic,plain,image');
// Insert the image and exit
$this->insertImage();
......@@ -132,6 +132,7 @@ class SelectImage extends ElementBrowser {
*/
public function initVariables() {
parent::initVariables();
// Get "act"
$this->act = GeneralUtility::_GP('act');
if (!$this->act) {
......@@ -151,11 +152,16 @@ class SelectImage extends ElementBrowser {
}
$pArr[1] = implode(':', array($this->editorNo, $this->sys_language_content));
$pArr[2] = $this->RTEtsConfigParams;
if ($this->act == 'dragdrop' || $this->act == 'plain') {
if ($this->act === 'dragdrop' || $this->act === 'plain') {
$this->allowedFileTypes = explode(',', self::PLAIN_MODE_IMAGE_FILE_EXTENSIONS);
}
$pArr[3] = implode(',', $this->allowedFileTypes);
$this->bparams = implode('|', $pArr);
$this->buttonConfig = $this->getButtonConfig();
$this->imgPath = $this->getImgPath();
$this->defaultClass = $this->getDefaultClass();
$this->setMaximumPlainImageDimensions();
}
/**
......@@ -167,18 +173,19 @@ class SelectImage extends ElementBrowser {
parent::initDocumentTemplate();
$this->doc->bodyTagAdditions = 'onload="SelectImage.initEventListeners();"';
$this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/LegacyTree', 'function(Tree) {
$pageRenderer = $this->getPageRenderer();
$pageRenderer->addCssFile(ExtensionManagementUtility::extRelPath('t3skin') . 'rtehtmlarea/htmlarea.css');
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/LegacyTree', 'function(Tree) {
Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
}');
$this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Rtehtmlarea/Modules/SelectImage', 'function(SelectImage) {
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Rtehtmlarea/Modules/SelectImage', 'function(SelectImage) {
SelectImage.editorNo = ' . GeneralUtility::quoteJSvalue($this->editorNo) . ';
SelectImage.act = ' . GeneralUtility::quoteJSvalue($this->act ?: reset($this->allowedItems)) . ';
SelectImage.sys_language_content = ' . GeneralUtility::quoteJSvalue($this->sys_language_content) . ';
SelectImage.RTEtsConfigParams = ' . GeneralUtility::quoteJSvalue(rawurlencode($this->RTEtsConfigParams)) . ';
SelectImage.bparams = ' . GeneralUtility::quoteJSvalue($this->bparams) . ';
}');
$this->getPageRenderer()->addCssFile(ExtensionManagementUtility::extRelPath('t3skin') . 'rtehtmlarea/htmlarea.css');
$this->doc->getContextMenuCode();
}
/**
......@@ -232,7 +239,7 @@ class SelectImage extends ElementBrowser {
// Create the magic image service
/** @var $magicImageService MagicImageService */
$magicImageService = GeneralUtility::makeInstance(MagicImageService::class);
$magicImageService->setMagicImageMaximumDimensions($this->thisConfig);
$magicImageService->setMagicImageMaximumDimensions($this->RTEProperties['default.']);
// Create the magic image
$imageConfiguration = array(
'width' => GeneralUtility::_GP('cWidth'),
......@@ -330,7 +337,7 @@ plugin.insertImage(imageTags.join(\' \'));
* @return string the generated JS code
*/
public function getJSCode($act, $editorNo, $sys_language_content) {
$JScode = '
return '
function insertElement(table, uid, type, fileName, filePath, fileExt, fileIcon, action, close) {
return SelectImage.jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript()) . ' + "insertImage=1&uidList=" + uid);
}
......@@ -341,7 +348,6 @@ plugin.insertImage(imageTags.join(\' \'));
function jumpToUrl(URL,anchor) {
SelectImage.jumpToUrl(URL, anchor);
};';
return $JScode;
}
/**
......@@ -353,8 +359,8 @@ plugin.insertImage(imageTags.join(\' \'));
*/
public function processSessionData($data) {
$store = FALSE;
if ($this->act != 'image') {
if (isset($this->act)) {
if ($this->act !== 'image') {
if ($this->act) {
$data['act'] = $this->act;
$store = TRUE;
} else {
......@@ -385,7 +391,7 @@ plugin.insertImage(imageTags.join(\' \'));
$this->content .= $this->doc->getTabMenuRaw($this->buildMenuArray($wiz, $this->allowedItems));
switch ($this->act) {
case 'image':
$classesImage = $this->buttonConfig['properties.']['class.']['allowedClasses'] || $this->thisConfig['classesImage'] ? 'true' : 'false';
$classesImage = $this->buttonConfig['properties.']['class.']['allowedClasses'] || $this->RTEProperties['default.']['classesImage'] ? 'true' : 'false';
$removedProperties = array();
if (is_array($this->buttonConfig['properties.'])) {
if ($this->buttonConfig['properties.']['removeItems']) {
......@@ -402,8 +408,8 @@ plugin.insertImage(imageTags.join(\' \'));
}
$lockPlainWidth = 'false';
$lockPlainHeight = 'false';
if (is_array($this->thisConfig['proc.']) && $this->thisConfig['proc.']['plainImageMode']) {
$plainImageMode = $this->thisConfig['proc.']['plainImageMode'];
if (is_array($this->RTEProperties['default.']['proc.']) && $this->RTEProperties['default.']['proc.']['plainImageMode']) {
$plainImageMode = $this->RTEProperties['default.']['proc.']['plainImageMode'];
$lockPlainWidth = $plainImageMode == 'lockDimensions' ? 'true' : 'false';
$lockPlainHeight = $lockPlainWidth || $plainImageMode == 'lockRatio' || $plainImageMode == 'lockRatioWhenSmaller' ? 'true' : 'false';
}
......@@ -614,19 +620,6 @@ plugin.insertImage(imageTags.join(\' \'));
return $menuDef;
}
/**
* Initializes the configuration variables
*
* @return void
*/
public function initConfiguration() {
$this->thisConfig = $this->getRTEConfig();
$this->buttonConfig = $this->getButtonConfig();
$this->imgPath = $this->getImgPath();
$this->defaultClass = $this->getDefaultClass();
$this->setMaximumPlainImageDimensions();
}
/**
* Get the path of the image to be inserted or modified
*
......@@ -643,7 +636,9 @@ plugin.insertImage(imageTags.join(\' \'));
* @return array the configuration array of the image button
*/
protected function getButtonConfig() {
return is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.']['image.']) ? $this->thisConfig['buttons.']['image.'] : array();
return isset($this->RTEProperties['default.']['buttons.']['image.'])
? $this->RTEProperties['default.']['buttons.']['image.']
: array();
}
/**
......@@ -670,6 +665,11 @@ plugin.insertImage(imageTags.join(\' \'));
if (is_array($this->buttonConfig['options.']) && $this->buttonConfig['options.']['removeItems']) {
$allowedItems = array_diff($allowedItems, GeneralUtility::trimExplode(',', $this->buttonConfig['options.']['removeItems'], TRUE));
}
reset($allowedItems);
if (!in_array($this->act, $allowedItems)) {
$this->act = current($allowedItems);
}
return $allowedItems;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment