当前位置: 首页>>代码示例>>PHP>>正文


PHP file::nyroExists方法代码示例

本文整理汇总了PHP中file::nyroExists方法的典型用法代码示例。如果您正苦于以下问题:PHP file::nyroExists方法的具体用法?PHP file::nyroExists怎么用?PHP file::nyroExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在file的用法示例。


在下文中一共展示了file::nyroExists方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execTinyMce

	protected function execTinyMce($prm=null) {
		$search = 'js/tiny_mce/';
		$request = request::get('request');
		$pos = strpos($request, $search);
		if ($pos === false)
			exit;
		$tmp = substr($request, $pos+strlen($search));
		$file = file::nyroExists(array(
			'name'=>'lib'.DS.'tinyMce'.DS.$tmp,
			'realName'=>true,
			'type'=>'other'
		));
		if (strpos($file, '.php') !== false) {
			array_walk($_GET, create_function('&$v', '$v = urldecode($v);'));
			$path = str_replace($tmp, '', $file);
			ini_set('include_path', $path);
			define('TINYMCEPATH', substr($path, 0, -1));
			define('TINYMCECACHEPATH', substr(TMPROOT, 0, -1));
			if (ob_get_length())
				ob_clean();
			include($file);
			exit;
		} else
			response::getInstance()->showFile($file);
	}
开发者ID:nyroDev,项目名称:nyroFwk,代码行数:25,代码来源:controller.class.php

示例2: initFile

	/**
	 * Find the init file for a library
	 * ie: nyro/lib/$name/init.lib.php
	 *
	 * @param string $name The library name
	 * @return false|string The file path or false if not found
	 */
	public static function initFile($name) {
		if (!array_key_exists($name, self::$libFiles)) {
			self::$libFiles[$name] = file::nyroExists(array(
				'name'=>'lib_'.$name.'_init',
				'type'=>'lib'
			));
		}
		return self::$libFiles[$name];
	}
开发者ID:nyroDev,项目名称:nyroFwk,代码行数:16,代码来源:lib.class.php

示例3: getFileContents

	/**
	 * Returns the contents of the script file if it exists and removes the UTF-8 BOM header if it exists.
	 *
	 * @param String $file File to load.
	 * @return String File contents or empty string if it doesn't exist.
	 */
	private function getFileContents($file) {
		/////////////////////////// Update for nyroFwk ///////////////////////////
		if (!file_exists($file)) {
			$file = file::nyroExists(array(
				'realName'=>true,
				'name'=>'lib/tinyMce/'.substr($file, strlen(TINYMCEPATH)+1),
				'type'=>'other'
			));
			if (!$file)
				return '';
		}
		if (file_exists($file)) {
			$content = file_get_contents($file);

			// Remove UTF-8 BOM
			if (substr($content, 0, 3) === pack("CCC", 0xef, 0xbb, 0xbf))
				$content = substr($content, 3);
		} else
			$content = "";

		return $content;
	}
开发者ID:nyroDev,项目名称:nyroFwk,代码行数:28,代码来源:tiny_mce_gzip.php

示例4: add

	/**
	 * Add an include file
	 *
	 * @param array $prm Same parameter as addCss or addJs, with adding:
	 *  - string type File type (js or css) (required)
	 * @return bool True if addedor already added, False if not found
	 * @throws nExecption if type or file not  provided
	 * @see addJs, addCss
	 */
	public function add(array $prm) {
		if (config::initTab($prm, array(
			'type'=>null,
			'file'=>null,
			'dir'=>'nyro',
			'media'=>'screen',
			'condIE'=>false,
			'verifExists'=>true
		))) {
			$ret = false;
			$firstFile = $prm['file'];
			
			if (strpos($firstFile, 'jquery') === 0 && $firstFile != 'jquery')
				$this->addJS('jquery');

			foreach($this->getDepend($prm['file'], $prm['type']) as $d) {
				if (is_array($d))
					$this->add(array_merge($prm, $d));
				else
					$this->add(array_merge($prm, array('file'=>$d)));
			}

            foreach($this->cfg->getInArray($prm['type'], 'alias') as $k=>$a) {
                if (strtolower($prm['file']) == strtolower($k))
                    $prm['file'] = $a;
            }

			$prmType = $this->cfg->get($prm['type']);

			$locDir = $prm['dir'];
			if (!array_key_exists($locDir, $this->incFiles[$prm['type']]))
				$locDir = 'nyro';

			$fileExt = $prm['file'].'.'.$prm['type'];

			if ($prm['verifExists'])
				$fileExists = $locDir == 'web'
					? file::webExists($prmType['dirWeb'].DS.$fileExt)
					: file::nyroExists(array(
								'name'=>'module_'.nyro::getCfg()->compressModule.'_'.$prm['type'].'_'.$prm['file'],
								'type'=>'tpl',
								'tplExt'=>$prm['type']
							));
			else
				$fileExists = true;

			if ($fileExists) {
				if (!isset($this->incFiles[$prm['type']][$locDir][$prm['media']]))
					$this->incFiles[$prm['type']][$locDir][$prm['media']] = array();
				$this->incFiles[$prm['type']][$locDir][$prm['media']][$prm['file']] = $prm;
				if ($prm['type'] == 'css') {
					$c = file::read($fileExists);
					preg_match_all('`@import (url\()?"(.+).css"\)?;`', $c, $matches);
					if (!empty($matches[2])) {
						$prefix = substr($prm['file'], 0, strpos($prm['file'], '_')+1);
						foreach($matches[2	] as $m)
							$this->add(array_merge($prm, array('file'=>$prefix.$m)));
					}
				}
				$ret = true;
			}

			foreach($this->getDepend($firstFile, $prm['type'], true) as $d) {
				if (is_array($d))
					$this->add(array_merge($prm, $d));
				else
					$this->add(array_merge($prm, array('file'=>$d)));
			}

			return $ret;
		} else
			throw new nException('reponse::add: parameters file and/or type not provied');
	}
