[TASK] Migrate ext:viewpage to extbase
authorFelix Kopp <felix-source@phorax.com>
Mon, 16 Apr 2012 22:27:06 +0000 (00:27 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 5 May 2012 14:25:17 +0000 (16:25 +0200)
Change-Id: I9929cb7f185319d052b13640f4e6e1681e7bda95
Resolves: #36122
Releases: 6.0
Reviewed-on: http://review.typo3.org/10558
Reviewed-by: Ingo Pfennigstorf
Tested-by: Ingo Pfennigstorf
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
14 files changed:
typo3/sysext/viewpage/Classes/Controller/ViewController.php [new file with mode: 0644]
typo3/sysext/viewpage/Resources/Private/Language/locallang_mod.xlf [new file with mode: 0644]
typo3/sysext/viewpage/Resources/Private/Layouts/DocHeader.html [new file with mode: 0644]
typo3/sysext/viewpage/Resources/Private/Templates/View/Show.html [new file with mode: 0644]
typo3/sysext/viewpage/ext_emconf.php
typo3/sysext/viewpage/ext_tables.php
typo3/sysext/viewpage/view/clear.gif [deleted file]
typo3/sysext/viewpage/view/conf.php [deleted file]
typo3/sysext/viewpage/view/dummy.html [deleted file]
typo3/sysext/viewpage/view/frameset.php [deleted file]
typo3/sysext/viewpage/view/index.php [deleted file]
typo3/sysext/viewpage/view/layout.gif [deleted file]
typo3/sysext/viewpage/view/locallang_mod.xlf [deleted file]
typo3/sysext/viewpage/view/view.gif [deleted file]

diff --git a/typo3/sysext/viewpage/Classes/Controller/ViewController.php b/typo3/sysext/viewpage/Classes/Controller/ViewController.php
new file mode 100644 (file)
index 0000000..6174a65
--- /dev/null
@@ -0,0 +1,136 @@
+<?php
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2012 Felix Kopp <felix-source@phorax.com>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Controller for viewing the frontend
+ *
+ * @author Felix Kopp <felix-source@phorax.com>
+ * @author Kasper Skårhøj <kasperYYYY@typo3.com>
+ * @package TYPO3
+ * @subpackage viewpage
+ */
+class Tx_Viewpage_Controller_ViewController extends Tx_Extbase_MVC_Controller_ActionController {
+
+       /**
+        * Show selected page from pagetree in iframe
+        *
+        * @return void
+        */
+       public function showAction() {
+               $this->view->assign('url', $this->getTargetUrl());
+       }
+
+       /**
+        * Determine the url to view
+        *
+        * @return string
+        */
+       protected function getTargetUrl() {
+               $pageIdToShow = intval(t3lib_div::_GP('id'));
+
+               $adminCommand = $this->getAdminCommand($pageIdToShow);
+               $domainName = $this->getDomainName($pageIdToShow);
+
+                       // Mount point overlay: Set new target page id and mp parameter
+                       /** @var t3lib_pageSelect $sysPage */
+               $sysPage = t3lib_div::makeInstance('t3lib_pageSelect');
+               $sysPage->init(FALSE);
+               $mountPointMpParameter = '';
+               $finalPageIdToShow = $pageIdToShow;
+               $mountPointInformation = $sysPage->getMountPointInfo($pageIdToShow);
+               if ($mountPointInformation && $mountPointInformation['overlay']) {
+                               // New page id
+                       $finalPageIdToShow = $mountPointInformation['mount_pid'];
+                       $mountPointMpParameter = '&MP=' . $mountPointInformation['MPvar'];
+               }
+
+                       // Modify relative path to protocol with host if domain record is given
+               $protocolAndHost = '..';
+               if ($domainName) {
+                       $protocol = 'http';
+                       $page = (array)$sysPage->getPage($finalPageIdToShow);
+                       if ($page['url_scheme'] == 2 || $page['url_scheme'] == 0 && t3lib_div::getIndpEnv('TYPO3_SSL')) {
+                               $protocol = 'https';
+                       }
+                       $protocolAndHost = $protocol . '://' . $domainName;
+               }
+
+               $url = $protocolAndHost
+                       . '/index.php?id=' . $finalPageIdToShow
+                       . $this->getTypeParameterIfSet($finalPageIdToShow)
+                       . $mountPointMpParameter
+                       . $adminCommand
+               ;
+
+               return $url;
+       }
+
+       /**
+        * Get admin command
+        *
+        * @param $pageId
+        * @return string
+        */
+       protected function getAdminCommand($pageId) {
+                       // The page will show only if there is a valid page and if this page may be viewed by the user
+               $pageinfo = t3lib_BEfunc::readPageAccess($pageId, $GLOBALS['BE_USER']->getPagePermsClause(1));
+               $addCommand = '';
+               if (is_array($pageinfo)) {
+                       $addCommand = '&ADMCMD_view=1&ADMCMD_editIcons=1' . t3lib_BEfunc::ADMCMD_previewCmds($pageinfo);
+               }
+               return $addCommand;
+       }
+
+       /**
+        * With page TS config it is possible to force a specific type id via mod.web_view.type
+        * for a page id or a page tree.
+        * The method checks if a type is set for the given id and returns the additional GET string.
+        *
+        * @param $pageId
+        * @return string
+        */
+       protected function getTypeParameterIfSet($pageId) {
+               $typeParameter = '';
+               $modTSconfig = t3lib_BEfunc::getModTSconfig($pageId, 'mod.web_view');
+               $typeId = intval($modTSconfig['properties']['type']);
+               if ($typeId > 0) {
+                       $typeParameter = '&type=' . $typeId;
+               }
+               return $typeParameter;
+       }
+
+       /**
+        * Get domain name for requested page id
+        *
+        * @param $pageId
+        * @return boolean|string Domain name if there is one, FALSE if not
+        */
+       protected function getDomainName($pageId) {
+               $domain = t3lib_BEfunc::firstDomainRecord(t3lib_BEfunc::BEgetRootLine($pageId));
+               return $domain;
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/viewpage/Resources/Private/Language/locallang_mod.xlf b/typo3/sysext/viewpage/Resources/Private/Language/locallang_mod.xlf
new file mode 100644 (file)
index 0000000..87eb058
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.0">
+       <file source-language="en" datatype="plaintext" original="messages" date="2011-10-17T20:22:37Z" product-name="viewpage">
+               <header/>
+               <body>
+                       <trans-unit id="mlang_labels_tablabel" xml:space="preserve">
+                               <source>View page</source>
+                       </trans-unit>
+                       <trans-unit id="mlang_labels_tabdescr" xml:space="preserve">
+                               <source>Shows the look of the current page and lets you edit the content directly.</source>
+                       </trans-unit>
+                       <trans-unit id="mlang_tabs_tab" xml:space="preserve">
+                               <source>View</source>
+                       </trans-unit>
+               </body>
+       </file>
+</xliff>
diff --git a/typo3/sysext/viewpage/Resources/Private/Layouts/DocHeader.html b/typo3/sysext/viewpage/Resources/Private/Layouts/DocHeader.html
new file mode 100644 (file)
index 0000000..67f9093
--- /dev/null
@@ -0,0 +1,29 @@
+<f:be.container loadExtJs="1">
+       <style type="text/css">
+               .typo3-inner-docbody {
+                       height: 100%;
+               }
+       </style>
+
+       <div class="typo3-fullDoc">
+               <div id="typo3-docheader">
+                       <div id="typo3-docheader-row1">
+                               <div class="docheader-row1-left">
+                               </div>
+                               <div class="docheader-row2-right">
+                                       <f:be.buttons.icon uri="" icon="actions-system-refresh" />
+                                       <f:be.buttons.shortcut />
+                               </div>
+                       </div>
+                       <div id="typo3-docheader-row2">
+                               &nbsp;
+                       </div>
+               </div>
+
+               <div id="typo3-docbody">
+                       <div id="typo3-inner-docbody" style="height: 100%;">
+                               <f:render section="Content" />
+                       </div>
+               </div>
+       </div>
+</f:be.container>
diff --git a/typo3/sysext/viewpage/Resources/Private/Templates/View/Show.html b/typo3/sysext/viewpage/Resources/Private/Templates/View/Show.html
new file mode 100644 (file)
index 0000000..404e118
--- /dev/null
@@ -0,0 +1,5 @@
+<f:layout name="DocHeader" />
+
+<f:section name="Content">
+       <iframe src="{url}" width="100%" height="100%" id="tx_viewpage_iframe" frameborder="0" border="0"></iframe>
+</f:section>
\ No newline at end of file
index 0f9a83f..841a947 100755 (executable)
@@ -15,7 +15,7 @@ $EM_CONF[$_EXTKEY] = array(
        'description' => 'Shows the frontend webpage inside the backend frameset.',
        'category' => 'module',
        'shy' => 1,
-       'dependencies' => 'cms',
+       'dependencies' => 'extbase,fluid',
        'conflicts' => '',
        'priority' => '',
        'loadOrder' => '',
@@ -32,13 +32,14 @@ $EM_CONF[$_EXTKEY] = array(
        'author_company' => 'Curby Soft Multimedia',
        'CGLcompliance' => '',
        'CGLcompliance_note' => '',
-       'version' => '1.1.0',
+       'version' => '2.0.0',
        '_md5_values_when_last_written' => 'a:10:{s:12:"ext_icon.gif";s:4:"9b98";s:14:"ext_tables.php";s:4:"a104";s:14:"view/clear.gif";s:4:"cc11";s:13:"view/conf.php";s:4:"24ff";s:15:"view/dummy.html";s:4:"e302";s:17:"view/frameset.php";s:4:"a100";s:14:"view/index.php";s:4:"8a1e";s:15:"view/layout.gif";s:4:"edde";s:22:"view/locallang_mod.xlf";s:4:"dffe";s:13:"view/view.gif";s:4:"1898";}',
        'constraints' => array(
                'depends' => array(
                        'php' => '5.3.0-0.0.0',
-                       'typo3' => '4.6.0-0.0.0',
-                       'cms' => '',
+                       'typo3' => '6.0.0-0.0.0',
+                       'extbase' => '1.4.0-0.0.0',
+                       'fluid' => '1.5.0-0.0.0',
                ),
                'conflicts' => array(
                ),
index de4d857..9465dfa 100755 (executable)
@@ -1,5 +1,23 @@
 <?php
-if (!defined ('TYPO3_MODE'))   die ('Access denied.');
+if (!defined ('TYPO3_MODE')) {
+       die ('Access denied.');
+}
 
-if (TYPO3_MODE=='BE')  t3lib_extMgm::addModule('web','view','after:layout',t3lib_extMgm::extPath($_EXTKEY).'view/');
+if (TYPO3_MODE === 'BE' && !(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_INSTALL)) {
+               // Module Web->View
+       Tx_Extbase_Utility_Extension::registerModule(
+               $_EXTKEY,
+               'web',
+               'view',
+               'after:layout',
+               array(
+                       'View' => 'show',
+               ),
+               array(
+                       'icon' => 'EXT:viewpage/ext_icon.gif',
+                       'labels' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_mod.xlf',
+                       'access' => 'user,group',
+               )
+       );
+}
 ?>
\ No newline at end of file
diff --git a/typo3/sysext/viewpage/view/clear.gif b/typo3/sysext/viewpage/view/clear.gif
deleted file mode 100755 (executable)
index 9ed1269..0000000
Binary files a/typo3/sysext/viewpage/view/clear.gif and /dev/null differ
diff --git a/typo3/sysext/viewpage/view/conf.php b/typo3/sysext/viewpage/view/conf.php
deleted file mode 100755 (executable)
index a2bb528..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-define('TYPO3_MOD_PATH', 'sysext/viewpage/view/');
-$BACK_PATH='../../../';
-
-$MLANG['default']['tabs_images']['tab'] = 'view.gif';
-$MLANG['default']['ll_ref']='LLL:EXT:viewpage/view/locallang_mod.xml';
-
-$MCONF['script']='frameset.php';
-$MCONF['access']='user,group';
-$MCONF['name']='web_view';
-?>
\ No newline at end of file
diff --git a/typo3/sysext/viewpage/view/dummy.html b/typo3/sysext/viewpage/view/dummy.html
deleted file mode 100755 (executable)
index 7a29d8b..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
-<html>
-<head>
-       <title>Untitled</title>
-</head>
-
-<body>
-
-
-
-</body>
-</html>
diff --git a/typo3/sysext/viewpage/view/frameset.php b/typo3/sysext/viewpage/view/frameset.php
deleted file mode 100755 (executable)
index c2c876b..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-
-unset($MCONF);
-require ('conf.php');
-require ($BACK_PATH.'init.php');
-
-
-$urlP = parse_url(t3lib_div::getIndpEnv("REQUEST_URI"));
-//header("Location: index.php?".$urlP["query"]);
-
-
-$iFrame =0;    // I hoped that with an IFRAME the links to "_top" would not really open in "_top" but top of the IFRAME. But that was not the case...
-if ($iFrame)   {
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
-<head>
-       <title>Untitled</title>
-</head>
-<body marginwidth=0 marginheight=0 topmargin=0 leftmargin=0>
-<?php
-echo '<IFRAME src="index.php?'.$urlP["query"].'" id="VIEWFRAME" style="visibility: visible; position: absolute; left: 0px; top: 0px; height=100%; width=100%"></IFRAME>';
-?>
-</body>
-</html>
-<?php
-} else {
-?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
-<html>
-<head>
-       <title>View Frameset</title>
-       <script language="javascript" type="text/javascript">
-       if (top.fsMod) top.fsMod.recentIds['web'] = <?php echo intval(t3lib_div::_GET("id"));?>;
-       </script>
-</head>
-<frameset rows="*,1" framespacing="0" frameborder="0" border="0">
-       <frame name="view_frame" src="index.php?<?php echo $urlP["query"];?>" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto" noresize>
-       <frame name="dummy_frame" src="dummy.html" marginwidth="0" marginheight="0" frameborder="0" scrolling="0"  scrolling="no" noresize>
-</frameset>
-</html><?php
-}
-?>
\ No newline at end of file
diff --git a/typo3/sysext/viewpage/view/index.php b/typo3/sysext/viewpage/view/index.php
deleted file mode 100755 (executable)
index c3141ca..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-<?php
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
-*  All rights reserved
-*
-*  This script is part of the TYPO3 project. The TYPO3 project is
-*  free software; you can redistribute it and/or modify
-*  it under the terms of the GNU General Public License as published by
-*  the Free Software Foundation; either version 2 of the License, or
-*  (at your option) any later version.
-*
-*  The GNU General Public License can be found at
-*  http://www.gnu.org/copyleft/gpl.html.
-*  A copy is found in the textfile GPL.txt and important notices to the license
-*  from the author is found in LICENSE.txt distributed with these scripts.
-*
-*
-*  This script is distributed in the hope that it will be useful,
-*  but WITHOUT ANY WARRANTY; without even the implied warranty of
-*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*  GNU General Public License for more details.
-*
-*  This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-/**
- * Module: View
- *
- * Views the webpage
- *
- * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
- */
-
-unset($MCONF);
-require ('conf.php');
-require ($BACK_PATH.'init.php');
-//require ($BACK_PATH.'template.php');
-$BE_USER->modAccess($MCONF,1);
-
-
-
-/**
- * Script Class for the Web > View
- *
- * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
- * @package TYPO3
- * @subpackage core
- */
-class SC_mod_web_view_index {
-       var $MCONF=array();
-       var $MOD_MENU=array();
-       var $MOD_SETTINGS=array();
-
-       var $perms_clause;
-       var $modTSconfig;
-       var $type;
-       var $pageinfo;
-       var $url;
-       var $id;
-       var $wsInstruction='';
-
-       /**
-        * Initialization of module
-        *
-        * @return      void
-        */
-       function init() {
-               $this->MCONF = $GLOBALS['MCONF'];
-               $this->id = intval(t3lib_div::_GP('id'));
-
-               $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
-
-                       // page/be_user TSconfig settings and blinding of menu-items
-               $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->id,'mod.'.$this->MCONF['name']);
-               $this->type = intval($this->modTSconfig['properties']['type']);
-       }
-
-       /**
-        * Main function
-        *
-        * @return      void
-        */
-       function main() {
-
-                       // Access check...
-                       // The page will show only if there is a valid page and if this page may be viewed by the user
-               $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause);
-               $access = is_array($this->pageinfo) ? 1 : 0;
-               $addCmd='';
-               if ($this->id && $access)       {
-                       $addCmd = '&ADMCMD_view=1&ADMCMD_editIcons=1'.t3lib_BEfunc::ADMCMD_previewCmds($this->pageinfo);
-               }
-
-               $parts = parse_url(t3lib_div::getIndpEnv('TYPO3_SITE_URL'));
-               $dName = t3lib_BEfunc::getDomainStartPage($parts['host'],$parts['path']) ?
-                                               t3lib_BEfunc::firstDomainRecord(t3lib_BEfunc::BEgetRootLine($this->id)):
-                                               '';
-
-                       // preview of mount pages
-               $sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
-               /** @var t3lib_pageSelect $sys_page */
-               $sys_page->init(FALSE);
-               $mountPointInfo = $sys_page->getMountPointInfo($this->id);
-               if ($mountPointInfo && $mountPointInfo['overlay']) {
-                       $this->id = $mountPointInfo['mount_pid'];
-                       $addCmd .= '&MP=' . $mountPointInfo['MPvar'];
-               }
-
-               $page = (array)$sys_page->getPage($this->id);
-
-               $urlScheme = 'http';
-               if ($page['url_scheme'] == 2 || $page['url_scheme'] == 0 && t3lib_div::getIndpEnv('TYPO3_SSL')) {
-                       $urlScheme = 'https';
-               }
-
-               $this->url .= ($dName
-                       ? $urlScheme . '://' . $dName
-                       : $GLOBALS['BACK_PATH'] . '..') . '/index.php?id=' . $this->id .
-                               ($this->type ? '&type='.$this->type : '') . $addCmd;
-       }
-
-       /**
-        * Redirect URL
-        *
-        * @return      void
-        */
-       function printContent() {
-               t3lib_utility_Http::redirect($this->url);
-       }
-}
-
-// Make instance:
-$SOBE = t3lib_div::makeInstance('SC_mod_web_view_index');
-$SOBE->init();
-$SOBE->main();
-$SOBE->printContent();
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/viewpage/view/layout.gif b/typo3/sysext/viewpage/view/layout.gif
deleted file mode 100755 (executable)
index 8f584c7..0000000
Binary files a/typo3/sysext/viewpage/view/layout.gif and /dev/null differ
diff --git a/typo3/sysext/viewpage/view/locallang_mod.xlf b/typo3/sysext/viewpage/view/locallang_mod.xlf
deleted file mode 100644 (file)
index 87eb058..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xliff version="1.0">
-       <file source-language="en" datatype="plaintext" original="messages" date="2011-10-17T20:22:37Z" product-name="viewpage">
-               <header/>
-               <body>
-                       <trans-unit id="mlang_labels_tablabel" xml:space="preserve">
-                               <source>View page</source>
-                       </trans-unit>
-                       <trans-unit id="mlang_labels_tabdescr" xml:space="preserve">
-                               <source>Shows the look of the current page and lets you edit the content directly.</source>
-                       </trans-unit>
-                       <trans-unit id="mlang_tabs_tab" xml:space="preserve">
-                               <source>View</source>
-                       </trans-unit>
-               </body>
-       </file>
-</xliff>
diff --git a/typo3/sysext/viewpage/view/view.gif b/typo3/sysext/viewpage/view/view.gif
deleted file mode 100755 (executable)
index 5eabb84..0000000
Binary files a/typo3/sysext/viewpage/view/view.gif and /dev/null differ