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
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
00090 class localPageTree extends t3lib_pageTree {
00091
00099 function wrapIcon($icon,$row) {
00100 return $this->addTagAttributes($icon,' title="id='.htmlspecialchars($row['uid']).'"');
00101 }
00102
00110 function expandNext($id) {
00111 return $id==$GLOBALS['SOBE']->id ? 1 : 0;
00112 }
00113 }
00114
00115
00116
00117
00118
00119
00120
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 $web_list_modTSconfig_pid;
00137 var $allowedNewTables_pid;
00138 var $code;
00139 var $R_URI;
00140
00141
00142 var $id;
00143 var $returnUrl;
00144 var $pagesOnly;
00145
00146
00147 var $perms_clause;
00148 var $doc;
00149 var $content;
00150
00151
00157 function init() {
00158 global $BE_USER,$LANG,$BACK_PATH;
00159
00160
00161 $this->perms_clause = $BE_USER->getPagePermsClause(1);
00162
00163
00164 $this->id = intval(t3lib_div::_GP('id'));
00165 $this->returnUrl = t3lib_div::_GP('returnUrl');
00166 $this->pagesOnly = t3lib_div::_GP('pagesOnly');
00167
00168
00169 $this->doc = t3lib_div::makeInstance('mediumDoc');
00170 $this->doc->backPath = $BACK_PATH;
00171 $this->doc->docType= 'xhtml_trans';
00172 $this->doc->JScode='';
00173
00174
00175 $this->content='';
00176 $this->content.=$this->doc->startPage($LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.pagetitle'));
00177 $this->content.=$this->doc->header($LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.pagetitle'));
00178
00179
00180 if ($this->id > 0) {
00181 $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause);
00182 }
00183
00184
00185 if ($this->pageinfo['uid']) {
00186
00187 $this->pidInfo=t3lib_BEfunc::getRecord('pages',$this->pageinfo['pid']);
00188
00189 if ($BE_USER->doesUserHaveAccess($this->pageinfo,8)) {
00190 $this->newPagesInto=1;
00191 }
00192 if ($BE_USER->doesUserHaveAccess($this->pageinfo,16)) {
00193 $this->newContentInto=1;
00194 }
00195
00196 if (($BE_USER->isAdmin()||is_array($this->pidInfo)) && $BE_USER->doesUserHaveAccess($this->pidInfo,8)) {
00197 $this->newPagesAfter=1;
00198 }
00199 } elseif ($BE_USER->isAdmin()) {
00200
00201 $this->newPagesInto=1;
00202 $this->newContentInto=1;
00203 $this->newPagesAfter=0;
00204 } else {
00205
00206 $this->newPagesInto=0;
00207 $this->newContentInto=0;
00208 $this->newPagesAfter=0;
00209 }
00210 }
00211
00217 function main() {
00218 global $BE_USER,$LANG;
00219
00220
00221 if ($this->pageinfo['uid'] || $BE_USER->isAdmin()) {
00222
00223 $this->web_list_modTSconfig = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
00224 $this->allowedNewTables = t3lib_div::trimExplode(',',$this->web_list_modTSconfig['properties']['allowedNewTables'],1);
00225
00226
00227 $this->web_list_modTSconfig_pid = t3lib_BEfunc::getModTSconfig($this->pageinfo['pid'],'mod.web_list');
00228 $this->allowedNewTables_pid = t3lib_div::trimExplode(',',$this->web_list_modTSconfig_pid['properties']['allowedNewTables'],1);
00229
00230
00231 if (!$this->showNewRecLink('pages')) {
00232 $this->newPagesInto=0;
00233 }
00234 if (!$this->showNewRecLink('pages',$this->allowedNewTables_pid)) {
00235 $this->newPagesAfter=0;
00236 }
00237
00238
00239
00240 $this->code=$this->doc->getHeader('pages',$this->pageinfo,$this->pageinfo['_thePath']).'<br />
00241 ';
00242 $this->R_URI=$this->returnUrl;
00243
00244
00245 if (!$this->pagesOnly) {
00246 $this->regularNew();
00247 } elseif ($this->showNewRecLink('pages')) {
00248 $this->pagesOnly();
00249 }
00250
00251
00252 if ($this->R_URI) {
00253 $this->code.='<br />
00254 <a href="'.htmlspecialchars($this->R_URI).'" class="typo3-goBack">'.
00255 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/goback.gif','width="14" height="14"').' alt="" />'.
00256 $LANG->getLL('goBack',1).
00257 '</a>';
00258 }
00259
00260 $this->content.=$this->doc->section('',$this->code);
00261 }
00262 }
00263
00269 function pagesOnly() {
00270 global $LANG;
00271
00272 $posMap = t3lib_div::makeInstance('t3lib_positionMap');
00273 $this->code.='
00274 <h3>'.htmlspecialchars($LANG->getLL('selectPosition')).':</h3>
00275 ';
00276 $this->code.= $posMap->positionTree($this->id,$this->pageinfo,$this->perms_clause,$this->R_URI);
00277
00278
00279 $this->code.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'new_pages', $GLOBALS['BACK_PATH'],'<br/>');
00280 }
00281
00287 function regularNew() {
00288 global $BE_USER,$LANG,$BACK_PATH,$TCA;
00289
00290 $doNotShowFullDescr = FALSE;
00291
00292
00293 $this->code.='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/halfline.gif','width="18" height="8"').' alt="" /><br />';
00294
00295
00296 $tRows = array();
00297
00298
00299 if ($this->newPagesInto && $this->isTableAllowedForThisPage($this->pageinfo, 'pages') && $BE_USER->check('tables_modify','pages')) {
00300
00301
00302 $t = 'pages';
00303 $v = $TCA[$t];
00304 $rowContent = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join.gif','width="18" height="16"').' alt="" />'.
00305 $this->linkWrap(
00306 '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/'.($v['ctrl']['iconfile'] ? $v['ctrl']['iconfile'] : $t.'.gif'),'width="18" height="16"').' alt="" />'.
00307 $LANG->sL($v['ctrl']['title'],1).' ('.$LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.inside',1).')',
00308 $t,
00309 $this->id).'<br/>';
00310
00311
00312 $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="" />'.
00313 '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('pagesOnly'=>1))).'">'.
00314 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/new_page.gif','width="13" height="12"').' alt="" /> '.
00315 htmlspecialchars($LANG->getLL('clickForWizard')).
00316 '</a>';
00317
00318 $rowContent.= '<br /><img'.t3lib_iconWorks::skinImg('','gfx/ol/halfline.gif','width="18" height="8"').' alt="" />';
00319
00320
00321 $tRows[]='
00322 <tr>
00323 <td nowrap="nowrap">'.$rowContent.'</td>
00324 <td>'.t3lib_BEfunc::cshItem($t,'',$GLOBALS['BACK_PATH'],'',$doNotShowFullDescr).'</td>
00325 </tr>
00326 ';
00327 }
00328
00329
00330 if ($this->newContentInto) {
00331 if (is_array($TCA)) {
00332 foreach($TCA as $t => $v) {
00333 if ($t!='pages'
00334 && $this->showNewRecLink($t)
00335 && $this->isTableAllowedForThisPage($this->pageinfo, $t)
00336 && $BE_USER->check('tables_modify',$t)
00337 && (($v['ctrl']['rootLevel'] xor $this->id) || $v['ctrl']['rootLevel']==-1)
00338 ) {
00339
00340
00341 $rowContent = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join.gif','width="18" height="16"').' alt="" />'.
00342 $this->linkWrap(
00343 t3lib_iconWorks::getIconImage($t,array(),$BACK_PATH,'').
00344 $LANG->sL($v['ctrl']['title'],1)
00345 ,$t
00346 ,$this->id);
00347
00348
00349 if ($t=='tt_content') {
00350
00351
00352 $overrideExt = $this->web_list_modTSconfig['properties']['newContentWiz.']['overrideWithExtension'];
00353 $pathToWizard = (t3lib_extMgm::isLoaded($overrideExt)) ? (t3lib_extMgm::extRelPath($overrideExt).'mod1/db_new_content_el.php') : 'sysext/cms/layout/db_new_content_el.php';
00354
00355 $href = $pathToWizard.'?id='.$this->id.'&returnUrl='.rawurlencode($this->R_URI);
00356 $rowContent.= '<br /><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/line.gif','width="18" height="16"').' alt="" />'.
00357 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/joinbottom.gif','width="18" height="16"').' alt="" />'.
00358 '<a href="'.htmlspecialchars($href).'"><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/new_record.gif','width="16" height="12"').' alt="" /> '.
00359 htmlspecialchars($LANG->getLL('clickForWizard')).
00360 '</a>';
00361
00362
00363 $rowContent.= '<br /><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/halfline.gif','width="18" height="8"').' alt="" />';
00364 }
00365
00366
00367
00368 $tRows[] = '
00369 <tr>
00370 <td nowrap="nowrap">'.$rowContent.'</td>
00371 <td>'.t3lib_BEfunc::cshItem($t,'',$GLOBALS['BACK_PATH'],'',$doNotShowFullDescr).'</td>
00372 </tr>
00373 ';
00374
00375 }
00376 }
00377 }
00378 }
00379
00380
00381 if ($this->newPagesAfter && $this->isTableAllowedForThisPage($this->pidInfo,'pages') && $BE_USER->check('tables_modify','pages')) {
00382
00383
00384 $t = 'pages';
00385 $v = $TCA[$t];
00386 $rowContent = $this->linkWrap(
00387 t3lib_iconWorks::getIconImage($t,array(),$BACK_PATH,'').
00388 $LANG->sL($v['ctrl']['title'],1).' ('.$LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.after',1).')',
00389 'pages',
00390 -$this->id
00391 );
00392
00393
00394 $tRows[] = '
00395 <tr>
00396 <td nowrap="nowrap">'.$rowContent.'</td>
00397 <td>'.t3lib_BEfunc::cshItem($t,'',$GLOBALS['BACK_PATH'],'',$doNotShowFullDescr).'</td>
00398 </tr>
00399 ';
00400 } else {
00401
00402 $tRows[]='
00403 <tr>
00404 <td><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/stopper.gif','width="18" height="16"').' alt="" /></td>
00405 <td></td>
00406 </tr>
00407 ';
00408 }
00409
00410
00411 $this->code.='
00412 <table border="0" cellpadding="0" cellspacing="0" id="typo3-newRecord">
00413 '.implode('',$tRows).'
00414 </table>
00415 ';
00416
00417
00418 if ($this->showNewRecLink('pages')) {
00419 $this->code.='
00420
00421 <!--
00422 Link; create new page:
00423 -->
00424 <div id="typo3-newPageLink">
00425 <a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('pagesOnly'=>'1'))).'">'.
00426 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/new_page.gif','width="13" height="12"').' alt="" />'.
00427 htmlspecialchars($LANG->getLL('createNewPage')).
00428 '</a>
00429 </div>
00430 ';
00431 }
00432
00433
00434 $this->code.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'new_regular', $GLOBALS['BACK_PATH'],'<br/>');
00435 }
00436
00442 function printContent() {
00443 $this->content.= $this->doc->endPage();
00444 echo $this->content;
00445 }
00446
00456 function linkWrap($code,$table,$pid,$addContentTable=0) {
00457 $params = '&edit['.$table.']['.$pid.']=new'.
00458 ($table=='pages'
00459 && $GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']
00460 && isset($GLOBALS['TCA'][$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']])
00461 && $addContentTable ?
00462 '&edit['.$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable'].'][prev]=new&returnNewPageId=1' :
00463 ''
00464 );
00465 $onClick = t3lib_BEfunc::editOnClick($params,'',$this->returnUrl);
00466 return '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.$code.'</a>';
00467 }
00468
00476 function isTableAllowedForThisPage($pid_row, $checkTable) {
00477 global $TCA, $PAGES_TYPES;
00478 if (!is_array($pid_row)) {
00479 if ($GLOBALS['BE_USER']->user['admin']) {
00480 return true;
00481 } else {
00482 return false;
00483 }
00484 }
00485
00486 if ($checkTable=='be_users' || $checkTable=='be_groups') {
00487 return false;
00488 }
00489
00490 $doktype = intval($pid_row['doktype']);
00491 if (!$allowedTableList = $PAGES_TYPES[$doktype]['allowedTables']) {
00492 $allowedTableList = $PAGES_TYPES['default']['allowedTables'];
00493 }
00494 if (strstr($allowedTableList,'*') || t3lib_div::inList($allowedTableList,$checkTable)) {
00495 return true;
00496 }
00497 }
00498
00506 function showNewRecLink($table,$allowedNewTables='') {
00507 $allowedNewTables = is_array($allowedNewTables) ? $allowedNewTables : $this->allowedNewTables;
00508 return !count($allowedNewTables) || in_array($table,$allowedNewTables);
00509 }
00510 }
00511
00512
00513 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/db_new.php']) {
00514 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/db_new.php']);
00515 }
00516
00517
00518
00519
00520
00521
00522 $SOBE = t3lib_div::makeInstance('SC_db_new');
00523 $SOBE->init();
00524 $SOBE->main();
00525 $SOBE->printContent();
00526 ?>