开发者ID:nyroDev,项目名称:nyroFwk,代码行数:82,代码来源:html.class.php

示例5: isCreable

 /**
  * Check if a className is creable (ie if it's file exists)
  *
  * @return bool
  */
 public static function isCreable($className)
 {
     return file::nyroExists(array('name' => $className)) !== false;
 }
开发者ID:nyroDev,项目名称:nyroFwk,代码行数:9,代码来源:factory.class.php

示例6: findTpl

	/**
	 * Find the template file
	 *
	 * @param array $prm Parameter used in file::nyroExists
	 * @param array $name Template name
	 * @return string|null The first template file path found or null
	 */
	protected function findTpl(array $prm, array $name) {
		foreach($name as $n) {
			if ($file = file::nyroExists(array_merge($prm, array('name'=>$n,'type'=>'tpl'))))
				return $file;
		}
		return null;
	}
开发者ID:nyroDev,项目名称:nyroFwk,代码行数:14,代码来源:tpl.class.php

示例7: compress

	/**
	 * Compress the file requested, using MoxieCompressor library
	 *
	 * @param string $type File type (css or js)
	 * @param array $prm Files to compress
	 */
	protected function compress($type, $prm) {
		$resp = response::getInstance();
		
		if ($type == 'js') {
			$conf = $this->cfg->all;
			factory::mergeCfg($conf, $this->cfg->js);
		} else if ($type == 'css') {
			$conf = $this->cfg->all;
			factory::mergeCfg($conf, $this->cfg->css);
		}
		
		$key = $type.'--'.md5(serialize($prm)).'--'.md5(serialize($conf));
		$supportsGzip = false;
		if ($conf['compress']) {
			$encodings = isset($_SERVER['HTTP_ACCEPT_ENCODING']) ? explode(',', strtolower(preg_replace("/\s+/", "", $_SERVER['HTTP_ACCEPT_ENCODING']))) : array();
			if ($conf['gzip_compress'] && (in_array('gzip', $encodings) || in_array('x-gzip', $encodings) || isset($_SERVER['---------------'])) && function_exists('gzencode') && !ini_get('zlib.output_compression')) {
				$enc = in_array('x-gzip', $encodings) ? 'x-gzip' : 'gzip';
				$supportsGzip = true;
				$key = 'gzip-'.$key;
			}
		}
		$content = null;
		$cache = cache::getInstance($this->cfg->cache);
		$cacheDate = $cache->get($content, array('id'=>$key));
		
		if (!$conf['disk_cache'] || !$cacheDate) {
			foreach($prm as $file) {
				$f = file::nyroExists(array(
								'name'=>'module_'.nyro::getCfg()->compressModule.'_'.$type.'_'.$file,
								'type'=>'tpl',
								'tplExt'=>$type
							));
				if ($f) {
					if ($conf['php'])
						$content.= file::fetch($f);
					else
						$content.= file::read($f);
				}
			}
			
			if ($conf['compress']) {
				if ($type == 'js') {
					lib::load('jsMin');
					$content = JSMin::minify($content);
				} else if ($type == 'css') {
					lib::load('cssMin');
					$content = CssMin::minify($content, $conf['filters'], $conf['plugins']);
				}
				if ($supportsGzip)
					$content = gzencode($content, 9, FORCE_GZIP);
			}
			$cache->save();
		} else if ($cacheDate) {
			$resp->addHeader('Age', time() - $cacheDate);
		}
		
		/* @var $resp response_http */
		if ($conf['compress']) {
			$resp->setCompress(false);
			$resp->addHeader('Vary', 'Accept-Encoding'); // Handle proxies
			if ($conf['etags'] || preg_match('/MSIE/i', $_SERVER['HTTP_USER_AGENT'])) {
				// We need to use etags on IE since it will otherwise always load the contents
				$resp->addHeader('ETag', md5($content));
			}
			$parseTime = $this->_parseTime($conf['expires_offset']);
			$resp->addHeader('Expires', gmdate('D, d M Y H:i:s', time() + $parseTime).' GMT');
			$resp->addHeader('Cache-Control', 'public, max-age='.$parseTime);
			
			if ($type == 'js') {
				// Output explorer workaround or compressed file
				if (!isset($_GET['gz']) && $supportsGzip && $conf['patch_ie'] && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) {
					// Build request URL
					$url = $_SERVER['REQUEST_URI'];

					if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'])
						$url.= '?'.$_SERVER['QUERY_STRING'].'&gz=1';
					else
						$url.= '?gz=1';

					// This script will ensure that the gzipped script gets loaded on IE versions with the Gzip request chunk bug
					echo 'var gz;try {gz = new XMLHttpRequest();} catch(gz) { try {gz = new ActiveXObject("Microsoft.XMLHTTP");}';
					echo 'catch (gz) {gz = new ActiveXObject("Msxml2.XMLHTTP");}}';
					echo 'gz.open("GET", "'.$url.'", false);gz.send(null);eval(gz.responseText);';
					die();
				}
			}
			
			if ($supportsGzip)
				$resp->addHeader('Content-Encoding', $enc);	
		}
		
		$resp->sendText($content);
	}
开发者ID:nyroDev,项目名称:nyroFwk,代码行数:99,代码来源:controller.class.php


注:本文中的file::nyroExists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。