Main Page | Directories | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages | Examples

SC_db_new Class Reference

List of all members.

Public Member Functions

 init ()
 Constructor function for the class.
 main ()
 Main processing, creating the list of new record tables to select from.
 pagesOnly ()
 Creates the position map for pages wizard.
 regularNew ()
 Create a regular new element (pages and records).
 printContent ()
 Ending page output and echo'ing content to browser.
 linkWrap ($code, $table, $pid, $addContentTable=0)
 Links the string $code to a create-new form for a record in $table created on page $pid.
 isTableAllowedForThisPage ($pid_row, $checkTable)
 Returns true if the tablename $checkTable is allowed to be created on the page with record $pid_row.
 showNewRecLink ($table, $allowedNewTables='')
 Returns true if the $table tablename is found in $allowedNewTables (or if $allowedNewTables is empty).

Public Attributes

 $pageinfo
 $pidInfo
 $newPagesInto
 $newContentInto
 $newPagesAfter
 $web_list_modTSconfig
 $allowedNewTables
 $web_list_modTSconfig_pid
 $allowedNewTables_pid
 $code
 $R_URI
 $id
 $returnUrl
 $pagesOnly
 $perms_clause
 $doc
 $content

Member Function Documentation

SC_db_new::init  ) 
 

Constructor function for the class.

Returns:
void

Definition at line 157 of file db_new.php.

References t3lib_BEfunc::getRecord(), pagesOnly(), and t3lib_BEfunc::readPageAccess().

00157                      {
00158       global $BE_USER,$LANG,$BACK_PATH;
00159 
00160          // page-selection permission clause (reading)
00161       $this->perms_clause = $BE_USER->getPagePermsClause(1);
00162 
00163          // Setting GPvars:
00164       $this->id = intval(t3lib_div::_GP('id')); // The page id to operate from
00165       $this->returnUrl = t3lib_div::_GP('returnUrl');
00166       $this->pagesOnly = t3lib_div::_GP('pagesOnly');
00167 
00168          // Create instance of template class for output
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          // Creating content
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          // Id a positive id is supplied, ask for the page record with permission information contained:
00180       if ($this->id > 0)   {
00181          $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause);
00182       }
00183 
00184          // If a page-record was returned, the user had read-access to the page.
00185       if ($this->pageinfo['uid'])   {
00186             // Get record of parent page
00187          $this->pidInfo=t3lib_BEfunc::getRecord('pages',$this->pageinfo['pid']);
00188             // Checking the permissions for the user with regard to the parent page: Can he create new pages, new content record, new page after?
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             // Admins can do it all
00201          $this->newPagesInto=1;
00202          $this->newContentInto=1;
00203          $this->newPagesAfter=0;
00204       } else {
00205             // People with no permission can do nothing
00206          $this->newPagesInto=0;
00207          $this->newContentInto=0;
00208          $this->newPagesAfter=0;
00209       }
00210    }

SC_db_new::isTableAllowedForThisPage pid_row,
checkTable
 

Returns true if the tablename $checkTable is allowed to be created on the page with record $pid_row.

Parameters:
array Record for parent page.
string Table name to check
Returns:
boolean Returns true if the tablename $checkTable is allowed to be created on the page with record $pid_row

Definition at line 476 of file db_new.php.

References $PAGES_TYPES.

Referenced by regularNew().

00476                                                                {
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          // be_users and be_groups may not be created anywhere but in the root.
00486       if ($checkTable=='be_users' || $checkTable=='be_groups') {
00487          return false;
00488       }
00489          // Checking doktype:
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)) {     // If all tables or the table is listed as a allowed type, return true
00495          return true;
00496       }
00497    }

SC_db_new::linkWrap code,
table,
pid,
addContentTable = 0
 

Links the string $code to a create-new form for a record in $table created on page $pid.

Parameters:
string Link string
string Table name (in which to create new record)
integer PID value for the "&edit['.$table.']['.$pid.']=new" command (positive/negative)
boolean If $addContentTable is set, then a new contentTable record is created together with pages
Returns:
string The link.

Definition at line 456 of file db_new.php.

References t3lib_BEfunc::editOnClick().

Referenced by regularNew().

00456                                                             {
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    }

SC_db_new::main  ) 
 

Main processing, creating the list of new record tables to select from.

Returns:
void

Definition at line 217 of file db_new.php.

References $LANG, t3lib_BEfunc::getModTSconfig(), pagesOnly(), regularNew(), and showNewRecLink().

00217                      {
00218       global $BE_USER,$LANG;
00219 
00220          // If there was a page - or if the user is admin (admins has access to the root) we proceed:
00221       if ($this->pageinfo['uid'] || $BE_USER->isAdmin()) {
00222             // Acquiring TSconfig for this module/current page:
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             // Acquiring TSconfig for this module/parent page:
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             // More init:
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             // Set header-HTML and return_url
00240          $this->code=$this->doc->getHeader('pages',$this->pageinfo,$this->pageinfo['_thePath']).'<br />
00241          ';
00242          $this->R_URI=$this->returnUrl;
00243 
00244             // GENERATE the HTML-output depending on mode (pagesOnly is the page wizard)
00245          if (!$this->pagesOnly)  {  // Regular new element:
00246             $this->regularNew();
00247          } elseif ($this->showNewRecLink('pages')) {  // Pages only wizard
00248             $this->pagesOnly();
00249          }
00250 
00251             // Create go-back link.
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             // Add all the content to an output section
00260          $this->content.=$this->doc->section('',$this->code);
00261       }
00262    }

