Added a $ sign at the end of the regular expression and fixed indenting in the new...
[Packages/TYPO3.CMS.git] / typo3 / alt_shortcut.php
index 47d5565..f88c3be 100755 (executable)
  *
  *
  *
- *   82: class SC_alt_shortcut
- *  121:     function preinit()
- *  146:     function preprocess()
- *  203:     function init()
- *  237:     function main()
- *  345:     function editLoadedFunc()
- *  406:     function editPageIdFunc()
- *  454:     function printContent()
+ *   86: class SC_alt_shortcut
+ *  125:     function preinit()
+ *  152:     function preprocess()
+ *  234:     function init()
+ *  275:     function main()
+ *  452:     function editLoadedFunc()
+ *  532:     function editPageIdFunc()
+ *  586:     function printContent()
+ *
+ *              SECTION: WORKSPACE FUNCTIONS:
+ *  611:     function workspaceSelector()
  *
  *              SECTION: OTHER FUNCTIONS:
- *  482:     function mIconFilename($Ifilename,$backPath)
- *  495:     function getIcon($modName)
- *  519:     function itemLabel($inlabel,$modName,$M_modName='')
+ *  686:     function mIconFilename($Ifilename,$backPath)
+ *  702:     function getIcon($modName)
+ *  726:     function itemLabel($inlabel,$modName,$M_modName='')
+ *  748:     function getLinkedPageId($url)
  *
- * TOTAL FUNCTIONS: 10
+ * TOTAL FUNCTIONS: 12
  * (This index is automatically created/updated by the extension "extdeveval")
  *
  */
@@ -247,16 +251,19 @@ class SC_alt_shortcut {
                                top.goToModule(modName);
                        }
                        function editSh(uid)    {       //
-                               document.location="alt_shortcut.php?editShortcut="+uid;
+                               window.location.href="alt_shortcut.php?editShortcut="+uid;
                        }
                        function submitEditPage(id)     {       //
-                               document.location="alt_shortcut.php?editPage="+top.rawurlencode(id);
+                               window.location.href="alt_shortcut.php?editPage="+top.rawurlencode(id);
                        }
                        function changeWorkspace(workspaceId)   {       //
-                               document.location="alt_shortcut.php?changeWorkspace="+top.rawurlencode(workspaceId);
+                               window.location.href="alt_shortcut.php?changeWorkspace="+top.rawurlencode(workspaceId);
                        }
                        function changeWorkspacePreview(newstate)       {       //
-                               document.location="alt_shortcut.php?changeWorkspacePreview="+newstate;
+                               window.location.href="alt_shortcut.php?changeWorkspacePreview="+newstate;
+                       }
+                       function refreshShortcuts() { 
+                               window.location.href = document.URL;
                        }
 
                        ');
