⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class.tx_rtehtmlarea_select_image.php

📁 Typo3, 开源里边最强大的
💻 PHP
📖 第 1 页 / 共 3 页
字号:
<?php/****************************************************************  Copyright notice**  (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)*  (c) 2004-2006 Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>*  All rights reserved**  This script is part of the TYPO3 project. The TYPO3 project is*  free software; you can redistribute it and/or modify*  it under the terms of the GNU General Public License as published by*  the Free Software Foundation; either version 2 of the License, or*  (at your option) any later version.**  The GNU General Public License can be found at*  http://www.gnu.org/copyleft/gpl.html.*  A copy is found in the textfile GPL.txt and important notices to the license*  from the author is found in LICENSE.txt distributed with these scripts.***  This script is distributed in the hope that it will be useful,*  but WITHOUT ANY WARRANTY; without even the implied warranty of*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the*  GNU General Public License for more details.**  This copyright notice MUST APPEAR in all copies of the script!***************************************************************//** * Displays image selector for the RTE * * @author	Kasper Skaarhoj <kasper@typo3.com> * @author	Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca> * * $Id: class.tx_rtehtmlarea_select_image.php 1997 2007-02-05 18:24:44Z ingmars $  * */require_once(PATH_typo3.'class.browse_links.php');require_once(PATH_t3lib.'class.t3lib_foldertree.php');require_once(PATH_t3lib.'class.t3lib_stdgraphic.php');require_once(PATH_t3lib.'class.t3lib_basicfilefunc.php');/** * Local Folder Tree * * @author	Kasper Skaarhoj <kasper@typo3.com> * @package TYPO3 * @subpackage tx_rte */class tx_rtehtmlarea_image_folderTree extends t3lib_folderTree {	var $ext_IconMode=1;	/**	 * Wrapping the title in a link, if applicable.	 *	 * @param	string		Title, ready for output.	 * @param	array		The "record"	 * @return	string		Wrapping title string.	 */	function wrapTitle($title,$v)	{		if ($this->ext_isLinkable($v))	{			$aOnClick = 'return jumpToUrl(\'?editorNo='.$GLOBALS['SOBE']->browser->editorNo.'&expandFolder='.rawurlencode($v['path']).'\');';			return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';		} else {			return '<span class="typo3-dimmed">'.$title.'</span>';		}	}	/**	 * Returns true if the input "record" contains a folder which can be linked.	 *	 * @param	array		Array with information about the folder element. Contains keys like title, uid, path, _title	 * @return	boolean		True is returned if the path is found in the web-part of the the server and is NOT a recycler or temp folder	 */	function ext_isLinkable($v)	{		$webpath=t3lib_BEfunc::getPathType_web_nonweb($v['path']);		if ($GLOBALS['SOBE']->browser->act=='magic') return 1;	//$webpath='web';	// The web/non-web path does not matter if the mode is 'magic'		if (strstr($v['path'],'_recycler_') || strstr($v['path'],'_temp_') || $webpath!='web')	{			return 0;		}		return 1;	}	/**	 * Wrap the plus/minus icon in a link	 *	 * @param	string		HTML string to wrap, probably an image tag.	 * @param	string		Command for 'PM' get var	 * @param	boolean		If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark)	 * @return	string		Link-wrapped input string	 * @access private	 */	function PM_ATagWrap($icon,$cmd,$bMark='')	{		if ($bMark)	{			$anchor = '#'.$bMark;			$name=' name="'.$bMark.'"';		}		$aOnClick = 'return jumpToUrl(\'?PM='.$cmd.'\',\''.$anchor.'\');';		return '<a href="#"'.$name.' onclick="'.htmlspecialchars($aOnClick).'">'.$icon.'</a>';	}	/**	 * Print tree.	 *	 * @param	mixed		Input tree array. If not array, then $this->tree is used.	 * @return	string		HTML output of the tree.	 */	function printTree($treeArr='')	{		$titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);		if (!is_array($treeArr))	$treeArr=$this->tree;		$out='';		$c=0;			// Traverse rows for the tree and print them into table rows:		foreach($treeArr as $k => $v) {			$c++;			$bgColor=' class="'.(($c+1)%2 ? 'bgColor' : 'bgColor-10').'"';			$out.='<tr'.$bgColor.'><td nowrap="nowrap">'.$v['HTML'].$this->wrapTitle(t3lib_div::fixed_lgd($v['row']['title'],$titleLen),$v['row']).'</td></tr>';		}		$out='<table border="0" cellpadding="0" cellspacing="0">'.$out.'</table>';		return $out;	}}/** * Script Class * * @author	Kasper Skaarhoj <kasper@typo3.com> * @package TYPO3 * @subpackage tx_rte */class tx_rtehtmlarea_select_image extends browse_links {	var $extKey = 'rtehtmlarea';	var $content;	var $act;	var $allowedItems;	var $plainMaxWidth;	var $plainMaxHeight;	var $magicMaxWidth;	var $magicMaxHeight;	var $imgPath;	var $classesImageJSOptions;	var $editorNo;	var $buttonConfig = array();		/**	 * Initialisation	 *	 * @return	[type]		...	 */	function init()	{		global $BE_USER,$BACK_PATH,$TYPO3_CONF_VARS;			// Main GPvars:		$this->siteUrl = t3lib_div::getIndpEnv('TYPO3_SITE_URL');		$this->act = t3lib_div::_GP('act');		$this->editorNo = t3lib_div::_GP('editorNo');		$this->expandPage = t3lib_div::_GP('expandPage');		$this->expandFolder = t3lib_div::_GP('expandFolder');					// Find "mode"		$this->mode = t3lib_div::_GP('mode');		if (!$this->mode)	{			$this->mode='rte';		}			// Site URL		$this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');	// Current site url			// the script to link to		$this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');				if (!$this->act)	{			$this->act='magic';		}				$RTEtsConfigParts = explode(':',t3lib_div::_GP('RTEtsConfigParams'));		$RTEsetup = $BE_USER->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));		$this->thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);		$this->imgPath = $RTEtsConfigParts[6];				if (is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.']['image.'])) {			$this->buttonConfig = $this->thisConfig['buttons.']['image.'];		}				$this->allowedItems = explode(',','magic,plain,dragdrop,image');		if (is_array($this->buttonConfig['options.']) && $this->buttonConfig['options.']['removeItems']) {			$this->allowedItems = array_diff($this->allowedItems,t3lib_div::trimExplode(',',$this->buttonConfig['options.']['removeItems'],1));		} else {			$this->allowedItems = array_diff($this->allowedItems,t3lib_div::trimExplode(',',$this->thisConfig['blindImageOptions'],1));		}		reset($this->allowedItems);		if (!in_array($this->act,$this->allowedItems))	{			$this->act = current($this->allowedItems);		}				if ($this->act == 'plain') {			if ($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['plainImageMaxWidth']) $this->plainMaxWidth = $TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['plainImageMaxWidth'];			if ($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['plainImageMaxHeight']) $this->plainMaxHeight = $TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['plainImageMaxHeight'];			if (is_array($this->buttonConfig['options.']) && is_array($this->buttonConfig['options.']['plain.'])) {				if ($this->buttonConfig['options.']['plain.']['maxWidth']) $this->plainMaxWidth = $this->buttonConfig['options.']['plain.']['maxWidth'];				if ($this->buttonConfig['options.']['plain.']['maxHeight']) $this->plainMaxHeight = $this->buttonConfig['options.']['plain.']['maxHeight'];			}			if (!$this->plainMaxWidth) $this->plainMaxWidth = 640;			if (!$this->plainMaxHeight) $this->plainMaxHeight = 680;		} elseif ($this->act == 'magic') {			if (is_array($this->buttonConfig['options.']) && is_array($this->buttonConfig['options.']['magic.'])) {				if ($this->buttonConfig['options.']['magic.']['maxWidth']) $this->magicMaxWidth = $this->buttonConfig['options.']['magic.']['maxWidth'];				if ($this->buttonConfig['options.']['magic.']['maxHeight']) $this->magicMaxHeight = $this->buttonConfig['options.']['magic.']['maxHeight'];			}				// These defaults allow images to be based on their width - to a certain degree - by setting a high height. Then we're almost certain the image will be based on the width			if (!$this->magicMaxWidth) $this->magicMaxWidth = 300;			if (!$this->magicMaxHeight) $this->magicMaxHeight = 1000;		}				if($this->thisConfig['classesImage']) {			$classesImageArray = t3lib_div::trimExplode(',',$this->thisConfig['classesImage'],1);			$this->classesImageJSOptions = '<option value=""></option>';			reset($classesImageArray);			while(list(,$class)=each($classesImageArray)) {				$this->classesImageJSOptions .= '<option value="' .$class . '">' . $class . '</option>';			}		}				$this->magicProcess();					// Creating backend template object:		$this->doc = t3lib_div::makeInstance('template');		$this->doc->docType= 'xhtml_trans';		$this->doc->backPath = $BACK_PATH;				$this->getJSCode();	}	/**	 * [Describe function...]	 *	 * @return	[type]		...	 */	function rteImageStorageDir()	{		$dir = $this->imgPath ? $this->imgPath : $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir'];;		return $dir;	}	/**	 * [Describe function...]	 *	 * @return	[type]		...	 */	function magicProcess()	{		global $TYPO3_CONF_VARS;		if ($this->act=='magic' && t3lib_div::_GP('insertMagicImage'))	{			$filepath = t3lib_div::_GP('insertMagicImage');			$imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');			$imgObj->init();			$imgObj->mayScaleUp=0;			$imgObj->tempPath=PATH_site.$imgObj->tempPath;			$imgInfo = $imgObj->getImageDimensions($filepath);			if (is_array($imgInfo) && count($imgInfo)==4 && $this->rteImageStorageDir())	{				$fI=pathinfo($imgInfo[3]);				$fileFunc = t3lib_div::makeInstance('t3lib_basicFileFunctions');				$basename = $fileFunc->cleanFileName('RTEmagicP_'.$fI['basename']);				$destPath =PATH_site.$this->rteImageStorageDir();				if (@is_dir($destPath))	{					$destName = $fileFunc->getUniqueName($basename,$destPath);					@copy($imgInfo[3],$destName);										$cWidth = t3lib_div::intInRange(t3lib_div::_GP('cWidth'),0,$this->magicMaxWidth);					$cHeight = t3lib_div::intInRange(t3lib_div::_GP('cHeight'),0,$this->magicMaxHeight);					if (!$cWidth)	$cWidth = $this->magicMaxWidth;					if (!$cHeight)	$cHeight = $this->magicMaxHeight;										$imgI = $imgObj->imageMagickConvert($filepath,'WEB',$cWidth.'m',$cHeight.'m');	// ($imagefile,$newExt,$w,$h,$params,$frame,$options,$mustCreate=0)					if ($imgI[3])	{						$fI=pathinfo($imgI[3]);						$mainBase='RTEmagicC_'.substr(basename($destName),10).'.'.$fI['extension'];						$destName = $fileFunc->getUniqueName($mainBase,$destPath);						@copy($imgI[3],$destName);						$destName = dirname($destName).'/'.rawurlencode(basename($destName));						$iurl = $this->siteUrl.substr($destName,strlen(PATH_site));						echo'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

⌨️ 快捷键说明

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