function main() { set_error_handler('error_handler'); $c = new c(false); $c->get(); echo "Error\n"; }
function main() { $c = new c(); $f = $c->genclo(); foreach ($f() as $v) { var_dump($v); } }
/** * Create an instance of the view * * @param array $options * @return void */ public function __construct($options = array()) { $views = isset($options['views']) ? $options['views'] : Config::get('blade_views_dir', kirby()->roots()->templates()); $cache = isset($options['cache']) ? $options['cache'] : Config::get('blade_cache_dir', kirby()->roots()->cache() . DS . 'views'); $this->engine = new Blade($views, $cache); $this->setEchoFormat(); }
function ct($n, $m) { $ct = c::get($n, $m); if (!is_null($ct)) { return $ct; } if ($n === $m) { $ct = 0.0; } elseif ($n === 1 && $m === 0) { $ct = 2.0; } elseif ($m === 0) { $ct = (1 + ct($n - 1, 0)) * 2; } else { for ($i = $m + 1; $i != $n; ++$i) { $ct0 = c::get($n, $i); if (!is_null($ct0)) { break; } } for ($i -= 1; $i != $m; --$i) { $ct1 = 1 + $ct0 / 2 + ct($n, 0) / 2; c::set($n, $i, $ct1); $ct0 = $ct1; } $ct = 1 + ct($n, $m + 1) / 2 + ct($n, 0) / 2; } c::set($n, $m, $ct); return $ct; }
public function set_cache($type, $result) { $cache_path = __DIR__ . '/../cache/' . $type . '.json'; $period = c::get('kg.cache_period') ? c::get('kg.cache_period') : '30 Minutes'; $cache = array('to' => strtotime($period), 'payload' => $result); \f::write($cache_path, json_encode($cache)); }
/** * Load and prepare configuration * * @since 1.0.0 * * @return \WysiwygField */ public function __construct() { /* (1) Load button configuration */ $this->buttons = c::get('field.wysiwyg.buttons', false); if (!is_array($this->buttons) or count($this->buttons) <= 0) { $this->buttons = $this->defaults['buttons']; } /* (2) Load heading style configuration */ $this->headingStyle = c::get('field.wysiwyg.heading-style', false); if (!in_array($this->headingStyle, array('atx', 'setext'))) { $this->headingStyle = $this->defaults['heading-style']; } /* (3) Load double returns configuration */ $this->doubleReturns = c::get('field.wysiwyg.double-returns', null); if (!is_bool($this->doubleReturns)) { $this->doubleReturns = $this->defaults['double-returns']; } /* (4) Load drag/drop configuration */ $this->kirbyDragDrop = c::get('field.wysiwyg.dragdrop.kirby', false); if (!is_bool($this->kirbyDragDrop)) { $this->kirbyDragDrop = false; } $this->mediumDragDrop = c::get('field.wysiwyg.dragdrop.medium', false); if (!is_bool($this->mediumDragDrop)) { $this->mediumDragDrop = false; } }
function dragText($obj) { if (c::get('panel.kirbytext') === false) { if (is_a($obj, 'Page')) { return '[' . $obj->title() . '](' . $obj->url() . ')'; } else { if (is_a($obj, 'File')) { switch ($obj->type()) { case 'image': return '![' . $obj->name() . '](' . $obj->url() . ')'; break; default: return '[' . $obj->filename() . '](' . $obj->url() . ')'; break; } } } } else { if (is_a($obj, 'Page')) { return '(link: ' . $obj->uri() . ' text: ' . $obj->title() . ')'; } else { if (is_a($obj, 'File')) { switch ($obj->type()) { case 'image': return '(image: ' . $obj->filename() . ')'; break; default: return '(file: ' . $obj->filename() . ')'; break; } } } } }
protected function template($class = false) { $output = new Brick('div'); $output->addClass('oembed'); if ($class !== false) { $output->addClass($class); } else { $output->addClass('oembed-' . substr(md5($this->url), 0, 6)); } if ($this->media->get('type') === 'video') { $output = OembedTemplate::ratio($output, $this->media); if (c::get('oembed.lazyvideo', false)) { $output->addClass('oembed-lazyvideo'); } $play = OembedTemplate::play(); $output->append($play); $thumb = OembedTemplate::thumb($this->thumb->get($this->media())); $output->append($thumb); $html = OembedTemplate::embed($this->media, $this->autoplay); } else { $html = $this->media->get('html'); } $html = OembedTemplate::validation($html); $output->append($html); return $output; }
/** * Helpfer function relativeDate() */ function relativeDate($date, $args = array()) { // default for $args $defaults = array('lang' => count(site()->languages()) >= 1 ? site()->language()->code() : c::get('relativedate.lang', 'en'), 'length' => c::get('relativedate.length', 2), 'threshold' => c::get('relativedate.threshold', false), 'fuzzy' => c::get('relativedate.fuzzy', true), 'format' => c::get('relativedate.format', 'd.m.Y')); $args = array_merge($defaults, $args); // check if $date is a timestamp if (RelativeDate::isTimestamp($date)) { $date = date(DATE_ATOM, $date); } // only convert to relative if time difference no exceeds threshold if ($args['threshold'] === false or abs(strtotime($date) - time()) <= $args['threshold']) { try { $relative = new RelativeDate($date, $args); $result = $relative->get($args['length']); } catch (Exception $e) { $result = $date; } } else { $result = $date; } // if we had no change to date due to any bug or exceeding threshold if ($result === $date) { $date = new Datetime($date); $result = $date->format($args['format']); } return $result; }
public function index() { if (app::$site->users()->count() > 0) { go('panel/login'); } if ($problems = installation::check()) { $content = view('installation/check', array('problems' => $problems)); } else { $form = app::form('installation', array('language' => c::get('panel.language', 'en'))); $form->cancel = false; $form->save = l::get('installation.signup.button'); $form->centered = true; foreach (app::languages() as $lang) { $form->fields()->get('language')->options[$lang->code()] = $lang->title(); } $form->on('submit', function ($form) { try { app::$site->users()->create($form->serialize()); go('panel/login/welcome'); } catch (Exception $e) { $form->alert($e->getMessage()); } }); $content = view('installation/signup', array('form' => $form)); } return layout('installation', array('meta' => new Snippet('meta'), 'content' => $content)); }
function __construct($image, $options = array()) { $this->root = c::get('thumb.cache.root', c::get('root') . '/thumbs'); $this->url = c::get('thumb.cache.url', c::get('url') . '/thumbs'); if (!$image) { return false; } $this->obj = $image; // set some values from the image $this->sourceWidth = $this->obj->width(); $this->sourceHeight = $this->obj->height(); $this->width = $this->sourceWidth; $this->height = $this->sourceHeight; $this->source = $this->obj->root(); $this->mime = $this->obj->mime(); // set the max width and height $this->maxWidth = @$options['width']; $this->maxHeight = @$options['height']; // set the quality $this->crop = @$options['crop']; // set the quality $this->quality = a::get($options, 'quality', c::get('thumb.quality', 100)); // set the default upscale behavior $this->upscale = a::get($options, 'upscale', c::get('thumb.upscale', false)); // set the alt text $this->alt = a::get($options, 'alt', $this->obj->name()); // set the className text $this->className = @$options['class']; // set the new size $this->size(); // create the thumbnail $this->create(); }
public function kirbyInstance($options = array()) { c::$data = array(); $kirby = new Kirby($options); $kirby->roots->content = TEST_ROOT_ETC . DS . 'content'; return $kirby; }
function ourl($url = false) { if (!$url) { $url = c::get('url'); } return replace_once('/' . c::get('panel.folder'), '', $url); }
function foo() { a::inFamilya(); a::inFamilyb(); a::notDefined(); c::notAClass(); }
protected function clearCache($path) { $expired = time() - c::get('oembed.cacheexpires', 3600 * 24); if (file_exists($path) and filemtime($path) < $expired) { unlink($path); } }
static function modified($file) { if (!c::get('cache')) { return false; } return @filectime(self::file($file)); }
public function __construct($params = null) { if (isset($params['baseurl'])) { $this->_baseUrl = $params['baseurl']; } else { $this->_baseUrl = c::config()->baseUrl->{c::env()}; } }
static function language() { $root = c::get('root.site') . '/languages'; $default = $root . '/' . c::get('lang.default') . '.php'; $current = $root . '/' . c::get('lang.current') . '.php'; self::file($default); self::file($current); }
public function __construct() { $this->type = 'place'; $this->icon = 'map-marker'; $this->label = l::get('fields.place.label', 'Place'); $this->placeholder = l::get('fields.place.placeholder', 'Address or Location'); $this->map_settings = array('lat' => c::get('place.defaults.lat', 43.9), 'lng' => c::get('place.defaults.lng', -120.2291901), 'zoom' => c::get('place.defaults.zoom', 1)); }
public function __construct($visible) { $this->before = array(); $this->elements = array(); $this->after = array(); $this->visible = $visible; $this->position = c::get('panelbar.position', 'top'); }
function raw($uri = false) { $raw = $uri ? $uri : ltrim(server::get('request_uri'), '/'); // strip subfolders from uri if (c::get('subfolder')) { $raw = ltrim(str_replace(c::get('subfolder') . '/', '/', $raw), '/'); } return $raw; }
function foo() { parent::inAA(); parent::inA(); parent::inB(); parent::inTrait(); parent::nowhere(); c::inC(); }
function foo() { self::inAA(); self::inA(); self::inB(); self::inTrait(); self::nowhere(); c::inC(); }
function foo() { \a::inAA(); \a::inA(); \a::inB(); \a::inTrait(); \a::nowhere(); \c::inC(); }
public function aPublicMethod() { $a = true ? true : false; c::m(); c::$m(); c::$a; c::$a; c::aConstant; }
function foo() { a::inAA(); a::inA(); a::inB(); a::inTrait(); a::nowhere(); c::inC(); }
public function aPublicMethod() { $a = TRUE ? TRUE : FALSE; c::m(); c::$m(); c::$a; c::$a; c::aConstant; }
static function raw($uri = false) { $raw = $uri ? $uri : ltrim(server::get('request_uri'), '/'); // strip subfolders from uri if (c::get('subfolder')) { $raw = ltrim(preg_replace('!^' . preg_quote(c::get('subfolder')) . '\\/!i', '/', $raw), '/'); } return $raw; }
function foo() { static::inAA(); static::inA(); static::inB(); static::inTrait(); static::nowhere(); c::inC(); }
/** * Create a new CrazyMailer * * @var array $config data, accepts same as Email::__construct() */ public function __construct($config) { $defaults = ['to' => KirbyConfig::get('mailer.to'), 'from' => KirbyConfig::get('mailer.from'), 'service' => 'mailgun', 'options' => ['key' => KirbyConfig::get('mailgun.key'), 'domain' => KirbyConfig::get('mailgun.domain')]]; $this->emailer = new KirbyEmailer(KirbyArray::merge($defaults, $config)); $this->enabled = env('MAILER_ENABLED', false); $handler = new StreamHandler(kirby()->roots()->site() . '/../logs/emailer.log', Logger::WARNING); $this->logger = new Logger('crazy'); $this->logger->pushHandler($handler); }