@@ -348,7 +355,7 @@ class SC_alt_shortcut {
                                        }
 
                                        if ($sc_group>=0)       {
-                                               $onC = 'if (confirm('.$GLOBALS['LANG']->JScharCode($LANG->getLL('shortcut_delAllInCat')).')){document.location=\'alt_shortcut.php?deleteCategory='.$sc_group.'\';}return false;';
+                                               $onC = 'if (confirm('.$GLOBALS['LANG']->JScharCode($LANG->getLL('shortcut_delAllInCat')).')){window.location.href=\'alt_shortcut.php?deleteCategory='.$sc_group.'\';}return false;';
                                                $this->linesPre[]='<td>&nbsp;</td><td class="bgColor5"><a href="#" onclick="'.htmlspecialchars($onC).'" title="'.$LANG->getLL('shortcut_delAllInCat',1).'">'.$label.'</a></td>';
                                        } else {
                                                $label = $LANG->getLL('shortcut_global',1).': '.($label ? $label : abs($sc_group));     // Fallback label
@@ -390,7 +397,7 @@ class SC_alt_shortcut {
                if (!$this->editLoaded && t3lib_extMgm::isLoaded('cms'))        {
                                $editIdCode = '<td nowrap="nowrap">'.$LANG->getLL('shortcut_editID',1).': <input type="text" value="'.($this->editError?htmlspecialchars($this->editPage):'').'" name="editPage"'.$this->doc->formWidth(15).' onchange="submitEditPage(this.value);" />'.
                                        ($this->editError?'&nbsp;<strong><span class="typo3-red">'.htmlspecialchars($this->editError).'</span></strong>':'').
-                                       (is_array($this->theEditRec)?'&nbsp;<strong>'.$LANG->getLL('shortcut_loadEdit',1).' \''.t3lib_BEfunc::getRecordTitle('pages',$this->theEditRec,1).'\'</strong> ('.htmlspecialchars($this->editPath).')':'').
+                                       (is_array($this->theEditRec)?'&nbsp;<strong>'.$LANG->getLL('shortcut_loadEdit',1).' \''.t3lib_BEfunc::getRecordTitle('pages',$this->theEditRec,TRUE).'\'</strong> ('.htmlspecialchars($this->editPath).')':'').
                                        ($this->searchFor?'&nbsp;'.$LANG->getLL('shortcut_searchFor',1).' <strong>\''.htmlspecialchars($this->searchFor).'\'</strong>':'').
                                        '</td>';
                } else $editIdCode = '';
@@ -414,9 +421,12 @@ class SC_alt_shortcut {
                                                        </tr>
                                                </table>
                                        </td>
-                                       <td align="right">
-                                               '.$this->workspaceSelector().
-                                                       t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'workspaceSelector', $GLOBALS['BACK_PATH'],'',TRUE).'
+                                       <td align="right">';
+               if ($this->hasWorkspaceAccess()) {
+                       $this->content .= $this->workspaceSelector() .
+                                                               t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'workspaceSelector', $GLOBALS['BACK_PATH'],'',TRUE);
+               }
+               $this->content .= '
                                        </td>
                                </tr>
                        </table>
@@ -512,7 +522,7 @@ class SC_alt_shortcut {
 
                if (count($this->lines))        {
                        if (!$BE_USER->getTSConfigVal('options.mayNotCreateEditShortcuts'))     {
-                               $this->lines=array_merge(array('<td><input type="checkbox" id="editShortcut_check" name="editShortcut_check" value="1"'.($this->editSC?' checked="checked"':'').' /><label for="editShortcut_check">'.$LANG->getLL('shortcut_edit',1).'</label>&nbsp;</td>'),$this->lines);
+                               $this->lines=array_merge(array('<td><input type="checkbox" id="editShortcut_check" name="editShortcut_check" value="1"'.($this->editSC?' checked="checked"':'').' /> <label for="editShortcut_check">'.$LANG->getLL('shortcut_edit',1).'</label>&nbsp;</td>'),$this->lines);
                                $this->lines[]='<td>'.$manageForm.'</td>';
                        }
                        $this->lines[]='<td><img src="clear.gif" width="10" height="1" alt="" /></td>';
@@ -531,7 +541,7 @@ class SC_alt_shortcut {
                if (!t3lib_extMgm::isLoaded('cms'))     return;
 
                        // EDIT page:
-               $this->editPage = trim(strtolower($this->editPage));
+               $this->editPage = trim($LANG->csConvObj->conv_case($LANG->charSet,$this->editPage,'toLower'));
                $this->editError = '';
                $this->theEditRec = '';
                $this->searchFor = '';
@@ -581,6 +591,7 @@ class SC_alt_shortcut {
         */
        function printContent() {
                $this->content.= $this->doc->endPage();
+               $this->content = $this->doc->insertStylesAndJS($this->content);
                echo $this->content;
        }
 
@@ -609,7 +620,7 @@ class SC_alt_shortcut {
                        // Changing workspace and if so, reloading entire backend:
                if (strlen($this->changeWorkspace))     {
                        $BE_USER->setWorkspace($this->changeWorkspace);
-                       return $this->doc->wrapScriptTags('top.document.location="alt_main.php";');
+                       return $this->doc->wrapScriptTags('top.location.href="alt_main.php";');
                }
                        // Changing workspace and if so, reloading entire backend:
                if (strlen($this->changeWorkspacePreview))      {
@@ -627,9 +638,11 @@ class SC_alt_shortcut {
 
                        // Add custom workspaces (selecting all, filtering by BE_USER check):
                $workspaces = $TYPO3_DB->exec_SELECTgetRows('uid,title,adminusers,members,reviewers','sys_workspace','pid=0'.t3lib_BEfunc::deleteClause('sys_workspace'),'','title');
-               foreach($workspaces as $rec)    {
-                       if ($BE_USER->checkWorkspace($rec))     {
-                               $options[$rec['uid']] = $rec['uid'].': '.$rec['title'];
+               if (count($workspaces)) {
+                       foreach ($workspaces as $rec)   {
+                               if ($BE_USER->checkWorkspace($rec))     {
+                                       $options[$rec['uid']] = $rec['uid'].': '.$rec['title'];
+                               }
                        }
                }
 
@@ -646,13 +659,15 @@ class SC_alt_shortcut {
                $selector = '';
                        // Preview:
                if ($BE_USER->workspace!==0)    {
-                       $selector.= 'Frontend Preview: <input type="checkbox" onclick="changeWorkspacePreview('.($BE_USER->user['workspace_preview'] ? 0 : 1).')"; '.($BE_USER->user['workspace_preview'] ? 'checked="checked"' : '').'/>&nbsp;';
+                       $selector.= '<label for="workspacePreview">Frontend Preview:</label> <input type="checkbox" name="workspacePreview" id="workspacePreview" onclick="changeWorkspacePreview('.($BE_USER->user['workspace_preview'] ? 0 : 1).')"; '.($BE_USER->user['workspace_preview'] ? 'checked="checked"' : '').'/>&nbsp;';
                }
 
                $selector.= '<a href="mod/user/ws/index.php" target="content">'.
                                        t3lib_iconWorks::getIconImage('sys_workspace',array(),$this->doc->backPath,'align="top"').
-                                       '</a>'.
-                                       '<select name="_workspaceSelector" onchange="changeWorkspace(this.options[this.selectedIndex].value);">'.implode('',$options).'</select>';
+                                       '</a>';
+               if (count($options) > 1) {
+                       $selector .= '<select name="_workspaceSelector" onchange="changeWorkspace(this.options[this.selectedIndex].value);">'.implode('',$options).'</select>';
+               }
 
                return $selector;
        }
@@ -741,6 +756,17 @@ class SC_alt_shortcut {
        function getLinkedPageId($url)  {
                return preg_replace('/.*[\?&]id=([^&]+).*/', '$1', $url);
        }
+
+       /**
+        * Checks if user has access to Workspace module.
+        *
+        * @return      boolean         Returns true if user has access to workspace module.
+        */
+       function hasWorkspaceAccess() {
+               $MCONF = array();
+               include('mod/user/ws/conf.php');
+               return $GLOBALS['BE_USER']->modAccess($MCONF, false);
+       }
 }
 
 // Include extension?