[CLEANUP] Surrounding ElementBrowser classes 60/41760/6
authorMarkus Klein <markus.klein@typo3.org>
Mon, 20 Jul 2015 21:49:29 +0000 (23:49 +0200)
committerBenni Mack <benni@typo3.org>
Thu, 13 Aug 2015 05:28:56 +0000 (07:28 +0200)
Resolves: #68394
Releases: master
Change-Id: I539f9b063db55d677f47fc01a7691e8e9e2496e0
Reviewed-on: http://review.typo3.org/41760
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/backend/Classes/Controller/PageTreeNavigationController.php
typo3/sysext/backend/Classes/Tree/View/AbstractTreeView.php
typo3/sysext/backend/Classes/Tree/View/ElementBrowserPageTreeView.php
typo3/sysext/backend/Classes/Tree/View/PageTreeView.php
typo3/sysext/backend/Classes/View/PageTreeView.php
typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php
typo3/sysext/recordlist/Classes/Tree/View/ElementBrowserPageTreeView.php
typo3/sysext/rtehtmlarea/Classes/BrowseLinks.php
typo3/sysext/rtehtmlarea/Classes/PageTree.php
typo3/sysext/rtehtmlarea/Classes/SelectImage.php
typo3/sysext/rtehtmlarea/Resources/Public/JavaScript/Modules/SelectImage.js

