[FEATURE] Make frame sizes in viewpage module configurable 20/23720/8
authorJohannes Feustel <s@feustel.eu>
Mon, 9 Sep 2013 23:08:10 +0000 (01:08 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Mon, 14 Oct 2013 10:39:44 +0000 (12:39 +0200)
Available sizes in viewpage module can be configured with Page
TSConfig mod.web_view.previewFrameWidths. Defining a height
property is optional.

Change-Id: I7900959bc76fc2c586307c0fd4200f9665876dd3
Resolves: #51865
Documentation: #52783
Releases: 6.2
Reviewed-on: https://review.typo3.org/23720
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/core/Configuration/DefaultConfiguration.php
typo3/sysext/viewpage/Classes/Controller/ViewModuleController.php
typo3/sysext/viewpage/Resources/Public/JavaScript/common.js

index 8389b1a..b39d45a 100644 (file)
@@ -567,6 +567,19 @@ return array(
                        mod.wizards.newRecord.pages.show.pageInside=1
                        mod.wizards.newRecord.pages.show.pageAfter=1
                        mod.wizards.newRecord.pages.show.pageSelectPosition=1
+                       mod.web_view.previewFrameWidths {
+                               1280.label = LLL:EXT:viewpage/Resources/Private/Language/locallang.xlf:computer
+                               1024.label = LLL:EXT:viewpage/Resources/Private/Language/locallang.xlf:tablet
+                               960.label = LLL:EXT:viewpage/Resources/Private/Language/locallang.xlf:mobile
+                               800.label = LLL:EXT:viewpage/Resources/Private/Language/locallang.xlf:computer
+                               768.label = LLL:EXT:viewpage/Resources/Private/Language/locallang.xlf:tablet
+                               600.label = LLL:EXT:viewpage/Resources/Private/Language/locallang.xlf:tablet
+                               640.label = LLL:EXT:viewpage/Resources/Private/Language/locallang.xlf:mobile
+                               480.label = LLL:EXT:viewpage/Resources/Private/Language/locallang.xlf:mobile
+                               400.label = LLL:EXT:viewpage/Resources/Private/Language/locallang.xlf:mobile
+                               360.label = LLL:EXT:viewpage/Resources/Private/Language/locallang.xlf:mobile
+                               300.label = LLL:EXT:viewpage/Resources/Private/Language/locallang.xlf:mobile
+                       }
                ',
                // String (exclude).Enter lines of default Page TSconfig.
                'defaultPermissions' => array(),
index 6fb3095..9636100 100644 (file)
@@ -147,23 +147,37 @@ class ViewModuleController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionContr
         * @return array
         */
        protected function getPreviewFrameWidths() {
-               $autoSize = json_encode(array(
+               $pageId = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id'));
+               $modTSconfig = BackendUtility::getModTSconfig($pageId, 'mod.web_view');
+               $data = json_encode(array(
                        'width' => '100%',
                        'height' => "100%"
                ));
-               return array(
-                       $autoSize => $GLOBALS['LANG']->getLL('autoSize'),
-                       json_encode(array('width' => '1280')) => '1280px ' . $GLOBALS['LANG']->getLL('computer'),
-                       json_encode(array('width' => '1024')) => '1024px ' . $GLOBALS['LANG']->getLL('tablet'),
-                       json_encode(array('width' => '960')) => '960px ' . $GLOBALS['LANG']->getLL('mobile'),
-                       json_encode(array('width' => '800')) => '800px ' . $GLOBALS['LANG']->getLL('computer'),
-                       json_encode(array('width' => '768')) => '768px ' . $GLOBALS['LANG']->getLL('tablet'),
-                       json_encode(array('width' => '600')) => '600px ' . $GLOBALS['LANG']->getLL('tablet'),
-                       json_encode(array('width' => '640')) => '640px ' . $GLOBALS['LANG']->getLL('mobile'),
-                       json_encode(array('width' => '480')) => '480px ' . $GLOBALS['LANG']->getLL('mobile'),
-                       json_encode(array('width' => '400')) => '400px ' . $GLOBALS['LANG']->getLL('mobile'),
-                       json_encode(array('width' => '360')) => '360px ' . $GLOBALS['LANG']->getLL('mobile'),
-                       json_encode(array('width' => '300')) => '300px ' . $GLOBALS['LANG']->getLL('mobile')
+               $widths = array(
+                       $data => $GLOBALS['LANG']->getLL('autoSize')
                );
+               if (is_array($modTSconfig['properties']['previewFrameWidths.'])) {
+                       foreach ($modTSconfig['properties']['previewFrameWidths.'] as $item => $conf ){
+                               $label = '';
+
+                               $width = substr($item, 0, -1);
+                               $data = array('width' => $width);
+                               $label .= $width . 'px ';
+
+                               //if height is set
+                               if (isset($conf['height'])) {
+                                       $label .= ' × ' . $conf['height'] . 'px ';
+                                       $data['height'] = $conf['height'];
+                               }
+
+                               if (strcmp(substr($conf['label'], 0, 4), 'LLL:')) {
+                                       $label .= $conf['label'];
+                               } else {
+                                       $label .= $GLOBALS['LANG']->sL(trim($conf['label']));
+                               }
+                               $widths[json_encode($data)] = $label;
+                       }
+               }
+               return $widths;
        }
 }
index 466e5e0..be377bf 100644 (file)
 
                function getOptionLabel(data) {
                        var jsonObject = JSON.parse(data);
-                       var height = jsonObject['height'] ? '×' + jsonObject['height'] : '';
-                       return jsonObject['width'] + height + ' ' + TYPO3.lang['customWidth'];
+                       var height = jsonObject['height'] ? ' × ' + jsonObject['height'] + 'px ' : '';
+                       return jsonObject['width'] + 'px ' + height + TYPO3.lang['customWidth'];
                }
        };
 }(jQuery, Ext));
\ No newline at end of file