Documentation TYPO3 par Ameos

db_list.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2004 Kasper Skaarhoj (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 ***************************************************************/
00060 unset($MCONF);
00061 require ('mod/web/list/conf.php');
00062 require ('init.php');
00063 require ('template.php');
00064 $LANG->includeLLFile('EXT:lang/locallang_mod_web_list.xml');
00065 require_once (PATH_t3lib.'class.t3lib_page.php');
00066 require_once (PATH_t3lib.'class.t3lib_pagetree.php');
00067 require_once (PATH_t3lib.'class.t3lib_recordlist.php');
00068 require_once (PATH_t3lib.'class.t3lib_clipboard.php');
00069 require_once ('class.db_list.inc');
00070 require_once ('class.db_list_extra.inc');
00071 $BE_USER->modAccess($MCONF,1);
00072 
00073 t3lib_BEfunc::lockRecords();
00074 
00075 
00076 
00077 
00078 
00079 
00080 
00081 
00089 class SC_db_list {
00090 
00091                 // Internal, GPvars:
00092         var $id;                                        // Page Id for which to make the listing
00093         var $pointer;                           // Pointer - for browsing list of records.
00094         var $imagemode;                         // Thumbnails or not
00095         var $table;                                     // Which table to make extended listing for
00096         var $search_field;                      // Search-fields
00097         var $search_levels;                     // Search-levels
00098         var $showLimit;                         // Show-limit
00099         var $returnUrl;                         // Return URL
00100 
00101         var $clear_cache;                       // Clear-cache flag - if set, clears page cache for current id.
00102         var $cmd;                                       // Command: Eg. "delete" or "setCB" (for TCEmain / clipboard operations)
00103         var $cmd_table;                         // Table on which the cmd-action is performed.
00104 
00105                 // Internal, static:
00106         var $perms_clause;                      // Page select perms clause
00107         var $modTSconfig;                       // Module TSconfig
00108         var $pageinfo;                          // Current ids page record
00109         var $doc;                                       // Document template object
00110 
00111         var $MCONF=array();                     // Module configuration
00112         var $MOD_MENU=array();          // Menu configuration
00113         var $MOD_SETTINGS=array();      // Module settings (session variable)
00114         var $include_once=array();      // Array, where files to include is accumulated in the init() function
00115 
00116                 // Internal, dynamic:
00117         var $content;                           // Module output accumulation
00118 
00119 
00125         function init() {
00126                 global $BE_USER;
00127 
00128                         // Setting module configuration / page select clause
00129                 $this->MCONF = $GLOBALS['MCONF'];
00130                 $this->perms_clause = $BE_USER->getPagePermsClause(1);
00131 
00132                         // GPvars:
00133                 $this->id = t3lib_div::_GP('id');
00134                 $this->pointer = t3lib_div::_GP('pointer');
00135                 $this->imagemode = t3lib_div::_GP('imagemode');
00136                 $this->table = t3lib_div::_GP('table');
00137                 $this->search_field = t3lib_div::_GP('search_field');
00138                 $this->search_levels = t3lib_div::_GP('search_levels');
00139                 $this->showLimit = t3lib_div::_GP('showLimit');
00140                 $this->returnUrl = t3lib_div::_GP('returnUrl');
00141 
00142                 $this->clear_cache = t3lib_div::_GP('clear_cache');
00143                 $this->cmd = t3lib_div::_GP('cmd');
00144                 $this->cmd_table = t3lib_div::_GP('cmd_table');
00145 
00146                         // Initialize menu
00147                 $this->menuConfig();
00148 
00149                         // Inclusions?
00150                 if ($this->clear_cache || $this->cmd=='delete') {
00151                         $this->include_once[]=PATH_t3lib.'class.t3lib_tcemain.php';
00152                 }
00153         }
00154 
00160         function menuConfig()   {
00161 
00162                         // MENU-ITEMS:
00163                 $this->MOD_MENU = array(
00164                         'bigControlPanel' => '',
00165                         'clipBoard' => '',
00166                         'localization' => ''
00167                 );
00168 
00169                         // Loading module configuration:
00170                 $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->id,'mod.'.$this->MCONF['name']);
00171 
00172                         // Clean up settings:
00173                 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
00174         }
00175 
00181         function clearCache()   {
00182                 if ($this->clear_cache) {
00183                         $tce = t3lib_div::makeInstance('t3lib_TCEmain');
00184                         $tce->stripslashes_values=0;
00185                         $tce->start(Array(),Array());
00186                         $tce->clear_cacheCmd($this->id);
00187                 }
00188         }
00189 
00195         function main() {
00196                 global $BE_USER,$LANG,$BACK_PATH,$CLIENT;
00197 
00198                         // Start document template object:
00199                 $this->doc = t3lib_div::makeInstance('template');
00200                 $this->doc->backPath = $BACK_PATH;
00201                 $this->doc->docType='xhtml_trans';
00202 
00203                         // Loading current page record and checking access:
00204                 $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause);
00205                 $access = is_array($this->pageinfo) ? 1 : 0;
00206 
00207                         // Initialize the dblist object:
00208                 $dblist = t3lib_div::makeInstance('localRecordList');
00209                 $dblist->backPath = $BACK_PATH;
00210                 $dblist->calcPerms = $BE_USER->calcPerms($this->pageinfo);
00211                 $dblist->thumbs = $BE_USER->uc['thumbnailsByDefault'];
00212                 $dblist->returnUrl=$this->returnUrl;
00213                 $dblist->allFields = ($this->MOD_SETTINGS['bigControlPanel'] || $this->table) ? 1 : 0;
00214                 $dblist->localizationView = $this->MOD_SETTINGS['localization'];
00215                 $dblist->showClipboard = 1;
00216                 $dblist->disableSingleTableView = $this->modTSconfig['properties']['disableSingleTableView'];
00217                 $dblist->listOnlyInSingleTableMode = $this->modTSconfig['properties']['listOnlyInSingleTableView'];
00218                 $dblist->clickTitleMode = $this->modTSconfig['properties']['clickTitleMode'];
00219                 $dblist->alternateBgColors=$this->modTSconfig['properties']['alternateBgColors']?1:0;
00220                 $dblist->allowedNewTables = t3lib_div::trimExplode(',',$this->modTSconfig['properties']['allowedNewTables'],1);
00221                 $dblist->newWizards=$this->modTSconfig['properties']['newWizards']?1:0;
00222 
00223 
00224 
00225                         // Clipboard is initialized:
00226                 $dblist->clipObj = t3lib_div::makeInstance('t3lib_clipboard');          // Start clipboard
00227                 $dblist->clipObj->initializeClipboard();        // Initialize - reads the clipboard content from the user session
00228 
00229                         // Clipboard actions are handled:
00230                 $CB = t3lib_div::_GET('CB');    // CB is the clipboard command array
00231                 if ($this->cmd=='setCB') {
00232                                 // 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
00233                                 // This is set to the 'el' array of the CB after being parsed so only the table in question is registered.
00234                         $CB['el'] = $dblist->clipObj->cleanUpCBC(array_merge(t3lib_div::_POST('CBH'),t3lib_div::_POST('CBC')),$this->cmd_table);
00235                 }
00236                 if (!$this->MOD_SETTINGS['clipBoard'])  $CB['setP']='normal';   // If the clipboard is NOT shown, set the pad to 'normal'.
00237                 $dblist->clipObj->setCmd($CB);          // Execute commands.
00238                 $dblist->clipObj->cleanCurrent();       // Clean up pad
00239                 $dblist->clipObj->endClipboard();       // Save the clipboard content
00240 
00241                         // This flag will prevent the clipboard panel in being shown.
00242                         // It is set, if the clickmenu-layer is active AND the extended view is not enabled.
00243                 $dblist->dontShowClipControlPanels = $CLIENT['FORMSTYLE'] && !$this->MOD_SETTINGS['bigControlPanel'] && $dblist->clipObj->current=='normal' && !$BE_USER->uc['disableCMlayers'] && !$this->modTSconfig['properties']['showClipControlPanelsDespiteOfCMlayers'];
00244 
00245 
00246 
00247                         // If there is access to the page, then render the list contents and set up the document template object:
00248                 if ($access)    {
00249 
00250                                 // Deleting records...:
00251                                 // 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.
00252                         if ($this->cmd=='delete')       {
00253                                 $items = $dblist->clipObj->cleanUpCBC(t3lib_div::_POST('CBC'),$this->cmd_table,1);
00254                                 if (count($items))      {
00255                                         $cmd=array();
00256                                         reset($items);
00257                                         while(list($iK)=each($items))   {
00258                                                 $iKParts = explode('|',$iK);
00259                                                 $cmd[$iKParts[0]][$iKParts[1]]['delete']=1;
00260                                         }
00261                                         $tce = t3lib_div::makeInstance('t3lib_TCEmain');
00262                                         $tce->stripslashes_values=0;
00263                                         $tce->start(array(),$cmd);
00264                                         $tce->process_cmdmap();
00265 
00266                                         if (isset($cmd['pages']))       {
00267                                                 t3lib_BEfunc::getSetUpdateSignal('updatePageTree');
00268                                         }
00269 
00270                                         $tce->printLogErrorMessages(t3lib_div::getIndpEnv('REQUEST_URI'));
00271                                 }
00272                         }
00273 
00274                                 // Initialize the listing object, dblist, for rendering the list:
00275                         $this->pointer = t3lib_div::intInRange($this->pointer,0,100000);
00276                         $dblist->start($this->id,$this->table,$this->pointer,$this->search_field,$this->search_levels,$this->showLimit);
00277                         $dblist->setDispFields();
00278 
00279                                 // Render the page header:
00280                         $dblist->writeTop($this->pageinfo);
00281 
00282                                 // Render versioning selector:
00283                         $dblist->HTMLcode.= $this->doc->getVersionSelector($this->id);
00284 
00285                                 // Render the list of tables:
00286                         $dblist->generateList($this->id,$this->table);
00287 
00288                                 // Write the bottom of the page:
00289                         $dblist->writeBottom();
00290 
00291                                 // Add JavaScript functions to the page:
00292                         $this->doc->JScode=$this->doc->wrapScriptTags('
00293                                 function jumpToUrl(URL) {       //
00294                                         document.location = URL;
00295                                         return false;
00296                                 }
00297                                 function jumpExt(URL,anchor)    {       //
00298                                         var anc = anchor?anchor:"";
00299                                         document.location = URL+(T3_THIS_LOCATION?"&returnUrl="+T3_THIS_LOCATION:"")+anc;
00300                                         return false;
00301                                 }
00302                                 function jumpSelf(URL)  {       //
00303                                         document.location = URL+(T3_RETURN_URL?"&returnUrl="+T3_RETURN_URL:"");
00304                                         return false;
00305                                 }
00306                                 '.$this->doc->redirectUrls($dblist->listURL()).'
00307                                 '.$dblist->CBfunctions().'
00308                                 function editRecords(table,idList,addParams,CBflag)     {       //
00309                                         document.location="'.$backPath.'alt_doc.php?returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')).
00310                                                 '&edit["+table+"]["+idList+"]=edit"+addParams;
00311                                 }
00312                                 function editList(table,idList) {       //
00313                                         var list="";
00314 
00315                                                 // Checking how many is checked, how many is not
00316                                         var pointer=0;
00317                                         var pos = idList.indexOf(",");
00318                                         while (pos!=-1) {
00319                                                 if (cbValue(table+"|"+idList.substr(pointer,pos-pointer))) {
00320                                                         list+=idList.substr(pointer,pos-pointer)+",";
00321                                                 }
00322                                                 pointer=pos+1;
00323                                                 pos = idList.indexOf(",",pointer);
00324                                         }
00325                                         if (cbValue(table+"|"+idList.substr(pointer))) {
00326                                                 list+=idList.substr(pointer)+",";
00327                                         }
00328 
00329                                         return list ? list : idList;
00330                                 }
00331 
00332                                 if (top.fsMod) top.fsMod.recentIds["web"] = '.intval($this->id).';
00333                         ');
00334 
00335                                 // Setting up the context sensitive menu:
00336                         $CMparts=$this->doc->getContextMenuCode();
00337                         $this->doc->bodyTagAdditions = $CMparts[1];
00338                         $this->doc->JScode.=$CMparts[0];
00339                         $this->doc->postCode.= $CMparts[2];
00340                 } // access
00341 
00342 
00343 
00344                         // Begin to compile the whole page, starting out with page header:
00345                 $this->content='';
00346                 $this->content.=$this->doc->startPage('DB list');
00347                 $this->content.= '<form action="'.htmlspecialchars($dblist->listURL()).'" method="post" name="dblistForm">';
00348 
00349                         // List Module CSH:
00350                 if (!strlen($this->id)) {
00351                         $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'list_module_noId', $GLOBALS['BACK_PATH'],'<br/>|');
00352                 } elseif (!$this->id)   {       // zero...:
00353                         $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'list_module_root', $GLOBALS['BACK_PATH'],'<br/>|');
00354                 }
00355 
00356                         // Add listing HTML code:
00357                 $this->content.= $dblist->HTMLcode;
00358                 $this->content.= '<input type="hidden" name="cmd_table" /><input type="hidden" name="cmd" /></form>';
00359 
00360                         // List Module CSH:
00361                 if ($this->id)  {
00362                         $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'list_module', $GLOBALS['BACK_PATH'],'<br/>|');
00363                 }
00364 
00365 
00366                         // If a listing was produced, create the page footer with search form etc:
00367                 if ($dblist->HTMLcode)  {
00368 
00369                                 // Making field select box (when extended view for a single table is enabled):
00370                         if ($dblist->table)     {
00371                                 $this->content.=$dblist->fieldSelectBox($dblist->table);
00372                         }
00373 
00374                                 // Adding checkbox options for extended listing and clipboard display:
00375                         $this->content.='
00376 
00377                                         <!--
00378                                                 Listing options for clipboard and thumbnails
00379                                         -->
00380                                         <div id="typo3-listOptions">
00381                                                 <form action="" method="post">';
00382 
00383                         $this->content.=t3lib_BEfunc::getFuncCheck($this->id,'SET[bigControlPanel]',$this->MOD_SETTINGS['bigControlPanel'],'db_list.php','').' '.$LANG->getLL('largeControl',1).'<br />';
00384                         if ($dblist->showClipboard)     {
00385                                 $this->content.=t3lib_BEfunc::getFuncCheck($this->id,'SET[clipBoard]',$this->MOD_SETTINGS['clipBoard'],'db_list.php','').' '.$LANG->getLL('showClipBoard',1).'<br />';
00386                         }
00387                         $this->content.=t3lib_BEfunc::getFuncCheck($this->id,'SET[localization]',$this->MOD_SETTINGS['localization'],'db_list.php','').' '.$LANG->getLL('localization',1).'<br />';
00388                         $this->content.='
00389                                                 </form>
00390                                         </div>';
00391                         $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'list_options', $GLOBALS['BACK_PATH']);
00392 
00393                                 // Printing clipboard if enabled:
00394                         if ($this->MOD_SETTINGS['clipBoard'] && $dblist->showClipboard) {
00395                                 $this->content.= $dblist->clipObj->printClipboard();
00396                                 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'list_clipboard', $GLOBALS['BACK_PATH']);
00397                         }
00398 
00399                                 // Link for creating new records:
00400                         if (!$this->modTSconfig['properties']['noCreateRecordsLink'])   {
00401                                 $this->content.='
00402 
00403                                         <!--
00404                                                 Link for creating a new record:
00405                                         -->
00406                                         <div id="typo3-newRecordLink">
00407                                         <a href="'.htmlspecialchars('db_new.php?id='.$this->id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
00408                                                                 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/new_el.gif','width="11" height="12"').' alt="" />'.
00409                                                                 $LANG->getLL('newRecordGeneral',1).
00410                                                                 '</a>
00411                                         </div>';
00412                         }
00413 
00414                                 // Search box:
00415                         $this->content.=$dblist->getSearchBox();
00416 
00417                                 // Display sys-notes, if any are found:
00418                         $this->content.=$dblist->showSysNotesForPage();
00419 
00420                                 // ShortCut:
00421                         if ($BE_USER->mayMakeShortcut())        {
00422                                 $this->content.='<br/>'.$this->doc->makeShortcutIcon('id,imagemode,pointer,table,search_field,search_levels,showLimit,sortField,sortRev',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name']);
00423                         }
00424                 }
00425 
00426                         // Finally, close off the page:
00427                 $this->content.= $this->doc->endPage();
00428         }
00429 
00435         function printContent() {
00436                 echo $this->content;
00437         }
00438 }
00439 
00440 // Include extension?
00441 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/db_list.php'])       {
00442         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/db_list.php']);
00443 }
00444 
00445 
00446 
00447 
00448 
00449 
00450 
00451 
00452 
00453 
00454 
00455 
00456 // Make instance:
00457 $SOBE = t3lib_div::makeInstance('SC_db_list');
00458 $SOBE->init();
00459 
00460 // Include files?
00461 foreach($SOBE->include_once as $INC_FILE)       include_once($INC_FILE);
00462 
00463 $SOBE->clearCache();
00464 $SOBE->main();
00465 $SOBE->printContent();
00466 ?>


Généré par TYPO3 Ameos avec  doxygen 1.4.6