14050_cleaning_t3lib_arraybrowser
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_scbase.php
index a1e7278..5494ee6 100644 (file)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
+*  (c) 1999-2010 Kasper Skårhøj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -28,9 +28,9 @@
  * Contains the parent class for 'ScriptClasses' in backend modules.
  *
  * $Id$
- * Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj
+ * Revised for TYPO3 3.6 July/2003 by Kasper Skårhøj
  *
- * @author     Kasper Skaarhoj <kasper@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  */
 /**
  * [CLASS/FUNCTION INDEX of SCRIPT]
  *
  *  133: class t3lib_SCbase
  *  249:     function init()
- *  266:     function menuConfig()
- *  286:     function mergeExternalItems($modName,$menuKey,$menuArr)
- *  305:     function handleExternalFunctionValue($MM_key='function')
- *  322:     function getExternalItemConfig($modName,$menuKey,$value='')
- *  336:     function checkExtObj()
- *  350:     function checkSubExtObj()
- *  362:     function extObjHeader()
- *  371:     function extObjContent()
+ *  269:     function menuConfig()
+ *  292:     function mergeExternalItems($modName,$menuKey,$menuArr)
+ *  317:     function handleExternalFunctionValue($MM_key='function', $MS_value=NULL)
+ *  335:     function getExternalItemConfig($modName,$menuKey,$value='')
+ *  349:     function checkExtObj()
+ *  363:     function checkSubExtObj()
+ *  375:     function extObjHeader()
+ *  384:     function extObjContent()
  *
  * TOTAL FUNCTIONS: 9
  * (This index is automatically created/updated by the extension "extdeveval")
@@ -80,7 +80,6 @@
  *             require ($BACK_PATH.'init.php');
  *             require ($BACK_PATH.'template.php');
  *             $LANG->includeLLFile('EXT:prototype/locallang.php');
- *             require_once(PATH_t3lib.'class.t3lib_scbase.php');              // NOTICE THE INCLUSION OF t3lib_SCbase
  *             $BE_USER->modAccess($MCONF,1);
  *
  *                     // SC_mod_prototype EXTENDS THE CLASS t3lib_SCbase with a main() and printContent() function:
  * Parent class for 'ScriptClasses' in backend modules.
  * See example comment above.
  *
- * @author     Kasper Skaarhoj <kasper@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage t3lib
  * @see t3lib_extobjbase
@@ -223,6 +222,8 @@ class t3lib_SCbase {
 
        /**
         * Generally used to hold an instance of the 'template' class from typo3/template.php
+        *
+        * @var template
         */
        var $doc;
 
@@ -247,7 +248,10 @@ class t3lib_SCbase {
         * @see menuConfig()
         */
        function init() {
-               $this->MCONF = $GLOBALS['MCONF'];
+                       // name might be set from outside
+               if (!$this->MCONF['name']) {
+                       $this->MCONF = $GLOBALS['MCONF'];
+               }
                $this->id = intval(t3lib_div::_GP('id'));
                $this->CMD = t3lib_div::_GP('CMD');
                $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
@@ -272,7 +276,6 @@ class t3lib_SCbase {
                #debug($this->MOD_MENU['function'],$this->MCONF['name']);
                #debug($this->modTSconfig['properties']);
 
-                       // CLEANSE 'function' SETTINGS
                $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name'], $this->modMenu_type, $this->modMenu_dontValidateList, $this->modMenu_setDefaultList);
        }
 
@@ -289,9 +292,13 @@ class t3lib_SCbase {
        function mergeExternalItems($modName,$menuKey,$menuArr) {
                $mergeArray = $GLOBALS['TBE_MODULES_EXT'][$modName]['MOD_MENU'][$menuKey];
                if (is_array($mergeArray))      {
-                       reset($mergeArray);
-                       while(list($k,$v)=each($mergeArray))    {
-                               $menuArr[$k]=$GLOBALS['LANG']->sL($v['title']);
+                       foreach ($mergeArray as $k => $v) {
+                               if ((string)$v['ws']==='' ||
+                                       ($GLOBALS['BE_USER']->workspace===0 && t3lib_div::inList($v['ws'],'online')) ||
+                                       ($GLOBALS['BE_USER']->workspace===-1 && t3lib_div::inList($v['ws'],'offline')) ||
+                                       ($GLOBALS['BE_USER']->workspace>0 && t3lib_div::inList($v['ws'],'custom')))     {
+                                               $menuArr[$k]=$GLOBALS['LANG']->sL($v['title']);
+                               }
                        }
                }
                return $menuArr;
@@ -302,11 +309,13 @@ class t3lib_SCbase {
         * If for this array the key 'path' is set then that is expected to be an absolute path to a file which should be included - so it is set in the internal array $this->include_once
         *
         * @param       string          The key to MOD_MENU for which to fetch configuration. 'function' is default since it is first and foremost used to get information per "extension object" (I think that is what its called)
+        * @param       string          The value-key to fetch from the config array. If NULL (default) MOD_SETTINGS[$MM_key] will be used. This is usefull if you want to force another function than the one defined in MOD_SETTINGS[function]. Call this in init() function of your Script Class: handleExternalFunctionValue('function', $forcedSubModKey)
         * @return      void
-        * @see $include_once, init()
+        * @see getExternalItemConfig(), $include_once, init()
         */
-       function handleExternalFunctionValue($MM_key='function')        {
-               $this->extClassConf = $this->getExternalItemConfig($this->MCONF['name'],$MM_key,$this->MOD_SETTINGS[$MM_key]);
+       function handleExternalFunctionValue($MM_key='function', $MS_value=NULL)        {
+               $MS_value = is_null($MS_value) ? $this->MOD_SETTINGS[$MM_key] : $MS_value;
+               $this->extClassConf = $this->getExternalItemConfig($this->MCONF['name'],$MM_key,$MS_value);
                if (is_array($this->extClassConf) && $this->extClassConf['path'])       {
                        $this->include_once[]=$this->extClassConf['path'];
                }
@@ -341,7 +350,7 @@ class t3lib_SCbase {
                        $this->extObj = t3lib_div::makeInstance($this->extClassConf['name']);
                        $this->extObj->init($this,$this->extClassConf);
                                // Re-write:
-                       $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
+                       $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name'], $this->modMenu_type, $this->modMenu_dontValidateList, $this->modMenu_setDefaultList);
                }
        }
 
@@ -371,9 +380,13 @@ class t3lib_SCbase {
         *
         * @return      void
         */
-       function extObjContent()        {
-               $this->extObj->pObj = &$this;
-               if (is_callable(array($this->extObj, 'main')))  $this->content.=$this->extObj->main();
+       function extObjContent() {
+               $this->extObj->pObj = $this;
+
+               if (is_callable(array($this->extObj, 'main'))) {
+                       $this->content .= $this->extObj->main();
+               }
        }
 }
-?>
+
+?>
\ No newline at end of file