Follow-up to #16396: cleanup code, added phpDoc and XCLASS definition
authorSteffen Kamper <info@sk-typo3.de>
Fri, 3 Dec 2010 12:46:11 +0000 (12:46 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Fri, 3 Dec 2010 12:46:11 +0000 (12:46 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@9752 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/cms/class.tx_cms_be_layout.php
typo3/sysext/cms/layout/class.tx_cms_layout.php

index 5d152b3..8bb3e15 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-12-03  Steffen Kamper  <steffen@typo3.org>
+
+       * Follow-up to #16396: cleanup code, added phpDoc and XCLASS definition
+
 2010-12-02  Steffen Kamper  <steffen@typo3.org>
 
        * Fixed bug #16645: EM - Install extension with dependency
index 4c12486..a73b85e 100644 (file)
 class tx_cms_be_layout {
 
        /**
-        * @mficzel
-        * @todo add items
-        * @param unknown_type $params
+        * ItemProcFunc for colpos items
+        *
+        * @param  array $params
+        * @return void
         */
-       function colPosListItemProcFunc(&$params) {
+       public function colPosListItemProcFunc(&$params) {
                $params['items'] = $this->addColPosListLayoutItems($params['row']['pid'], $params['items']);
        }
 
-       function addColPosListLayoutItems($pageId, $items) {
+       /**
+        * Adds items to a colpos list
+        *
+        * @param  int  $pageId
+        * @param  array  $items
+        * @return array
+        */
+       protected function addColPosListLayoutItems($pageId, $items) {
                $layout = $this->getSelectedBackendLayout($pageId);
                if ($layout && $layout['__items']) {
                        $items = $layout['__items'];
@@ -44,28 +52,46 @@ class tx_cms_be_layout {
                return $items;
        }
 
-       function getColPosListItemsParsed($id) {
+       /**
+        * Gets the list of available columns for a given page id
+        *
+        * @param  int  $id
+        * @return  array  $tcaItems
+        */
+       public function getColPosListItemsParsed($id) {
 
                $tsConfig = t3lib_BEfunc::getModTSconfig($id, 'TCEFORM.tt_content.colPos');
                $tcaConfig = $GLOBALS['TCA']['tt_content']['columns']['colPos']['config'];
 
-               $TCEForms = t3lib_div::makeInstance('t3lib_TCEForms');
+               /** @var $tceForms  t3lib_TCEForms */
+               $tceForms = t3lib_div::makeInstance('t3lib_TCEForms');
                $tcaItems = $tcaConfig['items'];
-               $tcaItems = $TCEForms->addItems($tcaItems, $tsConfig['properties']['addItems.']);
+               $tcaItems = $tceForms->addItems($tcaItems, $tsConfig['properties']['addItems.']);
                if (isset($tcaConfig['itemsProcFunc']) && $tcaConfig['itemsProcFunc']) {
                        $tcaItems = $this->addColPosListLayoutItems($id, $tcaItems);
                }
                foreach (t3lib_div::trimExplode(',', $tsConfig['properties']['removeItems'], 1) as $removeId) {
                        unset($tcaItems[$removeId]);
                }
+
                return $tcaItems;
        }
 
-       function getSelectedBackendLayout($id) {
+       /**
+        * Gets the selected backend layout
+        *
+        * @param  int  $id
+        * @return array|null  $backendLayout
+        */
+       public function getSelectedBackendLayout($id) {
                $rootline = t3lib_BEfunc::BEgetRootLine($id);
                $backendLayoutUid = null;
                for ($i = count($rootline); $i > 0; $i--) {
-                       $page = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('uid, be_layout, be_layout_next_level', 'pages', 'uid=' . intval($rootline[$i]['uid']));
+                       $page = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
+                               'uid, be_layout, be_layout_next_level',
+                               'pages',
+                               'uid=' . intval($rootline[$i]['uid'])
+                       );
                        if (intval($page['be_layout_next_level']) > 0 && $page['uid'] != $id) {
                                $backendLayoutUid = intval($page['be_layout_next_level']);
                                break;
@@ -76,10 +102,11 @@ class tx_cms_be_layout {
                                }
                        }
                }
-               $backendLayout = null;
+               $backendLayout = NULL;
                if ($backendLayoutUid) {
                        $backendLayout = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'be_layouts', 'uid=' . $backendLayoutUid);
                        if ($backendLayout) {
+                               /** @var $parser  t3lib_TSparser */
                                $parser = t3lib_div::makeInstance('t3lib_TSparser');
                                $parser->parse($backendLayout['config']);
                                $backendLayout['__config'] = $parser->setup;
@@ -89,16 +116,18 @@ class tx_cms_be_layout {
                                // create items and colPosList
                                if ($backendLayout['__config']['be_layout.'] && $backendLayout['__config']['be_layout.']['rows.']) {
                                        foreach ($backendLayout['__config']['be_layout.']['rows.'] as $row) {
+                                               if (isset($row['columns.']) && is_array($row['columns.'])) {
                                                        foreach ($row['columns.'] as $column) {
-                                                                       $backendLayout['__items'][] = array(
-                                                                               $column['name'],
-                                                                               $column['colPos'],
-                                                               NULL
-                                                                       );
-                                                                       $backendLayout['__colPosList'][] = $column['colPos'];
-                                                               }
+                                                               $backendLayout['__items'][] = array(
+                                                                       $column['name'],
+                                                                       $column['colPos'],
+                                                                       NULL
+                                                               );
+                                                               $backendLayout['__colPosList'][] = $column['colPos'];
                                                        }
                                                }
+                                       }
+                               }
 
                        }
                }
@@ -107,4 +136,8 @@ class tx_cms_be_layout {
 
 }
 
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/class.tx_cms_be_layout.php']) {
+       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/class.tx_cms_be_layout.php']);
+}
+
 ?>
\ No newline at end of file
index 8293b0b..257926f 100755 (executable)
@@ -2739,4 +2739,4 @@ if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/lay
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/layout/class.tx_cms_layout.php']);
 }
 
-?>
+?>
\ No newline at end of file