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


PHP file::webExists方法代码示例

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


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

示例1: getBody

 /**
  * Get the body content
  *
  * @param string|null $headers Header to edit or null to add the header in the email
  * @return string
  */
 protected function getBody(&$headers = null)
 {
     $body = null;
     //$text = $this->quotePrintable($this->cfg->text);
     $text = $this->cfg->text;
     if ($this->cfg->html) {
         if (empty($this->cfg->text)) {
             //$text = $this->quotePrintable(utils::html2Text($this->cfg->html));
             $text = utils::html2Text($this->cfg->html);
         }
         $boundary = '------------' . $this->getBoundary();
         if ($headers) {
             $headers .= $this->headerLine('Content-Type', 'multipart/alternative;' . $this->cfg->crlf . ' boundary="' . $boundary . '"');
             //$headers.= $this->textLine(' boundary="'.$boundary.'"');
         } else {
             $body .= $this->headerLine('Content-Type', 'multipart/alternative;' . $this->cfg->crlf . ' boundary="' . $boundary . '"');
             //$body.= $this->textLine(' boundary="'.$boundary.'"');
             $body .= $this->textLine('');
         }
         // Text part
         $body .= $this->textLine('This is a multi-part message in MIME format.');
         $body .= $this->textLine('--' . $boundary);
     }
     $body .= $this->headerLine('Content-Type', 'text/plain; charset=' . $this->cfg->charset);
     //$body.= $this->textLine(' charset="'.$this->cfg->charset.'"');
     $body .= $this->headerLine('Content-Transfer-Encoding', $this->cfg->encoding);
     //$body.= $this->headerLine('Content-Disposition', 'inline');
     $body .= $this->textLine(null);
     $body .= $this->textLine($this->encode($this->wrapText($text)));
     if ($this->cfg->html) {
         // HTML part
         $body .= $this->textLine('--' . $boundary);
         $html = $this->cfg->html;
         $inlineImages = false;
         if ($this->cfg->htmlInlineImage) {
             $rootUri = request::get('rootUri');
             preg_match_all('@src="(' . $rootUri . '|/)(.+)"@siU', $html, $matches);
             if (!empty($matches)) {
                 $images = array_unique($matches[2]);
                 $inlineImages = array();
                 $i = 1;
                 foreach ($images as $img) {
                     if (file::webExists($img)) {
                         $file = WEBROOT . str_replace('/', DS, $img);
                         $cid = 'part' . $i . '.' . $this->getBoundary(16) . '@' . $this->cfg->serverName;
                         $inlineImages[] = array('cid' => $cid, 'file' => $file, 'name' => file::name($file), 'type' => file::getType($file));
                         $i++;
                         $html = preg_replace('@src="(' . $rootUri . '|/)(' . $img . ')"@siU', 'src="cid:' . $cid . '"', $html);
                     }
                 }
             }
         }
         if (!empty($inlineImages)) {
             $boundaryRel = '------------' . $this->getBoundary();
             $body .= $this->headerLine('Content-Type', 'multipart/related;' . $this->cfg->crlf . ' boundary="' . $boundaryRel . '"');
             //$body.= $this->textLine(' boundary="'.$boundaryRel.'"');
             $body .= $this->textLine(null);
             $body .= $this->textLine(null);
             $body .= $this->textLine('--' . $boundaryRel);
         }
         $body .= $this->headerLine('Content-Type', 'text/html; charset=' . $this->cfg->charset . '');
         //$body.= $this->textLine(' charset="'.$this->cfg->charset.'"');
         $body .= $this->headerLine('Content-Transfer-Encoding', $this->cfg->encoding);
         //$body.= $this->headerLine('Content-Disposition', 'inline');
         $body .= $this->textLine(null);
         //$body.= $this->textLine($this->quotePrintable($html));
         $body .= $this->textLine($this->encode($this->wrapText($html)));
         if (!empty($inlineImages)) {
             foreach ($inlineImages as $img) {
                 $body .= $this->textLine('--' . $boundaryRel);
                 $body .= $this->headerLine('Content-Type', $img['type']);
                 //.'; name="'.$img['name'].'"');
                 $body .= $this->headerLine('Content-Transfer-Encoding', $this->cfg->fileEncoding);
                 $body .= $this->headerLine('Content-ID', '<' . $img['cid'] . '>');
                 //$body.= $this->headerLine('Content-Disposition', 'inline; filename="'.$img['name'].'"');
                 $body .= $this->textLine(null);
                 $body .= $this->encode(file::read($img['file']), $this->cfg->fileEncoding);
             }
             $body .= $this->textLine('--' . $boundaryRel . '--');
             $body .= $this->textLine(null);
         }
         $body .= '--' . $boundary . '--';
     }
     return $body;
 }
开发者ID:nyroDev,项目名称:nyroFwk,代码行数:91,代码来源:email.class.php

示例2: 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


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