SC_db_new::pagesOnly  ) 
 

Creates the position map for pages wizard.

Returns:
void

Definition at line 269 of file db_new.php.

References t3lib_BEfunc::cshItem().

Referenced by init(), and main().

00269                         {
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             // Add CSH:
00279       $this->code.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'new_pages', $GLOBALS['BACK_PATH'],'<br/>');
00280    }

SC_db_new::printContent  ) 
 

Ending page output and echo'ing content to browser.

Returns:
void

Definition at line 442 of file db_new.php.

00442                            {
00443       $this->content.= $this->doc->endPage();
00444       echo $this->content;
00445    }

SC_db_new::regularNew  ) 
 

Create a regular new element (pages and records).

Returns:
void

Definition at line 287 of file db_new.php.

References $TCA, $tRows, t3lib_BEfunc::cshItem(), t3lib_extMgm::extRelPath(), t3lib_extMgm::isLoaded(), isTableAllowedForThisPage(), linkWrap(), showNewRecLink(), and table().

Referenced by main().

00287                            {
00288       global $BE_USER,$LANG,$BACK_PATH,$TCA;
00289 
00290       $doNotShowFullDescr = FALSE;
00291 
00292          // Slight spacer from header:
00293       $this->code.='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/halfline.gif','width="18" height="8"').' alt="" /><br />';
00294 
00295          // Initialize array for accumulating table rows:
00296       $tRows = array();
00297 
00298          // New pages INSIDE this pages
00299       if ($this->newPagesInto && $this->isTableAllowedForThisPage($this->pageinfo, 'pages') && $BE_USER->check('tables_modify','pages'))  {
00300 
00301             // Create link to new page inside:
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             // Link to page-wizard:
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             // Half-line:
00318          $rowContent.= '<br /><img'.t3lib_iconWorks::skinImg('','gfx/ol/halfline.gif','width="18" height="8"').' alt="" />';
00319 
00320             // Compile table row:
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          // New tables (but not pages) INSIDE this pages
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                      // Create new link for record:
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                      // If the table is 'tt_content' (from "cms" extension), create link to wizard
00349                   if ($t=='tt_content')   {
00350 
00351                         // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's wizard instead:
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                         // Half-line added:
00363                      $rowContent.= '<br /><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/halfline.gif','width="18" height="8"').' alt="" />';
00364                   }
00365 
00366 
00367                      // Compile table row:
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          // New pages AFTER this pages
00381       if ($this->newPagesAfter && $this->isTableAllowedForThisPage($this->pidInfo,'pages') && $BE_USER->check('tables_modify','pages'))   {
00382 
00383             // Create link to new page after
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             // Compile table row:
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             // Compile table row:
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          // Make table:
00411       $this->code.='
00412          <table border="0" cellpadding="0" cellspacing="0" id="typo3-newRecord">
00413          '.implode('',$tRows).'
00414          </table>
00415       ';
00416 
00417          // Create a link to the new-pages wizard.
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          // Add CSH:
00434       $this->code.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'new_regular', $GLOBALS['BACK_PATH'],'<br/>');
00435    }

SC_db_new::showNewRecLink table,
allowedNewTables = ''
 

Returns true if the $table tablename is found in $allowedNewTables (or if $allowedNewTables is empty).

Parameters:
string Table name to test if in allowedTables
array Array of new tables that are allowed.
Returns:
boolean Returns true if the $table tablename is found in $allowedNewTables (or if $allowedNewTables is empty)

Definition at line 506 of file db_new.php.

References $allowedNewTables, and table().

Referenced by main(), and regularNew().

00506                                                          {
00507       $allowedNewTables = is_array($allowedNewTables) ? $allowedNewTables : $this->allowedNewTables;
00508       return !count($allowedNewTables) || in_array($table,$allowedNewTables);
00509    }


Member Data Documentation

SC_db_new::$allowedNewTables
 

Definition at line 135 of file db_new.php.

Referenced by showNewRecLink().

SC_db_new::$allowedNewTables_pid
 

Definition at line 137 of file db_new.php.

SC_db_new::$code
 

Definition at line 138 of file db_new.php.

SC_db_new::$content
 

Definition at line 149 of file db_new.php.

SC_db_new::$doc
 

Definition at line 148 of file db_new.php.

SC_db_new::$id
 

Definition at line 142 of file db_new.php.

SC_db_new::$newContentInto
 

Definition at line 132 of file db_new.php.

SC_db_new::$newPagesAfter
 

Definition at line 133 of file db_new.php.

SC_db_new::$newPagesInto
 

Definition at line 131 of file db_new.php.

SC_db_new::$pageinfo
 

Definition at line 129 of file db_new.php.

SC_db_new::$pagesOnly
 

Definition at line 144 of file db_new.php.

SC_db_new::$perms_clause
 

Definition at line 147 of file db_new.php.

SC_db_new::$pidInfo
 

Definition at line 130 of file db_new.php.

SC_db_new::$R_URI
 

Definition at line 139 of file db_new.php.

SC_db_new::$returnUrl
 

Definition at line 143 of file db_new.php.

SC_db_new::$web_list_modTSconfig
 

Definition at line 134 of file db_new.php.

SC_db_new::$web_list_modTSconfig_pid
 

Definition at line 136 of file db_new.php.


The documentation for this class was generated from the following file:
Generated on Sun Oct 3 01:06:28 2004 for TYPO3core 3.7.0 dev by  doxygen 1.3.8-20040913