/home
/pourpieger
/public_html
/kirby
/vendor
/getkirby
/toolkit
/lib
/url.php
/**
* Returns the path without params
*/
public static function fragments($url = null) {
if(is_null($url)) $url = static::current();
$path = static::path($url);
if(empty($path)) return null;
$frag = array();
foreach(explode('/', $path) as $part) {
if(strpos($part, static::paramSeparator()) === false) $frag[] = $part;
}
return $frag;
}
/**
* Returns the query as array
*/
public static function query($url = null) {
if(is_null($url)) $url = static::current();
parse_str(parse_url($url, PHP_URL_QUERY), $array);
return $array;
}
/**
* Checks if the url contains a query string
*/
public static function hasQuery($url = null) {
if(is_null($url)) $url = static::current();
return str::contains($url, '?');
}
/**
*/
public static function hash($url = null) {
if(is_null($url)) $url = static::current();
return parse_url($url, PHP_URL_FRAGMENT);
}
public static function build($parts = array(), $url = null) {
/home
/pourpieger
/public_html
/kirby
/vendor
/getkirby
/toolkit
/lib
/url.php
/**
* Returns the path without params
*/
public static function fragments($url = null) {
if(is_null($url)) $url = static::current();
$path = static::path($url);
if(empty($path)) return null;
$frag = array();
foreach(explode('/', $path) as $part) {
if(strpos($part, static::paramSeparator()) === false) $frag[] = $part;
}
return $frag;
}
/**
* Returns the query as array
*/
public static function query($url = null) {
if(is_null($url)) $url = static::current();
parse_str(parse_url($url, PHP_URL_QUERY), $array);
return $array;
}
/**
* Checks if the url contains a query string
*/
public static function hasQuery($url = null) {
if(is_null($url)) $url = static::current();
return str::contains($url, '?');
}
/**
*/
public static function hash($url = null) {
if(is_null($url)) $url = static::current();
return parse_url($url, PHP_URL_FRAGMENT);
}
public static function build($parts = array(), $url = null) {
/home
/pourpieger
/public_html
/kirby
/kirby
/request.php
use URL;
class Request {
protected $kirby;
public function __construct($kirby) {
$this->kirby = $kirby;
}
public function url() {
return url::current();
}
public function params() {
return new Request\Params(url::params());
}
public function query() {
return new Request\Query(url::query());
}
public function path() {
return new Request\Path($this->kirby->path());
}
public function __call($method, $arguments) {
if(method_exists('r', $method)) {
return call('r::' . $method, $arguments);
} else {
throw new Exception('Invalid method: ' . $method);
}
}
/**
* Improved var_dump() output
*
* @return array
*/
public function __debuginfo() {
/home
/pourpieger
/public_html
/kirby
/kirby.php
}
/**
* Renders the HTML for the page or fetches it from the cache
*
* @param Page $page
* @param boolean $headers
* @return string
*/
public function render(Page $page, $data = array(), $headers = true) {
// register the currently rendered page
$this->page = $page;
// send all headers for the page
if($headers) $page->headers();
// configure pagination urls
$query = (string)$this->request()->query();
$params = (string)$this->request()->params() . r($query, '?') . $query;
pagination::$defaults['url'] = $page->url() . r($params, '/') . $params;
// cache the result if possible
if($this->options['cache'] && $page->isCachable() && in_array(r::method(), ['GET', 'HEAD'])) {
// try to read the cache by cid (cache id)
$cacheId = md5(url::current() . $page->representation());
// check for modified content within the content folder
// and auto-expire the page cache in such a case
if($this->options['cache.autoupdate'] and $this->cache()->exists($cacheId)) {
// get the creation date of the cache file
$created = $this->cache()->created($cacheId);
// make sure to kill the cache if the site has been modified
if($this->site->wasModifiedAfter($created)) {
$this->cache()->remove($cacheId);
/home
/pourpieger
/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
/pourpieger
/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
/pourpieger
/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();