index 65ae931..b4831d5 100644 (file)
@@ -102,8 +102,8 @@ class PageTreeNavigationController {
                $beUser = $this->getBackendUser();
                $this->pagetree = GeneralUtility::makeInstance(PageTreeView::class);
                $this->pagetree->ext_IconMode = $beUser->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu');
-               $this->pagetree->ext_showPageId = $beUser->getTSConfigVal('options.pageTree.showPageIdWithTitle');
-               $this->pagetree->ext_showNavTitle = $beUser->getTSConfigVal('options.pageTree.showNavTitle');
+               $this->pagetree->ext_showPageId = (bool)$beUser->getTSConfigVal('options.pageTree.showPageIdWithTitle');
+               $this->pagetree->ext_showNavTitle = (bool)$beUser->getTSConfigVal('options.pageTree.showNavTitle');
                $this->pagetree->ext_separateNotinmenuPages = $beUser->getTSConfigVal('options.pageTree.separateNotinmenuPages');
                $this->pagetree->ext_alphasortNotinmenuPages = $beUser->getTSConfigVal('options.pageTree.alphasortNotinmenuPages');
                $this->pagetree->thisScript = 'alt_db_navframe.php';
index ff5dfc3..38b2f41 100644 (file)
@@ -90,9 +90,9 @@ abstract class AbstractTreeView {
         * values are the ID of the root element (COULD be zero or anything else.
         * For pages that would be the uid of the page, zero for the pagetree root.)
         *
-        * @var string
+        * @var array|NULL
         */
-       public $MOUNTS = '';
+       public $MOUNTS = NULL;
 
        /**
         * Database table to get the tree data from.
@@ -477,17 +477,15 @@ abstract class AbstractTreeView {
         *
         * @param string $icon HTML string to wrap, probably an image tag.
         * @param string $cmd Command for 'PM' get var
-        * @param bool $bMark If set, the link will have an anchor point (=$bMark) and a name attribute (=$bMark)
+        * @param string $bMark If set, the link will have an anchor point (=$bMark) and a name attribute (=$bMark)
         * @param bool $isOpen
         * @return string Link-wrapped input string
         * @access private
         */
        public function PM_ATagWrap($icon, $cmd, $bMark = '', $isOpen = FALSE) {
                if ($this->thisScript) {
-                       if ($bMark) {
-                               $anchor = '#' . $bMark;
-                               $name = ' name="' . $bMark . '"';
-                       }
+                       $anchor = $bMark ? '#' . $bMark : '';
+                       $name = $bMark ? ' name="' . $bMark . '"' : '';
                        $aUrl = $this->getThisScript() . 'PM=' . $cmd . $anchor;
                        return '<a class="list-tree-control ' . ($isOpen ? 'list-tree-control-open' : 'list-tree-control-closed') . ' href="' . htmlspecialchars($aUrl) . '"' . $name . '><i class="fa"></i></a>';
                } else {
index 43319fe..f763941 100644 (file)
@@ -13,6 +13,8 @@ namespace TYPO3\CMS\Backend\Tree\View;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
  * Class which generates the page tree
@@ -31,12 +33,22 @@ class ElementBrowserPageTreeView extends BrowseTreeView {
        public $ext_showPageId = FALSE;
 
        /**
+        * @var bool
+        */
+       public $ext_showNavTitle = FALSE;
+
+       /**
+        * @var bool
+        */
+       public $ext_pArrPages = TRUE;
+
+       /**
         * Constructor. Just calling init()
         */
        public function __construct() {
                $this->determineScriptUrl();
                $this->init();
-               $this->clause = ' AND doktype!=' . \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_RECYCLER . $this->clause;
+               $this->clause = ' AND doktype != ' . PageRepository::DOKTYPE_RECYCLER . $this->clause;
        }
 
        /**
@@ -44,12 +56,12 @@ class ElementBrowserPageTreeView extends BrowseTreeView {
         *
         * @param string $title Title, (must be ready for output, that means it must be htmlspecialchars()'ed).
         * @param array $v The record
-        * @param bool $ext_pArrPages (Ignore)
+        * @param bool $ext_pArrPages (ignored)
         * @return string Wrapping title string.
         */
-       public function wrapTitle($title, $v, $ext_pArrPages = '') {
+       public function wrapTitle($title, $v, $ext_pArrPages = FALSE) {
                if ($this->ext_isLinkable($v['doktype'], $v['uid'])) {
-                       $aOnClick = 'return link_typo3Page(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($v['uid']) . ');';
+                       $aOnClick = 'return link_typo3Page(' . GeneralUtility::quoteJSvalue($v['uid']) . ');';
                        return '<span class="list-tree-title"><a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $title . '</a></span>';
                } else {
                        return '<span class="list-tree-title text-muted">' . $title . '</span>';
@@ -59,7 +71,7 @@ class ElementBrowserPageTreeView extends BrowseTreeView {
        /**
         * Create the page navigation tree in HTML
         *
-        * @param array $treeArr Tree array
+        * @param array|string $treeArr Tree array
         * @return string HTML output.
         */
        public function printTree($treeArr = '') {
@@ -87,7 +99,7 @@ class ElementBrowserPageTreeView extends BrowseTreeView {
                                $selected = ' bg-success';
                                $classAttr .= ' active';
                        }
-                       $aOnClick = 'return jumpToUrl(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=' . $GLOBALS['SOBE']->browser->act . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&expandPage=' . $treeItem['row']['uid']) . ');';
+                       $aOnClick = 'return jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=' . $GLOBALS['SOBE']->browser->act . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&expandPage=' . $treeItem['row']['uid']) . ');';
                        $cEbullet = $this->ext_isLinkable($treeItem['row']['doktype'], $treeItem['row']['uid']) ? '<a href="#" class="list-tree-show" onclick="' . htmlspecialchars($aOnClick) . '"><i class="fa fa-caret-square-o-right"></i></a>' : '';
                        $out .= '
                                <li' . ($classAttr ? ' class="' . trim($classAttr) . '"' : '') . '>
@@ -126,9 +138,7 @@ class ElementBrowserPageTreeView extends BrowseTreeView {
         * @return bool
         */
        public function ext_isLinkable($doktype, $uid) {
-               if ($uid && $doktype < 199) {
-                       return TRUE;
-               }
+               return $uid && $doktype < PageRepository::DOKTYPE_SPACER;
        }
 
        /**
@@ -136,18 +146,16 @@ class ElementBrowserPageTreeView extends BrowseTreeView {
         *
         * @param string $icon HTML string to wrap, probably an image tag.
         * @param string $cmd Command for 'PM' get var
-        * @param bool $bMark If set, the link will have an anchor point (=$bMark) and a name attribute (=$bMark)
+        * @param string $bMark If set, the link will have an anchor point (=$bMark) and a name attribute (=$bMark)
         * @param bool $isOpen
         * @return string Link-wrapped input string
         */
        public function PM_ATagWrap($icon, $cmd, $bMark = '', $isOpen = FALSE) {
-               $name = '';
-               if ($bMark) {
-                       $anchor = '#' . $bMark;
-                       $name = ' name=' . $bMark;
-               }
-               $aOnClick = 'return jumpToUrl(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($this->getThisScript() . 'PM=' . $cmd) . ',' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($anchor) . ');';
-               return '<a class="list-tree-control ' . ($isOpen ? 'list-tree-control-open' : 'list-tree-control-closed') . '" href="#"' . htmlspecialchars($name) . ' onclick="' . htmlspecialchars($aOnClick) . '"><i class="fa"></i></a>';
+               $anchor = $bMark ? '#' . $bMark : '';
+               $name = $bMark ? ' name=' . $bMark : '';
+               $aOnClick = 'return jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . 'PM=' . $cmd) . ',' . GeneralUtility::quoteJSvalue($anchor) . ');';
+               return '<a class="list-tree-control ' . ($isOpen ? 'list-tree-control-open' : 'list-tree-control-closed')
+                       . '" href="#"' . htmlspecialchars($name) . ' onclick="' . htmlspecialchars($aOnClick) . '"><i class="fa"></i></a>';
        }
 
        /**
index 9386847..5ca8972 100644 (file)
@@ -13,7 +13,10 @@ namespace TYPO3\CMS\Backend\Tree\View;
  *
  * The TYPO3 project - inspiring people to share!
  */
-use \TYPO3\CMS\Core\Utility\GeneralUtility;
+
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Lang\LanguageService;
+
 /**
  * Generate a page-tree, non-browsable.
  */
@@ -54,6 +57,11 @@ class PageTreeView extends AbstractTreeView {
        public $table = 'pages';
 
        /**
+        * @var bool
+        */
+       public $ext_showNavTitle = FALSE;
+
+       /**
         * Init function
         * REMEMBER to feed a $clause which will filter out non-readable pages!
         *
@@ -112,14 +120,16 @@ class PageTreeView extends AbstractTreeView {
         * @return string The title.
         */
        public function getTitleStr($row, $titleLen = 30) {
+               /** @var LanguageService $lang */
+               $lang = $GLOBALS['LANG'];
                if ($this->ext_showNavTitle && trim($row['nav_title']) !== '') {
-                       $title = '<span title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_tca.xlf:title', TRUE) . ' ' . htmlspecialchars(trim($row['title'])) . '">' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($row['nav_title'], $titleLen)) . '</span>';
+                       $title = '<span title="' . $lang->sL('LLL:EXT:lang/locallang_tca.xlf:title', TRUE) . ' ' . htmlspecialchars(trim($row['title'])) . '">' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($row['nav_title'], $titleLen)) . '</span>';
                } else {
                        $title = htmlspecialchars(GeneralUtility::fixed_lgd_cs($row['title'], $titleLen));
                        if (trim($row['nav_title']) !== '') {
-                               $title = '<span title="' . $GLOBALS['LANG']->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.nav_title', TRUE) . ' ' . htmlspecialchars(trim($row['nav_title'])) . '">' . $title . '</span>';
+                               $title = '<span title="' . $lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.nav_title', TRUE) . ' ' . htmlspecialchars(trim($row['nav_title'])) . '">' . $title . '</span>';
                        }
-                       $title = trim($row['title']) === '' ? '<em>[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title', TRUE) . ']</em>' : $title;
+                       $title = trim($row['title']) === '' ? '<em>[' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title', TRUE) . ']</em>' : $title;
                }
                return $title;
        }
index 8797ff9..b75706a 100644 (file)
@@ -14,18 +14,25 @@ namespace TYPO3\CMS\Backend\View;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Backend\Tree\View\BrowseTreeView;
+use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
  * Browse pages in Web module
  */
-class PageTreeView extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
+class PageTreeView extends BrowseTreeView {
 
        /**
         * @var bool
         */
-       public $ext_showPageId;
+       public $ext_showPageId = FALSE;
+
+       /**
+        * @var bool
+        */
+       public $ext_showNavTitle = FALSE;
 
        /**
         * @var string
@@ -65,7 +72,7 @@ class PageTreeView extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
         */
        public function wrapIcon($thePageIcon, &$row) {
                // If the record is locked, present a warning sign.
-               if ($lockInfo = \TYPO3\CMS\Backend\Utility\BackendUtility::isRecordLocked('pages', $row['uid'])) {
+               if ($lockInfo = BackendUtility::isRecordLocked('pages', $row['uid'])) {
                        $aOnClick = 'alert(' . GeneralUtility::quoteJSvalue($lockInfo['msg']) . ');return false;';
                        $lockIcon = '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . IconUtility::getSpriteIcon('status-warning-in-use', array('title' => $lockInfo['msg'])) . '</a>';
                } else {
@@ -73,7 +80,7 @@ class PageTreeView extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
                }
                // Wrap icon in click-menu link.
                if (!$this->ext_IconMode) {
-                       $thePageIcon = $GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon($thePageIcon, 'pages', $row['uid'], 0, '&bank=' . $this->bank);
+                       $thePageIcon = $this->getDocumentTemplate()->wrapClickMenuOnIcon($thePageIcon, 'pages', $row['uid'], 0, '&bank=' . $this->bank);
                } elseif ($this->ext_IconMode === 'titlelink') {
                        $aOnClick = 'return jumpTo(' . GeneralUtility::quoteJSvalue($this->getJumpToParam($row)) . ',this,' . GeneralUtility::quoteJSvalue($this->treeName) . ');';
                        $thePageIcon = '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $thePageIcon . '</a>';
@@ -115,7 +122,7 @@ class PageTreeView extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
                        unset($_params);
                }
                $aOnClick = 'return jumpTo(' . GeneralUtility::quoteJSvalue($this->getJumpToParam($row)) . ',this,' . GeneralUtility::quoteJSvalue($this->domIdPrefix . $this->getId($row)) . ',' . $bank . ');';
-               $clickMenuParts = $GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon('', 'pages', $row['uid'], 0, ('&bank=' . $this->bank), '', TRUE);
+               $clickMenuParts = $this->getDocumentTemplate()->wrapClickMenuOnIcon('', 'pages', $row['uid'], 0, ('&bank=' . $this->bank), '', TRUE);
 
                $thePageTitle = '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '"' . GeneralUtility::implodeAttributes($clickMenuParts) . '>' . $title . '</a>';
                // Wrap title in a drag/drop span.
@@ -125,7 +132,7 @@ class PageTreeView extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
        /**
         * Compiles the HTML code for displaying the structure found inside the ->tree array
         *
-        * @param array $treeArr "tree-array" - if blank string, the internal ->tree array is used.
+        * @param array|string $treeArr "tree-array" - if blank string, the internal ->tree array is used.
         * @return string The HTML code for the tree
         */
        public function printTree($treeArr = '') {
@@ -141,12 +148,14 @@ class PageTreeView extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
                        $PM = substr($PM, 0, $PMpos);
                }
                $PM = explode('_', $PM);
+
+               $doCollapse = FALSE;
+               $doExpand = FALSE;
+               $expandedPageUid = NULL;
+               $collapsedPageUid = NULL;
                if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX && is_array($PM) && count($PM) === 4 && $PM[2] != 0) {
                        if ($PM[1]) {
                                $expandedPageUid = $PM[2];
-                               $ajaxOutput = '';
-                               // We don't know yet. Will be set later.
-                               $invertedDepthOfAjaxRequestedItem = 0;
                                $doExpand = TRUE;
                        } else {
                                $collapsedPageUid = $PM[2];
@@ -156,6 +165,8 @@ class PageTreeView extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
                // We need to count the opened <ul>'s every time we dig into another level,
                // so we know how many we have to close when all children are done rendering
                $closeDepth = array();
+               $ajaxOutput = '';
+               $invertedDepthOfAjaxRequestedItem = 0;
                foreach ($treeArr as $k => $treeItem) {
                        $classAttr = $treeItem['row']['_CSSCLASS'];
                        $uid = $treeItem['row']['uid'];
@@ -163,7 +174,7 @@ class PageTreeView extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
                        $itemHTML = '';
                        // If this item is the start of a new level,
                        // then a new level <ul> is needed, but not in ajax mode
-                       if ($treeItem['isFirst'] && !$doCollapse && !($doExpand && $expandedPageUid == $uid)) {
+                       if ($treeItem['isFirst'] && !$doCollapse && (!$doExpand || (int)$expandedPageUid !== (int)$uid)) {
                                $itemHTML = '<ul class="list-tree">';
                        }
 
@@ -171,7 +182,9 @@ class PageTreeView extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
                        if ($treeItem['hasSub']) {
                                $classAttr .= ' list-tree-control-open';
                        }
-                       $itemHTML .= '<li id="' . $idAttr . '" ' . ($classAttr ? ' class="' . trim($classAttr) . '"' : '') . '><span class="list-tree-group">' . $treeItem['HTML'] . $this->wrapTitle($this->getTitleStr($treeItem['row'], $titleLen), $treeItem['row'], $treeItem['bank']) . '</span>';
+                       $itemHTML .= '<li id="' . $idAttr . '" ' . ($classAttr ? ' class="' . trim($classAttr) . '"' : '')
+                               . '><span class="list-tree-group">' . $treeItem['HTML']
+                               . $this->wrapTitle($this->getTitleStr($treeItem['row'], $titleLen), $treeItem['row'], $treeItem['bank']) . '</span>';
                        if (!$treeItem['hasSub']) {
                                $itemHTML .= '</li>';
                        }
@@ -190,12 +203,12 @@ class PageTreeView extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
                                }
                        }
                        // Ajax request: collapse
-                       if ($doCollapse && $collapsedPageUid == $uid) {
+                       if ($doCollapse && (int)$collapsedPageUid === (int)$uid) {
                                $this->ajaxStatus = TRUE;
                                return $itemHTML;
                        }
                        // ajax request: expand
-                       if ($doExpand && $expandedPageUid == $uid) {
+                       if ($doExpand && (int)$expandedPageUid === (int)$uid) {
                                $ajaxOutput .= $itemHTML;
                                $invertedDepthOfAjaxRequestedItem = $treeItem['invertedDepth'];
                        } elseif ($invertedDepthOfAjaxRequestedItem) {
@@ -243,7 +256,8 @@ class PageTreeView extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
         *
         * @param string $icon HTML string to wrap, probably an image tag.
         * @param string $cmd Command for 'PM' get var
-        * @return bool $isExpand Link-wrapped input string
+        * @param bool $isExpand Link-wrapped input string
+        * @return string
         * @access private
         */
        public function PMiconATagWrap($icon, $cmd, $isExpand = TRUE) {
@@ -266,9 +280,9 @@ class PageTreeView extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
                // Get stored tree structure AND updating it if needed according to incoming PM GET var.
                $this->initializePositionSaving();
                // Init done:
-               $titleLen = (int)$this->BE_USER->uc['titleLen'];
                $treeArr = array();
                // Traverse mounts:
+               $firstHtml = '';
                foreach ($this->MOUNTS as $idx => $uid) {
                        // Set first:
                        $this->bank = $idx;
@@ -281,7 +295,8 @@ class PageTreeView extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
                        if ($uid) {
                                // Set PM icon for root of mount:
                                $cmd = $this->bank . '_' . ($isOpen ? '0_' : '1_') . $uid . '_' . $this->treeName;
-                               $firstHtml = '<a class="list-tree-control list-tree-control-' . ($isOpen ? 'open' : 'closed') . '" href="' . htmlspecialchars($this->getThisScript() . 'PM=' . $cmd) . '"><i class="fa"></i></a>';
+                               $firstHtml = '<a class="list-tree-control list-tree-control-' . ($isOpen ? 'open' : 'closed')
+                                       . '" href="' . htmlspecialchars($this->getThisScript() . 'PM=' . $cmd) . '"><i class="fa"></i></a>';
                        }
                        // Preparing rootRec for the mount
                        if ($uid) {
@@ -312,4 +327,13 @@ class PageTreeView extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
                return $this->printTree($treeArr);
        }
 
+       /**
+        * Returns an instance of DocumentTemplate
+        *
+        * @return \TYPO3\CMS\Backend\Template\DocumentTemplate
+        */
+       protected function getDocumentTemplate() {
+               return $GLOBALS['TBE_TEMPLATE'];
+       }
+
 }
index 06b022b..7bfaebd 100755 (executable)
@@ -183,7 +183,7 @@ class ElementBrowser {
         *
         * Values:
         * 0: form field name reference, eg. "data[tt_content][123][image]"
-        * 1: htmlArea RTE parameters: editorNo:contentTypo3Language:contentTypo3Charset
+        * 1: htmlArea RTE parameters: editorNo:contentTypo3Language
         * 2: RTE config parameters: RTEtsConfigParams
         * 3: allowed types. Eg. "tt_content" or "gif,jpg,jpeg,tif,bmp,pcx,tga,png,pdf,ai"
         * 4: IRRE uniqueness: target level object-id to perform actions/checks on, eg. "data[79][tt_address][1][<field>][<foreign_table>]"
@@ -555,7 +555,7 @@ class ElementBrowser {
                        }
                ' . $this->doc->redirectUrls();
                // Functions used, if the link selector is in wizard mode (= TCEforms fields)
-               if ($this->mode == 'wizard') {
+               if ($this->mode === 'wizard') {
                        if (!$this->areFieldChangeFunctionsValid() && !$this->areFieldChangeFunctionsValid(TRUE)) {
                                $this->P['fieldChangeFunc'] = array();
                        }
@@ -854,9 +854,7 @@ class ElementBrowser {
                                }
                                break;
                        case 'file':
-
                        case 'filedrag':
-
                        case 'folder':
                                if (isset($this->expandFolder)) {
                                        $data['expandFolder'] = $this->expandFolder;
@@ -1103,45 +1101,46 @@ class ElementBrowser {
        /**
         * Returns an array definition of the top menu
         *
-        * @param $wiz
-        * @param $allowedItems
+        * @param bool $wiz
+        * @param array $allowedItems
         * @return mixed[][]
         */
        protected function buildMenuArray($wiz, $allowedItems) {
+               $lang = $this->getLanguageService();
+
                // Making menu in top:
                $menuDef = array();
-               $lang = $this->getLanguageService();
                if (!$wiz) {
                        $menuDef['removeLink']['isActive'] = $this->act === 'removeLink';
                        $menuDef['removeLink']['label'] = $lang->getLL('removeLink', TRUE);
                        $menuDef['removeLink']['url'] = '#';
                        $menuDef['removeLink']['addParams'] = 'onclick="self.parent.parent.renderPopup_unLink();return false;"';
                }
-               if (in_array('page', $allowedItems)) {
+               if (in_array('page', $allowedItems, TRUE)) {
                        $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') . ');return false;"';
                }
-               if (in_array('file', $allowedItems)) {
+               if (in_array('file', $allowedItems, TRUE)) {
                        $menuDef['file']['isActive'] = $this->act === 'file';
                        $menuDef['file']['label'] = $lang->getLL('file', TRUE);
                        $menuDef['file']['url'] = '#';
                        $menuDef['file']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=file') . ');return false;"';
                }
-               if (in_array('folder', $allowedItems)) {
+               if (in_array('folder', $allowedItems, TRUE)) {
                        $menuDef['folder']['isActive'] = $this->act === 'folder';
                        $menuDef['folder']['label'] = $lang->getLL('folder', TRUE);
                        $menuDef['folder']['url'] = '#';
                        $menuDef['folder']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=folder') . ');return false;"';
                }
-               if (in_array('url', $allowedItems)) {
+               if (in_array('url', $allowedItems, TRUE)) {
                        $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') . ');return false;"';
                }
-               if (in_array('mail', $allowedItems)) {
+               if (in_array('mail', $allowedItems, TRUE)) {
                        $menuDef['mail']['isActive'] = $this->act === 'mail';
                        $menuDef['mail']['label'] = $lang->getLL('email', TRUE);
                        $menuDef['mail']['url'] = '#';
@@ -1222,9 +1221,7 @@ class ElementBrowser {
                $folderTree->thisScript = $this->thisScript;
                $tree = $folderTree->getBrowsableTree();
                $backendUser = $this->getBackendUser();
-               if (!$this->curUrlInfo['value'] || $this->curUrlInfo['act'] != $this->act) {
-                       $cmpPath = '';
-               } else {
+               if ($this->curUrlInfo['value'] && $this->curUrlInfo['act'] === $this->act) {
                        $cmpPath = $this->curUrlInfo['value'];
                        if (!isset($this->expandFolder)) {
                                $this->expandFolder = $cmpPath;
@@ -1312,8 +1309,8 @@ class ElementBrowser {
                /** @var ElementBrowserPageTreeView $pageTree */
                $pageTree = GeneralUtility::makeInstance($treeClassName);
                $pageTree->thisScript = $this->thisScript;
-               $pageTree->ext_showPageId = $backendUser->getTSConfigVal('options.pageTree.showPageIdWithTitle');
-               $pageTree->ext_showNavTitle = $backendUser->getTSConfigVal('options.pageTree.showNavTitle');
+               $pageTree->ext_showPageId = (bool)$backendUser->getTSConfigVal('options.pageTree.showPageIdWithTitle');
+               $pageTree->ext_showNavTitle = (bool)$backendUser->getTSConfigVal('options.pageTree.showNavTitle');
                $pageTree->addField('nav_title');
                $tree = $pageTree->getBrowsableTree();
                $cElements = $this->expandPage();
@@ -1353,9 +1350,9 @@ class ElementBrowser {
                /** @var \TYPO3\CMS\Recordlist\Tree\View\ElementBrowserPageTreeView $pageTree */
                $pageTree = GeneralUtility::makeInstance(\TYPO3\CMS\Recordlist\Tree\View\ElementBrowserPageTreeView::class);
                $pageTree->thisScript = $this->thisScript;
-               $pageTree->ext_pArrPages = $tables === 'pages' ? 1 : 0;
-               $pageTree->ext_showNavTitle = $backendUser->getTSConfigVal('options.pageTree.showNavTitle');
-               $pageTree->ext_showPageId = $backendUser->getTSConfigVal('options.pageTree.showPageIdWithTitle');
+               $pageTree->ext_pArrPages = $tables === 'pages';
+               $pageTree->ext_showNavTitle = (bool)$backendUser->getTSConfigVal('options.pageTree.showNavTitle');
+               $pageTree->ext_showPageId = (bool)$backendUser->getTSConfigVal('options.pageTree.showPageIdWithTitle');
                $pageTree->addField('nav_title');
 
                $withTree = TRUE;
@@ -1618,7 +1615,8 @@ class ElementBrowser {
                        $expPageId = $this->curUrlInfo['pageid'];
                }
                // Draw the record list IF there is a page id to expand:
-               if ($expPageId
+               if (
+                       $expPageId
                        && MathUtility::canBeInterpretedAsInteger($expPageId)
                        && $this->getBackendUser()->isInWebMount($expPageId)
                ) {
@@ -1646,7 +1644,6 @@ class ElementBrowser {
                                '',
                                'colPos,sorting'
                        );
-                       $cc = $db->sql_num_rows($res);
                        // Traverse list of records:
                        $c = 0;
                        while ($row = $db->sql_fetch_assoc($res)) {
@@ -1932,7 +1929,7 @@ class ElementBrowser {
                                </tr>';
                }
                // Traverse the filelist:
-               /** @var $fileObject \TYPO3\CMS\Core\Resource\File */
+               /** @var $fileObject File */
                foreach ($files as $fileObject) {
                        $fileExtension = $fileObject->getExtension();
                        // Thumbnail/size generation:
@@ -2621,7 +2618,7 @@ class ElementBrowser {
         *
         * @param Folder $folder
         * @param string $extensionList
-        * @return \TYPO3\CMS\Core\Resource\File[]
+        * @return File[]
         */
        protected function getFilesInFolder(Folder $folder, $extensionList) {
                if ($extensionList !== '') {
@@ -2661,7 +2658,6 @@ class ElementBrowser {
                if ($this->pageRenderer === NULL) {
                        $this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
                }
-
                return $this->pageRenderer;
        }
 
index b0748e8..5c2601f 100644 (file)
@@ -14,6 +14,10 @@ namespace TYPO3\CMS\Recordlist\Tree\View;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Backend\Utility\IconUtility;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Recordlist\Controller\ElementBrowserController;
+
 /**
  * Extension class for the TBE record browser
  */
@@ -40,10 +44,12 @@ class ElementBrowserPageTreeView extends \TYPO3\CMS\Backend\Tree\View\ElementBro
         */
        public function wrapTitle($title, $v, $ext_pArrPages) {
                if ($ext_pArrPages) {
-                       $ficon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', $v);
-                       $onClick = 'return insertElement(\'pages\', \'' . $v['uid'] . '\', \'db\', ' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($v['title']) . ', \'\', \'\', ' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($ficon) . ',\'\',1);';
+                       $ficon = IconUtility::getSpriteIconForRecord('pages', $v);
+                       $onClick = 'return insertElement(\'pages\', \'' . $v['uid'] . '\', \'db\', ' . GeneralUtility::quoteJSvalue($v['title']) . ', \'\', \'\', ' . GeneralUtility::quoteJSvalue($ficon) . ',\'\',1);';
                } else {
-                       $onClick = 'return jumpToUrl(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=' . $GLOBALS['SOBE']->browser->act . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&expandPage=' . $v['uid']) . ');';
+                       /** @var ElementBrowserController $controller */
+                       $controller = $GLOBALS['SOBE'];
+                       $onClick = 'return jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=' . $controller->browser->act . '&mode=' . $controller->browser->mode . '&expandPage=' . $v['uid']) . ');';
                }
                return '<a href="#" onclick="' . htmlspecialchars($onClick) . '">' . $title . '</a>';
        }
index 638ee39..9291941 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Rtehtmlarea;
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
+use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Lang\LanguageService;
 use TYPO3\CMS\Recordlist\Browser\ElementBrowser;
@@ -25,14 +26,18 @@ use TYPO3\CMS\Recordlist\Browser\ElementBrowser;
  */
 class BrowseLinks extends ElementBrowser {
 
+       /**
+        * @var int
+        */
        public $editorNo;
+
        /**
         * TYPO3 language code of the content language
+        *
+        * @var int
         */
        public $contentTypo3Language;
 
-       public $contentTypo3Charset = 'utf-8';
-
        /**
         * Language service object for localization to the content language
         *
@@ -40,26 +45,59 @@ class BrowseLinks extends ElementBrowser {
         */
        protected $contentLanguageService;
 
+       /**
+        * @var array
+        */
        public $additionalAttributes = array();
 
+       /**
+        * @var array
+        */
        public $buttonConfig = array();
 
+       /**
+        * @var array
+        */
        public $RTEProperties = array();
 
+       /**
+        * @var array
+        */
        public $anchorTypes = array('page', 'url', 'file', 'mail');
 
+       /**
+        * @var array
+        */
        public $classesAnchorDefault = array();
 
+       /**
+        * @var array
+        */
        public $classesAnchorDefaultTitle = array();
 
+       /**
+        * @var array
+        */
        public $classesAnchorClassTitle = array();
 
+       /**
+        * @var array
+        */
        public $classesAnchorDefaultTarget = array();
 
+       /**
+        * @var array
+        */
        public $classesAnchorJSOptions = array();
 
+       /**
+        * @var
+        */
        protected $defaultLinkTarget;
 
+       /**
+        * @var
+        */
        public $allowedItems;
 
        /**
@@ -114,7 +152,7 @@ class BrowseLinks extends ElementBrowser {
                        $this->contentTypo3Language = GeneralUtility::_GP('contentTypo3Language');
                        $this->RTEtsConfigParams = GeneralUtility::_GP('RTEtsConfigParams');
                }
-               $pArr[1] = implode(':', array($this->editorNo, $this->contentTypo3Language, $this->contentTypo3Charset));
+               $pArr[1] = implode(':', array($this->editorNo, $this->contentTypo3Language));
                $pArr[2] = $this->RTEtsConfigParams;
                $this->bparams = implode('|', $pArr);
        }
@@ -138,8 +176,7 @@ class BrowseLinks extends ElementBrowser {
                parent::initDocumentTemplate();
                $this->doc->getContextMenuCode();
                // Apply the same styles as those of the base script
-               $this->doc->bodyTagId = 'typo3-browse-links-php';
-               $this->getPageRenderer()->addCssFile(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('t3skin') . 'rtehtmlarea/htmlarea.css');
+               $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) {
@@ -406,7 +443,10 @@ class BrowseLinks extends ElementBrowser {
                        }
                ';
                // 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'])) {
+               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'])
+               ) {
                        $conf = array();
                        $_params = array(
                                'conf' => &$conf
@@ -610,17 +650,10 @@ class BrowseLinks extends ElementBrowser {
         * @return string The HTML code of the form
         */
        public function addAttributesForm($rows = '') {
-               $ltargetForm = '';
-               $additionalAttributeFields = '';
-               // Add page id, target, class selector box, title and parameters fields:
-               $lpageId = $this->addPageIdSelector();
-               $queryParameters = $this->addQueryParametersSelector();
-               $ltarget = $this->addTargetSelector();
-               $lclass = $this->addClassSelector();
-               $ltitle = $this->addTitleSelector();
-               $rel = $this->addRelField();
                // additional fields for links
-               if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']['addAttributeFields'])
+               $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'])
                ) {
                        $conf = array();
@@ -632,6 +665,16 @@ class BrowseLinks extends ElementBrowser {
                                $additionalAttributeFields .= $processor->getAttributefields($_params, $this);
                        }
                }
+
+               // Add page id, target, class selector box, title and parameters fields:
+               $lpageId = $this->addPageIdSelector();
+               $queryParameters = $this->addQueryParametersSelector();
+               $ltarget = $this->addTargetSelector();
+               $lclass = $this->addClassSelector();
+               $ltitle = $this->addTitleSelector();
+               $rel = $this->addRelField();
+
+               $ltargetForm = '';
                if ($rows || $lpageId || $queryParameters || $lclass || $ltitle || $ltarget || $rel) {
                        $ltargetForm = $this->wrapInForm($rows . $lpageId . $queryParameters . $lclass . $ltitle . $ltarget . $rel . $additionalAttributeFields);
                }
@@ -658,7 +701,7 @@ class BrowseLinks extends ElementBrowser {
                                                </td>
                                                <td colspan="3">
                                                        <input class="btn btn-default" type="submit" value="' . $this->getLanguageService()->getLL('update', TRUE) . '" onclick="'
-                                                               . ($this->act == 'url' ? 'browse_links_setAdditionalValue(\'data-htmlarea-external\', \'1\'); ' : '')
+                                                               . ($this->act === 'url' ? 'browse_links_setAdditionalValue(\'data-htmlarea-external\', \'1\'); ' : '')
                                                                . 'return link_current();" />
                                                </td>
                                        </tr>';
index 9e3be01..f21501e 100644 (file)
@@ -21,17 +21,20 @@ namespace TYPO3\CMS\Rtehtmlarea;
  *
  * Adapted for htmlArea RTE by Stanislas Rolland
  */
+
+use TYPO3\CMS\Backend\Tree\View\ElementBrowserPageTreeView;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Rtehtmlarea\Controller\BrowseLinksController;
 
 /**
  * Class which generates the page tree
  */
-class PageTree extends \TYPO3\CMS\Backend\Tree\View\ElementBrowserPageTreeView {
+class PageTree extends ElementBrowserPageTreeView {
 
        /**
         * Create the page navigation tree in HTML
         *
-        * @param array Tree array
+        * @param array|string $treeArr Tree array
         * @return string HTML output.
         */
        public function printTree($treeArr = '') {
@@ -54,14 +57,21 @@ class PageTree extends \TYPO3\CMS\Backend\Tree\View\ElementBrowserPageTreeView {
                        }
 
                        $selected = '';
-                       if ($GLOBALS['SOBE']->browser->curUrlInfo['act'] == 'page' && $GLOBALS['SOBE']->browser->curUrlInfo['pageid'] == $treeItem['row']['uid'] && $GLOBALS['SOBE']->browser->curUrlInfo['pageid']) {
-                               $classAttr .= ' active';
+                       /** @var BrowseLinksController $controller */
+                       $controller = $GLOBALS['SOBE'];
+                       if ($controller->browser->curUrlInfo['act'] === 'page' && $controller->browser->curUrlInfo['pageid'] == $treeItem['row']['uid'] && $controller->browser->curUrlInfo['pageid']) {
+                               $selected = ' bg-success';
                        }
-                       $aOnClick = 'return jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=' . $GLOBALS['SOBE']->browser->act . '&editorNo=' . $GLOBALS['SOBE']->browser->editorNo . '&contentTypo3Language=' . $GLOBALS['SOBE']->browser->contentTypo3Language . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&expandPage=' . $treeItem['row']['uid']) . ');';
-                       $cEbullet = $this->ext_isLinkable($treeItem['row']['doktype'], $treeItem['row']['uid']) ? '<a href="#" class="list-tree-show" onclick="' . htmlspecialchars($aOnClick) . '"><i class="fa fa-caret-square-o-right"></i></a>' : '';
+                       $aOnClick = 'return jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript()
+                                       . 'act=' . $controller->browser->act . '&editorNo=' . $controller->browser->editorNo
+                                       . '&contentTypo3Language=' . $controller->browser->contentTypo3Language
+                                       . '&mode=' . $controller->browser->mode . '&expandPage=' . $treeItem['row']['uid']) . ');';
+                       $cEbullet = $this->ext_isLinkable($treeItem['row']['doktype'], $treeItem['row']['uid'])
+                               ? '<a href="#" class="pull-right" onclick="' . htmlspecialchars($aOnClick) . '"><i class="fa fa-caret-square-o-right"></i></a>'
+                               : '';
                        $out .= '
                                <li' . ($classAttr ? ' class="' . trim($classAttr) . '"' : '') . '>
-                                       <span class="list-tree-group">
+                                       <span class="list-tree-group' . $selected . '">
                                                ' . $cEbullet . '
                                                <span class="list-tree-icon">' . $treeItem['HTML'] . '</span>
                                                ' . $this->wrapTitle($this->getTitleStr($treeItem['row'], $titleLen), $treeItem['row'], $this->ext_pArrPages) . '
@@ -86,8 +96,7 @@ class PageTree extends \TYPO3\CMS\Backend\Tree\View\ElementBrowserPageTreeView {
                                }
                        }
                }
-               $out = '<ul class="list-tree list-tree-root">' . $out . '</ul>';
-               return $out;
+               return '<ul class="list-tree list-tree-root">' . $out . '</ul>';
        }
 
 }
index cdbd412..84c9f67 100644 (file)
@@ -17,10 +17,14 @@ namespace TYPO3\CMS\Rtehtmlarea;
 use TYPO3\CMS\Backend\Tree\View\ElementBrowserFolderTreeView;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
+use TYPO3\CMS\Core\Resource;
+use TYPO3\CMS\Core\Resource\File;
+use TYPO3\CMS\Core\Resource\FileInterface;
+use TYPO3\CMS\Core\Resource\Folder;
+use TYPO3\CMS\Core\Resource\ResourceFactory;
 use TYPO3\CMS\Core\Resource\Service\MagicImageService;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Resource;
 use TYPO3\CMS\Lang\LanguageService;
 use TYPO3\CMS\Recordlist\Browser\ElementBrowser;
 
@@ -46,10 +50,19 @@ class SelectImage extends ElementBrowser {
         */
        public $content;
 
+       /**
+        * @var array
+        */
        public $allowedItems;
 
+       /**
+        * @var array
+        */
        public $allowedFileTypes = array();
 
+       /**
+        * @var string
+        */
        protected $defaultClass;
 
        /**
@@ -66,20 +79,33 @@ class SelectImage extends ElementBrowser {
         */
        protected $plainMaxHeight;
 
+       /**
+        * @var string
+        */
        protected $imgPath;
 
+       /**
+        * @var int
+        */
        public $editorNo;
 
+       /**
+        * @var int
+        */
        public $sys_language_content;
 
+       /**
+        * @var array
+        */
        public $thisConfig;
 
+       /**
+        * @var array
+        */
        public $buttonConfig;
 
-       protected $imgObj;
-
        /**
-        * @var string
+        * @var bool
         */
        public $addModifyTab;
 
@@ -111,7 +137,7 @@ class SelectImage extends ElementBrowser {
                if (!$this->act) {
                        $this->act = FALSE;
                }
-               $this->addModifyTab = GeneralUtility::_GP('addModifyTab');
+               $this->addModifyTab = (bool)GeneralUtility::_GP('addModifyTab');
                // Process bparams
                $pArr = explode('|', $this->bparams);
                $pRteArr = explode(':', $pArr[1]);
@@ -140,7 +166,7 @@ class SelectImage extends ElementBrowser {
        protected function initDocumentTemplate() {
                parent::initDocumentTemplate();
 
-               $this->doc->bodyTagId = 'typo3-browse-links-php';
+               $this->doc->bodyTagAdditions = 'onload="SelectImage.initEventListeners();"';
                $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/LegacyTree', 'function(Tree) {
                        Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
                }');
@@ -156,63 +182,53 @@ class SelectImage extends ElementBrowser {
        }
 
        /**
-        * Provide the additional parameters to be included in the template body tag
-        *
-        * @return string the body tag additions
-        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
-        */
-       public function getBodyTagAdditions() {
-               GeneralUtility::logDeprecatedFunction();
-               return 'onload="SelectImage.initEventListeners();"';
-       }
-
-       /**
         * Insert the image in the editing area
         *
         * @return void
         */
        protected function insertImage() {
                $uidList = (string)GeneralUtility::_GP('uidList');
-               if (GeneralUtility::_GP('insertImage') && $uidList) {
-                       $uids = explode('|', $uidList);
-                       $insertJsStatements = array();
-                       foreach ($uids as $uid) {
-                               /** @var $fileObject Resource\File */
-                               $fileObject = Resource\ResourceFactory::getInstance()->getFileObject((int)$uid);
-                               // Get default values for alt and title attributes from file properties
-                               $altText = $fileObject->getProperty('alternative');
-                               $titleText = $fileObject->getProperty('title');
-                               switch ($this->act) {
-                                       case 'magic':
-                                               $insertJsStatements[] = $this->insertMagicImage($fileObject, $altText, $titleText, 'data-htmlarea-file-uid="' . $uid . '"');
-                                               break;
-                                       case 'plain':
-                                               $insertJsStatements[] = $this->insertPlainImage($fileObject, $altText, $titleText, 'data-htmlarea-file-uid="' . $uid . '"');
-                                               break;
-                                       default:
-                                               // Call hook
-                                               foreach ($this->hookObjects as $hookObject) {
-                                                       if (method_exists($hookObject, 'insertElement')) {
-                                                               $hookObject->insertElement($this->act);
-                                                       }
+               if (!GeneralUtility::_GP('insertImage') || !$uidList) {
+                       return;
+               }
+               $uids = explode('|', $uidList);
+               $insertJsStatements = array();
+               foreach ($uids as $uid) {
+                       /** @var $fileObject File */
+                       $fileObject = ResourceFactory::getInstance()->getFileObject((int)$uid);
+                       // Get default values for alt and title attributes from file properties
+                       $altText = $fileObject->getProperty('alternative');
+                       $titleText = $fileObject->getProperty('title');
+                       switch ($this->act) {
+                               case 'magic':
+                                       $insertJsStatements[] = $this->insertMagicImage($fileObject, $altText, $titleText, 'data-htmlarea-file-uid="' . $uid . '"');
+                                       break;
+                               case 'plain':
+                                       $insertJsStatements[] = $this->insertPlainImage($fileObject, $altText, $titleText, 'data-htmlarea-file-uid="' . $uid . '"');
+                                       break;
+                               default:
+                                       // Call hook
+                                       foreach ($this->hookObjects as $hookObject) {
+                                               if (method_exists($hookObject, 'insertElement')) {
+                                                       $hookObject->insertElement($this->act);
                                                }
-                               }
+                                       }
                        }
-                       $this->insertImages($insertJsStatements);
-                       die;
                }
+               $this->insertImages($insertJsStatements);
+               die;
        }
 
        /**
         * Insert a magic image
         *
-        * @param Resource\File $fileObject: the image file
+        * @param File $fileObject: the image file
         * @param string $altText: text for the alt attribute of the image
         * @param string $titleText: text for the title attribute of the image
         * @param string $additionalParams: text representing more HTML attributes to be added on the img tag
         * @return string the magic image JS insertion statement
         */
-       public function insertMagicImage(Resource\File $fileObject, $altText = '', $titleText = '', $additionalParams = '') {
+       public function insertMagicImage(File $fileObject, $altText = '', $titleText = '', $additionalParams = '') {
                // Create the magic image service
                /** @var $magicImageService MagicImageService */
                $magicImageService = GeneralUtility::makeInstance(MagicImageService::class);
@@ -241,7 +257,7 @@ class SelectImage extends ElementBrowser {
         * @param string $additionalParams: text representing more HTML attributes to be added on the img tag
         * @return string the plain image JS insertion statement
         */
-       public function insertPlainImage(Resource\File $fileObject, $altText = '', $titleText = '', $additionalParams = '') {
+       public function insertPlainImage(File $fileObject, $altText = '', $titleText = '', $additionalParams = '') {
                $width = $fileObject->getProperty('width');
                $height = $fileObject->getProperty('height');
                if (!$width || !$height) {
@@ -287,18 +303,19 @@ class SelectImage extends ElementBrowser {
 <head>
        <title>Untitled</title>
        <script type="text/javascript">
-       /*<![CDATA[*/
                var plugin = window.parent.RTEarea[' . GeneralUtility::quoteJSvalue($this->editorNo) . '].editor.getPlugin("TYPO3Image");
                var imageTags = [];
                function insertImage(file,width,height,alt,title,additionalParams) {
-                       imageTags.push(\'<img src="\'+file+\'" width="\'+parseInt(width)+\'" height="\'+parseInt(height)+\'"\'' . ($this->defaultClass ? '+\' class="' . $this->defaultClass . '"\'' : '') . '+(alt?\' alt="\'+alt+\'"\':\'\')+(title?\' title="\'+title+\'"\':\'\')+(additionalParams?\' \'+additionalParams:\'\')+\' />\');
+                       imageTags.push(\'<img src="\'+file+\'" width="\'+parseInt(width)+\'" height="\'+parseInt(height)+\'"\''
+                       . ($this->defaultClass ? '+\' class="' . $this->defaultClass . '"\'' : '')
+                       . '+ (alt ? \' alt="\' + alt + \'"\' : \'\') + (title ? \' title="\' + title + \'"\' : \'\') + (additionalParams ? \' \' + additionalParams : \'\') +\' />\');
                }
-       /*]]>*/
        </script>
 </head>
 <body>
 <script type="text/javascript">
-/*<![CDATA[*/' . implode (LF, $insertJsStatements) . 'plugin.insertImage(imageTags.join(\' \'));/*]]>*/
+' . implode (LF, $insertJsStatements) . '
+plugin.insertImage(imageTags.join(\' \'));
 </script>
 </body>
 </html>';
@@ -427,14 +444,14 @@ class SelectImage extends ElementBrowser {
                                if ($this->expandFolder) {
                                        $fileOrFolderObject = NULL;
                                        try {
-                                               $fileOrFolderObject = Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->expandFolder);
+                                               $fileOrFolderObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->expandFolder);
                                        } catch (\Exception $e) {
                                                // No path is selected
                                        }
-                                       if ($fileOrFolderObject instanceof Resource\Folder) {
+                                       if ($fileOrFolderObject instanceof Folder) {
                                                // it's a folder
                                                $selectedFolder = $fileOrFolderObject;
-                                       } elseif ($fileOrFolderObject instanceof Resource\FileInterface) {
+                                       } elseif ($fileOrFolderObject instanceof FileInterface) {
                                                // it's a file
                                                try {
                                                        $selectedFolder = $fileOrFolderObject->getParentFolder();
@@ -466,7 +483,11 @@ class SelectImage extends ElementBrowser {
                                // Render the filelist if there is a folder selected
                                $files = '';
                                if ($selectedFolder) {
-                                       $files = $this->TBE_expandFolder($selectedFolder, $this->act === 'plain' ? self::PLAIN_MODE_IMAGE_FILE_EXTENSIONS : $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $backendUser->getTSConfigVal('options.noThumbsInRTEimageSelect'));
+                                       $files = $this->TBE_expandFolder(
+                                               $selectedFolder,
+                                               $this->act === 'plain' ? self::PLAIN_MODE_IMAGE_FILE_EXTENSIONS : $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
+                                               $backendUser->getTSConfigVal('options.noThumbsInRTEimageSelect')
+                                       );
                                }
                                // Setup filelist indexed elements:
                                $this->doc->JScode .= $this->doc->wrapScriptTags('
@@ -514,7 +535,7 @@ class SelectImage extends ElementBrowser {
                                $selectedFolder = FALSE;
                                if ($this->expandFolder) {
                                        try {
-                                               $selectedFolder = Resource\ResourceFactory::getInstance()->getFolderObjectFromCombinedIdentifier($this->expandFolder);
+                                               $selectedFolder = ResourceFactory::getInstance()->getFolderObjectFromCombinedIdentifier($this->expandFolder);
                                        } catch (\Exception $e) {
                                        }
                                }
@@ -547,8 +568,8 @@ class SelectImage extends ElementBrowser {
        /**
         * Returns an array definition of the top menu
         *
-        * @param $wiz
-        * @param $allowedItems
+        * @param bool $wiz
+        * @param array $allowedItems
         * @return array
         */
        protected function buildMenuArray($wiz, $allowedItems) {
@@ -733,11 +754,11 @@ class SelectImage extends ElementBrowser {
         *
         * In "plain" RTE mode only image files with a maximum width and height are selectable.
         *
-        * @param Resource\FileInterface $file
+        * @param FileInterface $file
         * @param array $imgInfo Image dimensions from \TYPO3\CMS\Core\Imaging\GraphicalFunctions::getImageDimensions()
         * @return bool TRUE if file is selectable.
         */
-       protected function fileIsSelectableInFileList(Resource\FileInterface $file, array $imgInfo) {
+       protected function fileIsSelectableInFileList(FileInterface $file, array $imgInfo) {
                return (
                        $this->act !== 'plain'
                        || (
index f557c43..5ade063 100644 (file)
  *
  * The TYPO3 project - inspiring people to share!
  */
+
 /**
  * This module is used by the RTE SelectImage module
  */
 define('TYPO3/CMS/Rtehtmlarea/Modules/SelectImage', function () {
+       'use strict';
 
-       SelectImage = {
+       var SelectImage = {
                // The id of the current editor
                editorNo: '',
                // The current action
@@ -41,12 +43,20 @@ define('TYPO3/CMS/Rtehtmlarea/Modules/SelectImage', function () {
                        if (typeof console !== 'undefined') {
                                console.log('SelectImage.initEventListeners() is deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8');
                        }
+                       require(
+                               ['TYPO3/CMS/Rtehtmlarea/HTMLArea/UserAgent/UserAgent', 'TYPO3/CMS/Rtehtmlarea/HTMLArea/Event/Event'],
+                               function (UserAgent, Event) {
+                                       if (UserAgent.isWebKit) {
+                                               Event.one(window.document.body, 'dragend.TYPO3Image', function (event) { SelectImage.Plugin.get().onDrop(event); });
+                                       }
+                               }
+                       );
                },
 
                /**
                 * Jump to the specified url after adding some parameters specific to the RTE context
                 *
-                * @return void
+                * @return bool
                 */
                jumpToUrl: function(URL, anchor) {
                        var selectedImageRef = SelectImage.CurrentImage.get();
@@ -60,18 +70,17 @@ define('TYPO3/CMS/Rtehtmlarea/Modules/SelectImage', function () {
                        var cur_height = selectedImageRef ? '&cHeight=' + selectedImageRef.style.height : '';
                        var addModifyTab = selectedImageRef ? '&addModifyTab=1' : '';
 
-                       var theLocation = URL + add_act + add_editorNo + add_sys_language_content + RTEtsConfigParams + bparams + addModifyTab + cur_width + cur_height + (typeof anchor === 'string' ? anchor : '');
-                       window.location.href = theLocation;
+                       window.location.href = URL + add_act + add_editorNo + add_sys_language_content + RTEtsConfigParams + bparams + addModifyTab + cur_width + cur_height + (typeof anchor === 'string' ? anchor : '');
                        return false;
                }
        };
 
-       /**
-        * Get a reference to the TYPO3Image plugin instance
-        *
-        * @return object a reference to the plugin instance
-        */
        SelectImage.Plugin = {
+               /**
+                * Get a reference to the TYPO3Image plugin instance
+                *
+                * @returns {Object} a reference to the plugin instance
+                */
                get: function() {
                        return window.parent.RTEarea[SelectImage.editorNo].editor.getPlugin('TYPO3Image');
                }
@@ -85,15 +94,14 @@ define('TYPO3/CMS/Rtehtmlarea/Modules/SelectImage', function () {
                /**
                 * Get a reference to the current image as established by the plugin
                 *
-                * @return object a reference to the current image
+                * @return {Object|null} a reference to the current image
                 */
                get: function() {
                        var plugin = SelectImage.Plugin.get();
                        if (plugin.image) {
                                return plugin.image;
-                       } else {
-                               return null;
                        }
+                       return null;
                },
 
                /**
@@ -103,110 +111,107 @@ define('TYPO3/CMS/Rtehtmlarea/Modules/SelectImage', function () {
                 */
                setProperties: function () {
                        var selectedImageRef = this.get();
-                       var plugin = SelectImage.Plugin.get();
-                       if (selectedImageRef) {
-                               if (document.imageData.iWidth) {
-                                       if (document.imageData.iWidth.value && parseInt(document.imageData.iWidth.value)) {
-                                               selectedImageRef.style.width = "";
-                                               selectedImageRef.width = parseInt(document.imageData.iWidth.value);
-                                       }
-                               }
-                               if (document.imageData.iHeight) {
-                                       if (document.imageData.iHeight.value && parseInt(document.imageData.iHeight.value)) {
-                                               selectedImageRef.style.height = "";
-                                               selectedImageRef.height = parseInt(document.imageData.iHeight.value);
-                                       }
-                               }
-                               if (document.imageData.iPaddingTop) {
-                                       if (document.imageData.iPaddingTop.value != "" && !isNaN(parseInt(document.imageData.iPaddingTop.value))) {
-                                               selectedImageRef.style.paddingTop = parseInt(document.imageData.iPaddingTop.value) + "px";
-                                       } else {
-                                               selectedImageRef.style.paddingTop = "";
-                                       }
+                       if (!selectedImageRef) {
+                               return;
+                       }
+                       var imageData = document.imageData;
+                       if (imageData.iWidth) {
+                               if (imageData.iWidth.value && parseInt(imageData.iWidth.value)) {
+                                       selectedImageRef.style.width = "";
+                                       selectedImageRef.width = parseInt(imageData.iWidth.value);
                                }
-                               if (document.imageData.iPaddingRight) {
-                                       if (document.imageData.iPaddingRight.value != "" && !isNaN(parseInt(document.imageData.iPaddingRight.value))) {
-                                               selectedImageRef.style.paddingRight = parseInt(document.imageData.iPaddingRight.value) + "px";
-                                       } else {
-                                               selectedImageRef.style.paddingRight = "";
-                                       }
+                       }
+                       if (imageData.iHeight) {
+                               if (imageData.iHeight.value && parseInt(imageData.iHeight.value)) {
+                                       selectedImageRef.style.height = "";
+                                       selectedImageRef.height = parseInt(imageData.iHeight.value);
                                }
-                               if (document.imageData.iPaddingBottom) {
-                                       if (document.imageData.iPaddingBottom.value != "" && !isNaN(parseInt(document.imageData.iPaddingBottom.value))) {
-                                               selectedImageRef.style.paddingBottom = parseInt(document.imageData.iPaddingBottom.value) + "px";
-                                       } else {
-                                               selectedImageRef.style.paddingBottom = "";
-                                       }
+                       }
+                       if (imageData.iPaddingTop) {
+                               if (imageData.iPaddingTop.value !== "" && !isNaN(parseInt(imageData.iPaddingTop.value))) {
+                                       selectedImageRef.style.paddingTop = parseInt(imageData.iPaddingTop.value) + "px";
+                               } else {
+                                       selectedImageRef.style.paddingTop = "";
                                }
-                               if (document.imageData.iPaddingLeft) {
-                                       if (document.imageData.iPaddingLeft.value != "" && !isNaN(parseInt(document.imageData.iPaddingLeft.value))) {
-                                               selectedImageRef.style.paddingLeft = parseInt(document.imageData.iPaddingLeft.value) + "px";
-                                       } else {
-                                               selectedImageRef.style.paddingLeft = "";
-                                       }
+                       }
+                       if (imageData.iPaddingRight) {
+                               if (imageData.iPaddingRight.value !== "" && !isNaN(parseInt(imageData.iPaddingRight.value))) {
+                                       selectedImageRef.style.paddingRight = parseInt(imageData.iPaddingRight.value) + "px";
+                               } else {
+                                       selectedImageRef.style.paddingRight = "";
                                }
-                               if (document.imageData.iTitle) {
-                                       selectedImageRef.title=document.imageData.iTitle.value;
+                       }
+                       if (imageData.iPaddingBottom) {
+                               if (imageData.iPaddingBottom.value !== "" && !isNaN(parseInt(imageData.iPaddingBottom.value))) {
+                                       selectedImageRef.style.paddingBottom = parseInt(imageData.iPaddingBottom.value) + "px";
+                               } else {
+                                       selectedImageRef.style.paddingBottom = "";
                                }
-                               if (document.imageData.iAlt) {
-                                       selectedImageRef.alt=document.imageData.iAlt.value;
+                       }
+                       if (imageData.iPaddingLeft) {
+                               if (imageData.iPaddingLeft.value !== "" && !isNaN(parseInt(imageData.iPaddingLeft.value))) {
+                                       selectedImageRef.style.paddingLeft = parseInt(imageData.iPaddingLeft.value) + "px";
+                               } else {
+                                       selectedImageRef.style.paddingLeft = "";
                                }
-                               if (document.imageData.iBorder) {
-                                       selectedImageRef.style.borderStyle = "";
-                                       selectedImageRef.style.borderWidth = "";
-                                       selectedImageRef.style.border = "";  // this statement ignored by Mozilla 1.3.1
-                                       selectedImageRef.style.borderTopStyle = "";
-                                       selectedImageRef.style.borderRightStyle = "";
-                                       selectedImageRef.style.borderBottomStyle = "";
-                                       selectedImageRef.style.borderLeftStyle = "";
-                                       selectedImageRef.style.borderTopWidth = "";
-                                       selectedImageRef.style.borderRightWidth = "";
-                                       selectedImageRef.style.borderBottomWidth = "";
-                                       selectedImageRef.style.borderLeftWidth = "";
-                                       if(document.imageData.iBorder.checked) {
-                                               selectedImageRef.style.borderStyle = "solid";
-                                               selectedImageRef.style.borderWidth = "thin";
-                                       }
-                                       selectedImageRef.removeAttribute("border");
+                       }
+                       if (imageData.iTitle) {
+                               selectedImageRef.title = imageData.iTitle.value;
+                       }
+                       if (imageData.iAlt) {
+                               selectedImageRef.alt = imageData.iAlt.value;
+                       }
+                       if (imageData.iBorder) {
+                               selectedImageRef.style.borderStyle = "";
+                               selectedImageRef.style.borderWidth = "";
+                               selectedImageRef.style.border = "";  // this statement ignored by Mozilla 1.3.1
+                               selectedImageRef.style.borderTopStyle = "";
+                               selectedImageRef.style.borderRightStyle = "";
+                               selectedImageRef.style.borderBottomStyle = "";
+                               selectedImageRef.style.borderLeftStyle = "";
+                               selectedImageRef.style.borderTopWidth = "";
+                               selectedImageRef.style.borderRightWidth = "";
+                               selectedImageRef.style.borderBottomWidth = "";
+                               selectedImageRef.style.borderLeftWidth = "";
+                               if (imageData.iBorder.checked) {
+                                       selectedImageRef.style.borderStyle = "solid";
+                                       selectedImageRef.style.borderWidth = "thin";
                                }
-                               if (document.imageData.iFloat) {
-                                       var iFloat = document.imageData.iFloat.options[document.imageData.iFloat.selectedIndex].value;
-                                       if (document.all) {
-                                               selectedImageRef.style.styleFloat = iFloat ? iFloat : "";
-                                       } else {
-                                               selectedImageRef.style.cssFloat = iFloat ? iFloat : "";
-                                       }
+                               selectedImageRef.removeAttribute("border");
+                       }
+                       if (imageData.iFloat) {
+                               var iFloat = imageData.iFloat.options[imageData.iFloat.selectedIndex].value;
+                               selectedImageRef.style.cssFloat = iFloat ? iFloat : "";
+                       }
+                       if (SelectImage.classesImage && imageData.iClass) {
+                               var iClass;
+                               if (imageData.iClass.options.length > 0) {
+                                       iClass = imageData.iClass.options[imageData.iClass.selectedIndex].value;
                                }
-                               if (SelectImage.classesImage && document.imageData.iClass) {
-                                       var iClass;
-                                       if (document.imageData.iClass.options.length > 0) {
-                                               iClass = document.imageData.iClass.options[document.imageData.iClass.selectedIndex].value;
-                                       }
-                                       if (iClass || (selectedImageRef.attributes["class"] && selectedImageRef.attributes["class"].value)) {
-                                               selectedImageRef.className = iClass;
-                                       } else {
-                                               selectedImageRef.className = "";
-                                       }
+                               if (iClass || selectedImageRef.attributes["class"] && selectedImageRef.attributes["class"].value) {
+                                       selectedImageRef.className = iClass;
+                               } else {
+                                       selectedImageRef.className = "";
                                }
-                               if (document.imageData.iLang) {
-                                       var iLang = document.imageData.iLang.options[document.imageData.iLang.selectedIndex].value;
-                                       var languageObject = plugin.editor.getPlugin("Language");
-                                       if (iLang || languageObject.getLanguageAttribute(selectedImageRef)) {
-                                               languageObject.setLanguageAttributes(selectedImageRef, iLang);
-                                       } else {
-                                               languageObject.setLanguageAttributes(selectedImageRef, "none");
-                                       }
+                       }
+                       if (imageData.iLang) {
+                               var iLang = imageData.iLang.options[imageData.iLang.selectedIndex].value;
+                               var languageObject = SelectImage.Plugin.get().editor.getPlugin("Language");
+                               if (iLang || languageObject.getLanguageAttribute(selectedImageRef)) {
+                                       languageObject.setLanguageAttributes(selectedImageRef, iLang);
+                               } else {
+                                       languageObject.setLanguageAttributes(selectedImageRef, "none");
                                }
-                               if (document.imageData.iClickEnlarge) {
-                                       if (document.imageData.iClickEnlarge.checked) {
-                                               selectedImageRef.setAttribute("data-htmlarea-clickenlarge","1");
-                                       } else {
-                                               selectedImageRef.removeAttribute("data-htmlarea-clickenlarge");
-                                               selectedImageRef.removeAttribute("clickenlarge");
-                                       }
+                       }
+                       if (imageData.iClickEnlarge) {
+                               if (imageData.iClickEnlarge.checked) {
+                                       selectedImageRef.setAttribute("data-htmlarea-clickenlarge","1");
+                               } else {
+                                       selectedImageRef.removeAttribute("data-htmlarea-clickenlarge");
+                                       selectedImageRef.removeAttribute("clickenlarge");
                                }
-                               plugin.close();
                        }
+                       SelectImage.Plugin.get().close();
                }
        };
 
@@ -218,17 +223,18 @@ define('TYPO3/CMS/Rtehtmlarea/Modules/SelectImage', function () {
                /**
                 * Build the form and append it to the body of the document
                 *
-                * @param string classesImageJSOptions: options of the class selector
-                * @param array removedProperties: array of properties configured to be rmoved
-                * @param boolean lockPlainWidth: true if the plain image width is locked
-                * @param boolean lockPlainHeight: true if the plain image height is locked
+                * @param {string} classesImageJSOptions options of the class selector
+                * @param {array} removedProperties array of properties configured to be rmoved
+                * @param {bool} lockPlainWidth true if the plain image width is locked
+                * @param {bool} lockPlainHeight true if the plain image height is locked
                 * @return void
                 */
                build: function(classesImageJSOptions, removedProperties, lockPlainWidth, lockPlainHeight) {
                        var plugin = SelectImage.Plugin.get();
                        var selectedImageRef = SelectImage.CurrentImage.get();
+                       var styleSelector = '';
                        if (SelectImage.classesImage) {
-                               var styleSelector = '<select id="iClass" name="iClass" style="width:140px;">' + classesImageJSOptions + '</select>';
+                               styleSelector = '<select id="iClass" name="iClass" style="width:140px;">' + classesImageJSOptions + '</select>';
                        }
                        var floatSelector = '<select id="iFloat" name="iFloat">'
                                + '<option value="">' + SelectImage.labels['notSet'] + '</option>'
@@ -236,8 +242,9 @@ define('TYPO3/CMS/Rtehtmlarea/Modules/SelectImage', function () {
                                + '<option value="left">' + SelectImage.labels['left'] + '</option>'
                                + '<option value="right">' + SelectImage.labels['right'] + '</option>'
                                + '</select>';
+                       var languageSelector = '';
                        if (plugin.getButton('Language')) {
-                               var languageSelector = '<select id="iLang" name="iLang">';
+                               languageSelector = '<select id="iLang" name="iLang">';
                                var options = plugin.getButton('Language').getOptions();
                                for (var i = 0, n = options.length; i < n; i++) {
                                        languageSelector += '<option value="' + options[i].value + '">' + options[i].innerHTML + '</option>';
@@ -249,10 +256,10 @@ define('TYPO3/CMS/Rtehtmlarea/Modules/SelectImage', function () {
                        if (removedProperties.indexOf('class') === -1 && SelectImage.classesImage) {
                                sz += '<tr><td><label for="iClass">' + SelectImage.labels['class'] + ': </label></td><td>' + styleSelector + '</td></tr>';
                        }
-                       if (removedProperties.indexOf('width') === -1 && !(selectedImageRef && selectedImageRef.src.indexOf('RTEmagic') == -1 && lockPlainWidth)) {
+                       if (removedProperties.indexOf('width') === -1 && !(selectedImageRef && selectedImageRef.src.indexOf('RTEmagic') === -1 && lockPlainWidth)) {
                                sz += '<tr><td><label for="iWidth">' + SelectImage.labels['width'] + ': </label></td><td><input type="text" id="iWidth" name="iWidth" value="" style="width: 39px;" maxlength="4" /></td></tr>';
                        }
-                       if (removedProperties.indexOf('height') === -1 && !(selectedImageRef && selectedImageRef.src.indexOf('RTEmagic') == -1 && lockPlainHeight)) {
+                       if (removedProperties.indexOf('height') === -1 && !(selectedImageRef && selectedImageRef.src.indexOf('RTEmagic') === -1 && lockPlainHeight)) {
                                sz += '<tr><td><label for="iHeight">' + SelectImage.labels['height'] + ': </label></td><td><input type="text" id="iHeight" name="iHeight" value="" style="width: 39px;" maxlength="4" /></td></tr>';
                        }
                        if (removedProperties.indexOf('border') === -1) {
@@ -287,6 +294,7 @@ define('TYPO3/CMS/Rtehtmlarea/Modules/SelectImage', function () {
                        }
                        sz += '<tr><td></td><td><input class="btn btn-default" type="submit" value="' + SelectImage.labels['update'] + '" onclick="SelectImage.CurrentImage.setProperties(SelectImage.classesImage)"></td></tr>';
                        sz += '</table></form>';
+
                        var div = document.createElement('div');
                        div.innerHTML = sz;
                        document.body.appendChild(div);
@@ -304,38 +312,38 @@ define('TYPO3/CMS/Rtehtmlarea/Modules/SelectImage', function () {
                                if (document.imageData.iWidth) {
                                        styleWidth = selectedImageRef.style.width ? selectedImageRef.style.width : selectedImageRef.width;
                                        styleWidth = parseInt(styleWidth);
-                                       if (!(isNaN(styleWidth) || styleWidth == 0)) {
+                                       if (!isNaN(styleWidth) && styleWidth !== 0) {
                                                document.imageData.iWidth.value = styleWidth;
                                        }
                                }
                                if (document.imageData.iHeight) {
                                        styleHeight = selectedImageRef.style.height ? selectedImageRef.style.height : selectedImageRef.height;
                                        styleHeight = parseInt(styleHeight);
-                                       if (!(isNaN(styleHeight) || styleHeight == 0)) {
+                                       if (!isNaN(styleHeight) && styleHeight !== 0) {
                                                document.imageData.iHeight.value = styleHeight;
                                        }
                                }
                                if (document.imageData.iPaddingTop) {
-                                       var padding = selectedImageRef.style.paddingTop ? selectedImageRef.style.paddingTop : selectedImageRef.vspace;
-                                       var padding = parseInt(padding);
+                                       padding = selectedImageRef.style.paddingTop ? selectedImageRef.style.paddingTop : selectedImageRef.vspace;
+                                       padding = parseInt(padding);
                                        if (isNaN(padding) || padding <= 0) { padding = ""; }
                                        document.imageData.iPaddingTop.value = padding;
                                }
                                if (document.imageData.iPaddingRight) {
                                        padding = selectedImageRef.style.paddingRight ? selectedImageRef.style.paddingRight : selectedImageRef.hspace;
-                                       var padding = parseInt(padding);
+                                       padding = parseInt(padding);
                                        if (isNaN(padding) || padding <= 0) { padding = ""; }
                                        document.imageData.iPaddingRight.value = padding;
                                }
                                if (document.imageData.iPaddingBottom) {
-                                       var padding = selectedImageRef.style.paddingBottom ? selectedImageRef.style.paddingBottom : selectedImageRef.vspace;
-                                       var padding = parseInt(padding);
+                                       padding = selectedImageRef.style.paddingBottom ? selectedImageRef.style.paddingBottom : selectedImageRef.vspace;
+                                       padding = parseInt(padding);
                                        if (isNaN(padding) || padding <= 0) { padding = ""; }
                                        document.imageData.iPaddingBottom.value = padding;
                                }
                                if (document.imageData.iPaddingLeft) {
-                                       var padding = selectedImageRef.style.paddingLeft ? selectedImageRef.style.paddingLeft : selectedImageRef.hspace;
-                                       var padding = parseInt(padding);
+                                       padding = selectedImageRef.style.paddingLeft ? selectedImageRef.style.paddingLeft : selectedImageRef.hspace;
+                                       padding = parseInt(padding);
                                        if (isNaN(padding) || padding <= 0) { padding = ""; }
                                        document.imageData.iPaddingLeft.value = padding;
                                }
@@ -350,29 +358,28 @@ define('TYPO3/CMS/Rtehtmlarea/Modules/SelectImage', function () {
                                                document.imageData.iBorder.checked = 1;
                                        }
                                }
+                               var fObj, value, a;
                                if (document.imageData.iFloat) {
-                                       var fObj=document.imageData.iFloat;
-                                       var value = (selectedImageRef.style.cssFloat ? selectedImageRef.style.cssFloat : selectedImageRef.style.styleFloat);
-                                       var l=fObj.length;
-                                       for (var a=0;a<l;a++) {
+                                       fObj = document.imageData.iFloat;
+                                       value = selectedImageRef.style.cssFloat ? selectedImageRef.style.cssFloat : selectedImageRef.style.styleFloat;
+                                       for (a = 0; a < fObj.length; a++) {
                                                if (fObj.options[a].value == value) {
                                                        fObj.selectedIndex = a;
                                                }
                                        }
                                }
                                if (SelectImage.classesImage && document.imageData.iClass) {
-                                       var fObj=document.imageData.iClass;
-                                       var value=selectedImageRef.className;
-                                       var l=fObj.length;
-                                       for (var a=0;a < l; a++) {
+                                       fObj = document.imageData.iClass;
+                                       value = selectedImageRef.className;
+                                       for (a = 0; a < fObj.length; a++) {
                                                if (fObj.options[a].value == value) {
                                                        fObj.selectedIndex = a;
                                                }
                                        }
                                }
                                if (document.imageData.iLang) {
-                                       var fObj=document.imageData.iLang;
-                                       var value=plugin.editor.getPlugin("Language").getLanguageAttribute(selectedImageRef);
+                                       fObj = document.imageData.iLang;
+                                       value = plugin.editor.getPlugin("Language").getLanguageAttribute(selectedImageRef);
                                        for (var i = 0, n = fObj.length; i < n; i++) {
                                                if (fObj.options[i].value == value) {
                                                        fObj.selectedIndex = i;
@@ -383,15 +390,14 @@ define('TYPO3/CMS/Rtehtmlarea/Modules/SelectImage', function () {
                                        }
                                }
                                if (document.imageData.iClickEnlarge) {
-                                       if (selectedImageRef.getAttribute("data-htmlarea-clickenlarge") == "1" || selectedImageRef.getAttribute("clickenlarge") == "1") {
-                                               document.imageData.iClickEnlarge.checked = 1;
-                                       } else {
-                                               document.imageData.iClickEnlarge.checked = 0;
-                                       }
+                                       document.imageData.iClickEnlarge.checked = selectedImageRef.getAttribute("data-htmlarea-clickenlarge") === "1" || selectedImageRef.getAttribute("clickenlarge") === "1";
                                }
                        }
                }
        };
 
+       // public usage
+       window.SelectImage = SelectImage;
+
        return SelectImage;
 });