本文整理汇总了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);
}
}
示例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);
}
示例3: crc32
static function crc32($filename)
{
fs::exists($filename) or runtime_error('File not found: ' . $filename);
return hash_file('crc32', fs::normalize($filename));
}
示例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);
}