|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2011 Kasper Sk?rh?j (kasperYYYY@typo3.com) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00027 /** 00028 * Grid wizard 00029 * 00030 * $Id $ 00031 */ 00032 00033 require_once('conf.php'); 00034 require($BACK_PATH . 'init.php'); 00035 require($BACK_PATH . 'template.php'); 00036 $LANG->includeLLFile('EXT:lang/locallang_wizards.xml'); 00037 00038 /** 00039 * Script Class for grid wizard 00040 * 00041 * @author T3UXW09 Team1 <modernbe@cybercraft.de> 00042 * @package TYPO3 00043 * @subpackage core 00044 */ 00045 class SC_wizard_backend_layout { 00046 00047 // GET vars: 00048 var $P; // Wizard parameters, coming from TCEforms linking to the wizard. 00049 00050 /** 00051 * document template object 00052 * 00053 * @var smallDoc 00054 */ 00055 var $doc; 00056 var $content; // Accumulated content. 00057 00058 00059 /** 00060 * Initialises the Class 00061 * 00062 * @return void 00063 */ 00064 function init() { 00065 00066 00067 // Setting GET vars (used in frameset script): 00068 $this->P = t3lib_div::_GP('P', 1); 00069 00070 //data[layouts][2][config] 00071 $this->formName = $this->P['formName']; 00072 $this->fieldName = $this->P['itemName']; 00073 $this->md5ID = $this->P['md5ID']; 00074 $uid = intval($this->P['uid']); 00075 00076 // Initialize document object: 00077 $this->doc = t3lib_div::makeInstance('noDoc'); 00078 $this->doc->backPath = $GLOBALS['BACK_PATH']; 00079 00080 $pageRenderer = $this->doc->getPageRenderer(); 00081 $pageRenderer->addJsFile($GLOBALS['BACK_PATH'] . TYPO3_MOD_PATH . 'res/grideditor.js'); 00082 $pageRenderer->addJsInlineCode('storeData', ' 00083 function storeData(data) { 00084 if (parent.opener && parent.opener.document && parent.opener.document.' . $this->formName . ' && parent.opener.document.' . $this->formName . '["' . $this->fieldName . '"]) { 00085 parent.opener.document.' . $this->formName . '["' . $this->fieldName . '"].value = data; 00086 parent.opener.TBE_EDITOR.fieldChanged("backend_layout","' . $uid . '","config","data[backend_layout][' . $uid . '][config]"); 00087 } 00088 } 00089 '); 00090 00091 $languageLabels = array( 00092 'save' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_wizards.xml:grid_labelSave', 1), 00093 'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_wizards.xml:grid_windowTitle', 1), 00094 'name' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_wizards.xml:grid_labelName', 1), 00095 'column' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_wizards.xml:grid_labelColumn', 1), 00096 'editCell' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_wizards.xml:grid_editCell', 1), 00097 'mergeCell' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_wizards.xml:grid_mergeCell', 1), 00098 'splitCell' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_wizards.xml:grid_splitCell', 1), 00099 'name' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_wizards.xml:grid_name', 1), 00100 'column' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_wizards.xml:grid_column', 1), 00101 'notSet' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_wizards.xml:grid_notSet', 1), 00102 'nameHelp' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_wizards.xml:grid_nameHelp', 1), 00103 'columnHelp' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_wizards.xml:grid_columnHelp', 1), 00104 ); 00105 $pageRenderer->addInlineLanguageLabelArray($languageLabels); 00106 00107 // select record 00108 $record = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($this->P['field'], $this->P['table'], 'uid=' . intval($this->P['uid'])); 00109 if (trim($record[0][$this->P['field']]) == '') { 00110 $t3GridData = "[[{colspan:1,rowspan:1,spanned:false,name:''}]]"; 00111 $colCount = 1; 00112 $rowCount = 1; 00113 } else { 00114 00115 // load TS parser 00116 $parser = t3lib_div::makeInstance('t3lib_TSparser'); 00117 $parser->parse($record[0][$this->P['field']]); 00118 $data = $parser->setup['backend_layout.']; 00119 $t3GridData = '['; 00120 $colCount = $data['colCount']; 00121 $rowCount = $data['rowCount']; 00122 $dataRows = $data['rows.']; 00123 $spannedMatrix = array(); 00124 00125 for ($i = 1; $i <= $rowCount; $i++) { 00126 $rowString = ''; 00127 for ($j = 1; $j <= $colCount; $j++) { 00128 if ($j == 1) { 00129 $row = array_shift($dataRows); 00130 $columns = $row['columns.']; 00131 $rowString = '['; 00132 $cells = array(); 00133 } 00134 if (!$spannedMatrix[$i][$j]) { 00135 if (is_array($columns) && count($columns)) { 00136 $column = array_shift($columns); 00137 $cellString = '{'; 00138 $cellData = array(); 00139 if (isset($column['colspan'])) { 00140 $cellData[] = 'colspan:' . intval($column['colspan']); 00141 if (isset($column['rowspan'])) { 00142 for ($spanRow = 0; $spanRow < intval($column['rowspan']); $spanRow++) { 00143 for ($spanColumn = 0; $spanColumn < intval($column['colspan']); $spanColumn++) { 00144 $spannedMatrix[$i + $spanRow][$j + $spanColumn] = 1; 00145 } 00146 } 00147 } else { 00148 for ($spanColumn = 0; $spanColumn < intval($column['colspan']); $spanColumn++) { 00149 $spannedMatrix[$i][$j + $spanColumn] = 1; 00150 } 00151 } 00152 } else { 00153 $cellData[] = 'colspan:1'; 00154 if (isset($column['rowspan'])) { 00155 for ($spanRow = 0; $spanRow < intval($column['rowspan']); $spanRow++) { 00156 $spannedMatrix[$i + $spanRow][$j] = 1; 00157 } 00158 } 00159 } 00160 if (isset($column['rowspan'])) { 00161 $cellData[] = 'rowspan:' . intval($column['rowspan']); 00162 } else { 00163 $cellData[] = 'rowspan:1'; 00164 } 00165 if (isset($column['name'])) { 00166 $cellData[] = 'name:\'' . $column['name'] . '\''; 00167 } 00168 if (isset($column['colPos'])) { 00169 $cellData[] = 'column:' . $column['colPos']; 00170 } 00171 00172 $cellString .= implode(',', $cellData) . '}'; 00173 $cells[] = $cellString; 00174 00175 } 00176 } else { 00177 $cells[] = '{colspan:1,rowspan:1,spanned:1}'; 00178 } 00179 } 00180 $rowString .= implode(',', $cells); 00181 if ($rowString) { 00182 $rowString .= ']'; 00183 } 00184 $rows[] = $rowString; 00185 ksort($spannedMatrix[$i]); 00186 } 00187 00188 $t3GridData .= implode(',', $rows) . ']'; 00189 00190 00191 } 00192 00193 $pageRenderer->enableExtJSQuickTips(); 00194 00195 $pageRenderer->addExtOnReadyCode(' 00196 t3Grid = new TYPO3.Backend.t3Grid({ 00197 data: ' . $t3GridData . ', 00198 colCount: ' . $colCount . ', 00199 rowCount: ' . $rowCount . ', 00200 targetElement: \'editor\' 00201 }); 00202 t3Grid.drawTable(); 00203 '); 00204 00205 00206 $this->doc->styleSheetFile_post = TYPO3_MOD_PATH . 'res/grideditor.css'; 00207 } 00208 00209 /** 00210 * Main Method, rendering either colorpicker or frameset depending on ->showPicker 00211 * 00212 * @return void 00213 */ 00214 function main() { 00215 00216 $content .= '<a href="#" title="' . 00217 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc', TRUE) . '" onclick="storeData(t3Grid.export2LayoutRecord());return true;">' . 00218 t3lib_iconWorks::getSpriteIcon('actions-document-save') . '</a>'; 00219 00220 $content .= '<a href="#" title="' . 00221 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveCloseDoc', TRUE) . '" onclick="storeData(t3Grid.export2LayoutRecord());window.close();return true;">' . 00222 t3lib_iconWorks::getSpriteIcon('actions-document-save-close') . '</a>'; 00223 00224 $content .= '<a href="#" title="'. 00225 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc', TRUE) . '" onclick="window.close();return true;">' . 00226 t3lib_iconWorks::getSpriteIcon('actions-document-close') . '</a>'; 00227 00228 00229 $content .= $this->doc->spacer(10); 00230 00231 $content .= ' 00232 <table border="0" width="100%" height="100%" id="outer_container"> 00233 <tr> 00234 <td class="editor_cell"> 00235 <div id="editor"> 00236 </div> 00237 </td> 00238 <td width="20" valign="center"> 00239 <a class="addCol" href="#" title="' . $GLOBALS['LANG']->getLL('grid_addColumn') . '" onclick="t3Grid.addColumn(); t3Grid.drawTable(\'editor\');"> 00240 <img src="res/t3grid-tableright.png" border="0" /> 00241 </a><br /> 00242 <a class="removeCol" href="#" title="' . $GLOBALS['LANG']->getLL('grid_removeColumn') . '" onclick="t3Grid.removeColumn(); t3Grid.drawTable(\'editor\');"> 00243 <img src="res/t3grid-tableleft.png" border="0" /> 00244 </a> 00245 </td> 00246 </tr> 00247 <tr> 00248 <td colspan="2" height="20" align="center"> 00249 <a class="addCol" href="#" title="' . $GLOBALS['LANG']->getLL('grid_addRow') . '" onclick="t3Grid.addRow(); t3Grid.drawTable(\'editor\');"> 00250 <img src="res/t3grid-tabledown.png" border="0" /> 00251 </a> 00252 <a class="removeCol" href="#" title="' . $GLOBALS['LANG']->getLL('grid_removeRow') . '" onclick="t3Grid.removeRow(); t3Grid.drawTable(\'editor\');"> 00253 <img src="res/t3grid-tableup.png" border="0" /> 00254 </a> 00255 </td> 00256 </tr> 00257 </table> 00258 '; 00259 00260 $this->content = $content; 00261 } 00262 00263 /** 00264 * Returnes the sourcecode to the browser 00265 * 00266 * @return void 00267 */ 00268 function printContent() { 00269 echo $this->doc->render( 00270 'Grid wizard', 00271 $this->content 00272 ); 00273 } 00274 00275 } 00276 00277 00278 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/wizard_backend_layout.php'])) { 00279 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/wizard_backend_layout.php']); 00280 } 00281 00282 00283 // Make instance: 00284 $SOBE = t3lib_div::makeInstance('SC_wizard_backend_layout'); 00285 $SOBE->init(); 00286 $SOBE->main(); 00287 $SOBE->printContent(); 00288 00289 ?>
1.8.0