/homepages
/25
/d279067507
/htdocs
/delphinedeshayes.com
/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
*
/homepages
/25
/d279067507
/htdocs
/delphinedeshayes.com
/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
*
/homepages
/25
/d279067507
/htdocs
/delphinedeshayes.com
/kirby
/vendor
/getkirby
/toolkit
/lib
/cache
/driver.php
* @param int $minutes
* @return int
*/
protected function expiration($minutes = null) {
// keep forever if minutes are not defined
if(is_null($minutes)) $minutes = 2628000;
// calculate the time
return time() + ($minutes * 60);
}
/**
* Checks when an item in the cache expires
*
* @param string $key
* @return mixed
*/
public function expires($key) {
// get the Value object
$value = $this->retrieve($key);
// check for a valid Value object
if(!is_a($value, 'Cache\\Value')) return false;
// return the expires timestamp
return $value->expires();
}
/**
* Checks if an item in the cache is expired
*
* @param string $key
* @return int
*/
public function expired($key) {
return $this->expires($key) <= time();
}
/**
* Checks when the cache has been created
/homepages
/25
/d279067507
/htdocs
/delphinedeshayes.com
/kirby
/vendor
/getkirby
/toolkit
/lib
/cache
/driver.php
*/
public function expires($key) {
// get the Value object
$value = $this->retrieve($key);
// check for a valid Value object
if(!is_a($value, 'Cache\\Value')) return false;
// return the expires timestamp
return $value->expires();
}
/**
* Checks if an item in the cache is expired
*
* @param string $key
* @return int
*/
public function expired($key) {
return $this->expires($key) <= time();
}
/**
* Checks when the cache has been created
*
* @param string $key
* @return mixed
*/
public function created($key) {
// get the Value object
$value = $this->retrieve($key);
// check for a valid Value object
if(!is_a($value, 'Cache\\Value')) return false;
// return the expires timestamp
return $value->created();
}
/**
/homepages
/25
/d279067507
/htdocs
/delphinedeshayes.com
/site
/plugins
/oembed
/core
/lib
/cache.php
<?php
namespace Kirby\distantnative;
class Cache {
public function __construct($plugin, $url) {
$this->plugin = $plugin;
$this->key = md5($url);
// Cache DirectoryIterator
$dir = kirby()->roots()->cache() . DS . $this->plugin;
if(!file_exists($dir)) mkdir($dir);
// Cache setup
$this->cache = \cache::setup('file', ['root' => $dir]);
// Cache clean-up
if($this->cache->expired($this->key)) {
$this->cache->remove($this->key);
}
}
public function __call($name, $args = []) {
return $this->cache->{$name}($this->key, $args);
}
}
/homepages
/25
/d279067507
/htdocs
/delphinedeshayes.com
/site
/plugins
/oembed
/core
/core.php
<?php
namespace Kirby\distantnative\oEmbed;
use A;
use C;
use Kirby\distantnative\Cache;
use Kirby\distantnative\Thumb;
class Core {
public $provider = null;
public function __construct($url, $args = []) {
$this->input = $url;
$this->cache = c::get('plugin.oembed.caching', true) ? new Cache('oembed', $url) : false;
$this->load();
if($this->data !== false) {
$this->options = $this->options($args);
$this->provider = $this->provider();
$this->url = new Url($this->data()->code);
}
}
// ================================================
// Load remote or cached data
// ================================================
protected function load() {
// get data from cache
if($this->cache && $this->cache->exists()) {
return $this->data = $this->cache->get();
// load data from source
} else {
$this->data = Data::get($this->input);
}
/homepages
/25
/d279067507
/htdocs
/delphinedeshayes.com
/site
/plugins
/oembed
/oembed.php
'core' => ['core', 'data', 'url', 'html'],
'core/lib' => ['cache', 'thumb'],
'core/providers' => ['provider', true],
]);
include('registry/field-method.php');
include('registry/tag.php');
include('registry/field.php');
include('registry/route.php');
}
// ================================================
// Global helper
// ================================================
namespace {
function oembed($url, $args = []) {
return new Kirby\distantnative\oEmbed\Core($url, $args);
}
}
/homepages
/25
/d279067507
/htdocs
/delphinedeshayes.com
/site
/plugins
/oembed
/registry
/field-method.php
<?php
// ================================================
// $page->video()->oembed()
// ================================================
$kirby->set('field::method', 'oembed', function($field, $args = []) {
return oembed($field->value, $args);
});
/homepages
/25
/d279067507
/htdocs
/delphinedeshayes.com
/kirby
/vendor
/getkirby
/toolkit
/helpers.php
/**
* Facepalm typo alias
* @see csrf()
*/
function csfr($check = null) {
return csrf($check);
}
/**
* Shortcut for call_user_func_array with a better handling of arguments
*
* @param mixed $function
* @param mixed $arguments
* @return mixed
*/
function call($function, $arguments = array()) {
if(!is_callable($function)) return false;
if(!is_array($arguments)) $arguments = array($arguments);
return call_user_func_array($function, $arguments);
}
/**
* Parses yaml structured text
*
* @param $string
* @return array
*/
function yaml($string) {
return yaml::decode($string);
}
/**
* Simple email sender helper
*
* @param array $params
* @return Email
*/
function email($params = array()) {
return new Email($params);
/homepages
/25
/d279067507
/htdocs
/delphinedeshayes.com
/kirby
/core
/field.php
/**
* Returns the field value
*
* @return string
*/
public function toString() {
return $this->value;
}
/**
* Applies registered Field methods
*
* @param string $method
* @param array $arguments
* @return mixed
*/
public function __call($method, $arguments = array()) {
if(isset(static::$methods[$method])) {
array_unshift($arguments, clone $this);
return call(static::$methods[$method], $arguments);
} else {
return $this;
}
}
/**
* Improved var_dump() output
*
* @return array
*/
public function __debuginfo() {
return [
'page' => $this->page()->id(),
'key' => $this->key(),
'value' => $this->value()
];
}
}
/homepages
/25
/d279067507
/htdocs
/delphinedeshayes.com
/site
/templates
/portfolio-video.php
<?php snippet('header') ?>
<?= $page->featured_video()->oembed() ?>
<?php if(!$page->text()->empty()): ?>
<hr class="invisible space">
<?php echo $page->text()->kirbytext() ?>
<?php endif ?>
<?php snippet('footer') ?>
/homepages
/25
/d279067507
/htdocs
/delphinedeshayes.com
/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;
}
}
/homepages
/25
/d279067507
/htdocs
/delphinedeshayes.com
/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;
}
}
/homepages
/25
/d279067507
/htdocs
/delphinedeshayes.com
/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
*/
/homepages
/25
/d279067507
/htdocs
/delphinedeshayes.com
/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() {
/homepages
/25
/d279067507
/htdocs
/delphinedeshayes.com
/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;
}
}
}
/homepages
/25
/d279067507
/htdocs
/delphinedeshayes.com
/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
*/
/homepages
/25
/d279067507
/htdocs
/delphinedeshayes.com
/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();