index.php

来自「Typo3, 开源里边最强大的」· PHP 代码 · 共 1,589 行 · 第 1/5 页

PHP
1,589
字号
							$files1[$filename] = @is_file(PATH_site.$uploadFolder.'/'.$filename) ? md5(t3lib_div::getUrl(PATH_site.$uploadFolder.'/'.$filename)) : $filename;						}						foreach($files2 as $filename => $tmp)	{							$files2[$filename] = @is_file(PATH_site.$uploadFolder.'/'.$filename) ? md5(t3lib_div::getUrl(PATH_site.$uploadFolder.'/'.$filename)) : $filename;						}							// Implode MD5 sums and set flag:						$diff_1_record[$fN] = implode(' ',$files1);						$diff_2_record[$fN] = implode(' ',$files2);						$isFiles = TRUE;					}						// If there is a change of value:					if (strcmp(trim($diff_1_record[$fN]),trim($diff_2_record[$fN])))	{							// Get the best visual presentation of the value and present that:						$val1 = t3lib_BEfunc::getProcessedValue($table,$fN,$diff_2_record[$fN],0,1);						$val2 = t3lib_BEfunc::getProcessedValue($table,$fN,$diff_1_record[$fN],0,1);							// Make diff result and record string lenghts:						$diffres = $t3lib_diff_Obj->makeDiffDisplay($val1,$val2,$isFiles?'div':'span');						$diffStrLen+= $t3lib_diff_Obj->differenceLgd;						$allStrLen+= strlen($val1.$val2);							// If the compared values were files, substituted MD5 hashes:						if ($isFiles)	{							$allFiles = array_merge($files1,$files2);							foreach($allFiles as $filename => $token)	{								if (strlen($token)==32 && strstr($diffres,$token))	{									$filename =										t3lib_BEfunc::thumbCode(array($fN=>$filename),$table,$fN,$this->doc->backPath).										$filename;									$diffres = str_replace($token,$filename,$diffres);								}							}						}							// Add table row with result:						$tRows[] = '							<tr class="bgColor4">								<td>'.htmlspecialchars($GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel($table,$fN))).'</td>								<td width="98%">'.$diffres.'</td>							</tr>						';					} else {							// Add string lengths even if value matched - in this was the change percentage is not high if only a single field is changed:						$allStrLen+=strlen($diff_1_record[$fN].$diff_2_record[$fN]);					}				}			}				// Calculate final change percentage:			$pctChange = $allStrLen ? ceil($diffStrLen*100/$allStrLen) : -1;				// Create visual representation of result:			if (count($tRows)>1)	{				$content.= '<table border="0" cellpadding="1" cellspacing="1" class="diffTable">'.implode('',$tRows).'</table>';			} else {				$content.= '<span class="nobr">'.$this->doc->icons(1).$LANG->getLL('diffview_complete_match').'</span>';			}		} else $content.= $this->doc->icons(3).$LANG->getLL('diffview_cannot_find_records');			// Return value:		return array($content,$pctChange);	}	/********************************	 *	 * Module content: Workspace list	 *	 ********************************/	/**	 * Rendering of the workspace list	 *	 * @return	string		HTML	 */	function moduleContent_workspaceList()	{		// Original Kasper's TODO: Workspace listing		//		//	- LISTING: Shows list of available workspaces for user. Used can see title, description, publication time, freeze-state, db-mount, member users/groups etc. Current workspace is indicated.		//	- SWITCHING: Switching between available workspaces is done by a button shown for each in the list		//	- ADMIN: Administrator of a workspace can click an edit-button linking to a form where he can edit the workspace. Users and groups should be selected based on some filtering so he cannot select groups he is not a member off himself (or some other rule... like for permission display with blinded users/groups)		//	- CREATE: If allowed, the user can create a new workspace which brings up a form where he can enter basic data. This is saved by a local instance of tcemain with forced admin-rights (creation in pid=0!).		return $this->workspaceList_displayUserWorkspaceList();	}	/**	 * Generates HTML to display a list of workspaces.	 *	 * @return	string		Generated HTML code	 */	function workspaceList_displayUserWorkspaceList()	{		global	$BACK_PATH, $LANG;			// table header		$content = $this->workspaceList_displayUserWorkspaceListHeader();			// get & walk workspace list generating content		$wkspList = $this->workspaceList_getUserWorkspaceList();		$rowNum = 1;		foreach ($wkspList as $wksp)	{			$currentWksp = ($GLOBALS['BE_USER']->workspace == $wksp['uid']);			// Each workspace data occupies two rows:			// (1) Folding + Icons + Title + Description			// (2) Information about workspace (initially hidden)			$cssClass = ($currentWksp ? 'bgColor3' : 'bgColor4');				// Start first row			$content .= '<tr class="' . $cssClass . '">';				// row #1, column #1: expand icon			$content .= '<td>' .						'<a href="javascript:expandCollapse(' . $rowNum . ')">' .						'<img ' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/ol/plusbullet.gif', 'width="18" height="16"') . ' id="wl_' . $rowNum . 'i" border="0" hspace="1" alt="' . $LANG->getLL('img_title_show_more') . '" />' .						'</a></td>';				// row #1, column #2: icon panel			$content .= '<td nowrap="nowrap">';	// Mozilla Firefox will attempt wrap due to `width="1"` on topmost column			$content .= $this->workspaceList_displayIcons($currentWksp, $wksp);			$content .= '</td>';				// row #1, column #3: current workspace indicator			$content .= '<td nowrap="nowrap" style="text-align: center">';	// Mozilla Firefox will attempt wrap due to `width="1"` on topmost column			$content .= (!$currentWksp ? '&nbsp;' : '<img ' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/icon_ok.gif', 'width="18" height="16"') . ' id="wl_' . $rowNum . 'i" border="0" hspace="1" alt="' . $LANG->getLL('img_title_current_workspace') . '" />');			$content .= '</td>';				// row #1, column #4 and 5: title and description			$content .= '<td nowrap="nowrap">' . $wksp['title'] . '</td>' .						'<td>' . nl2br($wksp['description']) . '</td>';			$content .= '</tr>';				// row #2, column #1 and #2			$content .= '<tr id="wl_' . $rowNum . '" class="bgColor" style="display: none">';			$content .= '<td colspan="2" style="border-right: none;">&nbsp;</td>';				// row #2, column #3, #4 and #4			$content .= '<td colspan="3" style="border-left: none;">' .						$this->workspaceList_formatWorkspaceData($wksp) .						'</td>';			$content .= '</tr>';			$rowNum++;		}		$content .= '</table>';		$newWkspUrl = 'workspaceforms.php?action=new';			// workspace creation link		if ($GLOBALS['BE_USER']->isAdmin() || 0 != ($GLOBALS['BE_USER']->groupData['workspace_perms'] & 4))	{			$content .= '<br /><a href="' . $newWkspUrl . '">' .						'<img ' .						t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/new_el.gif', 'width="11" height="12"') .						' alt="' . $LANG->getLL('img_title_create_new_workspace'). '" id="ver-wl-new-workspace-icon" />' .						$LANG->getLL('link_text_create_new_workspace') . '</a>';		}		return $content;	}	/**	 * Retrieves a list of workspaces where user has access.	 *	 * @return	array		A list of workspaces available to the current BE user	 */	function workspaceList_getUserWorkspaceList()	{			// Get BE users if necessary		if (!is_array($this->be_user_Array))	{			$this->be_user_Array = t3lib_BEfunc::getUserNames();		}			// Get list of all workspaces. Note: system workspaces will be always displayed before custom ones!		$workspaces = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*','sys_workspace','pid=0'.t3lib_BEfunc::deleteClause('sys_workspace'),'','title');		$availableWorkspaces = array();			// Live		$wksp = $this->workspaceList_createFakeWorkspaceRecord(0);		$wksp = $GLOBALS['BE_USER']->checkWorkspace($wksp);		if (false !== $wksp) {			$availableWorkspaces[] = $wksp;		}			// Draft		$wksp = $this->workspaceList_createFakeWorkspaceRecord(-1);		$wksp = $GLOBALS['BE_USER']->checkWorkspace($wksp);		if (false !== $wksp) {			$availableWorkspaces[] = $wksp;		}			// Custom		foreach($workspaces as $rec)	{				// see if user can access this workspace in any way			if (false !== ($result = $GLOBALS['BE_USER']->checkWorkspace($rec)))	{				$availableWorkspaces[] = $result;	// `$result` contains `$rec` plus access type through '_ACCESS' key			}		}		return $availableWorkspaces;	}	/**	 * Create inner information panel for workspace list. This panel is	 * initially hidden and becomes visible when user click on the expand	 * icon on the very left of workspace list against the workspace he	 * wants to explore.	 *	 * @param	array		Workspace information	 * @return	string		Formatted workspace information	 */	function workspaceList_formatWorkspaceData(&$wksp)	{		global $LANG;		$content = '<table cellspacing="1" cellpadding="1" width="100%" class="ver-wl-details-table">' .				'<tr><td class="ver-wl-details-label"><b>' . $LANG->getLL('workspace_list_label_file_mountpoints') . '</b></td>' .				'<td class="ver-wl-details">' . $this->workspaceList_getFileMountPoints($wksp) . '</td></tr>' .				'<tr><td class="ver-wl-details-label"><b>' . $LANG->getLL('workspace_list_label_db_mountpoints') . '</b></td>' .				'<td class="ver-wl-details">' . $this->workspaceList_getWebMountPoints($wksp) . '</td></tr>';		if ($wksp['uid'] > 0) {			// Displaying information below makes sence only for custom workspaces			$content .=				'<tr><td class="ver-wl-details-label"><b>' . $LANG->getLL('workspace_list_label_frozen') . '</b></td>' .				'<td class="ver-wl-details">' . $LANG->getLL($wksp['freeze'] ? 'workspace_list_label_frozen_yes' : 'workspace_list_label_frozen_no') . '</td></tr>' .				'<tr><td class="ver-wl-details-label"><b>' . $LANG->getLL('workspace_list_label_publish_date') . '</b></td>' .				'<td class="ver-wl-details">' . ($wksp['publish_time'] == 0 ? '&nbsp;&ndash;' : t3lib_BEfunc::datetime($wksp['publish_time'])) . '</td></tr>' .				'<tr><td class="ver-wl-details-label"><b>' . $LANG->getLL('workspace_list_label_unpublish_date') . '</b></td>' .				'<td class="ver-wl-details">' . ($wksp['unpublish_time'] == 0 ? '&nbsp;&ndash;' : t3lib_BEfunc::datetime($wksp['unpublish_time'])) . '</td></tr>' .				'<tr><td class="ver-wl-details-label"><b>' . $LANG->getLL('workspace_list_label_your_access') . '</b></td>' .				'<td class="ver-wl-details">' . $LANG->getLL('workspace_list_access_' . $wksp['_ACCESS']) . '</td></tr>' .				'<tr><td class="ver-wl-details-label"><b>' . $LANG->getLL('workspace_list_label_workspace_users') . '</b></td>' .				'<td class="ver-wl-details">' . $this->workspaceList_getUserList($wksp) . '</td></tr>';		}		else if ($GLOBALS['BE_USER']->isAdmin()) {			// show users for draft/live workspace only to admin users			$content .=	'<tr><td class="ver-wl-details-label"><b>' . $LANG->getLL('workspace_list_label_workspace_users') . '</b></td>' .				'<td class="ver-wl-details">' . $this->workspaceList_getUserList($wksp) . '</td></tr>';		}		$content .= '</table>';		return $content;	}	/**	 * Retrieves and formats database mount points lists.	 *	 * @param	array		&$wksp	Workspace record	 * @return	string		Generated HTML	 */	function workspaceList_getWebMountPoints(&$wksp)	{		if ($wksp['uid'] <= 0) {			// system workspaces			return $GLOBALS['LANG']->getLL($wksp['uid'] == 0 ? 'workspace_list_db_mount_point_live' : 'workspace_list_db_mount_point_draft');		}		// here only if obtaining mount points for custom workspaces		// Warning: all fields needed for t3lib_iconWorks::getIconImage()!		$MPs = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'pages', 'deleted=0 AND uid IN (' . $GLOBALS['TYPO3_DB']->cleanIntList($wksp['db_mountpoints']) . ')', '', 'title');		$content_array = array();		if (count($MPs) > 0)	{			$isAdmin = $GLOBALS['BE_USER']->isAdmin();			if (!$isAdmin) {				// We need to fetch user's mount point list (including MPS mounted from groups).				// This list must not be affects by current user's workspace. It means we cannot use				// $BE_USER->isInWebMount() to check mount points.				$userMPs = explode(',', $GLOBALS['BE_USER']->dataLists['webmount_list']); // includes group data if necessary!			}			foreach ($MPs as $mp)	{				if (!$isAdmin && !in_array($mp['uid'], $userMPs)) {					// Show warning icon					$title = $GLOBALS['LANG']->getLL('workspace_list_mount_point_inaccessible');					$str = '<img ' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/icon_warning.gif', 'width="18" height="16"') .							' alt="' . $title . '" title="' . $title . '" align="absmiddle" />';					$classAttr = 'class="ver-wl-mp-inacessible" ';				}				else {					// normal icon					$str = t3lib_iconWorks::getIconImage('pages', $mp, $GLOBALS['BACK_PATH'], ' align="absmiddle"');					$classAttr = '';				}				// Will show UID on hover. Just convinient to user.				$content_array[] = $str . '<span ' . $classAttr . 'title="UID: ' . $mp['uid'] . '">' . $mp['title'] . '</span>';			}		}		if (count($content_array) > 0) {			return implode('<br />', $content_array);		}		// no mount points		return $GLOBALS['LANG']->getLL('workspace_list_db_mount_point_custom');	}	/**	 * Retrieves and formats file mount points lists.	 *	 * @param	array		&$wksp	Workspace record	 * @return	string		Generated HTML	 */	function workspaceList_getFileMountPoints(&$wksp)	{		if ($wksp['uid'] == -1) {			// draft wor

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?