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
00064
00065
00066
00067 $BACK_PATH='';
00068 require('init.php');
00069 require('template.php');
00070 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
00071
00072
00073
00074
00075 require_once(PATH_t3lib.'class.t3lib_page.php');
00076 require_once(PATH_t3lib.'class.t3lib_positionmap.php');
00077 require_once(PATH_t3lib.'class.t3lib_pagetree.php');
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 class localPageTree extends t3lib_pageTree {
00091
00092
00093
00094
00095
00096
00097
00098
00099 function wrapIcon($icon,$row) {
00100 return $this->addTagAttributes($icon,' title="id='.htmlspecialchars($row['uid']).'"');
00101 }
00102
00103
00104
00105
00106
00107
00108
00109
00110 function expandNext($id) {
00111 return $id==$GLOBALS['SOBE']->id ? 1 : 0;
00112 }
00113 }
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128 class SC_db_new {
00129 var $pageinfo;
00130 var $pidInfo;
00131 var $newPagesInto;
00132 var $newContentInto;
00133 var $newPagesAfter;
00134 var $web_list_modTSconfig;
00135 var $allowedNewTables;
00136 var $deniedNewTables;
00137 var $web_list_modTSconfig_pid;
00138 var $allowedNewTables_pid;
00139 var $deniedNewTables_pid;
00140 var $code;
00141 var $R_URI;
00142
00143
00144 var $id;
00145 var $returnUrl;
00146 var $pagesOnly;
00147
00148
00149 var $perms_clause;
00150
00151
00152
00153
00154
00155
00156 var $doc;
00157 var $content;
00158
00159
00160
00161
00162
00163
00164
00165 function init() {
00166 global $BE_USER,$LANG,$BACK_PATH;
00167
00168
00169 $this->perms_clause = $BE_USER->getPagePermsClause(1);
00170
00171
00172 if ($pidList = $GLOBALS['BE_USER']->getTSConfigVal('options.hideRecords.pages')) {
00173 if ($pidList = $GLOBALS['TYPO3_DB']->cleanIntList($pidList)) {
00174 $this->perms_clause .= ' AND pages.uid NOT IN ('.$pidList.')';
00175 }
00176 }
00177
00178 $this->id = intval(t3lib_div::_GP('id'));
00179 $this->returnUrl = t3lib_div::_GP('returnUrl');
00180 $this->pagesOnly = t3lib_div::_GP('pagesOnly');
00181
00182
00183 $this->doc = t3lib_div::makeInstance('template');
00184 $this->doc->backPath = $BACK_PATH;
00185 $this->doc->setModuleTemplate('templates/db_new.html');
00186 $this->doc->JScode='';
00187
00188
00189 $this->doc->getContextMenuCode();
00190
00191
00192 $this->content='';
00193 $this->content.=$this->doc->header($LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.pagetitle'));
00194
00195
00196 if ($this->id > 0) {
00197 $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause);
00198 }
00199
00200
00201 if ($this->pageinfo['uid']) {
00202
00203
00204 $this->pidInfo=t3lib_BEfunc::getRecord('pages',$this->pageinfo['pid']);
00205
00206 if ($BE_USER->doesUserHaveAccess($this->pageinfo,8)) {
00207 $this->newPagesInto=1;
00208 }
00209 if ($BE_USER->doesUserHaveAccess($this->pageinfo,16)) {
00210 $this->newContentInto=1;
00211 }
00212
00213 if (($BE_USER->isAdmin()||is_array($this->pidInfo)) && $BE_USER->doesUserHaveAccess($this->pidInfo,8)) {
00214 $this->newPagesAfter=1;
00215 }
00216 } elseif ($BE_USER->isAdmin()) {
00217
00218 $this->newPagesInto=1;
00219 $this->newContentInto=1;
00220 $this->newPagesAfter=0;
00221 } else {
00222
00223 $this->newPagesInto=0;
00224 $this->newContentInto=0;
00225 $this->newPagesAfter=0;
00226 }
00227 }
00228
00229
00230
00231
00232
00233
00234 function main() {
00235 global $BE_USER,$LANG;
00236
00237
00238 if ($this->pageinfo['uid'] || $BE_USER->isAdmin()) {
00239
00240 $this->web_list_modTSconfig = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
00241 $this->allowedNewTables = t3lib_div::trimExplode(',',$this->web_list_modTSconfig['properties']['allowedNewTables'],1);
00242 $this->deniedNewTables = t3lib_div::trimExplode(',',$this->web_list_modTSconfig['properties']['deniedNewTables'],1);
00243
00244
00245 $this->web_list_modTSconfig_pid = t3lib_BEfunc::getModTSconfig($this->pageinfo['pid'],'mod.web_list');
00246 $this->allowedNewTables_pid = t3lib_div::trimExplode(',',$this->web_list_modTSconfig_pid['properties']['allowedNewTables'],1);
00247 $this->deniedNewTables_pid = t3lib_div::trimExplode(',',$this->web_list_modTSconfig_pid['properties']['deniedNewTables'],1);
00248
00249
00250 if (!$this->showNewRecLink('pages')) {
00251 $this->newPagesInto=0;
00252 }
00253 if (!$this->showNewRecLink('pages', $this->allowedNewTables_pid, $this->deniedNewTables_pid)) {
00254 $this->newPagesAfter=0;
00255 }
00256
00257
00258
00259 if (is_array($this->pageinfo) && $this->pageinfo['uid']) {
00260 $iconImgTag = t3lib_iconWorks::getIconImage('pages', $this->pageinfo, $this->backPath, 'title="' . htmlspecialchars($this->pageinfo['_thePath']) . '"');
00261 $title = strip_tags($this->pageinfo[$GLOBALS['TCA']['pages']['ctrl']['label']]);
00262 } else {
00263 $iconImgTag = '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/i/_icon_website.gif') . ' title="' . htmlspecialchars($this->pageinfo['_thePath']) . '" alt="" />';
00264 $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
00265 }
00266
00267 $this->code = '<span class="typo3-moduleHeader">' . $this->doc->wrapClickMenuOnIcon($iconImgTag, 'pages', $this->pageinfo['uid']) . htmlspecialchars(t3lib_div::fixed_lgd_cs($title, 45)) . '</span><br />';
00268
00269 $this->R_URI = $this->returnUrl;
00270
00271
00272 if (!$this->pagesOnly) {
00273 $this->regularNew();
00274 } elseif ($this->showNewRecLink('pages')) {
00275 $this->pagesOnly();
00276 }
00277
00278
00279 $this->content.=$this->doc->section('',$this->code);
00280
00281
00282 $docHeaderButtons = $this->getButtons();
00283 $markers['CSH'] = $docHeaderButtons['csh'];
00284
00285 $markers['CONTENT'] = $this->content;
00286
00287
00288 $this->content = $this->doc->startPage($LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.pagetitle'));
00289 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
00290 $this->content.= $this->doc->endPage();
00291 $this->content = $this->doc->insertStylesAndJS($this->content);
00292 }
00293 }
00294
00295
00296
00297
00298
00299
00300 protected function getButtons() {
00301 global $LANG, $BACK_PATH;
00302
00303 $buttons = array(
00304 'csh' => '',
00305 'back' => '',
00306 'view' => '',
00307 'new_page' => '',
00308 'record_list' => ''
00309 );
00310
00311
00312 if (!$this->pagesOnly) {
00313
00314 if ($this->showNewRecLink('pages')) {
00315 $buttons['new_page'] = '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('pagesOnly' => '1'))) . '">' .
00316 '<img' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/new_page.gif') . ' alt="" />' .
00317 '</a>';
00318 }
00319
00320 $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'new_regular', $GLOBALS['BACK_PATH'], '', TRUE);
00321 } elseif($this->showNewRecLink('pages')) {
00322
00323 $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'new_pages', $GLOBALS['BACK_PATH'], '', TRUE);
00324 }
00325
00326
00327 if ($this->R_URI) {
00328 $buttons['back'] = '<a href="' . htmlspecialchars($this->R_URI) . '" class="typo3-goBack">' .
00329 '<img' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/goback.gif') . ' alt="" />' .
00330 '</a>';
00331 }
00332
00333 if (is_array($this->pageinfo) && $this->pageinfo['uid']) {
00334
00335 $buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::viewOnClick($this->pageinfo['uid'], $this->backPath, t3lib_BEfunc::BEgetRootLine($this->pageinfo['uid']))) . '">' .
00336 '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/zoom.gif') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', 1) . '" alt="" />' .
00337 '</a>';
00338
00339
00340 if ($GLOBALS['BE_USER']->check('modules', 'web_list')) {
00341 $href = $this->backPath . 'db_list.php?id=' . $this->pageinfo['uid'] . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
00342 $buttons['record_list'] = '<a href="' . htmlspecialchars($href) . '">' .
00343 '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/list.gif') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList', 1) . '" alt="" />' .
00344 '</a>';
00345 }
00346 }
00347
00348
00349
00350 return $buttons;
00351 }
00352
00353
00354
00355
00356
00357
00358 function pagesOnly() {
00359 global $LANG;
00360
00361 $posMap = t3lib_div::makeInstance('t3lib_positionMap');
00362 $this->code.='
00363 <h3>'.htmlspecialchars($LANG->getLL('selectPosition')).':</h3>
00364 ';
00365 $this->code.= $posMap->positionTree($this->id,$this->pageinfo,$this->perms_clause,$this->R_URI);
00366 }
00367
00368
00369
00370
00371
00372
00373 function regularNew() {
00374 global $BE_USER,$LANG,$BACK_PATH,$TCA;
00375
00376 $doNotShowFullDescr = FALSE;
00377
00378
00379 $this->code.='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/halfline.gif','width="18" height="8"').' alt="" /><br />';
00380
00381
00382 $tRows = array();
00383
00384
00385 if ($this->newPagesInto
00386 && $this->isTableAllowedForThisPage($this->pageinfo, 'pages')
00387 && $BE_USER->check('tables_modify','pages')
00388 && $BE_USER->workspaceCreateNewRecord($this->pageinfo['_ORIG_uid']?$this->pageinfo['_ORIG_uid']:$this->id, 'pages')
00389 ) {
00390
00391
00392 $t = 'pages';
00393 $v = $TCA[$t];
00394 $rowContent = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join.gif','width="18" height="16"').' alt="" />'.
00395 $this->linkWrap(
00396 '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/'.($v['ctrl']['iconfile'] ? $v['ctrl']['iconfile'] : $t.'.gif'),'width="18" height="16"').' alt="" />'.
00397 $LANG->sL($v['ctrl']['title'],1).' ('.$LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.inside',1).')',
00398 $t,
00399 $this->id).'<br/>';
00400
00401
00402 $rowContent.= '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/line.gif','width="18" height="16"').' alt="" /><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/joinbottom.gif','width="18" height="16"').' alt="" />'.
00403 '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('pagesOnly'=>1))).'">'.
00404 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/new_page.gif','width="13" height="12"').' alt="" /> '.
00405 htmlspecialchars($LANG->getLL('clickForWizard')).
00406 '</a>';
00407
00408 $rowContent.= '<br /><img'.t3lib_iconWorks::skinImg('','gfx/ol/halfline.gif','width="18" height="8"').' alt="" />';
00409
00410
00411 $tRows[]='
00412 <tr>
00413 <td nowrap="nowrap">'.$rowContent.'</td>
00414 <td>'.t3lib_BEfunc::cshItem($t,'',$GLOBALS['BACK_PATH'],'',$doNotShowFullDescr).'</td>
00415 </tr>
00416 ';
00417 }
00418
00419
00420 if ($this->newContentInto) {
00421 if (is_array($TCA)) {
00422 foreach($TCA as $t => $v) {
00423 if ($t!='pages'
00424 && $this->showNewRecLink($t)
00425 && $this->isTableAllowedForThisPage($this->pageinfo, $t)
00426 && $BE_USER->check('tables_modify',$t)
00427 && (($v['ctrl']['rootLevel'] xor $this->id) || $v['ctrl']['rootLevel']==-1)
00428 && $BE_USER->workspaceCreateNewRecord($this->pageinfo['_ORIG_uid']?$this->pageinfo['_ORIG_uid']:$this->id, $t)
00429 ) {
00430
00431
00432 $rowContent = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join.gif','width="18" height="16"').' alt="" />'.
00433 $this->linkWrap(
00434 t3lib_iconWorks::getIconImage($t,array(),$BACK_PATH,'').
00435 $LANG->sL($v['ctrl']['title'],1)
00436 ,$t
00437 ,$this->id);
00438
00439
00440 if ($t=='tt_content') {
00441
00442
00443 $overrideExt = $this->web_list_modTSconfig['properties']['newContentWiz.']['overrideWithExtension'];
00444 $pathToWizard = (t3lib_extMgm::isLoaded($overrideExt)) ? (t3lib_extMgm::extRelPath($overrideExt).'mod1/db_new_content_el.php') : 'sysext/cms/layout/db_new_content_el.php';
00445
00446 $href = $pathToWizard.'?id='.$this->id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
00447 $rowContent.= '<br /><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/line.gif','width="18" height="16"').' alt="" />'.
00448 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/joinbottom.gif','width="18" height="16"').' alt="" />'.
00449 '<a href="'.htmlspecialchars($href).'"><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/new_record.gif','width="16" height="12"').' alt="" /> '.
00450 htmlspecialchars($LANG->getLL('clickForWizard')).
00451 '</a>';
00452
00453
00454 $rowContent.= '<br /><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/halfline.gif','width="18" height="8"').' alt="" />';
00455 }
00456
00457
00458
00459 $tRows[] = '
00460 <tr>
00461 <td nowrap="nowrap">'.$rowContent.'</td>
00462 <td>'.t3lib_BEfunc::cshItem($t,'',$GLOBALS['BACK_PATH'],'',$doNotShowFullDescr).'</td>
00463 </tr>
00464 ';
00465
00466 }
00467 }
00468 }
00469 }
00470
00471
00472 if ($this->newPagesAfter
00473 && $this->isTableAllowedForThisPage($this->pidInfo,'pages')
00474 && $BE_USER->check('tables_modify','pages')
00475 && $BE_USER->workspaceCreateNewRecord($this->pidInfo['uid'], 'pages')
00476 ) {
00477
00478
00479 $t = 'pages';
00480 $v = $TCA[$t];
00481 $rowContent = $this->linkWrap(
00482 t3lib_iconWorks::getIconImage($t,array(),$BACK_PATH,'').
00483 $LANG->sL($v['ctrl']['title'],1).' ('.$LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.after',1).')',
00484 'pages',
00485 -$this->id
00486 );
00487
00488
00489 $tRows[] = '
00490 <tr>
00491 <td nowrap="nowrap">'.$rowContent.'</td>
00492 <td>'.t3lib_BEfunc::cshItem($t,'',$GLOBALS['BACK_PATH'],'',$doNotShowFullDescr).'</td>
00493 </tr>
00494 ';
00495 } else {
00496
00497 $tRows[]='
00498 <tr>
00499 <td><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/stopper.gif','width="18" height="16"').' alt="" /></td>
00500 <td></td>
00501 </tr>
00502 ';
00503 }
00504
00505
00506 $this->code.='
00507 <table border="0" cellpadding="0" cellspacing="0" id="typo3-newRecord">
00508 '.implode('',$tRows).'
00509 </table>
00510 ';
00511 }
00512
00513
00514
00515
00516
00517
00518 function printContent() {
00519 echo $this->content;
00520 }
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531 function linkWrap($code,$table,$pid,$addContentTable=0) {
00532 $params = '&edit['.$table.']['.$pid.']=new'.
00533 ($table=='pages'
00534 && $GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']
00535 && isset($GLOBALS['TCA'][$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']])
00536 && $addContentTable ?
00537 '&edit['.$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable'].'][prev]=new&returnNewPageId=1' :
00538 ''
00539 );
00540 $onClick = t3lib_BEfunc::editOnClick($params,'',$this->returnUrl);
00541 return '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.$code.'</a>';
00542 }
00543
00544
00545
00546
00547
00548
00549
00550
00551 function isTableAllowedForThisPage($pid_row, $checkTable) {
00552 global $TCA, $PAGES_TYPES;
00553 if (!is_array($pid_row)) {
00554 if ($GLOBALS['BE_USER']->user['admin']) {
00555 return true;
00556 } else {
00557 return false;
00558 }
00559 }
00560
00561 if ($checkTable=='be_users' || $checkTable=='be_groups') {
00562 return false;
00563 }
00564
00565 $doktype = intval($pid_row['doktype']);
00566 if (!$allowedTableList = $PAGES_TYPES[$doktype]['allowedTables']) {
00567 $allowedTableList = $PAGES_TYPES['default']['allowedTables'];
00568 }
00569 if (strstr($allowedTableList,'*') || t3lib_div::inList($allowedTableList,$checkTable)) {
00570 return true;
00571 }
00572 }
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587 function showNewRecLink($table, array $allowedNewTables=array(), array $deniedNewTables=array()) {
00588 $allowedNewTables = ($allowedNewTables ? $allowedNewTables : $this->allowedNewTables);
00589 $deniedNewTables = ($deniedNewTables ? $deniedNewTables : $this->deniedNewTables);
00590
00591 if (!count($allowedNewTables) && !count($deniedNewTables)) {
00592 return true;
00593
00594 } elseif (!in_array($table, $deniedNewTables) && (!count($allowedNewTables) || in_array($table, $allowedNewTables))) {
00595 return true;
00596
00597 } else {
00598 return false;
00599 }
00600 }
00601 }
00602
00603
00604 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/db_new.php']) {
00605 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/db_new.php']);
00606 }
00607
00608
00609
00610
00611 $SOBE = t3lib_div::makeInstance('SC_db_new');
00612 $SOBE->init();
00613 $SOBE->main();
00614 $SOBE->printContent();
00615
00616 ?>