TYPO3 API  SVNRelease
index.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2011 Kasper Skårhøj (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 ***************************************************************/
00027 /**
00028  * Module: Web>List
00029  *
00030  * Listing database records from the tables configured in $TCA as they are related to the current page or root.
00031  *
00032  * Notice: This module and Web>Page (db_layout.php) module has a special status since they
00033  * are NOT located in their actual module directories (fx. mod/web/list/) but in the
00034  * backend root directory. This has some historical and practical causes.
00035  *
00036  * $Id: index.php 10295 2011-01-25 09:33:06Z baschny $
00037  * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
00038  * XHTML compliant
00039  *
00040  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00041  */
00042 /**
00043  * [CLASS/FUNCTION INDEX of SCRIPT]
00044  *
00045  *
00046  *
00047  *   89: class SC_db_list
00048  *  125:     function init()
00049  *  160:     function menuConfig()
00050  *  181:     function clearCache()
00051  *  195:     function main()
00052  *  451:     function printContent()
00053  *
00054  * TOTAL FUNCTIONS: 5
00055  * (This index is automatically created/updated by the extension "extdeveval")
00056  *
00057  */
00058 
00059 
00060 $LANG->includeLLFile('EXT:lang/locallang_mod_web_list.xml');
00061 require_once ($BACK_PATH.'class.db_list.inc');
00062 require_once ($BACK_PATH.'class.db_list_extra.inc');
00063 $BE_USER->modAccess($MCONF,1);
00064 
00065 t3lib_BEfunc::lockRecords();
00066 
00067 
00068 
00069 
00070 
00071 
00072 
00073 
00074 /**
00075  * Script Class for the Web > List module; rendering the listing of records on a page
00076  *
00077  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00078  * @package TYPO3
00079  * @subpackage core
00080  */
00081 class SC_db_list {
00082 
00083         // Internal, GPvars:
00084     var $id;                    // Page Id for which to make the listing
00085     var $pointer;               // Pointer - for browsing list of records.
00086     var $imagemode;             // Thumbnails or not
00087     var $table;                 // Which table to make extended listing for
00088     var $search_field;          // Search-fields
00089     var $search_levels;         // Search-levels
00090     var $showLimit;             // Show-limit
00091     var $returnUrl;             // Return URL
00092 
00093     var $clear_cache;           // Clear-cache flag - if set, clears page cache for current id.
00094     var $cmd;                   // Command: Eg. "delete" or "setCB" (for TCEmain / clipboard operations)
00095     var $cmd_table;             // Table on which the cmd-action is performed.
00096 
00097         // Internal, static:
00098     var $perms_clause;          // Page select perms clause
00099     var $modTSconfig;           // Module TSconfig
00100     var $pageinfo;              // Current ids page record
00101 
00102     /**
00103      * Document template object
00104      *
00105      * @var template
00106      */
00107     var $doc;
00108 
00109     var $MCONF=array();         // Module configuration
00110     var $MOD_MENU=array();      // Menu configuration
00111     var $MOD_SETTINGS=array();  // Module settings (session variable)
00112     var $include_once=array();  // Array, where files to include is accumulated in the init() function
00113 
00114         // Internal, dynamic:
00115     var $content;               // Module output accumulation
00116 
00117 
00118     /**
00119      * Initializing the module
00120      *
00121      * @return  void
00122      */
00123     function init() {
00124         global $BE_USER;
00125 
00126             // Setting module configuration / page select clause
00127         $this->MCONF = $GLOBALS['MCONF'];
00128         $this->perms_clause = $BE_USER->getPagePermsClause(1);
00129 
00130             // GPvars:
00131         $this->id = t3lib_div::_GP('id');
00132         $this->pointer = t3lib_div::_GP('pointer');
00133         $this->imagemode = t3lib_div::_GP('imagemode');
00134         $this->table = t3lib_div::_GP('table');
00135         $this->search_field = t3lib_div::_GP('search_field');
00136         $this->search_levels = t3lib_div::_GP('search_levels');
00137         $this->showLimit = t3lib_div::_GP('showLimit');
00138         $this->returnUrl = t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'));
00139 
00140         $this->clear_cache = t3lib_div::_GP('clear_cache');
00141         $this->cmd = t3lib_div::_GP('cmd');
00142         $this->cmd_table = t3lib_div::_GP('cmd_table');
00143 
00144             // Initialize menu
00145         $this->menuConfig();
00146 
00147             // Inclusions?
00148         if ($this->clear_cache || $this->cmd=='delete') {
00149             $this->include_once[]=PATH_t3lib.'class.t3lib_tcemain.php';
00150         }
00151     }
00152 
00153     /**
00154      * Initialize function menu array
00155      *
00156      * @return  void
00157      */
00158     function menuConfig()   {
00159 
00160             // MENU-ITEMS:
00161         $this->MOD_MENU = array(
00162             'bigControlPanel' => '',
00163             'clipBoard' => '',
00164             'localization' => ''
00165         );
00166 
00167             // Loading module configuration:
00168         $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->id,'mod.'.$this->MCONF['name']);
00169 
00170             // Clean up settings:
00171         $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
00172     }
00173 
00174     /**
00175      * Clears page cache for the current id, $this->id
00176      *
00177      * @return  void
00178      */
00179     function clearCache()   {
00180         if ($this->clear_cache) {
00181             $tce = t3lib_div::makeInstance('t3lib_TCEmain');
00182             $tce->stripslashes_values=0;
00183             $tce->start(Array(),Array());
00184             $tce->clear_cacheCmd($this->id);
00185         }
00186     }
00187 
00188     /**
00189      * Main function, starting the rendering of the list.
00190      *
00191      * @return  void
00192      */
00193     function main() {
00194         global $BE_USER,$LANG,$BACK_PATH,$CLIENT;
00195 
00196             // Start document template object:
00197         $this->doc = t3lib_div::makeInstance('template');
00198         $this->doc->backPath = $BACK_PATH;
00199         $this->doc->setModuleTemplate('templates/db_list.html');
00200 
00201             // Loading current page record and checking access:
00202         $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause);
00203         $access = is_array($this->pageinfo) ? 1 : 0;
00204 
00205             // Apply predefined values for hidden checkboxes
00206             // Set predefined value for DisplayBigControlPanel:
00207         if ($this->modTSconfig['properties']['enableDisplayBigControlPanel'] === 'activated') {
00208             $this->MOD_SETTINGS['bigControlPanel'] = TRUE;
00209         } elseif ($this->modTSconfig['properties']['enableDisplayBigControlPanel'] === 'deactivated') {
00210             $this->MOD_SETTINGS['bigControlPanel'] = FALSE;
00211         }
00212 
00213             // Set predefined value for Clipboard:
00214         if ($this->modTSconfig['properties']['enableClipBoard'] === 'activated') {
00215             $this->MOD_SETTINGS['clipBoard'] = TRUE;
00216         } elseif ($this->modTSconfig['properties']['enableClipBoard'] === 'deactivated') {
00217             $this->MOD_SETTINGS['clipBoard'] = FALSE;
00218         }
00219 
00220             // Set predefined value for LocalizationView:
00221         if ($this->modTSconfig['properties']['enableLocalizationView'] === 'activated') {
00222             $this->MOD_SETTINGS['localization'] = TRUE;
00223         } elseif ($this->modTSconfig['properties']['enableLocalizationView'] === 'deactivated') {
00224             $this->MOD_SETTINGS['localization'] = FALSE;
00225         }
00226 
00227             // Initialize the dblist object:
00228         $dblist = t3lib_div::makeInstance('localRecordList');
00229         $dblist->backPath = $BACK_PATH;
00230         $dblist->script = t3lib_BEfunc::getModuleUrl('web_list', array(), '');
00231         $dblist->calcPerms = $BE_USER->calcPerms($this->pageinfo);
00232         $dblist->thumbs = $BE_USER->uc['thumbnailsByDefault'];
00233         $dblist->returnUrl=$this->returnUrl;
00234         $dblist->allFields = ($this->MOD_SETTINGS['bigControlPanel'] || $this->table) ? 1 : 0;
00235         $dblist->localizationView = $this->MOD_SETTINGS['localization'];
00236         $dblist->showClipboard = 1;
00237         $dblist->disableSingleTableView = $this->modTSconfig['properties']['disableSingleTableView'];
00238         $dblist->listOnlyInSingleTableMode = $this->modTSconfig['properties']['listOnlyInSingleTableView'];
00239         $dblist->hideTables = $this->modTSconfig['properties']['hideTables'];
00240         $dblist->tableTSconfigOverTCA = $this->modTSconfig['properties']['table.'];
00241         $dblist->clickTitleMode = $this->modTSconfig['properties']['clickTitleMode'];
00242         $dblist->alternateBgColors=$this->modTSconfig['properties']['alternateBgColors']?1:0;
00243         $dblist->allowedNewTables = t3lib_div::trimExplode(',', $this->modTSconfig['properties']['allowedNewTables'], 1);
00244         $dblist->deniedNewTables = t3lib_div::trimExplode(',', $this->modTSconfig['properties']['deniedNewTables'], 1);
00245         $dblist->newWizards=$this->modTSconfig['properties']['newWizards']?1:0;
00246         $dblist->pageRow = $this->pageinfo;
00247         $dblist->counter++;
00248         $dblist->MOD_MENU = array('bigControlPanel' => '', 'clipBoard' => '', 'localization' => '');
00249         $dblist->modTSconfig = $this->modTSconfig;
00250 
00251             // Clipboard is initialized:
00252         $dblist->clipObj = t3lib_div::makeInstance('t3lib_clipboard');      // Start clipboard
00253         $dblist->clipObj->initializeClipboard();    // Initialize - reads the clipboard content from the user session
00254 
00255             // Clipboard actions are handled:
00256         $CB = t3lib_div::_GET('CB');    // CB is the clipboard command array
00257         if ($this->cmd=='setCB') {
00258                 // CBH is all the fields selected for the clipboard, CBC is the checkbox fields which were checked. By merging we get a full array of checked/unchecked elements
00259                 // This is set to the 'el' array of the CB after being parsed so only the table in question is registered.
00260             $CB['el'] = $dblist->clipObj->cleanUpCBC(array_merge((array)t3lib_div::_POST('CBH'),(array)t3lib_div::_POST('CBC')),$this->cmd_table);
00261         }
00262         if (!$this->MOD_SETTINGS['clipBoard'])  $CB['setP']='normal';   // If the clipboard is NOT shown, set the pad to 'normal'.
00263         $dblist->clipObj->setCmd($CB);      // Execute commands.
00264         $dblist->clipObj->cleanCurrent();   // Clean up pad
00265         $dblist->clipObj->endClipboard();   // Save the clipboard content
00266 
00267             // This flag will prevent the clipboard panel in being shown.
00268             // It is set, if the clickmenu-layer is active AND the extended view is not enabled.
00269         $dblist->dontShowClipControlPanels = $CLIENT['FORMSTYLE'] && !$this->MOD_SETTINGS['bigControlPanel'] && $dblist->clipObj->current=='normal' && !$BE_USER->uc['disableCMlayers'] && !$this->modTSconfig['properties']['showClipControlPanelsDespiteOfCMlayers'];
00270 
00271 
00272 
00273             // If there is access to the page, then render the list contents and set up the document template object:
00274         if ($access)    {
00275 
00276                 // Deleting records...:
00277                 // Has not to do with the clipboard but is simply the delete action. The clipboard object is used to clean up the submitted entries to only the selected table.
00278             if ($this->cmd=='delete')   {
00279                 $items = $dblist->clipObj->cleanUpCBC(t3lib_div::_POST('CBC'),$this->cmd_table,1);
00280                 if (count($items))  {
00281                     $cmd=array();
00282                     foreach ($items as $iK => $value) {
00283                         $iKParts = explode('|',$iK);
00284                         $cmd[$iKParts[0]][$iKParts[1]]['delete']=1;
00285                     }
00286                     $tce = t3lib_div::makeInstance('t3lib_TCEmain');
00287                     $tce->stripslashes_values=0;
00288                     $tce->start(array(),$cmd);
00289                     $tce->process_cmdmap();
00290 
00291                     if (isset($cmd['pages']))   {
00292                         t3lib_BEfunc::setUpdateSignal('updatePageTree');
00293                     }
00294 
00295                     $tce->printLogErrorMessages(t3lib_div::getIndpEnv('REQUEST_URI'));
00296                 }
00297             }
00298 
00299                 // Initialize the listing object, dblist, for rendering the list:
00300             $this->pointer = t3lib_div::intInRange($this->pointer,0,100000);
00301             $dblist->start($this->id,$this->table,$this->pointer,$this->search_field,$this->search_levels,$this->showLimit);
00302             $dblist->setDispFields();
00303 
00304                 // Render versioning selector:
00305             if (t3lib_extMgm::isLoaded('version')) {
00306                 $dblist->HTMLcode .= $this->doc->getVersionSelector($this->id);
00307             }
00308 
00309                 // Render the list of tables:
00310             $dblist->generateList();
00311 
00312                 // Write the bottom of the page:
00313             $dblist->writeBottom();
00314             $listUrl = substr($dblist->listURL(), strlen($GLOBALS['BACK_PATH']));
00315                 // Add JavaScript functions to the page:
00316             $this->doc->JScode=$this->doc->wrapScriptTags('
00317                 function jumpToUrl(URL) {   //
00318                     window.location.href = URL;
00319                     return false;
00320                 }
00321                 function jumpExt(URL,anchor)    {   //
00322                     var anc = anchor?anchor:"";
00323                     window.location.href = URL+(T3_THIS_LOCATION?"&returnUrl="+T3_THIS_LOCATION:"")+anc;
00324                     return false;
00325                 }
00326                 function jumpSelf(URL)  {   //
00327                     window.location.href = URL+(T3_RETURN_URL?"&returnUrl="+T3_RETURN_URL:"");
00328                     return false;
00329                 }
00330 
00331                 function setHighlight(id)   {   //
00332                     top.fsMod.recentIds["web"]=id;
00333                     top.fsMod.navFrameHighlightedID["web"]="pages"+id+"_"+top.fsMod.currentBank;    // For highlighting
00334 
00335                     if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav)  {
00336                         top.content.nav_frame.refresh_nav();
00337                     }
00338                 }
00339                 ' . $this->doc->redirectUrls($listUrl) . '
00340                 '.$dblist->CBfunctions().'
00341                 function editRecords(table,idList,addParams,CBflag) {   //
00342                     window.location.href="'.$BACK_PATH.'alt_doc.php?returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')).
00343                         '&edit["+table+"]["+idList+"]=edit"+addParams;
00344                 }
00345                 function editList(table,idList) {   //
00346                     var list="";
00347 
00348                         // Checking how many is checked, how many is not
00349                     var pointer=0;
00350                     var pos = idList.indexOf(",");
00351                     while (pos!=-1) {
00352                         if (cbValue(table+"|"+idList.substr(pointer,pos-pointer))) {
00353                             list+=idList.substr(pointer,pos-pointer)+",";
00354                         }
00355                         pointer=pos+1;
00356                         pos = idList.indexOf(",",pointer);
00357                     }
00358                     if (cbValue(table+"|"+idList.substr(pointer))) {
00359                         list+=idList.substr(pointer)+",";
00360                     }
00361 
00362                     return list ? list : idList;
00363                 }
00364 
00365                 if (top.fsMod) top.fsMod.recentIds["web"] = '.intval($this->id).';
00366             ');
00367 
00368                 // Setting up the context sensitive menu:
00369             $this->doc->getContextMenuCode();
00370         } // access
00371 
00372             // Begin to compile the whole page, starting out with page header:
00373         $this->body='';
00374         $this->body.= '<form action="'.htmlspecialchars($dblist->listURL()).'" method="post" name="dblistForm">';
00375         $this->body.= $dblist->HTMLcode;
00376         $this->body.= '<input type="hidden" name="cmd_table" /><input type="hidden" name="cmd" /></form>';
00377 
00378             // If a listing was produced, create the page footer with search form etc:
00379         if ($dblist->HTMLcode)  {
00380 
00381                 // Making field select box (when extended view for a single table is enabled):
00382             if ($dblist->table) {
00383                 $this->body.=$dblist->fieldSelectBox($dblist->table);
00384             }
00385 
00386                 // Adding checkbox options for extended listing and clipboard display:
00387             $this->body.='
00388 
00389                     <!--
00390                         Listing options for extended view, clipboard and localization view
00391                     -->
00392                     <div id="typo3-listOptions">
00393                         <form action="" method="post">';
00394 
00395                 // Add "display bigControlPanel" checkbox:
00396             if ($this->modTSconfig['properties']['enableDisplayBigControlPanel'] === 'selectable') {
00397                 $this->body .= t3lib_BEfunc::getFuncCheck(
00398                     $this->id,
00399                     'SET[bigControlPanel]',
00400                     $this->MOD_SETTINGS['bigControlPanel'],
00401                     '',
00402                     ($this->table ? '&table=' . $this->table : ''),
00403                     'id="checkLargeControl"'
00404                 );
00405                 $this->body .= '<label for="checkLargeControl">' .
00406                     t3lib_BEfunc::wrapInHelp(
00407                         'xMOD_csh_corebe',
00408                         'list_options',
00409                         $GLOBALS['LANG']->getLL('largeControl', TRUE)
00410                     ) . '</label><br />';
00411             }
00412 
00413                 // Add "clipboard" checkbox:
00414             if ($this->modTSconfig['properties']['enableClipBoard'] === 'selectable') {
00415                 if ($dblist->showClipboard) {
00416                     $this->body .= t3lib_BEfunc::getFuncCheck(
00417                         $this->id,
00418                         'SET[clipBoard]',
00419                         $this->MOD_SETTINGS['clipBoard'],
00420                         '',
00421                         ($this->table ? '&table=' . $this->table : ''),
00422                         'id="checkShowClipBoard"'
00423                     );
00424                     $this->body .= '<label for="checkShowClipBoard">' .
00425                         t3lib_BEfunc::wrapInHelp(
00426                             'xMOD_csh_corebe',
00427                             'list_options',
00428                             $GLOBALS['LANG']->getLL('showClipBoard', TRUE)
00429                         ) . '</label><br />';
00430                 }
00431             }
00432 
00433                 // Add "localization view" checkbox:
00434             if ($this->modTSconfig['properties']['enableLocalizationView'] === 'selectable') {
00435                 $this->body .= t3lib_BEfunc::getFuncCheck(
00436                     $this->id,
00437                     'SET[localization]',
00438                     $this->MOD_SETTINGS['localization'],
00439                     '',
00440                     ($this->table ? '&table=' . $this->table : ''),
00441                     'id="checkLocalization"'
00442                 );
00443                 $this->body .= '<label for="checkLocalization">' .
00444                     t3lib_BEfunc::wrapInHelp(
00445                         'xMOD_csh_corebe',
00446                         'list_options',
00447                         $GLOBALS['LANG']->getLL('localization', TRUE)
00448                     ) . '</label><br />';
00449             }
00450 
00451             $this->body.='
00452                         </form>
00453                     </div>';
00454 
00455                 // Printing clipboard if enabled:
00456             if ($this->MOD_SETTINGS['clipBoard'] && $dblist->showClipboard) {
00457                 $this->body.= $dblist->clipObj->printClipboard();
00458             }
00459 
00460                 // Search box:
00461             $sectionTitle = t3lib_BEfunc::wrapInHelp('xMOD_csh_corebe', 'list_searchbox', $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.search', TRUE));
00462             $this->body .= $this->doc->section(
00463                 $sectionTitle,
00464                 $dblist->getSearchBox(),
00465                 FALSE, TRUE, FALSE, TRUE
00466             );
00467 
00468                 // Display sys-notes, if any are found:
00469             $this->body.=$dblist->showSysNotesForPage();
00470         }
00471 
00472             // Setting up the buttons and markers for docheader
00473         $docHeaderButtons = $dblist->getButtons();
00474         $markers = array(
00475             'CSH' => $docHeaderButtons['csh'],
00476             'CONTENT' => $this->body
00477         );
00478 
00479             // Build the <body> for the module
00480         $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
00481             // Renders the module page
00482         $this->content = $this->doc->render(
00483             'DB list',
00484             $this->content
00485         );
00486     }
00487 
00488     /**
00489      * Outputting the accumulated content to screen
00490      *
00491      * @return  void
00492      */
00493     function printContent() {
00494         echo $this->content;
00495     }
00496 
00497 }
00498 
00499 
00500 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/db_list.php'])) {
00501     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/db_list.php']);
00502 }
00503 
00504 
00505 
00506 // Make instance:
00507 $SOBE = t3lib_div::makeInstance('SC_db_list');
00508 $SOBE->init();
00509 
00510 // Include files?
00511 foreach($SOBE->include_once as $INC_FILE)   include_once($INC_FILE);
00512 
00513 $SOBE->clearCache();
00514 $SOBE->main();
00515 $SOBE->printContent();
00516 
00517 ?>