Fixed bug: #10831: New preview window shows wrong behavior for new page in LIVE WS
authortolleiv <tolleiv@743128fe-103e-dd11-99c4-001b210b3e58>
Mon, 29 Nov 2010 17:09:29 +0000 (17:09 +0000)
committertolleiv <tolleiv@743128fe-103e-dd11-99c4-001b210b3e58>
Mon, 29 Nov 2010 17:09:29 +0000 (17:09 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/CoreProjects/workspaces/workspaces/trunk@3105 743128fe-103e-dd11-99c4-001b210b3e58

typo3/sysext/workspaces/ChangeLog
typo3/sysext/workspaces/Classes/Controller/PreviewController.php
typo3/sysext/workspaces/Classes/Service/Workspaces.php
typo3/sysext/workspaces/Resources/Private/Language/locallang.xml
typo3/sysext/workspaces/Resources/Private/Layouts/nodoc.html
typo3/sysext/workspaces/Resources/Private/Templates/Preview/NewPage.html [new file with mode: 0644]
typo3/sysext/workspaces/ext_tables.php

index 281cae2..3cf92d7 100644 (file)
@@ -1,3 +1,7 @@
+2010-11-29  Sonja Scholz  <ss@cabag.ch>
+
+       * Fixed bug: #10831: New preview window shows wrong behavior for new page in LIVE WS
+
 2010-11-28  Sonja Scholz  <ss@cabag.ch>
 
        * Fixed bug: #11116: Add some CSS classes for detailView
index 06ce938..21314dd 100644 (file)
@@ -92,7 +92,13 @@ class Tx_Workspaces_Controller_PreviewController extends Tx_Workspaces_Controlle
 
                // @todo - handle new pages here
                // branchpoints are not handled anymore because this feature is not supposed anymore
-               $this->view->assign('liveUrl', $wsBaseUrl . '&ADMCMD_noBeUser=1');
+               if (tx_Workspaces_Service_Workspaces::isNewPage($this->pageId)) {
+                       $wsNewPageUri = $uriBuilder->uriFor('newPage', array(), $this, 'workspaces', 'web_workspacesworkspaces');
+                       $wsNewPageParams = '&tx_workspaces_web_workspacesworkspaces[controller]=Preview';
+                       $this->view->assign('liveUrl', $wsSettingsPath . $wsNewPageUri . $wsNewPageParams);
+               } else {
+                       $this->view->assign('liveUrl', $wsBaseUrl . '&ADMCMD_noBeUser=1');
+               }
                $this->view->assign('wsUrl', $wsBaseUrl . '&ADMCMD_view=1&ADMCMD_editIcons=1&ADMCMD_previewWS=' . $GLOBALS['BE_USER']->workspace);
                $this->view->assign('wsSettingsUrl', $wsSettingsUrl);
                $this->view->assign('wsHelpUrl', $wsHelpUrl);
@@ -106,6 +112,19 @@ class Tx_Workspaces_Controller_PreviewController extends Tx_Workspaces_Controlle
        }
 
        /**
+        * @return void
+        */
+       public function newPageAction() {
+               $message = t3lib_div::makeInstance(
+                       't3lib_FlashMessage',
+                       $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:info.newpage.detail'),
+                       $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:info.newpage'),
+                       t3lib_FlashMessage::INFO
+               );
+               t3lib_FlashMessageQueue::addMessage($message);
+       }
+
+       /**
         * Generates the JavaScript code for the backend,
         * and since we're loading a backend module outside of the actual backend
         * this copies parts of the backend.php
index d31cb80..d2f0aa8 100644 (file)
@@ -423,6 +423,37 @@ class tx_Workspaces_Service_Workspaces {
                }
                return $oldStyleWorkspaceIsUsed;
        }
+
+       /**
+        * Determine whether a specific page is new and not yet available in the LIVE workspace
+        *
+        * @static
+        * @param $id Primary key of the page to check
+        * @param $language Language for which to check the page
+        * @return bool
+        */
+       public static function isNewPage($id, $language = 0) {
+               $isNewPage = FALSE;
+                       // If the language is not default, check state of overlay
+               if ($language > 0) {
+                       $whereClause = 'pid = ' . $id;
+                       $whereClause .= ' AND ' .$GLOBALS['TCA']['pages_language_overlay']['ctrl']['languageField'] . ' = ' . $language;
+                       $whereClause .= ' AND t3ver_wsid = ' . $GLOBALS['BE_USER']->workspace;
+                       $whereClause .= t3lib_BEfunc::deleteClause('pages_language_overlay');
+                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('t3ver_state', 'pages_language_overlay', $whereClause);
+                       if (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))) {
+                               $isNewPage = (int) $row['t3ver_state'] === 1;
+                       }
+
+                       // Otherwise check state of page itself
+               } else {
+                       $rec = t3lib_BEfunc::getRecord('pages', $id, 't3ver_state');
+                       if (is_array($rec)) {
+                               $isNewPage = (int) $rec['t3ver_state'] === 1;
+                       }
+               }
+               return $isNewPage;
+       }
 }
 
 
index 2c15205..daa7785 100644 (file)
@@ -68,6 +68,8 @@
                        <label index="window.sendToNextStageWindow.comments">Comments</label>
                        <label index="error.getStageTitle.stageNotFound">Stage not found</label>
                        <label index="warning.oldStyleWorkspaceInUser">It seems that you're stil using old-style workspace. If you continue using this module without migrating your workspace you might loose data.</label>
+                       <label index="info.newpage">New Page!</label>
+                       <label index="info.newpage.detail">The previewed page has been created in a workspace and has no live counterpart.</label>
                </languageKey>
        </data>
 </T3locallang>
\ No newline at end of file
index 3c5e0bc..38ad7bc 100644 (file)
@@ -1,8 +1,11 @@
-<!-- ###FULLDOC### begin -->
+{namespace this=Tx_Workspaces_ViewHelpers}
 <div class="typo3-noDoc">
        <!-- Content of module, for instance listing, info or editing -->
        <div id="typo3-docbody">
                <div id="typo3-inner-docbody">
+
+                       <this:TempFlashMessageQueue />
+
                        <f:render section="main"/>
                </div>
        </div>
diff --git a/typo3/sysext/workspaces/Resources/Private/Templates/Preview/NewPage.html b/typo3/sysext/workspaces/Resources/Private/Templates/Preview/NewPage.html
new file mode 100644 (file)
index 0000000..41fac08
--- /dev/null
@@ -0,0 +1,3 @@
+<f:layout name="nodoc" />
+
+<f:section name="main"></f:section>
index 84744c5..1ea0a51 100644 (file)
@@ -15,7 +15,7 @@ if (TYPO3_MODE == 'BE') {
                array(
                                // An array holding the controller-action-combinations that are accessible
                        'Review'                => 'index,fullIndex,singleIndex',
-                       'Preview'               => 'index,help'
+                       'Preview'               => 'index,help,newPage'
                ),
                array(
                        'access' => 'user,group',