/home
/u317782303
/domains
/xtba.co.uk
/public_html
/kirby
/vendor
/getkirby
/toolkit
/lib
/str.php
/**
* Converts a string to UTF-8
*
* @param string $string
* @return string
*/
public static function utf8($string) {
return static::convert($string, 'utf-8');
}
/**
* A better way to strip slashes
*
* @param string $string
* @return string
*/
public static function stripslashes($string) {
if(is_array($string)) return $string;
return get_magic_quotes_gpc() ? stripslashes($string) : $string;
}
/**
* A super simple string template engine,
* which replaces tags like {mytag} with any other string
*
* @param string $string
* @param array $data An associative array with keys, which should be replaced and values.
* @return string
*/
public static function template($string, $data = array()) {
$replace = array();
foreach($data as $key => $value) $replace['{' . $key . '}'] = $value;
return str_replace(array_keys($replace), array_values($replace), $string);
}
/**
* Convert a string to 7-bit ASCII.
*
* @param string $string
/home
/u317782303
/domains
/xtba.co.uk
/public_html
/kirby
/vendor
/getkirby
/toolkit
/lib
/str.php
/**
* Converts a string to UTF-8
*
* @param string $string
* @return string
*/
public static function utf8($string) {
return static::convert($string, 'utf-8');
}
/**
* A better way to strip slashes
*
* @param string $string
* @return string
*/
public static function stripslashes($string) {
if(is_array($string)) return $string;
return get_magic_quotes_gpc() ? stripslashes($string) : $string;
}
/**
* A super simple string template engine,
* which replaces tags like {mytag} with any other string
*
* @param string $string
* @param array $data An associative array with keys, which should be replaced and values.
* @return string
*/
public static function template($string, $data = array()) {
$replace = array();
foreach($data as $key => $value) $replace['{' . $key . '}'] = $value;
return str_replace(array_keys($replace), array_values($replace), $string);
}
/**
* Convert a string to 7-bit ASCII.
*
* @param string $string
/home
/u317782303
/domains
/xtba.co.uk
/public_html
/kirby
/vendor
/getkirby
/toolkit
/lib
/r.php
/**
* Only returns post data
*
* @return array
*/
public static function postData($key = null, $default = null) {
return a::get((array)static::sanitize($_POST), $key, $default);
}
/**
* Private method to sanitize incoming request data
*
* @param array $data
* @return array
*/
protected static function sanitize($data) {
if(!is_array($data)) {
return trim(str::stripslashes($data));
}
foreach($data as $key => $value) {
$data[$key] = static::sanitize($value);
}
return $data;
}
/**
* Sets or overwrites a variable in the data array
*
* <code>
*
* r::set('username', 'bastian');
*
* dump($request);
*
* // sample output: array(
/home
/u317782303
/domains
/xtba.co.uk
/public_html
/kirby
/vendor
/getkirby
/toolkit
/lib
/r.php
* @return array
*/
public static function postData($key = null, $default = null) {
return a::get((array)static::sanitize($_POST), $key, $default);
}
/**
* Private method to sanitize incoming request data
*
* @param array $data
* @return array
*/
protected static function sanitize($data) {
if(!is_array($data)) {
return trim(str::stripslashes($data));
}
foreach($data as $key => $value) {
$data[$key] = static::sanitize($value);
}
return $data;
}
/**
* Sets or overwrites a variable in the data array
*
* <code>
*
* r::set('username', 'bastian');
*
* dump($request);
*
* // sample output: array(
* // 'username' => 'bastian'
* // ... other stuff from the request
* // );
*
/home
/u317782303
/domains
/xtba.co.uk
/public_html
/kirby
/vendor
/getkirby
/toolkit
/lib
/r.php
* Returns either the entire data array or parts of it
*
* <code>
*
* echo r::data('username');
* // sample output 'bastian'
*
* echo r::data('username', 'peter');
* // if no username is found in the request peter will be echoed
*
* </code>
*
* @param string $key An optional key to receive only parts of the data array
* @param mixed $default A default value, which will be returned if nothing can be found for a given key
* @param mixed
*/
public static function data($key = null, $default = null) {
if(is_null(static::$data)) {
static::$data = static::sanitize(static::raw());
if(!static::is('GET')) {
$body = static::body();
parse_str($body, $parsed);
if(!is_array($parsed)) {
$parsed = json_decode($body, false);
if(!is_array($parsed)) $parsed = array();
}
static::$data = array_merge($parsed, static::$data);
}
}
if(is_null($key)) {
return static::$data;
} else if(isset(static::$data[$key])) {
return static::$data[$key];
/home
/u317782303
/domains
/xtba.co.uk
/public_html
/kirby
/vendor
/getkirby
/toolkit
/helpers.php
/**
* Redirects the user to a new URL
* This uses the URL::to() method and can be super
* smart with the custom url::to() handler. Check out
* the URL class for more information
*/
function go() {
call_user_func_array('redirect::to', func_get_args());
}
/**
* Shortcut for r::get()
*
* @param mixed $key The key to look for. Pass false or null to return the entire request array.
* @param mixed $default Optional default value, which should be returned if no element has been found
* @return mixed
*/
function get($key = null, $default = null) {
return r::data($key, $default);
}
/**
* Returns all params from the current url
*
* @return array
*/
function params() {
return url::params();
}
/**
* Get a parameter from the current URI object
*
* @param mixed $key The key to look for. Pass false or null to return the entire params array.
* @param mixed $default Optional default value, which should be returned if no element has been found
* @return mixed
*/
function param($key = null, $default = null) {
static $params;
/home
/u317782303
/domains
/xtba.co.uk
/public_html
/site
/controllers
/search.php
<?php
return function($site, $pages, $page) {
$query = get('q');
$results = $site->search($query, 'title|text|works_with|product_number|summary|categories|connectivity|supply_voltage|additional_info|packaging|pleasenote|cemarked');
return array(
'query' => $query,
'results' => $results,
);
};
/home
/u317782303
/domains
/xtba.co.uk
/public_html
/kirby
/core
/page.php
*
* @return array
*/
public function controller($arguments = array()) {
// first try to get a controller for the representation
$controller = null;
if($representation = $this->representation()) {
$controller = $this->kirby->registry->get('controller', $this->template() . '.' . $representation);
}
// no representation or no special controller: try the normal one
if(!$controller) $controller = $this->kirby->registry->get('controller', $this->template());
if(is_a($controller, 'Closure')) {
return (array)call_user_func_array($controller, array(
$this->site,
$this->site->children(),
$this,
$arguments
));
}
return array();
}
/**
* Converts the entire page array into
* a json string
*
* @param closure $callback Filter callback
* @return string
*/
public function toJson($callback = null) {
return json_encode($this->toArray($callback));
}
/**
* Makes it possible to echo the entire object
/home
/u317782303
/domains
/xtba.co.uk
/public_html
/kirby
/kirby
/component
/template.php
* @link http://getkirby.com
* @copyright Bastian Allgeier
* @license http://getkirby.com/license
*/
class Template extends \Kirby\Component {
/**
* Collects all template data by page
*
* @param mixed $page
* @param array $data
* @return array
*/
public function data($page, $data = []) {
if($page instanceof Page) {
$data = array_merge(
$page->templateData(),
$data,
$page->controller($data)
);
}
// apply the basic template vars
return array_merge(array(
'kirby' => $this->kirby,
'site' => $this->kirby->site(),
'pages' => $this->kirby->site()->children(),
'page' => $page
), $data);
}
/**
* Returns all available template files
*
* @return array
*/
public function files() {
$files = dir::read($this->kirby->roots()->templates());
/home
/u317782303
/domains
/xtba.co.uk
/public_html
/kirby
/kirby
/component
/template.php
* @return string
*/
public function file($name) {
return $this->kirby->roots()->templates() . DS . str_replace('/', DS, $name) . '.php';
}
/**
* Renders the template by page with the additional data
*
* @param Page|string $template
* @param array $data
* @param boolean $return
* @return string
*/
public function render($template, $data = [], $return = true) {
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;
/home
/u317782303
/domains
/xtba.co.uk
/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
/u317782303
/domains
/xtba.co.uk
/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
/u317782303
/domains
/xtba.co.uk
/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
/u317782303
/domains
/xtba.co.uk
/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
/u317782303
/domains
/xtba.co.uk
/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();