00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 unset($MCONF);
00064 require('conf.php');
00065 require($BACK_PATH.'init.php');
00066 require($BACK_PATH.'template.php');
00067
00068
00069 unset($MCONF);
00070 unset($MLANG);
00071
00072
00073 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
00074 $LOCAL_LANG_orig = $LOCAL_LANG;
00075 $LANG->includeLLFile('EXT:cms/layout/locallang_db_new_content_el.xml');
00076 $LOCAL_LANG = t3lib_div::array_merge_recursive_overrule($LOCAL_LANG_orig,$LOCAL_LANG);
00077
00078
00079 t3lib_extMgm::isLoaded('cms',1);
00080
00081
00082 require_once(PATH_t3lib.'class.t3lib_page.php');
00083 require_once(PATH_t3lib.'class.t3lib_positionmap.php');
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 class ext_posMap extends t3lib_positionMap {
00102 var $dontPrintPageInsertIcons = 1;
00103
00104
00105
00106
00107
00108
00109
00110
00111 function wrapRecordTitle($str,$row) {
00112 return $str;
00113 }
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125 function onClickInsertRecord($row,$vv,$moveUid,$pid,$sys_lang=0) {
00126 $table='tt_content';
00127
00128 $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);
00129
00130 return 'window.location.href=\''.$location.'\'+document.editForm.defValues.value; return false;';
00131 }
00132 }
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153 class SC_db_new_content_el {
00154
00155
00156 var $id;
00157 var $sys_language=0;
00158 var $R_URI='';
00159 var $colPos;
00160 var $uid_pid;
00161
00162
00163 var $modTSconfig=array();
00164
00165
00166
00167
00168
00169
00170 var $doc;
00171
00172
00173 var $include_once = array();
00174 var $content;
00175 var $access;
00176
00177
00178
00179
00180
00181
00182 function init() {
00183 global $BE_USER,$BACK_PATH,$TBE_MODULES_EXT;
00184
00185
00186 if (is_array($TBE_MODULES_EXT['xMOD_db_new_content_el']['addElClasses'])) {
00187 $this->include_once = array_merge($this->include_once,$TBE_MODULES_EXT['xMOD_db_new_content_el']['addElClasses']);
00188 }
00189
00190
00191 $this->id = intval(t3lib_div::_GP('id'));
00192 $this->sys_language = intval(t3lib_div::_GP('sys_language_uid'));
00193 $this->R_URI = t3lib_div::_GP('returnUrl');
00194 $this->colPos = t3lib_div::_GP('colPos');
00195 $this->uid_pid = intval(t3lib_div::_GP('uid_pid'));
00196
00197 $this->MCONF['name'] = 'xMOD_db_new_content_el';
00198 $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->id,'mod.'.$this->MCONF['name']);
00199
00200
00201 $this->doc = t3lib_div::makeInstance('template');
00202 $this->doc->backPath = $BACK_PATH;
00203 $this->doc->setModuleTemplate('templates/db_new_content_el.html');
00204 $this->doc->JScode='';
00205 $this->doc->form='<form action="" name="editForm"><input type="hidden" name="defValues" value="" />';
00206
00207
00208 $this->doc->getContextMenuCode();
00209
00210
00211 $perms_clause = $BE_USER->getPagePermsClause(1);
00212 $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$perms_clause);
00213 $this->access = is_array($this->pageinfo) ? 1 : 0;
00214 }
00215
00216
00217
00218
00219
00220
00221 function main() {
00222 global $LANG,$BACK_PATH;
00223
00224 if ($this->id && $this->access) {
00225
00226
00227 $posMap = t3lib_div::makeInstance('ext_posMap');
00228 $posMap->cur_sys_language = $this->sys_language;
00229 $posMap->backPath = $BACK_PATH;
00230
00231 if ((string)$this->colPos!='') {
00232 if ($this->uid_pid<0) {
00233 $row=array();
00234 $row['uid']=abs($this->uid_pid);
00235 } else {
00236 $row='';
00237 }
00238 $onClickEvent = $posMap->onClickInsertRecord($row,$this->colPos,'',$this->uid_pid,$this->sys_language);
00239 } else {
00240 $onClickEvent='';
00241 }
00242
00243 $this->doc->JScode=$this->doc->wrapScriptTags('
00244 function goToalt_doc() {
00245 '.$onClickEvent.'
00246 }
00247 ');
00248
00249
00250
00251
00252
00253 $this->content='';
00254 $this->content.=$this->doc->header($LANG->getLL('newContentElement'));
00255 $this->content.=$this->doc->spacer(5);
00256
00257
00258 $code='';
00259 $lines=array();
00260 $wizardItems = $this->getWizardItems();
00261
00262
00263
00264 $cc=0;
00265 foreach ($wizardItems as $k => $wInfo) {
00266 if ($wInfo['header']) {
00267 if ($cc>0) $lines[]='
00268 <tr>
00269 <td colspan="3"><br /></td>
00270 </tr>';
00271 $lines[]='
00272 <tr class="bgColor5">
00273 <td colspan="3"><strong>'.htmlspecialchars($wInfo['header']).'</strong></td>
00274 </tr>';
00275 } else {
00276 $tL=array();
00277
00278
00279 $oC = "document.editForm.defValues.value=unescape('".rawurlencode($wInfo['params'])."');goToalt_doc();".(!$onClickEvent?"window.location.hash='#sel2';":'');
00280 $tL[]='<input type="radio" name="tempB" value="'.htmlspecialchars($k).'" onclick="'.htmlspecialchars($this->doc->thisBlur().$oC).'" />';
00281
00282
00283 $aOnClick = 'document.getElementsByName(\'tempB\')['.$cc.'].checked=1;'.$this->doc->thisBlur().$oC.'return false;';
00284
00285
00286 $iInfo = @getimagesize($wInfo['icon']);
00287 $tL[]='<a href="#" onclick="'.htmlspecialchars($aOnClick).'"><img'.t3lib_iconWorks::skinImg($this->doc->backPath,$wInfo['icon'],'').' alt="" /></a>';
00288
00289
00290 $tL[]='<a href="#" onclick="'.htmlspecialchars($aOnClick).'"><strong>'.htmlspecialchars($wInfo['title']).'</strong><br />'.nl2br(htmlspecialchars(trim($wInfo['description']))).'</a>';
00291
00292
00293 $lines[]='
00294 <tr>
00295 <td valign="top">'.implode('</td>
00296 <td valign="top">',$tL).'</td>
00297 </tr>';
00298 $cc++;
00299 }
00300 }
00301
00302 $code.=$LANG->getLL('sel1',1).'<br /><br />
00303
00304
00305 <!--
00306 Content Element wizard table:
00307 -->
00308 <table border="0" cellpadding="1" cellspacing="2" id="typo3-ceWizardTable">
00309 '.implode('',$lines).'
00310 </table>';
00311 $this->content.= $this->doc->section(!$onClickEvent?$LANG->getLL('1_selectType'):'',$code,0,1);
00312
00313
00314
00315
00316 if (!$onClickEvent) {
00317
00318
00319 $this->content.= $this->doc->section('','<a name="sel2"></a>');
00320 $this->content.= $this->doc->spacer(20);
00321
00322
00323 $code = $LANG->getLL('sel2',1).'<br /><br />';
00324
00325
00326 $modTSconfig_SHARED = t3lib_BEfunc::getModTSconfig($this->id,'mod.SHARED');
00327 $colPosList = strcmp(trim($modTSconfig_SHARED['properties']['colPos_list']),'') ? trim($modTSconfig_SHARED['properties']['colPos_list']) : '1,0,2,3';
00328 $colPosList = implode(',',array_unique(t3lib_div::intExplode(',',$colPosList)));
00329
00330
00331 $code.= $posMap->printContentElementColumns($this->id,0,$colPosList,1,$this->R_URI);
00332 $this->content.= $this->doc->section($LANG->getLL('2_selectPosition'),$code,0,1);
00333 }
00334 } else {
00335 $this->content = '';
00336 $this->content.= $this->doc->header($LANG->getLL('newContentElement'));
00337 $this->content.= $this->doc->spacer(5);
00338 }
00339
00340
00341 $docHeaderButtons = $this->getButtons();
00342 $markers['CSH'] = $docHeaderButtons['csh'];
00343 $markers['CONTENT'] = $this->content;
00344
00345
00346 $this->content = $this->doc->startPage($LANG->getLL('newContentElement'));
00347 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
00348 $this->content.= $this->doc->endPage();
00349 $this->content = $this->doc->insertStylesAndJS($this->content);
00350 }
00351
00352
00353
00354
00355
00356
00357 function printContent() {
00358 echo $this->content;
00359 }
00360
00361
00362
00363
00364
00365
00366 protected function getButtons() {
00367 global $LANG, $BACK_PATH;
00368
00369 $buttons = array(
00370 'csh' => '',
00371 'back' => ''
00372 );
00373
00374
00375 if ($this->id && $this->access) {
00376
00377 $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'new_ce', $GLOBALS['BACK_PATH'], '', TRUE);
00378
00379
00380 if ($this->R_URI) {
00381 $buttons['back'] = '<a href="' . htmlspecialchars($this->R_URI) . '" class="typo3-goBack">' .
00382 '<img' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/goback.gif') . ' alt="" title="' . $LANG->getLL('goBack', 1) . '" />' .
00383 '</a>';
00384 }
00385 }
00386
00387
00388 return $buttons;
00389 }
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411 function getWizardItems() {
00412 return $this->wizardArray();
00413 }
00414
00415
00416
00417
00418
00419
00420
00421 function wizardArray() {
00422 global $LANG,$TBE_MODULES_EXT;
00423
00424 $wizardItems = array(
00425 'common' => array('header'=>$LANG->getLL('common')),
00426 'common_regularText' => array(
00427 'icon'=>'gfx/c_wiz/regular_text.gif',
00428 'title'=>$LANG->getLL('common_regularText_title'),
00429 'description'=>$LANG->getLL('common_regularText_description'),
00430 'tt_content_defValues' => array(
00431 'CType' => 'text'
00432 )
00433 ),
00434 'common_textImage' => array(
00435 'icon'=>'gfx/c_wiz/text_image_right.gif',
00436 'title'=>$LANG->getLL('common_textImage_title'),
00437 'description'=>$LANG->getLL('common_textImage_description'),
00438 'tt_content_defValues' => array(
00439 'CType' => 'textpic',
00440 'imageorient' => 17
00441 )
00442 ),
00443 'common_imagesOnly' => array(
00444 'icon'=>'gfx/c_wiz/images_only.gif',
00445 'title'=>$LANG->getLL('common_imagesOnly_title'),
00446 'description'=>$LANG->getLL('common_imagesOnly_description'),
00447 'tt_content_defValues' => array(
00448 'CType' => 'image',
00449 'imagecols' => 2
00450 )
00451 ),
00452 'common_bulletList' => array(
00453 'icon'=>'gfx/c_wiz/bullet_list.gif',
00454 'title'=>$LANG->getLL('common_bulletList_title'),
00455 'description'=>$LANG->getLL('common_bulletList_description'),
00456 'tt_content_defValues' => array(
00457 'CType' => 'bullets',
00458 )
00459 ),
00460 'common_table' => array(
00461 'icon'=>'gfx/c_wiz/table.gif',
00462 'title'=>$LANG->getLL('common_table_title'),
00463 'description'=>$LANG->getLL('common_table_description'),
00464 'tt_content_defValues' => array(
00465 'CType' => 'table',
00466 )
00467 ),
00468 'special' => array('header'=>$LANG->getLL('special')),
00469 'special_filelinks' => array(
00470 'icon'=>'gfx/c_wiz/filelinks.gif',
00471 'title'=>$LANG->getLL('special_filelinks_title'),
00472 'description'=>$LANG->getLL('special_filelinks_description'),
00473 'tt_content_defValues' => array(
00474 'CType' => 'uploads',
00475 )
00476 ),
00477 'special_multimedia' => array(
00478 'icon'=>'gfx/c_wiz/multimedia.gif',
00479 'title'=>$LANG->getLL('special_multimedia_title'),
00480 'description'=>$LANG->getLL('special_multimedia_description'),
00481 'tt_content_defValues' => array(
00482 'CType' => 'multimedia',
00483 )
00484 ),
00485 'special_sitemap' => array(
00486 'icon'=>'gfx/c_wiz/sitemap2.gif',
00487 'title'=>$LANG->getLL('special_sitemap_title'),
00488 'description'=>$LANG->getLL('special_sitemap_description'),
00489 'tt_content_defValues' => array(
00490 'CType' => 'menu',
00491 'menu_type' => 2
00492 )
00493 ),
00494 'special_plainHTML' => array(
00495 'icon'=>'gfx/c_wiz/html.gif',
00496 'title'=>$LANG->getLL('special_plainHTML_title'),
00497 'description'=>$LANG->getLL('special_plainHTML_description'),
00498 'tt_content_defValues' => array(
00499 'CType' => 'html',
00500 )
00501 ),
00502 'forms' => array('header'=>$LANG->getLL('forms')),
00503 'forms_mail' => array(
00504 'icon'=>'gfx/c_wiz/mailform.gif',
00505 'title'=>$LANG->getLL('forms_mail_title'),
00506 'description'=>$LANG->getLL('forms_mail_description'),
00507 'tt_content_defValues' => array(
00508 'CType' => 'mailform',
00509 'bodytext' => trim('
00510 # Example content:
00511 Name: | *name = input,40 | Enter your name here
00512 Email: | *email=input,40 |
00513 Address: | address=textarea,40,5 |
00514 Contact me: | tv=check | 1
00515
00516 |formtype_mail = submit | Send form!
00517 |html_enabled=hidden | 1
00518 |subject=hidden| This is the subject
00519 ')
00520 )
00521 ),
00522 'forms_search' => array(
00523 'icon'=>'gfx/c_wiz/searchform.gif',
00524 'title'=>$LANG->getLL('forms_search_title'),
00525 'description'=>$LANG->getLL('forms_search_description'),
00526 'tt_content_defValues' => array(
00527 'CType' => 'search',
00528 )
00529 ),
00530 'forms_login' => array(
00531 'icon'=>'gfx/c_wiz/login_form.gif',
00532 'title'=>$LANG->getLL('forms_login_title'),
00533 'description'=>$LANG->getLL('forms_login_description'),
00534 'tt_content_defValues' => array(
00535 'CType' => 'login',
00536 )
00537 ),
00538 'plugins' => array('header'=>$LANG->getLL('plugins')),
00539 'plugins_general' => array(
00540 'icon'=>'gfx/c_wiz/user_defined.gif',
00541 'title'=>$LANG->getLL('plugins_general_title'),
00542 'description'=>$LANG->getLL('plugins_general_description'),
00543 'tt_content_defValues' => array(
00544 'CType' => 'list',
00545 )
00546 ),
00547 );
00548
00549
00550
00551 if (is_array($TBE_MODULES_EXT['xMOD_db_new_content_el']['addElClasses'])) {
00552 reset($TBE_MODULES_EXT['xMOD_db_new_content_el']['addElClasses']);
00553 while(list($class,$path)=each($TBE_MODULES_EXT['xMOD_db_new_content_el']['addElClasses'])) {
00554 $modObj = t3lib_div::makeInstance($class);
00555 $wizardItems = $modObj->proc($wizardItems);
00556 }
00557 }
00558
00559
00560 $this->removeInvalidElements($wizardItems);
00561
00562 return $wizardItems;
00563 }
00564
00565
00566
00567
00568
00569
00570
00571
00572 function removeInvalidElements(&$wizardItems) {
00573 global $TCA;
00574
00575
00576 t3lib_div::loadTCA('tt_content');
00577
00578
00579 $row = array('pid' => $this->id);
00580 $TCEFORM_TSconfig = t3lib_BEfunc::getTCEFORM_TSconfig('tt_content', $row);
00581 $removeItems = t3lib_div::trimExplode(',', $TCEFORM_TSconfig['CType']['removeItems'], 1);
00582 $keepItems = t3lib_div::trimExplode(',', $TCEFORM_TSconfig['CType']['keepItems'], 1);
00583
00584 $headersUsed = Array();
00585
00586 foreach($wizardItems as $key => $cfg) {
00587
00588
00589 if ($wizardItems[$key]['params']) {
00590
00591 $tempGetVars = t3lib_div::explodeUrl2Array($wizardItems[$key]['params'],TRUE);
00592
00593 if (is_array($tempGetVars['defVals']['tt_content'])) {
00594 $wizardItems[$key]['tt_content_defValues'] = array_merge(is_array($wizardItems[$key]['tt_content_defValues']) ? $wizardItems[$key]['tt_content_defValues'] : array(), $tempGetVars['defVals']['tt_content']);
00595 unset($tempGetVars['defVals']['tt_content']);
00596 $wizardItems[$key]['params'] = t3lib_div::implodeArrayForUrl('',$tempGetVars);
00597 }
00598 }
00599
00600
00601 if (is_array($wizardItems[$key]['tt_content_defValues'])) {
00602
00603
00604 foreach($wizardItems[$key]['tt_content_defValues'] as $fN => $fV) {
00605 if (is_array($TCA['tt_content']['columns'][$fN])) {
00606
00607 $config = &$TCA['tt_content']['columns'][$fN]['config'];
00608 $authModeDeny = ($config['type']=='select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode('tt_content', $fN, $fV, $config['authMode']));
00609 $isNotInKeepItems = (count($keepItems) && !in_array($fV, $keepItems));
00610
00611 if ($authModeDeny || ($fN=='CType' && in_array($fV,$removeItems)) || $isNotInKeepItems) {
00612
00613 unset($wizardItems[$key]);
00614 break;
00615 } else {
00616
00617 $wizardItems[$key]['params'].= '&defVals[tt_content]['.$fN.']='.rawurlencode($fV);
00618 $tmp = explode('_', $key);
00619 $headersUsed[$tmp[0]] = $tmp[0];
00620 }
00621 }
00622 }
00623 }
00624 }
00625
00626 foreach ($wizardItems as $key => $cfg) {
00627 $tmp = explode('_',$key);
00628 if ($tmp[0] && !$tmp[1] && !in_array($tmp[0], $headersUsed)) {
00629 unset($wizardItems[$key]);
00630 }
00631 }
00632 }
00633 }
00634
00635
00636 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/layout/db_new_content_el.php']) {
00637 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/layout/db_new_content_el.php']);
00638 }
00639
00640
00641
00642
00643 $SOBE = t3lib_div::makeInstance('SC_db_new_content_el');
00644 $SOBE->init();
00645
00646
00647 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
00648
00649 $SOBE->main();
00650 $SOBE->printContent();
00651
00652 ?>