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


PHP fs::exists方法代码示例

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


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

示例1: replace_www

 private function replace_www($template, $document, $args = array())
 {
     foreach ($document->query('//www:*') as $node) {
         $nested = null;
         switch ($node->name()) {
             case 'www:template':
                 $nested = $this->render_template($template->get($node['@name']));
                 break;
             case 'www:xslt':
                 $args = $node->attribute('args');
                 if ($node->attribute('cache') !== 'true') {
                     $nested = $this->render_xslt($template, $node['@xsl'], $node['@xml'], $args ? args::decode($args) : array());
                 } else {
                     $cache_args = $node->attribute('cache-args') ? $node->attribute('cache-args') : array();
                     $cache_lifetime = $node->attribute('cache-lifetime');
                     is_null($cache_lifetime) or is_numeric($cache_lifetime) or runtime_error('Cache lifetime should be numeric: ' . $cache_lifetime);
                     $cache_args = args::decode($cache_args);
                     $filename = cache_location . md5($node['@xsl'] . $node['@xml'] . ($args ? $args : '')) . '.xml';
                     if (!fs::exists($filename) || $cache_lifetime && $cache_lifetime > time() - fs::modification($filename)) {
                         fs::write($filename, $this->render_xslt($template, $node['@xsl'], $node['@xml'], $args ? args::decode($args) : array())->render(false));
                     }
                     $fragment = fs::checked_read($filename);
                     if (!empty($cache_args)) {
                         $fragment = vars::apply_assoc($fragment, $cache_args);
                     }
                     $nested = $document->fragment($fragment);
                 }
                 break;
             case 'www:xquery':
                 require_once www_root . 'thirdparty/xquerylite/class_xquery_lite.php';
                 $xq = new XqueryLite();
                 $fragment = $xq->evaluate_xqueryl(fs::checked_read($node['@src']));
                 $nested = $document->fragment($fragment);
                 break;
             case 'www:style':
                 $src = $node['@src'];
                 $nested = $document->element('link');
                 $nested['@rel'] = 'stylesheet';
                 $nested['@href'] = $src . '?' . fs::crc32($src);
                 break;
             case 'www:script':
                 $src = $node['@src'];
                 $nested = $document->element('script', '');
                 $nested['@type'] = 'text/javascript';
                 $nested['@src'] = $src . '?' . fs::crc32($src);
                 break;
             case 'www:img':
                 $src = $node['@src'];
                 $nested = $document->element('img');
                 $nested['@src'] = $src . '?' . crc32(fs::modification($src));
                 foreach ($node->attributes() as $name => $value) {
                     if ($name != 'src') {
                         $nested['@' . $name] = $value;
                     }
                 }
                 break;
             case 'www:bbcode':
                 $allow = $node->attribute('allow');
                 $deny = $node->attribute('deny');
                 $nested = bbcode::parse($node, $allow ? preg_split('/, */', $allow) : null, $deny ? preg_split('/, */', $deny) : null);
                 break;
             default:
                 runtime_error('Unknown extension element: ' . $node->name());
         }
         self::replace_node($document, $node, $nested);
     }
 }
开发者ID:nyan-cat,项目名称:easyweb,代码行数:67,代码来源:www.php

示例2: import

 function import($filename, $params = array())
 {
     fs::exists($filename) or runtime_error('XSL stylesheet not found: ' . $filename);
     $xsl = new DOMDocument();
     $xsl->load(fs::normalize($filename));
     $import = $xsl->createElementNS('http://www.w3.org/1999/XSL/Transform', 'xsl:import');
     $href = $xsl->createAttribute('href');
     $href->value = dirname(__FILE__) . '/xpath.xsl';
     $import->appendChild($href);
     $xsl->firstChild->insertBefore($import, $xsl->firstChild->firstChild);
     $xsl->xinclude();
     $this->xslt->importStylesheet($xsl);
     foreach ($this->params as $name => $value) {
         $this->xslt->removeParameter('', $name);
     }
     $this->params = $params;
     $this->xslt->setParameter('', $params);
 }
开发者ID:nyan-cat,项目名称:easyweb,代码行数:18,代码来源:xslt.php

示例3: crc32

 static function crc32($filename)
 {
     fs::exists($filename) or runtime_error('File not found: ' . $filename);
     return hash_file('crc32', fs::normalize($filename));
 }
开发者ID:nyan-cat,项目名称:easyweb,代码行数:5,代码来源:filesystem.php

示例4: load

 static function load($filename)
 {
     fs::exists($filename) or runtime_error('XML document not found: ' . $filename);
     $xml = new DOMDocument();
     $xml->load(fs::normalize($filename));
     $xml->xinclude();
     return new xml($xml);
 }
开发者ID:nyan-cat,项目名称:easyweb,代码行数:8,代码来源:xml.php


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