Added feature #16396: Implement a Grid View + wizard to enable the backend layout...
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / class.tx_cms_be_layout.php
1 <?php
2
3 class tx_cms_be_layout {
4
5 /**
6 * @mficzel
7 * @todo add items
8 * @param unknown_type $params
9 */
10 function colPosListItemProcFunc( &$params ){
11 $params['items'] = $this->addColPosListLayoutItems ( $params['row']['pid'], $params['items'] );
12 }
13
14 function addColPosListLayoutItems ( $pageId, $items ){
15 $layout = $this->getSelectedBackendLayout($pageId);
16 if( $layout && $layout['__items'] ){
17 $items = $layout['__items'];
18 }
19 return $items;
20 }
21
22 function getColPosListItemsParsed ( $id ){
23
24 $tsConfig = t3lib_BEfunc::getModTSconfig( $id ,'TCEFORM.tt_content.colPos');
25 $tcaConfig = $GLOBALS['TCA']['tt_content']['columns']['colPos']['config'];
26
27 $TCEForms = t3lib_div::makeInstance( 't3lib_TCEForms' );
28 $tcaItems = $tcaConfig['items'];
29 $tcaItems = $TCEForms->addItems($tcaItems, $tsConfig['properties']['addItems.']);
30 if (isset($tcaConfig['itemsProcFunc']) && $tcaConfig['itemsProcFunc']) {
31 $tcaItems = $this->addColPosListLayoutItems ($id , $tcaItems ) ;
32 }
33 foreach ( t3lib_div::trimExplode(',',$tsConfig['properties']['removeItems'],1) as $removeId ){
34 unset( $tcaItems[$removeId] );
35 }
36 return $tcaItems;
37 }
38
39 function getSelectedBackendLayout($id) {
40 $rootline = t3lib_BEfunc::BEgetRootLine($id);
41 $backendLayoutUid = null;
42 for ($i = count($rootline); $i > 0; $i--) {
43 $res = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,be_layout,be_layout_next_level','pages','uid='.intval($rootline[$i]['uid']));
44 $page = $res[0];
45 if (intval($page['be_layout_next_level']) > 0 && $page['uid'] != $id ) {
46 $backendLayoutUid = intval($page['be_layout_next_level']);
47 break;
48 } else if (intval($page['be_layout']) > 0) {
49 $backendLayoutUid = intval($page['be_layout']);
50 break;
51 }
52 }
53 $backendLayout = null;
54 if ($backendLayoutUid){
55 $res = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*','be_layouts','uid='.$backendLayoutUid );
56 if ($res){
57 $backendLayout = $res[0];
58 $parser = t3lib_div::makeInstance('t3lib_TSparser');
59 $parser->parse($backendLayout['config']);
60 $backendLayout['__config'] = $parser->setup;
61 $backendLayout['__items'] = array();
62 $backendLayout['__colPosList'] = array();
63
64 // create items and colPosList
65 if ( $backendLayout['__config']['be_layout.'] && $backendLayout['__config']['be_layout.']['rows.'] ){
66 foreach( $backendLayout['__config']['be_layout.']['rows.'] as $row){
67 if ( true && count($row['columns.'])){
68 foreach ( $row['columns.'] as $column) {
69 if ( true ){
70 $backendLayout['__items'][] = array (
71 $column['name'],
72 $column['colPos'],
73 null
74 );
75 $backendLayout['__colPosList'][] = $column['colPos'];
76 }
77 }
78 }
79 }
80 }
81
82 }
83 }
84 return $backendLayout;
85 }
86
87 }
88
89 ?>
90 <?php
91
92 class tx_cms_be_layout {
93
94 /**
95 * @mficzel
96 * @todo add items
97 * @param unknown_type $params
98 */
99 function colPosListItemProcFunc( &$params ){
100 $params['items'] = $this->addColPosListLayoutItems ( $params['row']['pid'], $params['items'] );
101 }
102
103 function addColPosListLayoutItems ( $pageId, $items ){
104 $layout = $this->getSelectedBackendLayout($pageId);
105 if( $layout && $layout['__items'] ){
106 $items = $layout['__items'];
107 }
108 return $items;
109 }
110
111 function getColPosListItemsParsed ( $id ){
112
113 $tsConfig = t3lib_BEfunc::getModTSconfig( $id ,'TCEFORM.tt_content.colPos');
114 $tcaConfig = $GLOBALS['TCA']['tt_content']['columns']['colPos']['config'];
115
116 $TCEForms = t3lib_div::makeInstance( 't3lib_TCEForms' );
117 $tcaItems = $tcaConfig['items'];
118 $tcaItems = $TCEForms->addItems($tcaItems, $tsConfig['properties']['addItems.']);
119 if (isset($tcaConfig['itemsProcFunc']) && $tcaConfig['itemsProcFunc']) {
120 $tcaItems = $this->addColPosListLayoutItems ($id , $tcaItems ) ;
121 }
122 foreach ( t3lib_div::trimExplode(',',$tsConfig['properties']['removeItems'],1) as $removeId ){
123 unset( $tcaItems[$removeId] );
124 }
125 return $tcaItems;
126 }
127
128 function getSelectedBackendLayout($id) {
129 $rootline = t3lib_BEfunc::BEgetRootLine($id);
130 $backendLayoutUid = null;
131 for ($i = count($rootline); $i > 0; $i--) {
132 $res = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,be_layout,be_layout_next_level','pages','uid='.intval($rootline[$i]['uid']));
133 $page = $res[0];
134 if (intval($page['be_layout_next_level']) > 0 && $page['uid'] != $id ) {
135 $backendLayoutUid = intval($page['be_layout_next_level']);
136 break;
137 } else if (intval($page['be_layout']) > 0) {
138 $backendLayoutUid = intval($page['be_layout']);
139 break;
140 }
141 }
142 $backendLayout = null;
143 if ($backendLayoutUid){
144 $res = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*','be_layouts','uid='.$backendLayoutUid );
145 if ($res){
146 $backendLayout = $res[0];
147 $parser = t3lib_div::makeInstance('t3lib_TSparser');
148 $parser->parse($backendLayout['config']);
149 $backendLayout['__config'] = $parser->setup;
150 $backendLayout['__items'] = array();
151 $backendLayout['__colPosList'] = array();
152
153 // create items and colPosList
154 if ( $backendLayout['__config']['be_layout.'] && $backendLayout['__config']['be_layout.']['rows.'] ){
155 foreach( $backendLayout['__config']['be_layout.']['rows.'] as $row){
156 if ( true && count($row['columns.'])){
157 foreach ( $row['columns.'] as $column) {
158 if ( true ){
159 $backendLayout['__items'][] = array (
160 $column['name'],
161 $column['colPos'],
162 null
163 );
164 $backendLayout['__colPosList'][] = $column['colPos'];
165 }
166 }
167 }
168 }
169 }
170
171 }
172 }
173 return $backendLayout;
174 }
175
176 }
177
178 ?>