本文整理汇总了PHP中f::write方法的典型用法代码示例。如果您正苦于以下问题:PHP f::write方法的具体用法?PHP f::write怎么用?PHP f::write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类f
的用法示例。
在下文中一共展示了f::write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: combine
public static function combine($type, $files, $compress = false)
{
$root = panel::instance()->roots()->assets() . DS . $type;
$cache = new Media($root . DS . 'panel.' . $type);
$media = new Collection(array_map(function ($file) use($root) {
return new Media($root . DS . str_replace('/', DS, $file));
}, $files));
// get the max modification date
$modified = max($media->pluck('modified'));
if (is_writable($root) and (!$cache->exists() or $cache->modified() < $modified)) {
$cache->remove();
$content = '';
foreach ($media as $asset) {
$content .= $asset->read() . PHP_EOL;
}
if ($compress) {
$content = static::compress($content);
}
f::write($root . DS . 'panel.' . $type, $content);
}
if ($cache->exists()) {
return $type(panel()->urls()->{$type}() . '/panel.' . $type . '?v=' . panel()->version());
}
return $type(array_map(function ($item) use($type) {
return 'panel/assets/' . $type . '/' . $item;
}, $files));
}
示例2: set_cache
public function set_cache($type, $result)
{
$cache_path = __DIR__ . '/../cache/' . $type . '.json';
$period = c::get('kg.cache_period') ? c::get('kg.cache_period') : '30 Minutes';
$cache = array('to' => strtotime($period), 'payload' => $result);
\f::write($cache_path, json_encode($cache));
}
示例3: write
public static function write($file, $data, $type = null)
{
// type autodetection
if (is_null($type)) {
$type = f::extension($file);
}
return f::write($file, data::encode($data, $type));
}
示例4: copy
protected function copy()
{
if ($this->input->getOption('bare')) {
$blueprint = f::read($this->template());
$blueprint = str::template($blueprint, ['title' => ucfirst($this->name())]);
f::write($this->file(), $blueprint);
} else {
$this->questions();
}
}
示例5: testSize
public function testSize()
{
dir::make($this->tmpDir);
f::write($this->tmpDir . DS . 'testfile-1.txt', str::random(5));
f::write($this->tmpDir . DS . 'testfile-2.txt', str::random(5));
f::write($this->tmpDir . DS . 'testfile-3.txt', str::random(5));
$this->assertEquals(15, dir::size($this->tmpDir));
$this->assertEquals('15 b', dir::niceSize($this->tmpDir));
dir::remove($this->tmpDir);
}
示例6: set
static function set($file, $content, $raw = false)
{
if (!c::get('cache')) {
return false;
}
if ($raw == false) {
$content = @serialize($content);
}
if ($content) {
f::write(self::file($file), $content);
}
}
示例7: start
public function start()
{
$src = get('source');
$target = get('target');
if (!v::url($src)) {
throw new Exception('Invalid source');
}
if (!v::url($target)) {
throw new Exception('Invalid target');
}
if (!str::contains($target, site()->url())) {
throw new Exception('Invalid target');
}
require_once dirname(__DIR__) . DS . 'vendor' . DS . 'mf2.php';
require_once dirname(__DIR__) . DS . 'vendor' . DS . 'comments.php';
$data = \Mf2\fetch($src);
$result = \IndieWeb\comments\parse($data['items'][0], $src);
if (empty($result)) {
throw new Exception('Probably spam');
}
$path = ltrim(str_replace(site()->url(), '', $target), '/');
if (!empty($path) and $page = page($path)) {
if (!empty($result['published'])) {
$time = strtotime($result['published']);
} else {
$time = time();
$result['published'] = date('c');
}
$json = json_encode($result);
$hash = sha1($json);
$file = $page->root() . DS . '.webmentions' . DS . $time . '-' . $hash . '.json';
f::write($file, $json);
return true;
} else {
throw new Exception('Invalid page');
}
}
示例8: photo
public function photo()
{
if (!is_null($this->photo)) {
return $this->photo;
}
$extension = f::extension($this->data['photo']);
$filename = rtrim(sha1($this->url) . '.' . $extension, '.');
$path = c::get('webmentions.images', 'assets/images/mentions');
$root = kirby()->roots()->index() . DS . str_replace('/', DS, $path) . DS . $filename;
$url = kirby()->urls()->index() . '/' . $path . '/' . $filename;
$photo = new Media($root, $url);
if (!$photo->exists()) {
$image = remote::get($this->data['photo']);
$allowed = array('image/jpeg', 'image/png', 'image/gif');
f::write($root, $image->content());
if (!in_array($photo->mime(), $allowed) or $photo->size() == 0) {
$photo->delete();
}
}
if (!$photo->exists() or !$photo->type() == 'image') {
$photo = new Obj(array('url' => $this->data['photo'], 'exists' => false));
}
return $this->photo = $photo;
}
示例9: scripts
/**
* Combine and cache all javascript files.
*/
public function scripts()
{
$file = $this->hub()->finder()->cache() . DS . 'wizard.js';
if (!file_exists($file)) {
$js = $this->combine(array('js/jquery.js', 'js/jquery.breadcrumb.js', 'js/jquery.sidebar.js'));
f::write($file, $js);
}
header('Content-type: text/javascript');
echo f::read($file);
exit;
}
示例10: save
/**
* Saves the file
*
* @param string $content
* @return boolean
*/
public function save($content = null, $format = null)
{
$content = $this->content($content, $format);
return f::write($this->root, $content);
}
示例11: save
protected static function save($file, $data)
{
$yaml = '<?php if(!defined(\'KIRBY\')) exit ?>' . PHP_EOL . PHP_EOL;
$yaml .= data::encode($data, 'yaml');
if (!f::write($file, $yaml)) {
throw new Exception('The user account could not be saved');
} else {
return true;
}
}
示例12: copy
protected function copy()
{
f::write($this->_file($this->name() . '.php'), $this->_template('plugin.php'));
f::write($this->_file('package.json'), $this->_template('package.json'));
f::write($this->_file('readme.md'), $this->_template('readme.md'));
}
示例13: write
/**
* Creates a new yaml file from an array
*
* @param string $file
* @param array $array
* @return boolean
*/
public static function write($file, $array)
{
return f::write($file, static::encode($array));
}
示例14: date
}
$output[] = 'title: ' . $post['title'];
$output[] = 'date: ' . date($dateformat, $post['date']);
$output[] = 'text: ' . "\n\n" . trim($post['text']);
$output[] = 'tags: ' . $post['tags'];
$output[] = 'categories: ' . $post['cats'];
$name = pad($n, $len) . '-' . f::safe_name($post['slug']);
$dir = $root . '/' . $name;
if (is_dir($dir)) {
$skipped[] = basename($dir);
continue;
}
dir::make($dir);
$content = implode("\n\n" . '----' . "\n\n", $output);
$file = $dir . '/' . $template;
f::write($file, $content);
}
putmessage('Exported ' . $n . ' articles to ' . $root . '<br /><br />');
if (!empty($errors)) {
putmessage(count($errors) . ' article(s) could not be imported<br /><br />');
}
if (!empty($skipped)) {
putmessage('The following folders have been skipped, because they already existed:' . a::show($skipped, false));
}
/**
* IXR - The Inutio XML-RPC Library
*
* @package IXR
* @since 1.5
*
* @copyright Incutio Ltd 2002-2005
示例15: date_default_timezone_set
dir::copy(__DIR__ . DS . 'assets', __DIR__ . DS . 'static' . DS . 'assets');
dir::copy(__DIR__ . DS . 'content', __DIR__ . DS . 'static' . DS . 'content');
// set the timezone for all date functions
date_default_timezone_set($kirby->options['timezone']);
// load all extensions
$kirby->extensions();
// load all plugins
$kirby->plugins();
// load all models
$kirby->models();
// load all language variables
$kirby->localize();
foreach ($site->index() as $page) {
$site->visit($page->uri());
$html = $kirby->render($page);
if ($page->isHomePage()) {
$root = __DIR__ . DS . 'static' . DS . 'index.html';
} else {
$root = __DIR__ . DS . 'static' . DS . $page->uri() . DS . 'index.html';
}
f::write($root, $html);
}
?>
Your site has been exported to the <b>static</b> folder.<br />
Copy all sites and folders from there and upload them to your server.<br />
Make sure the main URL is correct: <b><?php
echo $url;
?>
</b>