/home
/ski2freedom
/public_html
/kirby
/vendor
/getkirby
/toolkit
/lib
/cache
/driver
/file.php
* </code>
*
* @param string $key
* @param mixed $value
* @param int $minutes
* @return void
*/
public function set($key, $value, $minutes = null) {
return f::write($this->file($key), serialize($this->value($value, $minutes)));
}
/**
* Retrieve an item from the cache.
*
* @param string $key
* @return object CacheValue
*/
public function retrieve($key) {
// unserialized value array (see $this->value())
return unserialize(f::read($this->file($key)));
}
/**
* Checks when the cache has been created
*
* @param string $key
* @return int
*/
public function created($key) {
// use the modification timestamp
// as indicator when the cache has been created/overwritten
clearstatcache();
// get the file for this cache key
$file = $this->file($key);
return file_exists($file) ? filemtime($this->file($key)) : 0;
}
/**
* Remove an item from the cache
*
/home
/ski2freedom
/public_html
/kirby
/vendor
/getkirby
/toolkit
/lib
/cache
/driver
/file.php
* </code>
*
* @param string $key
* @param mixed $value
* @param int $minutes
* @return void
*/
public function set($key, $value, $minutes = null) {
return f::write($this->file($key), serialize($this->value($value, $minutes)));
}
/**
* Retrieve an item from the cache.
*
* @param string $key
* @return object CacheValue
*/
public function retrieve($key) {
// unserialized value array (see $this->value())
return unserialize(f::read($this->file($key)));
}
/**
* Checks when the cache has been created
*
* @param string $key
* @return int
*/
public function created($key) {
// use the modification timestamp
// as indicator when the cache has been created/overwritten
clearstatcache();
// get the file for this cache key
$file = $this->file($key);
return file_exists($file) ? filemtime($this->file($key)) : 0;
}
/**
* Remove an item from the cache
*
/home
/ski2freedom
/public_html
/kirby
/vendor
/getkirby
/toolkit
/lib
/cache
/driver.php
/**
* Get an item from the cache.
*
* <code>
* // Get an item from the cache driver
* $value = Cache::get('value');
*
* // Return a default value if the requested item isn't cached
* $value = Cache::get('value', 'default value');
* </code>
*
* @param string $key
* @param mixed $default
* @return mixed
*/
public function get($key, $default = null) {
// get the Value
$value = $this->retrieve($key);
// check for a valid cache value
if(!is_a($value, 'Cache\\Value')) return $default;
// remove the item if it is expired
if(time() > $value->expires()) {
$this->remove($key);
return $default;
}
// get the pure value
$cache = $value->value();
// return the cache value or the default
return (!is_null($cache)) ? $cache : $default;
}
/**
* Calculates the expiration timestamp
/home
/ski2freedom
/public_html
/site
/plugins
/imageset
/lib
/cache.php
} else {
$path = dirname($image->root());
$file = $image->filename();
$index = $this->kirby->roots()->index();
$pos = strpos($path, $index);
if($pos === 0) {
$path = ltrim(substr($path, strlen($index)), DS);
}
}
return $path . DS . $file . '-' . $key . '.' . static::CACHE_EXTENSION;
}
public function created(Media $image, $key) {
return $this->driver->created($this->imageCachePath($image, $key));
}
public function get(Media $image, $key, $default = null) {
if($this->created($image, $key) > $image->modified()) {
return $this->driver->get($this->imageCachePath($image, $key), $default = null);
} else {
return $default;
}
}
public function set(Media $image, $key, $value, $minutes = null) {
$this->driver->set($this->imageCachePath($image, $key), $value, $minutes);
}
public function __call($name, $arguments) {
return call_user_func_array([$this->driver, $name], $arguments);
}
public function flush() {
$cacheFiles = $this->inventory();
foreach($cacheFiles as $file) {
f::remove($file);
}
/home
/ski2freedom
/public_html
/site
/plugins
/imageset
/lib
/imageset.php
$image = new Asset($image);
}
parent::__construct($image, array_merge(static::$defaults, is_array($options) ? $options : []));
$this->kirby = $kirby ?: kirby();
if(is_null(static::$fileCache)) {
static::$fileCache = Cache::instance();
static::$plugin = Plugin::instance();
}
if(is_string($sizes) && presets::exists($sizes)) {
$this->sizes = presets::get($sizes);
} else {
$this->sizes = $sizes;
};
// Try to load ImageSet from cache
$cacheValue = $this->option('cache', false) ? static::$fileCache->get($this->image, $this->hash()) : null;
if(!is_null($cacheValue) && $cacheValue['imageset.version'] === static::$plugin->version() && $cacheValue['site.url'] === $this->kirby->urls()->index()) {
$this->cache['html'] = $cacheValue['html'];
} else {
$this->sources = $this->setupSources($this->sizes);
}
}
/**
* Loads the settings defined in your `config.php` file
* and overrides the plugin defaults.
*
* @param $kirby The Kirby instance to read settings from.
*/
public static function loadConfig($kirby = null) {
$kirby = $kirby ?: kirby();
foreach(static::$defaults as $key => $value) {
$configValue = $kirby->option("imageset.$key");
if(!is_null($configValue)) {
/home
/ski2freedom
/public_html
/site
/plugins
/imageset
/helpers.php
<?php
use Kirby\Plugins\ImageSet\ImageSet as ImageSetClass;
use Kirby\Plugins\ImageSet\Presets;
use Kirby\Plugins\ImageSet\Utils;
/**
* Helper function for using imageset in templates.
*/
function imageset($image, $sizes = 'default', $options = null) {
return (new ImageSetClass($image, $sizes, $options));
}
// Register file helper method.
file::$methods['imageset'] = function($file, $sizes = 'default', $options = null) {
return (new ImageSetClass($file, $sizes, $options));
};
file::$methods['alpha'] = function($file) {
return utils::hasTransparency($file);
};
file::$methods['dominantColor'] = function($file) {
return utils::dominantColor($file);
};
class imageset {
/**
* API functions for getting/setting presets.
*/
public static function presets($action, $value = null) {
if($action === 'reset') {
return presets::reset();
} else if($action === 'load') {
return presets::load($value);
} else if($action === 'save') {
return presets::save($value);
} else if($action === 'clear') {
return presets::clear();
/home
/ski2freedom
/public_html
/site
/templates
/blog.php
?>
<div class="results">
<?php foreach($articles as $article): ?>
<article>
<header>
<h2><a href="<?php echo $article->url() ?>"><?php echo html($article->title()) ?></a></h2>
<div class="meta">
<time datetime="<?php echo $article->date('c') ?>"><?php echo $article->date('F dS, Y'); ?></time>
<?php if ($article->tags() != ''): ?>
<ul class="tags">
<?php foreach(str::split($article->tags()) as $tag): ?>
<li><a href="<?php echo url('en/blog/tag:' . urlencode($tag))?>">#<?php echo $tag; ?></a></li>
<?php endforeach ?>
</ul>
<?php endif ?>
<?php if($article->image('intro-slide.jpg') == (true)): ?>
<a href="<?php echo $article->url() ?>">
<?= imageset($article->image('intro-slide.jpg'), [
[ '300x100-900x300,5', 'media' => '(min-aspect-ratio: 3/2)' ],
[ '320x200-800x500,5' ],
]); ?>
</a>
<?php endif ?>
</div>
</header>
<p><?php echo excerpt($article->text(), 400) ?>
</article>
<?php endforeach ?>
</div>
<?php else: // show latest articles ?>
<?php $articles = $pages->find('blog')->children()->visible()->sortBy('date', 'desc')->paginate(10) ?>
<?php foreach($articles as $article): // article overview ?>
<article>
<header>
<h2><a href="<?php echo $article->url() ?>"><?php echo html($article->title()) ?></a></h2>
<div class="meta">
<time datetime="<?php echo $article->date('c') ?>"><?php echo $article->date('F dS, Y'); ?></time>
/home
/ski2freedom
/public_html
/kirby
/vendor
/getkirby
/toolkit
/lib
/tpl.php
/**
* Tpl
*
* Super simple template engine
*
* @package Kirby Toolkit
* @author Bastian Allgeier <bastian@getkirby.com>
* @link http://getkirby.com
* @copyright Bastian Allgeier
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
class Tpl extends Silo {
public static $data = array();
public static function load($_file, $_data = array(), $_return = true) {
if(!file_exists($_file)) return false;
ob_start();
extract(array_merge(static::$data, (array)$_data));
require($_file);
$_content = ob_get_contents();
ob_end_clean();
if($_return) return $_content;
echo $_content;
}
}
/home
/ski2freedom
/public_html
/kirby
/kirby
/component
/template.php
if($template instanceof Page) {
$page = $template;
$file = $page->templateFile();
$data = $this->data($page, $data);
} else {
$file = $template;
$data = $this->data(null, $data);
}
// check for an existing template
if(!file_exists($file)) {
throw new Exception('The template could not be found');
}
// merge and register the template data globally
$tplData = tpl::$data;
tpl::$data = array_merge(tpl::$data, $data);
// load the template
$result = tpl::load($file, null, $return);
// reset the template data
tpl::$data = $tplData;
return $result;
}
}
/home
/ski2freedom
/public_html
/kirby
/kirby.php
}
return $template;
}
// return a fresh template
return $this->template($page, $data);
}
/**
* Template configuration
*
* @param Page $page
* @param array $data
* @return string
*/
public function template(Page $page, $data = array()) {
return $this->component('template')->render($page, $data);
}
public function request() {
if(!is_null($this->request)) return $this->request;
return $this->request = new Request($this);
}
public function router() {
return $this->router;
}
public function route() {
return $this->route;
}
/**
* Starts the router, renders the page and returns the response
*
* @return mixed
*/
/home
/ski2freedom
/public_html
/kirby
/kirby.php
}
}
// try to fetch the template from cache
$template = $this->cache()->get($cacheId);
// fetch fresh content if the cache is empty
if(empty($template)) {
$template = $this->template($page, $data);
// store the result for the next round
$this->cache()->set($cacheId, $template);
}
return $template;
}
// return a fresh template
return $this->template($page, $data);
}
/**
* Template configuration
*
* @param Page $page
* @param array $data
* @return string
*/
public function template(Page $page, $data = array()) {
return $this->component('template')->render($page, $data);
}
public function request() {
if(!is_null($this->request)) return $this->request;
return $this->request = new Request($this);
}
public function router() {
/home
/ski2freedom
/public_html
/kirby
/kirby
/component
/response.php
* @link http://getkirby.com
* @copyright Bastian Allgeier
* @license http://getkirby.com/license
*/
class Response extends \Kirby\Component {
/**
* Builds and return the response by various input
*
* @param mixed $response
* @return mixed
*/
public function make($response) {
if(is_string($response)) {
return $this->kirby->render(page($response));
} else if(is_array($response)) {
return $this->kirby->render(page($response[0]), $response[1]);
} else if(is_a($response, 'Page')) {
return $this->kirby->render($response);
} else if(is_a($response, 'Response')) {
return $response;
} else {
return null;
}
}
}
/home
/ski2freedom
/public_html
/kirby
/kirby.php
// check for a valid route
if(is_null($this->route)) {
header::status('500');
header::type('json');
die(json_encode(array(
'status' => 'error',
'message' => 'Invalid route or request method'
)));
}
// call the router action with all arguments from the pattern
$response = call($this->route->action(), $this->route->arguments());
// load all language variables
// this can only be loaded once the router action has been called
// otherwise the current language is not yet available
$this->localize();
// build the response
$this->response = $this->component('response')->make($response);
// store the current language in the session
if(
$this->option('language.detect') &&
$this->site()->multilang() &&
$this->site()->language()
) {
s::set('kirby_language', $this->site()->language()->code());
}
return $this->response;
}
/**
* Register a new hook
*
* @param string/array $hook The name of the hook
* @param closure $callback
*/
/home
/ski2freedom
/public_html
/index.php
<?php
define('DS', DIRECTORY_SEPARATOR);
// load kirby
require(__DIR__ . DS . 'kirby' . DS . 'bootstrap.php');
// check for a custom site.php
if(file_exists(__DIR__ . DS . 'site.php')) {
require(__DIR__ . DS . 'site.php');
} else {
$kirby = kirby();
}
// render
echo $kirby->launch();