本文整理汇总了PHP中fs::write方法的典型用法代码示例。如果您正苦于以下问题:PHP fs::write方法的具体用法?PHP fs::write怎么用?PHP fs::write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fs
的用法示例。
在下文中一共展示了fs::write方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
static function create($options)
{
if (isset($options->cache)) {
$cache = $options->cache . 'cache.tmp';
if ($www = fs::read($cache)) {
$www = unserialize($www);
$www->locale->setup($options->language, $options->country);
return $www;
} else {
$www = new www($options);
fs::write($cache, serialize($www));
return $www;
}
} else {
return new www($options);
}
}
示例2: 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);
}
}