List module; rendering the listing of records on a page * * @author Kasper Skaarhoj * @author Tapio Markula * @author Dmitry Pikhno (tm_contentaccess) * @package TYPO3 * @subpackage core */ /** enable options and/or loaded extension related global conditions starts ***/ if($tm_contentaccessConf['enable.']['extra_be_icons']) // adds some new be icons $extraBEIcons=1; /** enable options and/or loaded extension related global conditions ends *****/ // something just for a project (" - for a project") /*************************** class starts *************************************/ class ux_localRecordList extends localRecordList { var $modTSconfig=array(); var $disableListmoduleTopIcons=array(); var $disableListmoduleMainIcons=array(); /** * Writes the top of the full listing * * @param array Current page record * @return void (Adds content to internal variable, $this->HTMLcode) */ function writeTop($row) { global $LANG,$extraBEIcons,$Typo4,$Typo4_1; $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list'); #t3lib_div::debug($this->modTSconfig); // deleting all records in the same page $deleteAllRecords=t3lib_div::_GP('delete_record'); // the value is the name of a table, for example 'tt_address' if($deleteAllRecords) { $res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery($deleteAllRecords, 'deleted="0" AND pid="'.$this->id.'"', array('deleted' => 1)); // hook for handling relation tables if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['mm_'.$deleteAllRecords]) && is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['mm_'.$deleteAllRecords])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['mm_'.$deleteAllRecords] as $classRef) { $hookObj= &t3lib_div::getUserObj($classRef); $hookName='mm_'.$deleteAllRecords; if (method_exists($hookObj,$hookName)) $hookObj->$hookName($this->id,$this->modTSconfig); } $hookObj=NULL;$hookName=NULL; } // special conditions if direct_mail has been installed in order to delete relations too (this could be put also using the previous mentioned hook) elseif($Typo4 && t3lib_extMgm::isLoaded('direct_mail')) { switch($deleteAllRecords) { CASE 'tt_address': $MinItem=$GLOBALS['TYPO3_DB']->exec_SELECTquery('MIN(uid_local)','sys_dmail_ttaddress_category_mm','','', '', ''); $MinItem=$GLOBALS['TYPO3_DB']->sql_fetch_row($MinItem); $MinItem=$MinItem[0]; $MaxItem=$GLOBALS['TYPO3_DB']->exec_SELECTquery('MAX(uid_local)','sys_dmail_ttaddress_category_mm','','', '', ''); $MaxItem=$GLOBALS['TYPO3_DB']->sql_fetch_row($MaxItem); $MaxItem=$MaxItem[0]; if($MinItem && $MaxItem) { for($i=$MinItem;$i<=$MaxItem;$i++) { // delete relations for 'tt_address' records, which has been marked as deleted in the current page if(!$this->modTSconfig['properties']['disableClearDirectMailRelations']) { $isDeleted=$GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)','tt_address','uid="'.$i.'" AND pid="'.$this->id.'" AND deleted="1"','', '', ''); $isDeleted=$GLOBALS['TYPO3_DB']->sql_fetch_row($isDeleted); $isDeleted=$isDeleted[0]; } // delete possible relations with unexisting items in the main table (lost relations to the table 'tt_address') $exists=$GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)','tt_address','uid="'.$i.'"','', '', ''); $exists=$GLOBALS['TYPO3_DB']->sql_fetch_row($exists); $exists=$exists[0]; if($isDeleted || !$exists) $GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_dmail_ttaddress_category_mm','uid_local='.$i.''); } } break; CASE 'fe_users': $MinItem=$GLOBALS['TYPO3_DB']->exec_SELECTquery('MIN(uid_local)','sys_dmail_feuser_category_mm','','', '', ''); $MinItem=$GLOBALS['TYPO3_DB']->sql_fetch_row($MinItem); $MinItem=$MinItem[0]; $MaxItem=$GLOBALS['TYPO3_DB']->exec_SELECTquery('MAX(uid_local)','sys_dmail_feuser_category_mm','','', '', ''); $MaxItem=$GLOBALS['TYPO3_DB']->sql_fetch_row($MaxItem); $MaxItem=$MaxItem[0]; if($MinItem && $MaxItem) { for($i=$MinItem;$i<=$MaxItem;$i++) { // delete relations for 'fe_users' records, which has been marked as deleted in the current page if(!$this->modTSconfig['properties']['disableClearDirectMailRelations']) { $isDeleted=$GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)','fe_users','uid="'.$i.'" AND pid="'.$this->id.'" AND deleted="1"','', '', ''); $isDeleted=$GLOBALS['TYPO3_DB']->sql_fetch_row($isDeleted); $isDeleted=$isDeleted[0]; } // delete possible relations with unexisting items in the main table (lost relations to the table 'fe_users') $exists=$GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)','fe_users','uid="'.$i.'"','', '', ''); $exists=$GLOBALS['TYPO3_DB']->sql_fetch_row($exists); $exists=$exists[0]; if($isDeleted || !$exists) $GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_dmail_feuser_category_mm','uid_local='.$i.''); } } break; CASE 'sys_dmail_group': $MinItem=$GLOBALS['TYPO3_DB']->exec_SELECTquery('MIN(uid_local)','sys_dmail_group_mm','','', '', ''); $MinItem=$GLOBALS['TYPO3_DB']->sql_fetch_row($MinItem); $MinItem=$MinItem[0]; $MaxItem=$GLOBALS['TYPO3_DB']->exec_SELECTquery('MAX(uid_local)','sys_dmail_group_mm','','', '', ''); $MaxItem=$GLOBALS['TYPO3_DB']->sql_fetch_row($MaxItem); $MaxItem=$MaxItem[0]; if($MinItem && $MaxItem) { for($i=$MinItem;$i<=$MaxItem;$i++) { // delete relations for 'sys_dmail_group' records, which has been marked as deleted in the current page if(!$this->modTSconfig['properties']['disableClearDirectMailRelations']) { $isDeleted=$GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)','sys_dmail_group','uid="'.$i.'" AND pid="'.$this->id.'" AND deleted="1"','', '', ''); $isDeleted=$GLOBALS['TYPO3_DB']->sql_fetch_row($isDeleted); $isDeleted=$isDeleted[0]; } // delete possible relations with unexisting items in the main table (lost relations to the table 'sys_dmail_group') $exists=$GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)','sys_dmail_group','uid="'.$i.'"','', '', ''); $exists=$GLOBALS['TYPO3_DB']->sql_fetch_row($exists); $exists=$exists[0]; if($isDeleted || !$exists) $GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_dmail_group_mm','uid_local='.$i.''); } } break; } } } // Makes the code for the pageicon in the top $this->pageRow = $row; $this->counter++; $alttext = t3lib_BEfunc::getRecordIconAltText($row,'pages'); $iconImg = t3lib_iconWorks::getIconImage('pages',$row,$this->backPath,'class="absmiddle" title="'.htmlspecialchars($alttext).'"'); $titleCol = 'test'; // pseudo title column name $this->fieldArray = Array($titleCol,'up'); // Setting the fields to display in the list (this is of course "pseudo fields" since this is the top!) // Filling in the pseudo data array: $theData = Array(); $theData[$titleCol] = $this->widthGif; // Get users permissions for this row: $localCalcPerms = $GLOBALS['BE_USER']->calcPerms($row); $theData['up']=array(); // Initialize control panel for currect page ($this->id): // Some of the controls are added only if $this->id is set - since they make sense only on a real page, not root level. $theCtrlPanel =array(); if($Typo4_1) $path=$this->backPath; if($this->modTSconfig['properties']['disableListmoduleTopIcons']) { $typesForDisableListmoduleTopIcons = t3lib_div::trimExplode(',',strtolower($this->modTSconfig['properties']['disableListmoduleTopIcons']),1); if(is_array($typesForDisableListmoduleTopIcons)) $this->disableListmoduleTopIcons = array_flip($typesForDisableListmoduleTopIcons); // resets temporary variable $typesForDisableListmoduleTopIcons=NULL; } // "View page" icon is added: if (!isset($this->disableListmoduleTopIcons['zoom'])) $theCtrlPanel[]=''. 'backPath,'gfx/zoom.gif','').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showPage',1).'" alt="" />'. ''; // If edit permissions are set (see class.t3lib_userauthgroup.php) if ($localCalcPerms&2) { if($extraBEIcons) #$imageSrc = ' src="../typo3conf/ext/tm_contentaccess/extra-icons/edit2Page.gif"'; $imageSrc = t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2Page.gif',''); else $imageSrc = t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif',''); // Adding "Edit page" icon: if (!isset($this->disableListmoduleTopIcons['edit_page']) && $this->id) { $params='&edit[pages]['.$row['uid'].']=edit'; $theCtrlPanel[]=''. ''. ''; } // Adding "move page" button: if (!isset($this->disableListmoduleTopIcons['move_page']) && $this->id) { $theCtrlPanel[]=''. 'backPath,'gfx/move_'.($this->table=='tt_content'?'record':'page').'.gif','').' title="'.$LANG->getLL('move_page',1).'" alt="" />'. ''; } // Adding "New record" icon: if (!(isset($this->disableListmoduleTopIcons['new_record'])) && !$GLOBALS['SOBE']->modTSconfig['properties']['noCreateRecordsLink']) { $theCtrlPanel[]=''. ''. ''; } // Adding "Hide/Unhide" icon: if (!(isset($this->disableListmoduleTopIcons['hide'])) && $this->id) { if ($row['hidden']) { $params='&data[pages]['.$row['uid'].'][hidden]=0'; $theCtrlPanel[]=''. 'backPath,'gfx/button_unhide.gif','width="11" height="10"').' title="'.$LANG->getLL('unHidePage',1).'" alt="" />'. ''; } else { $params='&data[pages]['.$row['uid'].'][hidden]=1'; $theCtrlPanel[]=''. 'backPath,'gfx/button_hide.gif','width="11" height="10"').' title="'.$LANG->getLL('hidePage',1).'" alt="" />'. ''; } } } // "Paste into page" link: if (!(isset($this->disableListmoduleTopIcons['paste'])) && ($localCalcPerms&8) || ($localCalcPerms&16)) { $elFromTable = $this->clipObj->elFromTable(''); if (count($elFromTable)) { $theCtrlPanel[]=''. ''. ''; } } // Finally, compile all elements of the control panel into table cells: if (count($theCtrlPanel)) { $theData['up'][]='
'.implode(' ',$theCtrlPanel).'
'; } // Add "clear-cache" link: if(!(isset($this->disableListmoduleTopIcons['clear_cache']))){ $theData['up'][]=''. 'backPath,'gfx/clear_cache.gif','').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.clear_cache',1).'" alt="" />'. ''; } // Add "CSV" link, if a specific table is shown: if (!(isset($this->disableListmoduleTopIcons['csv'])) && $this->table) { $theData['up'][]=''. 'backPath,'gfx/csv.gif','width="27" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.csv',1).'" alt="" />'. ''; } // Add "Export" link, if a specific table is shown: if (!(isset($this->disableListmoduleTopIcons['export'])) && $this->table && t3lib_extMgm::isLoaded('impexp')) { if($Typo4_1) $href = ''; else $href = ''; $theData['up'][] = $href.'backPath,t3lib_extMgm::extRelPath('impexp').'export.gif',' ').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.export',1).'" alt="" />'. ''; } // Add "refresh" link: $theData['up'][]=''. 'backPath,'gfx/refresh_n.gif','').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.reload',1).'" alt="" />'. ''; // Add icon with clickmenu, etc: if ($this->id) { // If there IS a real page...: if($Typo4) // New in Typo3 4.0.x $higlight=' onclick="setHighlight('.$row['pid'].')"'; // Setting title of page + the "Go up" link: $theData[$titleCol].='
'.htmlspecialchars(t3lib_div::fixed_lgd_cs($row['_thePath'],-$this->fixedL)).''; $theData['up'][]=''. 'backPath,'gfx/i/pages_up.gif','').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.upOneLevel',1).'" alt="" />'. ''; // Make Icon: $theIcon = $this->clickMenuEnabled ? $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg,'pages',$this->id) : $iconImg; } else { // On root-level of page tree: // Setting title of root (sitename): $theData[$titleCol].='
'.htmlspecialchars(t3lib_div::fixed_lgd_cs($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],-$this->fixedL)); // Make Icon: $theIcon = 'backPath,'gfx/i/_icon_website.gif','').' alt="" />'; } // If there is a returnUrl given, add a back-link: if ($this->returnUrl) { if(!$Typo4_1) $path=$GLOBALS["BACK_PATH"]; else $path=$this->backPath; $theData['up'][]=''. ''. ''; if(!$Typo4_1) // reset again $path=''; } if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['addTopItems']) && is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['addTopItems'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['addTopItems'] as $classRef) { $hookObj= &t3lib_div::getUserObj($classRef); if (method_exists($hookObj, 'addTopItems')) $hookObj->addTopItems($theData,$this,$this->disableListmoduleTopIcons); } } // Finally, the "up" pseudo field is compiled into a table - has been accumulated in an array: $theData['up']='
'.implode(' ',$theData['up']).'
'; // ... and the element row is created: $out.=$this->addelement(1,$theIcon,$theData,'',$this->leftMargin); // ... and wrapped into a table and added to the internal ->HTMLcode variable: $this->HTMLcode.=' '.$out.'
'; } /********************************* * * Rendering of various elements * *********************************/ /** * Creates the control panel for a single record in the listing. * * @param string The table * @param array The record for which to make the control panel. * @return string HTML table with the control panel (unless disabled) */ function makeControl($table,$row) { global $TCA,$LANG,$SOBE,$extraBEIcons,$Typo4,$Typo4_1; if($Typo4_1) $path=$this->backPath; if($this->modTSconfig['properties']['disableListmoduleMainIcons']) $typesForDisableListmoduleMainIcons = t3lib_div::trimExplode(',',strtolower($this->modTSconfig['properties']['disableListmoduleMainIcons']),1); if(isset($typesForDisableListmoduleMainIcons) && is_array($typesForDisableListmoduleMainIcons)) { $this->disableListmoduleMainIcons = array_flip($typesForDisableListmoduleMainIcons); // resets temporary variable $typesForDisableListmoduleMainIcons=NULL; } // Return blank, if disabled: if ($this->dontShowClipControlPanels) return ''; // remains only cut/clip but other off // Initialize: t3lib_div::loadTCA($table); $cells=array(); // If the listed table is 'pages' we have to request the permission settings for each page: if ($table=='pages') { $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$row['uid'])); } // This expresses the edit permissions for this particular element: $permsEdit = ($table=='pages' && ($localCalcPerms&2)) || ($table!='pages' && ($this->calcPerms&16)); // "Show" link (only pages and tt_content elements) if (!isset($this->disableListmoduleMainIcons['show']) && ($table=='pages' || $table=='tt_content')) { $params='&edit['.$table.']['.$row['uid'].']=edit'; if($Typo4_1) $href = ''; else $href = ''; $cells['show']=$href.'backPath,'gfx/zoom.gif','').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showPage',1).'" alt="" />'. ''; } // If the extended control panel is enabled OR if we are seeing a single table: if ($SOBE->MOD_SETTINGS['bigControlPanel'] || $this->table) { // If the table is NOT a read-only table, then show history link: if (!$TCA[$table]['ctrl']['readOnly']) { // "Revert" link (history/undo) if(!isset($this->disableListmoduleMainIcons['history'])) { $cells['history']=''. 'backPath,'gfx/history2.gif','').' title="'.$LANG->getLL('history',1).'" alt="" />'. ''; } } } // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id) if (!isset($this->disableListmoduleMainIcons['edit']) && $permsEdit) { $params='&edit['.$table.']['.$row['uid'].']=edit'; if($extraBEIcons && $table=='pages') $imageSrc = t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2Page'.(!$TCA[$table]['ctrl']['readOnly']?'':'_d').'.gif',''); #$imageSrc = ' src="../typo3conf/ext/tm_contentaccess/extra-icons/edit2Page'.(!$TCA[$table]['ctrl']['readOnly']?'':'_d').'.gif"'; else $imageSrc = t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2'.(!$TCA[$table]['ctrl']['readOnly']?'':'_d').'.gif',''); $cells['edit']=''. ''. ''; } // "Move" wizard link for pages/tt_content elements: if (!isset($this->disableListmoduleMainIcons['move_page']) && (($table=="tt_content" && $permsEdit) || ($table=='pages'))) { $cells['move_page']=''. 'backPath,'gfx/move_'.($table=='tt_content'?'record':'page').'.gif','').' title="'.$LANG->getLL('move_'.($table=='tt_content'?'record':'page'),1).'" alt="" />'. ''; } // If the extended control panel is enabled OR if we are seeing a single table: if ($SOBE->MOD_SETTINGS['bigControlPanel'] || $this->table) { // "Info": (All records) if (!isset($this->disableListmoduleMainIcons['info'])) $cells['info']=''. 'backPath,'gfx/zoom2.gif','width="12" height="12"').' title="'.$LANG->getLL('showInfo',1).'" alt="" />'. ''; // If the table is NOT a read-only table, then show these links: if (!$TCA[$table]['ctrl']['readOnly']) { // Versioning: if (!isset($this->disableListmoduleMainIcons['version']) && t3lib_extMgm::isLoaded('version')) { if($Typo4) // new in typo3 4.0 $vers = t3lib_BEfunc::selectVersionsOfRecord($table, $row['uid'], 'uid', $GLOBALS['BE_USER']->workspace); else $vers = t3lib_BEfunc::selectVersionsOfRecord($table, $row['uid'], $fields='uid'); if (is_array($vers)) { // If table can be versionized. if (count($vers)>1) { $st = 'background-color: #FFFF00; font-weight: bold;'; $lab = count($vers)-1; } else { $st = 'background-color: #9999cc; font-weight: bold;'; $lab = 'V'; } $cells['version']=''. $lab. ''; } } // "Edit Perms" link: if (!isset($this->disableListmoduleMainIcons['perms']) && $table=='pages' && $GLOBALS['BE_USER']->check('modules','web_perm')) { $cells['perms']=''. 'backPath,'gfx/perm.gif','width="7" height="12"').' title="'.$LANG->getLL('permissions',1).'" alt="" />'. ''; } // disable just creating new content element - for a project if($table=='tt_content' && isset($this->disableListmoduleMainIcons['new_cont_record'])) $noContEl=1; // "New record after" link (ONLY if the records in the table are sorted by a "sortby"-row or if default values can depend on previous record): if (!$noContEl && !isset($this->disableListmoduleMainIcons['new_record']) && ($TCA[$table]['ctrl']['sortby'] || $TCA[$table]['ctrl']['useColumnsForDefaultValues'])) { if ( ($table!='pages' && ($this->calcPerms&16)) || // For NON-pages, must have permission to edit content on this parent page ($table=='pages' && ($this->calcPerms&8)) // For pages, must have permission to create new pages here. ) { if ($this->showNewRecLink($table)) { $params='&edit['.$table.']['.(-$row['uid']).']=new'; $cells['new']=''. 'backPath,'gfx/new_'.($table=='pages'?'page':'el').'.gif','width="'.($table=='pages'?13:11).'" height="12"').' title="'.$LANG->getLL('new'.($table=='pages'?'Page':'Record'),1).'" alt="" />'. ''; } } } // "Up/Down" links if (!isset($this->disableListmoduleMainIcons['move']) && $permsEdit && $TCA[$table]['ctrl']['sortby'] && !$this->sortField && !$this->searchLevels) { if (isset($this->currentTable['prev'][$row['uid']])) { // Up $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['prev'][$row['uid']]; $cells['move'] .= ''. 'backPath,'gfx/button_up.gif','width="11" height="10"').' title="'.$LANG->getLL('moveUp',1).'" alt="" />'. ''; } else $cells['move'] .= 'backPath,'gfx/button_up.gif','width="11" height="10"',2).' alt="" />'; if ($this->currentTable['next'][$row['uid']]) { // Down $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['next'][$row['uid']]; $cells['move'] .= ''. 'backPath,'gfx/button_down.gif','width="11" height="10"').' title="'.$LANG->getLL('moveDown',1).'" alt="" />'. ''; } else $cells['move'] .= 'backPath,'gfx/button_down.gif','width="11" height="10"',2).' alt="" />'; } // "Hide/Unhide" links: $hiddenField = $TCA[$table]['ctrl']['enablecolumns']['disabled']; if (!isset($this->disableListmoduleMainIcons['hide']) && $permsEdit && $hiddenField && $TCA[$table]['columns'][$hiddenField] && (!$TCA[$table]['columns'][$hiddenField]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields',$table.':'.$hiddenField))) { if ($row[$hiddenField]) { $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=0'; $cells['hide']=''. 'backPath,'gfx/button_unhide.gif','width="11" height="10"').' title="'.$LANG->getLL('unHide'.($table=='pages'?'Page':''),1).'" alt="" />'. ''; } else { $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=1'; $cells['hide']=''. 'backPath,'gfx/button_hide.gif','width="11" height="10"').' title="'.$LANG->getLL('hide'.($table=='pages'?'Page':''),1).'" alt="" />'. ''; } } // "Delete" link: if (!isset($this->disableListmoduleMainIcons['delete']) && (($table=='pages' && ($localCalcPerms&4)) || ($table!='pages' && ($this->calcPerms&16)))) { $params='&cmd['.$table.']['.$row['uid'].'][delete]=1'; if($typo4) { // new in typo3 4.0 $cells[]=''. 'backPath,'gfx/garbage.gif','width="11" height="12"').' title="'.$LANG->getLL('delete',1).'" alt="" />'. ''; } else { $cells['delete']=''. 'backPath,'gfx/garbage.gif','').' title="'.$LANG->getLL('delete',1).'" alt="" />'. ''; } } // "Levels" links: Moving pages into new levels... if (!isset($this->disableListmoduleMainIcons['levels']) && $permsEdit && $table=='pages' && !$this->searchLevels) { // Up (Paste as the page right after the current parent page) if ($this->calcPerms&8) { $params='&cmd['.$table.']['.$row['uid'].'][move]='.-$this->id; $cells['levels'] .= ''. 'backPath,'gfx/button_left.gif','width="11" height="10"').' title="'.$LANG->getLL('prevLevel',1).'" alt="" />'. ''; } // Down (Paste as subpage to the page right above) if ($this->currentTable['prevUid'][$row['uid']]) { $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$this->currentTable['prevUid'][$row['uid']])); if ($localCalcPerms&8) { $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['prevUid'][$row['uid']]; $cells['levels'] .= ''. 'backPath,'gfx/button_right.gif','width="11" height="10"').' title="'.$LANG->getLL('nextLevel',1).'" alt="" />'. ''; } else $cells['levels'] .= 'backPath,'gfx/button_right.gif','width="11" height="10"',2).' alt="" />'; } else $cells['levels'] .= 'backPath,'gfx/button_right.gif','width="11" height="10"',2).' alt="" />'; } } } // If the record is edit-locked by another user, we will show a little warning sign: if ($lockInfo=t3lib_BEfunc::isRecordLocked($table,$row['uid'])) { $cells['locked']=''. ''. ''; } if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['addItems']) && is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['addItems'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['addItems'] as $classRef) { $hookObj= &t3lib_div::getUserObj($classRef); if (method_exists($hookObj, 'addItems')) $hookObj->addItems($cells,$this->disableListmoduleMainIcons,$this,$table,$row,$SOBE); } } $defaultOrderList='show,history,edit,move_page,info,version,perms,new_record,move,hide,delete,levels,locked'; if($this->modTSconfig['properties']['listmoduleMainIconsOrder']) $orderList=$this->modTSconfig['properties']['listmoduleMainIconsOrder']; else $orderList=$defaultOrderList; $orderList = t3lib_div::trimExplode(',',strtolower($orderList),1); if(isset($cells) && is_array($cells) && is_array($orderList)) { $orderList=array_flip($orderList); foreach($orderList as $cellItem => $item) { if(array_key_exists($cellItem,$cells)) $cellList .= $cells[$cellItem]; } } // Compile items into a DIV-element: return '
'.$cellList.'
'; } /** * Creates the clipboard panel for a single record in the listing. * * @param string The table * @param array The record for which to make the clipboard panel. * @return string HTML table with the clipboard panel (unless disabled) */ function makeClip($table,$row) { global $TCA,$LANG,$Typo4,$Typo4_1; if($Typo4_1) $path=$this->backPath; $this->modTSconfig=Array(); $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list'); $typesForDisableListmoduleMainIcons = t3lib_div::trimExplode(',',strtolower($this->modTSconfig['properties']['disableListmoduleMainIcons']),1); $this->disableListmoduleMainIcons = array_flip($typesForDisableListmoduleMainIcons); // Return blank, if disabled: if ($this->dontShowClipControlPanels) return ''; $cells=array(); // Whether a numeric clipboard pad is active or the normal pad we will see different content of the panel: if ($this->clipObj->current=='normal') { // For the "Normal" pad: // Show copy/cut icons: $isSel = (string)$this->clipObj->isSelected($table,$row['uid']); if(!(isset($this->disableListmoduleMainIcons['copy']))){ $cells[]=''. ''. ''; } if(!(isset($this->disableListmoduleMainIcons['cut']))){ $cells[]=''. ''. ''; } } else { // For the numeric clipboard pads (showing checkboxes where one can select elements on/off) // Setting name of the element in ->CBnames array: $n=$table.'|'.$row['uid']; $this->CBnames[]=$n; // Check if the current element is selected and if so, prepare to set the checkbox as selected: $checked = ($this->clipObj->isSelected($table,$row['uid'])?' checked="checked"':''); // If the "duplicateField" value is set then select all elements which are duplicates... if ($this->duplicateField && isset($row[$this->duplicateField])) { $checked=''; if (in_array($row[$this->duplicateField], $this->duplicateStack)) { $checked=' checked="checked"'; } $this->duplicateStack[] = $row[$this->duplicateField]; } // Adding the checkbox to the panel: $cells[]=''; } // Now, looking for selected elements from the current table: $elFromTable = $this->clipObj->elFromTable($table); if (count($elFromTable) && $TCA[$table]['ctrl']['sortby']) { // IF elements are found and they can be individually ordered, then add a "paste after" icon: $cells[]=''. ''. ''; } // Now, looking for elements in general: $elFromTable = $this->clipObj->elFromTable(''); if ($table=='pages' && count($elFromTable)) { $cells[]=''. ''. ''; } // Compile items into a DIV-element: return '
'.implode('',$cells).'
'; } /** * Creates the localization panel * * @param string The table * @param array The record for which to make the localization panel. * @return array Array with key 0/1 with content for column 1 and 2 */ function makeLocalizationPanel($table,$row) { global $TCA,$LANG,$Typo4,$Typo4_1; $this->modTSconfig=array(); $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list'); $out = array( 0 => '', 1 => '', ); if($Typo4_1) { // Typo4 4.1 has new handling system $t8Tools = t3lib_div::makeInstance('t3lib_transl8tools'); $translations = $t8Tools->translationInfo($table,$row['uid']); // Language title and icon: $out[0] = $this->languageFlag($row[$TCA[$table]['ctrl']['languageField']]); if (is_array($translations)) { // Traverse page translations and add icon for each language that does NOT yet exist: $lNew = ''; foreach($this->pageOverlays as $lUid_OnPage => $lsysRec) { if (!isset($translations['translations'][$lUid_OnPage]) && $GLOBALS['BE_USER']->checkLanguageAccess($lUid_OnPage)) { $href = $GLOBALS['TBE_TEMPLATE']->issueCommand( '&cmd['.$table.']['.$row['uid'].'][localize]='.$lUid_OnPage, $this->listURL().'&justLocalized='.rawurlencode($table.':'.$row['uid'].':'.$lUid_OnPage) ); $lC = ($this->languageIconTitles[$lUid_OnPage]['flagIcon'] ? '' : $this->languageIconTitles[$lUid_OnPage]['title']); $lC = ''.$lC.' '; $lNew.=$lC; } } if ($lNew) $out[1].= $lNew; } else { $out[0] = '    '.$out[0]; } } else { if($this->modTSconfig['properties']['listmoduleShowLocalizationDisabled']==0){ if ($TCA[$table]['ctrl']['languageField'] && $TCA[$table]['ctrl']['transOrigPointerField'] && !$TCA[$table]['ctrl']['transOrigPointerTable']) { // Language title and icon: $out[0] = $this->languageFlag($row[$TCA[$table]['ctrl']['languageField']]); // Create new localizations links: if ($row[$TCA[$table]['ctrl']['languageField']] <=0) { if($Typo4) // new in Typo3 4.0 $versionExtra = t3lib_BEfunc::versioningPlaceholderClause($table); // Look for translations of this record, index by language field value: $translations = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( 'uid,'.$TCA[$table]['ctrl']['languageField'], $table, 'pid='.intval($this->id). ' AND '.$TCA[$table]['ctrl']['languageField'].'>0'. ' AND '.$TCA[$table]['ctrl']['transOrigPointerField'].'='.intval($row['uid']). t3lib_BEfunc::deleteClause($table).$versionExtra, '', '', '', $TCA[$table]['ctrl']['languageField'] ); // Traverse page translations and add icon for each language that does NOT yet exist: $lNew = ''; if($Typo4) // new in typo3 4.0.x $LanguageAccesslUid_OnPage = $GLOBALS['BE_USER']->checkLanguageAccess($lUid_OnPage); else $LanguageAccesslUid_OnPage=1; foreach($this->pageOverlays as $lUid_OnPage => $lsysRec) { if (!isset($translations[$lUid_OnPage]) && $LanguageAccesslUid_OnPage) { if($typo4) $href = $GLOBALS['TBE_TEMPLATE']->issueCommand( '&cmd['.$table.']['.$row['uid'].'][localize]='.$lUid_OnPage, $this->listURL().'&justLocalized='.rawurlencode($table.':'.$row['uid'].':'.$lUid_OnPage) ); else $href = $GLOBALS['TBE_TEMPLATE']->issueCommand('&cmd['.$table.']['.$row['uid'].'][localize]='.$lUid_OnPage,$rUrl=''); $lC = ($this->languageIconTitles[$lUid_OnPage]['flagIcon'] ? '' : $this->languageIconTitles[$lUid_OnPage]['title']); $lC = ''.$lC.' '; $lNew.=$lC; } } if ($lNew) $out[1].= $lNew; } else { $out[0] = '    '.$out[0]; } } } } return $out; } /** * Create the selector box for selecting fields to display from a table: * * @param string Table name * @param boolean If true, form-fields will be wrapped around the table. * @return string HTML table with the selector box (name: displayFields['.$table.'][]) */ function fieldSelectBox($table,$formFields=1) { global $TCA,$LANG,$Typo4; $this->modTSconfig=array(); $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list'); // Init: t3lib_div::loadTCA($table); $formElements=array('',''); if ($formFields) $formElements=array('
','
'); // Load already selected fields, if any: $setFields=is_array($this->setFields[$table]) ? $this->setFields[$table] : array(); // Request fields from table: $fields = $this->makeFieldList($table); // Add pseudo "control" fields $fields[]='_PATH_'; $fields[]='_LOCALIZATION_'; $fields[]='_CONTROL_'; $fields[]='_CLIPBOARD_'; if($Typo4) { $fields[]='tstamp'; $fields[]='crdate'; $fields[]='_REF_'; } // Create an option for each field: $opt=array(); $opt[] = ''; foreach($fields as $fN) { $fL = is_array($TCA[$table]['columns'][$fN]) ? ereg_replace(':$','',$LANG->sL($TCA[$table]['columns'][$fN]['label'])) : '['.$fN.']'; // Field label $opt[] = ' '; } if($this->modTSconfig['properties']['listmoduleMenuBoxDisabled']==0){ // Compile the options into a multiple selector box: $lMenu = ' '; } else $lMenu =''; // Table with the field selector:: $content.= ' '.$formElements[0].' '; if($this->modTSconfig['properties']['listmoduleMenuBoxDisabled']==0) $content.= ''; $content.= '
'.$lMenu.'
'; $content.=$formElements[1]; return $content; } /**************** funtions from the plugin 'list_adv' starts *****************/ /** * @param string $type: * @param string $pointer: * @param string $table: name of the handled table * @return void doesn't return anything because executes a class function */ function fwd_rwd_HTML($type,$pointer,$table='') { $content = parent::fwd_rwd_HTML($type,$pointer,$table=''); $tParam = $table ? '&table='.rawurlencode($table) : ''; $this->paginationHTML = ''; if ($type == 'rwd') $pointer = $pointer - $this->iLimit; $total_pages = ceil($this->totalItems/$this->iLimit); if ( $total_pages <= 1){ return ''; } $on_page = floor($pointer/$this->iLimit) + 1; $this->paginationHTML = $this->_paginationAdvanced($total_pages, 5, $on_page, $tParam); return; } /** * adds pagination for showing ecords * * @param integer $total_pages: quantity of pages * @param integer $show: * @param integer $on_page: how many items to show on page * @param string $tParam: * @return string HTML */ function _paginationAdvanced($total_pages, $show = 5, $on_page, $tParam = '') { $disp = floor($show / 2); if ( $on_page <= $disp) { $low = ( ($disp - $on_page) > 0 ) ? ($disp - $on_page) : 1; $high = ($low + $show) - 1; } elseif ( ($on_page + $disp) > $total_pages) { $high = $total_pages; $low = ($total_pages - $show) + 1; } else { $low = ($on_page - $disp); $high = ($on_page + $disp); } $prev = (($on_page - 1) > 0) ? '['.$GLOBALS['LANG']->sL('LLL:EXT:tm_contentaccess/locallang.xml:prev').']' : '['.$GLOBALS['LANG']->sL('LLL:EXT:tm_contentaccess/locallang.xml:prev').']'; $next = (($on_page + 1) <= $total_pages) ? ' ['.$GLOBALS['LANG']->sL('LLL:EXT:tm_contentaccess/locallang.xml:next').'] ' : '['.$GLOBALS['LANG']->sL('LLL:EXT:tm_contentaccess/locallang.xml:next').']'; $first = ($on_page > 1) ? '['.$GLOBALS['LANG']->sL('LLL:EXT:tm_contentaccess/locallang.xml:first').']' : '['.$GLOBALS['LANG']->sL('LLL:EXT:tm_contentaccess/locallang.xml:first').']'; $last = $on_page <> $total_pages ? '['.$GLOBALS['LANG']->sL('LLL:EXT:tm_contentaccess/locallang.xml:last').']' : '['.$GLOBALS['LANG']->sL('LLL:EXT:tm_contentaccess/locallang.xml:last').']'; $content = '
'; $content .= $prev ." "; foreach (range($low, $high) as $i){ if ($i > $total_pages){ $content .= ''; } elseif ($i <= 0){ $content .= ''; } else{ $href = $this->listURL().'&pointer='.( ( $i - 1 ) * $this->iLimit ).$tParam; $from = ( $i - 1 ) * $this->iLimit; $to = ($this->totalItems > ($from + $this->iLimit) ) ? ($from + $this->iLimit) : $this->totalItems; $txt = '[' . ($from + 1 ). '-' . $to . ']'; $content .= ( $i == $on_page ) ? ''.$txt.' ' : '' . $txt . ' '; } } $content .= ''. $next; $content .= '
'; $showing = sprintf($GLOBALS['LANG']->sL('LLL:EXT:tm_contentaccess/locallang.xml:showing'), ''. $on_page .'', $total_pages); $content .= $first .' | '. $showing .' | '. $last .'    '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_browse_links.xml:page').' # '.$GLOBALS['LANG']->sL('LLL:EXT:tm_contentaccess/locallang.xml:goto').'
'; return $content; } /** * Creates the listing of records from a single table * * @param string Table name * @param integer Page id * @param string List of fields to show in the listing. Pseudo fields will be added including the record header. * @return string HTML table with the listing for the record. */ function getTable($table,$id,$rowlist) { global $LANG; $out = parent::getTable($table,$id,$rowlist); $query = 'SHOW COLUMNS FROM '.$table.' ;'; $res = $GLOBALS['TYPO3_DB']->sql_query($query); if ($res) { while ($defRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $avail_columns[] = $defRow['Field']; } } if(isset($avail_columns) && is_array($avail_columns)) $avail_columns=array_flip($avail_columns); $this->modTSconfig = t3lib_BEfunc::getModTSconfig($id,'mod.web_list'); $typesForAddDeleteAll = t3lib_div::trimExplode(',',strtolower($this->modTSconfig['properties']['addDeleteAll']),1); if(isset($typesForAddDeleteAll) && is_array($typesForAddDeleteAll)) $addDeleteAll = array_flip($typesForAddDeleteAll); if(isset($addDeleteAll[$table]) && $table!='pages' && isset($avail_columns['pid']) && isset($avail_columns['deleted'])) { $ifTable=$GLOBALS['TYPO3_DB']->exec_SELECTquery('COUNT(*)',$table,'pid='.$id.' AND deleted=0','', '', ''); $ifTable=$GLOBALS['TYPO3_DB']->sql_fetch_row($ifTable); if($ifTable[0]) { $out .='
backPath,'gfx/garbage.gif','').' title="'.$LANG->sL('LLL:EXT:tm_contentaccess/locallang_extra.xml:deleteAllRecords').'" alt="" />'.$LANG->sL('LLL:EXT:tm_contentaccess/locallang_extra.xml:deleteAllRecords').'
'; } } $out .= $this->paginationHTML; // resets temporary variable $this->paginationHTML=NULL; return $out; } /** * create URL for items * * @param integer $altId: alternative id * @param string $table: * @param string $exclList: list of excluded items * @return string Url */ function listURL($altId='',$table=-1,$exclList='') { /* global $tm_contentaccessConf; if($tm_contentaccessConf['enable.']['list_pagination']) $url = parent::listURL($altId,$table,$exclList); else { } */ $url = parent::listURL($altId,$table,$exclList); $url .= ($this->firstElementNumber?'&pointer='.rawurlencode($this->firstElementNumber):''); return $url; } /***************** funtions from the plugin 'list_adv' ends *******************/ /** * Creates the search box * * @param boolean If true, the search box is wrapped in its own form-tags * @return string HTML for the search box */ function getSearchBox($formFields=1) { $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list'); $content=''; // Setting form-elements, if applicable: $formElements=array('',''); if ($formFields) $formElements=array('
','
'); // Make level selector: $opt=array(); $parts = explode('|',$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.enterSearchLevels')); if(!$this->modTSconfig['properties']['listmoduleSearchBoxDisabled']) { while(list($kv,$label)=each($parts)) { $opt[] = ''; } $lMenu = ''; } // Table with the search box: $content.= ' '.$formElements[0].' '; if(!$this->modTSconfig['properties']['listmoduleSearchBoxDisabled']) $content.= ' '; if(!$this->modTSconfig['properties']['disableLimit']) $content.= ' '; $content.= ' '.$formElements[1]; $content.=t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'list_searchbox', $GLOBALS['BACK_PATH'],'|
'); return $content; } } ?>