Documentation TYPO3 par Ameos |
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2004 Kasper Skaarhoj (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 ***************************************************************/ 00062 unset($MCONF); 00063 require('conf.php'); 00064 require($BACK_PATH.'init.php'); 00065 require($BACK_PATH.'template.php'); 00066 00067 // Unset MCONF/MLANG since all we wanted was back path etc. for this particular script. 00068 unset($MCONF); 00069 unset($MLANG); 00070 00071 // Merging locallang files/arrays: 00072 $LANG->includeLLFile('EXT:lang/locallang_misc.xml'); 00073 $LOCAL_LANG_orig = $LOCAL_LANG; 00074 $LANG->includeLLFile('EXT:cms/layout/locallang_db_new_content_el.xml'); 00075 $LOCAL_LANG = t3lib_div::array_merge_recursive_overrule($LOCAL_LANG_orig,$LOCAL_LANG); 00076 00077 // Exits if 'cms' extension is not loaded: 00078 t3lib_extMgm::isLoaded('cms',1); 00079 00080 // Include needed libraries: 00081 require_once(PATH_t3lib.'class.t3lib_page.php'); 00082 require_once(PATH_t3lib.'class.t3lib_positionmap.php'); 00083 00084 00085 00086 00087 00088 00089 00090 00091 00092 00100 class ext_posMap extends t3lib_positionMap { 00101 var $dontPrintPageInsertIcons = 1; 00102 00110 function wrapRecordTitle($str,$row) { 00111 return $str; 00112 } 00113 00124 function onClickInsertRecord($row,$vv,$moveUid,$pid,$sys_lang=0) { 00125 $table='tt_content'; 00126 00127 $location=$this->backPath.'alt_doc.php?edit[tt_content]['.(is_array($row)?-$row['uid']:$pid).']=new&defVals[tt_content][colPos]='.$vv.'&defVals[tt_content][sys_language_uid]='.$sys_lang.'&returnUrl='.rawurlencode($GLOBALS['SOBE']->R_URI); 00128 00129 return 'document.location=\''.$location.'\'+document.editForm.defValues.value; return false;'; 00130 } 00131 } 00132 00133 00134 00135 00136 00137 00138 00139 00140 00141 00142 00143 00144 00152 class SC_db_new_content_el { 00153 00154 // Internal, static (from GPvars): 00155 var $id; // Page id 00156 var $sys_language=0; // Sys language 00157 var $R_URI=''; // Return URL. 00158 var $colPos; // If set, the content is destined for a specific column. 00159 var $uid_pid; // 00160 00161 // Internal, static: 00162 var $modTSconfig=array(); // Module TSconfig. 00163 var $doc; // Internal backend template object 00164 00165 // Internal, dynamic: 00166 var $include_once = array(); // Includes a list of files to include between init() and main() - see init() 00167 var $content; // Used to accumulate the content of the module. 00168 var $access; // Access boolean. 00169 00175 function init() { 00176 global $BE_USER,$BACK_PATH,$TBE_MODULES_EXT; 00177 00178 // Setting class files to include: 00179 if (is_array($TBE_MODULES_EXT['xMOD_db_new_content_el']['addElClasses'])) { 00180 $this->include_once = array_merge($this->include_once,$TBE_MODULES_EXT['xMOD_db_new_content_el']['addElClasses']); 00181 } 00182 00183 // Setting internal vars: 00184 $this->id = intval(t3lib_div::_GP('id')); 00185 $this->sys_language = intval(t3lib_div::_GP('sys_language_uid')); 00186 $this->R_URI = t3lib_div::_GP('returnUrl'); 00187 $this->colPos = t3lib_div::_GP('colPos'); 00188 $this->uid_pid = intval(t3lib_div::_GP('uid_pid')); 00189 00190 $this->MCONF['name'] = 'xMOD_db_new_content_el'; 00191 $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->id,'mod.'.$this->MCONF['name']); 00192 00193 // Starting the document template object: 00194 $this->doc = t3lib_div::makeInstance('mediumDoc'); 00195 $this->doc->docType= 'xhtml_trans'; 00196 $this->doc->backPath = $BACK_PATH; 00197 $this->doc->JScode=''; 00198 $this->doc->form='<form action="" name="editForm"><input type="hidden" name="defValues" value="" />'; 00199 00200 // Getting the current page and receiving access information (used in main()) 00201 $perms_clause = $BE_USER->getPagePermsClause(1); 00202 $pageinfo = t3lib_BEfunc::readPageAccess($this->id,$perms_clause); 00203 $this->access = is_array($pageinfo) ? 1 : 0; 00204 } 00205 00211 function main() { 00212 global $LANG,$BACK_PATH; 00213 00214 if ($this->id && $this->access) { 00215 00216 // Init position map object: 00217 $posMap = t3lib_div::makeInstance('ext_posMap'); 00218 $posMap->cur_sys_language = $this->sys_language; 00219 $posMap->backPath = $BACK_PATH; 00220 00221 if ((string)$this->colPos!='') { // If a column is pre-set: 00222 if ($this->uid_pid<0) { 00223 $row=array(); 00224 $row['uid']=abs($this->uid_pid); 00225 } else { 00226 $row=''; 00227 } 00228 $onClickEvent = $posMap->onClickInsertRecord($row,$this->colPos,'',$this->uid_pid,$this->sys_language); 00229 } else { 00230 $onClickEvent=''; 00231 } 00232 00233 $this->doc->JScode=$this->doc->wrapScriptTags(' 00234 function goToalt_doc() { // 00235 '.$onClickEvent.' 00236 } 00237 '); 00238 00239 00240 // *************************** 00241 // Creating content 00242 // *************************** 00243 $this->content=''; 00244 $this->content.=$this->doc->startPage($LANG->getLL('newContentElement')); 00245 $this->content.=$this->doc->header($LANG->getLL('newContentElement')); 00246 $this->content.=$this->doc->spacer(5); 00247 00248 $elRow = t3lib_BEfunc::getRecord('pages',$this->id); 00249 $hline = t3lib_iconWorks::getIconImage('pages',$elRow,$BACK_PATH,' title="'.htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($elRow,'pages')).'" align="top"'); 00250 $hline.= t3lib_BEfunc::getRecordTitle('pages',$elRow,1); 00251 $this->content.=$this->doc->section('',$hline,0,1); 00252 $this->content.=$this->doc->spacer(10); 00253 00254 00255 // Wizard 00256 $code=''; 00257 $lines=array(); 00258 $wizardItems = $this->getWizardItems(); 00259 00260 // Traverse items for the wizard. 00261 // An item is either a header or an item rendered with a radio button and title/description and icon: 00262 $cc=0; 00263 foreach($wizardItems as $k => $wInfo) { 00264 if ($wInfo['header']) { 00265 if ($cc>0) $lines[]=' 00266 <tr> 00267 <td colspan="3"><br /></td> 00268 </tr>'; 00269 $lines[]=' 00270 <tr class="bgColor5"> 00271 <td colspan="3"><strong>'.htmlspecialchars($wInfo['header']).'</strong></td> 00272 </tr>'; 00273 } else { 00274 $tL=array(); 00275 00276 // Radio button: 00277 $oC = "document.editForm.defValues.value=unescape('".rawurlencode($wInfo['params'])."');goToalt_doc();".(!$onClickEvent?"document.location='#sel2';":''); 00278 $tL[]='<input type="radio" name="tempB" value="'.htmlspecialchars($k).'" onclick="'.htmlspecialchars($this->doc->thisBlur().$oC).'" />'; 00279 00280 // Onclick action for icon/title: 00281 $aOnClick = 'document.editForm.tempB['.$cc.'].checked=1;'.$this->doc->thisBlur().$oC.'return false;'; 00282 00283 // Icon: 00284 $iInfo = @getimagesize($wInfo['icon']); 00285 $tL[]='<a href="#" onclick="'.htmlspecialchars($aOnClick).'"><img'.t3lib_iconWorks::skinImg($this->doc->backPath,$wInfo['icon'],'').' alt="" /></a>'; 00286 00287 // Title + description: 00288 $tL[]='<a href="#" onclick="'.htmlspecialchars($aOnClick).'"><strong>'.htmlspecialchars($wInfo['title']).'</strong><br />'.nl2br(htmlspecialchars(trim($wInfo['description']))).'</a>'; 00289 00290 // Finally, put it together in a table row: 00291 $lines[]=' 00292 <tr> 00293 <td valign="top">'.implode('</td> 00294 <td valign="top">',$tL).'</td> 00295 </tr>'; 00296 $cc++; 00297 } 00298 } 00299 // Add the wizard table to the content: 00300 $code.=$LANG->getLL('sel1',1).'<br /><br /> 00301 00302 00303 <!-- 00304 Content Element wizard table: 00305 --> 00306 <table border="0" cellpadding="1" cellspacing="2" id="typo3-ceWizardTable"> 00307 '.implode('',$lines).' 00308 </table>'; 00309 $this->content.=$this->doc->section(!$onClickEvent?$LANG->getLL('1_selectType'):'',$code,0,1); 00310 00311 00312 00313 // If the user must also select a column: 00314 if (!$onClickEvent) { 00315 00316 // Add anchor "sel2" 00317 $this->content.=$this->doc->section('','<a name="sel2"></a>'); 00318 $this->content.=$this->doc->spacer(20); 00319 00320 // Select position 00321 $code=$LANG->getLL('sel2',1).'<br /><br />'; 00322 00323 // Load SHARED page-TSconfig settings and retrieve column list from there, if applicable: 00324 $modTSconfig_SHARED = t3lib_BEfunc::getModTSconfig($this->id,'mod.SHARED'); 00325 $colPosList = strcmp(trim($modTSconfig_SHARED['properties']['colPos_list']),'') ? trim($modTSconfig_SHARED['properties']['colPos_list']) : '1,0,2,3'; 00326 $colPosList = implode(',',array_unique(t3lib_div::intExplode(',',$colPosList))); // Removing duplicates, if any 00327 00328 // Finally, add the content of the column selector to the content: 00329 $code.=$posMap->printContentElementColumns($this->id,0,$colPosList,1,$this->R_URI); 00330 $this->content.=$this->doc->section($LANG->getLL('2_selectPosition'),$code,0,1); 00331 } 00332 00333 // IF there is a return-url set, then print a go-back link: 00334 if ($this->R_URI) { 00335 $code='<br /><br /><a href="'.htmlspecialchars($this->R_URI).'" class="typo3-goBack"><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/goback.gif','width="14" height="14"').' alt="" />'.$LANG->getLL('goBack',1).'</a>'; 00336 $this->content.=$this->doc->section('',$code,0,1); 00337 } 00338 00339 // Add CSH: 00340 $this->content.= $this->doc->section('',t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'new_ce', $GLOBALS['BACK_PATH'],'<br/>'),0,1); 00341 00342 // Add a very high clear-gif, 700 px (so that the link to the anchor "sel2" shows this part in top for sure...) 00343 $this->content.=$this->doc->section('','<img src="clear.gif" width="1" height="700" alt="" />',0,1); 00344 00345 } else { // In case of no access: 00346 $this->content=''; 00347 $this->content.=$this->doc->startPage($LANG->getLL('newContentElement')); 00348 $this->content.=$this->doc->header($LANG->getLL('newContentElement')); 00349 $this->content.=$this->doc->spacer(5); 00350 } 00351 } 00352 00358 function printContent() { 00359 global $SOBE; 00360 00361 $this->content.= $this->doc->endPage(); 00362 echo $this->content; 00363 } 00364 00365 00366 00367 00368 00369 00370 00371 00372 00373 00374 00375 /*************************** 00376 * 00377 * OTHER FUNCTIONS: 00378 * 00379 ***************************/ 00380 00381 00387 function getWizardItems() { 00388 return $this->wizardArray(); 00389 } 00390 00397 function wizardArray() { 00398 global $LANG,$TBE_MODULES_EXT; 00399 00400 $wizardItems = array( 00401 'common' => array('header'=>$LANG->getLL('common')), 00402 'common_1' => array( 00403 'icon'=>'gfx/c_wiz/regular_text.gif', 00404 'title'=>$LANG->getLL('common_1_title'), 00405 'description'=>$LANG->getLL('common_1_description'), 00406 'params'=>'&defVals[tt_content][CType]=text' 00407 ), 00408 'common_2' => array( 00409 'icon'=>'gfx/c_wiz/text_image_below.gif', 00410 'title'=>$LANG->getLL('common_2_title'), 00411 'description'=>$LANG->getLL('common_2_description'), 00412 'params'=>'&defVals[tt_content][CType]=textpic&defVals[tt_content][imageorient]=8' 00413 ), 00414 'common_3' => array( 00415 'icon'=>'gfx/c_wiz/text_image_right.gif', 00416 'title'=>$LANG->getLL('common_3_title'), 00417 'description'=>$LANG->getLL('common_3_description'), 00418 'params'=>'&defVals[tt_content][CType]=textpic&defVals[tt_content][imageorient]=17' 00419 ), 00420 'common_4' => array( 00421 'icon'=>'gfx/c_wiz/images_only.gif', 00422 'title'=>$LANG->getLL('common_4_title'), 00423 'description'=>$LANG->getLL('common_4_description'), 00424 'params'=>'&defVals[tt_content][CType]=image&defVals[tt_content][imagecols]=2' 00425 ), 00426 'common_5' => array( 00427 'icon'=>'gfx/c_wiz/bullet_list.gif', 00428 'title'=>$LANG->getLL('common_5_title'), 00429 'description'=>$LANG->getLL('common_5_description'), 00430 'params'=>'&defVals[tt_content][CType]=bullets' 00431 ), 00432 'common_6' => array( 00433 'icon'=>'gfx/c_wiz/table.gif', 00434 'title'=>$LANG->getLL('common_6_title'), 00435 'description'=>$LANG->getLL('common_6_description'), 00436 'params'=>'&defVals[tt_content][CType]=table' 00437 ), 00438 'special' => array('header'=>$LANG->getLL('special')), 00439 'special_1' => array( 00440 'icon'=>'gfx/c_wiz/filelinks.gif', 00441 'title'=>$LANG->getLL('special_1_title'), 00442 'description'=>$LANG->getLL('special_1_description'), 00443 'params'=>'&defVals[tt_content][CType]=uploads' 00444 ), 00445 'special_2' => array( 00446 'icon'=>'gfx/c_wiz/multimedia.gif', 00447 'title'=>$LANG->getLL('special_2_title'), 00448 'description'=>$LANG->getLL('special_2_description'), 00449 'params'=>'&defVals[tt_content][CType]=multimedia' 00450 ), 00451 'special_3' => array( 00452 'icon'=>'gfx/c_wiz/sitemap2.gif', 00453 'title'=>$LANG->getLL('special_3_title'), 00454 'description'=>$LANG->getLL('special_3_description'), 00455 'params'=>'&defVals[tt_content][CType]=menu&defVals[tt_content][menu_type]=2' 00456 ), 00457 'special_4' => array( 00458 'icon'=>'gfx/c_wiz/html.gif', 00459 'title'=>$LANG->getLL('special_4_title'), 00460 'description'=>$LANG->getLL('special_4_description'), 00461 'params'=>'&defVals[tt_content][CType]=html' 00462 ), 00463 00464 00465 'forms' => array('header'=>$LANG->getLL('forms')), 00466 'forms_1' => array( 00467 'icon'=>'gfx/c_wiz/mailform.gif', 00468 'title'=>$LANG->getLL('forms_1_title'), 00469 'description'=>$LANG->getLL('forms_1_description'), 00470 'params'=>'&defVals[tt_content][CType]=mailform&defVals[tt_content][bodytext]='.rawurlencode(trim(' 00471 # Example content: 00472 Name: | *name = input,40 | Enter your name here 00473 Email: | *email=input,40 | 00474 Address: | address=textarea,40,5 | 00475 Contact me: | tv=check | 1 00476 00477 |formtype_mail = submit | Send form! 00478 |html_enabled=hidden | 1 00479 |subject=hidden| This is the subject 00480 ')) 00481 ), 00482 'forms_2' => array( 00483 'icon'=>'gfx/c_wiz/searchform.gif', 00484 'title'=>$LANG->getLL('forms_2_title'), 00485 'description'=>$LANG->getLL('forms_2_description'), 00486 'params'=>'&defVals[tt_content][CType]=search' 00487 ), 00488 'forms_3' => array( 00489 'icon'=>'gfx/c_wiz/login_form.gif', 00490 'title'=>$LANG->getLL('forms_3_title'), 00491 'description'=>$LANG->getLL('forms_3_description'), 00492 'params'=>'&defVals[tt_content][CType]=login' 00493 ), 00494 'plugins' => array('header'=>$LANG->getLL('plugins')), 00495 'plugins_1' => array( 00496 'icon'=>'gfx/c_wiz/user_defined.gif', 00497 'title'=>$LANG->getLL('plugins_1_title'), 00498 'description'=>$LANG->getLL('plugins_1_description'), 00499 'params'=>'&defVals[tt_content][CType]=list' 00500 ), 00501 ); 00502 00503 00504 // PLUG-INS: 00505 if (is_array($TBE_MODULES_EXT['xMOD_db_new_content_el']['addElClasses'])) { 00506 reset($TBE_MODULES_EXT['xMOD_db_new_content_el']['addElClasses']); 00507 while(list($class,$path)=each($TBE_MODULES_EXT['xMOD_db_new_content_el']['addElClasses'])) { 00508 $modObj = t3lib_div::makeInstance($class); 00509 $wizardItems = $modObj->proc($wizardItems); 00510 } 00511 } 00512 00513 return $wizardItems; 00514 } 00515 } 00516 00517 // Include extension? 00518 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/layout/db_new_content_el.php']) { 00519 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/layout/db_new_content_el.php']); 00520 } 00521 00522 00523 00524 00525 00526 00527 00528 00529 00530 00531 00532 00533 // Make instance: 00534 $SOBE = t3lib_div::makeInstance('SC_db_new_content_el'); 00535 $SOBE->init(); 00536 00537 // Include files? 00538 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE); 00539 00540 $SOBE->main(); 00541 $SOBE->printContent(); 00542 ?>