/home
/sarahgar
/site
/ccnov2
/kirby
/vendor
/getkirby
/toolkit
/lib
/s.php
* // do whatever you want with the session now
*
* </code>
*
*/
public static function start() {
if(session_status() === PHP_SESSION_ACTIVE) return true;
// store the session name
static::$cookie += array(
'lifetime' => 0,
'path' => ini_get('session.cookie_path'),
'domain' => ini_get('session.cookie_domain'),
'secure' => r::secure(),
'httponly' => true
);
// set the custom session name
session_name(static::$name);
// make sure to use cookies only
ini_set('session.use_cookies', 1);
ini_set('session.use_only_cookies', 1);
// set additional cookie options
session_set_cookie_params(
cookie::lifetime(static::$cookie['lifetime']),
static::$cookie['path'],
static::$cookie['domain'],
static::$cookie['secure'],
static::$cookie['httponly']
);
// try to start the session
if(!session_start()) return false;
// mark it as started
static::$started = true;
/home
/sarahgar
/site
/ccnov2
/kirby
/vendor
/getkirby
/toolkit
/lib
/s.php
* // do whatever you want with the session now
*
* </code>
*
*/
public static function start() {
if(session_status() === PHP_SESSION_ACTIVE) return true;
// store the session name
static::$cookie += array(
'lifetime' => 0,
'path' => ini_get('session.cookie_path'),
'domain' => ini_get('session.cookie_domain'),
'secure' => r::secure(),
'httponly' => true
);
// set the custom session name
session_name(static::$name);
// make sure to use cookies only
ini_set('session.use_cookies', 1);
ini_set('session.use_only_cookies', 1);
// set additional cookie options
session_set_cookie_params(
cookie::lifetime(static::$cookie['lifetime']),
static::$cookie['path'],
static::$cookie['domain'],
static::$cookie['secure'],
static::$cookie['httponly']
);
// try to start the session
if(!session_start()) return false;
// mark it as started
static::$started = true;
/home
/sarahgar
/site
/ccnov2
/kirby
/vendor
/getkirby
/toolkit
/lib
/s.php
/**
* Gets a session value by key
*
* <code>
*
* s::get('username', 'bastian');
* // saves the username in the session
*
* echo s::get('username');
* // output: 'bastian'
*
* </code>
*
* @param mixed $key The key to look for. Pass false or null to return the entire session array.
* @param mixed $default Optional default value, which should be returned if no element has been found
* @return mixed
*/
public static function get($key = false, $default = null) {
static::start(static::$name, static::$timeout, static::$cookie);
if(!isset($_SESSION)) return false;
if(empty($key)) return $_SESSION;
return isset($_SESSION[$key]) ? $_SESSION[$key] : $default;
}
/**
* Retrieves an item and removes it afterwards
*
* @param string $key
* @param mixed $default
* @return mixed
*/
public static function pull($key, $default = null) {
$value = s::get($key, $default);
s::remove($key);
return $value;
}
/home
/sarahgar
/site
/ccnov2
/kirby
/core
/user.php
throw new Exception('The user account could not be saved');
} else {
return true;
}
}
static public function unauthorize() {
s::remove('kirby_auth_secret');
s::remove('kirby_auth_username');
cookie::remove('kirby_auth');
}
static public function current() {
$cookey = cookie::get(s::$name . '_auth');
$username = s::get('kirby_auth_username');
if(empty($cookey)) {
static::unauthorize();
return false;
}
if(s::get('kirby_auth_secret') !== sha1($username . $cookey)) {
static::unauthorize();
return false;
}
// find the logged in user by token
try {
$user = new static($username);
return $user;
} catch(Exception $e) {
static::unauthorize();
return false;
}
/home
/sarahgar
/site
/ccnov2
/kirby
/core
/site.php
return null;
}
/**
* Returns a collection of all users
*
* @return Users
*/
public function users() {
return new Users();
}
/**
* Returns the current user
*
* @param string $username Optional way to search for a single user
* @return User
*/
public function user($username = null) {
if(is_null($username)) return User::current();
try {
return new User($username);
} catch(Exception $e) {
return null;
}
}
/**
* Returns a collection of all roles
*
* @return Roles
*/
public function roles() {
return new Roles();
}
/**
* Gets the last modification date of all pages
* in the content folder.
*
/home
/sarahgar
/site
/ccnov2
/site
/snippets
/header.php
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="">
<meta name="twitter:creator" content="<?php echo $site->author()->html() ?>">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#00aba9">
<meta name="theme-color" content="#ffffff">
</head>
<body
data-login="<?php e($site->user(),'true', 'false') ?>"
data-template="<?php echo $page->template() ?>"
data-intended-template="<?php echo $page->intendedTemplate() ?>"
data-parent-template="<?php echo $page->parent()->template() ?>"
<?php $section = getRubriqueFromUri($page->uri());?>
data-rubrique="<?= $section ?>"
data-count = "<?= $pages->visible()->count()?>"
<?php if($section == 'voulez-vous-danser'):?>
style="background: <?php echo $site->index()->find('voulez-vous-danser')->color()?>"
<?php endif;?>
<?php if($page->template() == 'jgm'):?>
style="background: <?php echo $page->backcolor()?>"
<?php endif;?>
>
<?php snippet('popupnewsletter') ?>
/home
/sarahgar
/site
/ccnov2
/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
/sarahgar
/site
/ccnov2
/kirby
/kirby
/component
/snippet.php
* Returns a snippet file path by name
*
* @param string $name
* @return string
*/
public function file($name) {
return $this->kirby->roots()->snippets() . DS . str_replace('/', DS, $name) . '.php';
}
/**
* Renders the snippet with the given data
*
* @param string $name
* @param array $data
* @param boolean $return
* @return string
*/
public function render($name, $data = [], $return = false) {
if(is_object($data)) $data = ['item' => $data];
return tpl::load($this->kirby->registry->get('snippet', $name), $data, $return);
}
}
/home
/sarahgar
/site
/ccnov2
/kirby
/helpers.php
<?php
/**
* Embeds a snippet from the snippet folder
*
* @param string $file
* @param mixed $data array or object
* @param boolean $return
* @return string
*/
function snippet($file, $data = array(), $return = false) {
return kirby::instance()->component('snippet')->render($file, $data, $return);
}
/**
* Builds a css link tag for relative or absolute urls
*
* @param string $url
* @param string|array $media Either a media string or an array of attributes
* @return string
*/
function css() {
return call([kirby::instance()->component('css'), 'tag'], func_get_args());
}
/**
* Builds a script tag for relative or absolute links
*
* @param string $src
* @param boolean|array $async Either true for the async attribute or an array of attributes
* @return string
*/
function js() {
return call([kirby::instance()->component('js'), 'tag'], func_get_args());
}
/**
* Global markdown parser shortcut
*
* @param string $text
/home
/sarahgar
/site
/ccnov2
/site
/templates
/home.php
<?php snippet('header') ?>
<?php
$projets = $site->index()->filterBy('template', 'in', ['default', 'atelier', 'accueil', 'maud']);
$col1 = "";
$col2 = "";
$col3 = "";
$url1;
$url2;
$url3;
foreach($projets as $projet):
$project = $site->page($projet);
$url = $project->url();
foreach($project->dates()->toStructure() as $date):
if($date->home()->isNotEmpty()):
if($date->home() == "col1"):
$project1 = $project;
$col1 = $date;
$url1 = $url;
elseif($date->home() == "col2"):
$project2 = $project;
$col2 = $date;
$url2 = $url;
else:
$project3 = $project;
$col3 = $date;
$url3 = $url;
endif;
endif;
endforeach;
endforeach;
?>
<div>
<?php snippet('menu') ?>
<div class="big-image-wrapper image-wrapper">
<img src="<?php echo $page->homeImage()->toFile()->url()?>" alt="CCNO">
</div>
/home
/sarahgar
/site
/ccnov2
/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
/sarahgar
/site
/ccnov2
/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
/sarahgar
/site
/ccnov2
/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
/sarahgar
/site
/ccnov2
/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
/sarahgar
/site
/ccnov2
/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
/sarahgar
/site
/ccnov2
/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
/sarahgar
/site
/ccnov2
/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();