get() 정적인 공개 메소드

Gets a config value by key
static public get ( string $key = null, mixed $default = null ) : mixed
$key string The key to look for. Pass false to get the entire config array
$default mixed The default value, which will be returned if the key has not been found
리턴 mixed The found config value
예제 #1
0
 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));
 }
예제 #2
0
 /**
  * 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;
     }
 }
예제 #3
0
/**
 *  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;
}
예제 #4
0
 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();
 }
예제 #5
0
 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;
 }
예제 #6
0
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;
}
예제 #7
0
 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));
 }
예제 #8
0
function ourl($url = false)
{
    if (!$url) {
        $url = c::get('url');
    }
    return replace_once('/' . c::get('panel.folder'), '', $url);
}
예제 #9
0
 protected function clearCache($path)
 {
     $expired = time() - c::get('oembed.cacheexpires', 3600 * 24);
     if (file_exists($path) and filemtime($path) < $expired) {
         unlink($path);
     }
 }
예제 #10
0
파일: 720.php 프로젝트: badlamer/hhvm
function main()
{
    set_error_handler('error_handler');
    $c = new c(false);
    $c->get();
    echo "Error\n";
}
예제 #11
0
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;
                }
            }
        }
    }
}
예제 #12
0
 static function modified($file)
 {
     if (!c::get('cache')) {
         return false;
     }
     return @filectime(self::file($file));
 }
예제 #13
0
 /**
  * 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();
 }
예제 #14
0
파일: output.php 프로젝트: dmak78/panel-bar
 public function __construct($visible)
 {
     $this->before = array();
     $this->elements = array();
     $this->after = array();
     $this->visible = $visible;
     $this->position = c::get('panelbar.position', 'top');
 }
예제 #15
0
 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);
 }
예제 #16
0
 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));
 }
예제 #17
0
파일: uri.php 프로젝트: narrenfrei/kirbycms
 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;
 }
예제 #18
0
 /**
  * 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);
 }
예제 #19
0
 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;
 }
예제 #20
0
파일: Twig.php 프로젝트: evendev/grg
 /**
  * Load Twig
  */
 private function twig()
 {
     $loader = new Twig_Loader_Filesystem(kirby()->roots()->twig());
     $twig = new Twig_Environment($loader, array('debug' => c::get('debug')));
     if (c::get('debug')) {
         $twig->addExtension(new Twig_Extension_Debug());
     }
     tpl::set('twig', $twig);
 }
예제 #21
0
 public static function embed($Media, $autoplay)
 {
     $Multiplayer = new Multiplayer();
     $defaults = array('autoPlay' => $autoplay or c::get('oembed.lazyvideo', false), 'showInfos' => false, 'showBranding' => false, 'showRelated' => false);
     $embed = $Multiplayer->html($Media->get('url'), $defaults);
     if (c::get('oembed.lazyvideo', false)) {
         $embed = str_replace(' src="', ' data-src="', $embed);
     }
     return $embed;
 }
예제 #22
0
 function get($key = '_global')
 {
     if (c::get('timer') === false) {
         return false;
     }
     $time = explode(' ', microtime());
     $time = (double) $time[1] + (double) $time[0];
     $timer = a::get(self::$timer, $key);
     return round($time - $timer, 5);
 }
예제 #23
0
 public static function options($keys)
 {
     $options = array();
     foreach ($keys as $key) {
         if (c::get('splitview.' . $key) !== null) {
             $options[$key] = c::get('splitview.' . $key);
         }
     }
     return $options;
 }
예제 #24
0
파일: CTest.php 프로젝트: LucasFyl/korakia
 public function testSet()
 {
     c::set('anothervar', 'anothervalue');
     c::set('testvar', 'overwrittenvalue');
     $this->assertEquals('anothervalue', c::get('anothervar'));
     $this->assertEquals('overwrittenvalue', c::get('testvar'));
     c::set(array('var1' => 'value1', 'var2' => 'value2'));
     $this->assertEquals('value1', c::get('var1'));
     $this->assertEquals('value2', c::get('var2'));
 }
 function sublime($params)
 {
     global $site;
     $page = $this->obj;
     $id = @$params['sublime'];
     $class = @$params['class'];
     $videos = array();
     $poster = false;
     // gather all video files which match the given id/name
     foreach ($page->videos() as $v) {
         if (preg_match('!^' . preg_quote($id) . '!i', $v->name())) {
             $extension = f::extension($v->name());
             $mobile = $extension == 'mobile' ? $v->mobile = true : ($v->mobile = false);
             $hd = $extension == 'hd' ? $v->hd = true : ($v->hd = false);
             $videos[] = $v;
         }
     }
     if (empty($videos)) {
         return false;
     }
     // find the poster for this video
     foreach ($page->images() as $i) {
         if (preg_match('!^' . preg_quote($id) . '!i', $i->name())) {
             $poster = $i;
             break;
         }
     }
     $defaults = array('uid' => $id, 'name' => $id);
     $options = array_merge($defaults, $params);
     $width = html($options['width']);
     $height = html($options['height']);
     $uid = html($options['uid']);
     $name = html($options['name']);
     if (!$width) {
         $width = c::get('kirbytext.video.width');
     }
     if (!$height) {
         $height = c::get('kirbytext.video.height');
     }
     // create an additional css class if specified
     if (!empty($class)) {
         $class = ' ' . html($class);
     }
     // check for a poster
     $poster = $poster ? ' poster="' . $poster->url() . '"' : false;
     $html = '<video class="sublime' . $class . '"' . $poster . ' width="' . $width . '" height="' . $height . '" data-uid="' . $uid . '" data-name="' . $name . '" preload="none">';
     foreach ($videos as $video) {
         // check for hd quality
         $hd = $video->hd() ? ' data-quality="hd"' : '';
         // generate the source tag for each video
         $html .= '<source src="' . $video->url() . '"' . $hd . ' />';
     }
     $html .= '</video>';
     return $html;
 }
예제 #26
0
 /**
  * (Re)connect the database
  *
  * @param mixed $params Pass array() to use the default params from the config
  * @return object
  */
 public static function connect($params = null)
 {
     if (is_null($params) && !is_null(static::$connection)) {
         return static::$connection;
     }
     if (is_null($params)) {
         // try to connect with the default connection settings
         $params = array('type' => c::get('db.type', 'mysql'), 'host' => c::get('db.host', 'localhost'), 'user' => c::get('db.user', 'root'), 'password' => c::get('db.password', ''), 'database' => c::get('db.name', ''), 'prefix' => c::get('db.prefix', ''));
     }
     return static::$connection = new Database($params);
 }
예제 #27
0
function run($page)
{
    $templates = c::get('autopublish.templates', array('project', 'item'));
    if (!$templates || in_array($page->template(), $templates)) {
        try {
            $page->toggle('last');
        } catch (Exception $e) {
            return response::error($e->getMessage());
        }
    }
}
예제 #28
0
파일: load.php 프로젝트: 04x10/04x10.com
 static function parsers()
 {
     $root = c::get('root.parsers');
     require_once $root . '/defaults.php';
     require_once $root . '/yaml.php';
     require_once $root . '/kirbytext.php';
     if (c::get('markdown.extra')) {
         require_once $root . '/markdown.extra.php';
     } else {
         require_once $root . '/markdown.php';
     }
 }
예제 #29
0
 function load($template = 'default', $vars = array(), $return = false)
 {
     $file = c::get('tpl.root') . '/' . $template . '.php';
     if (!file_exists($file)) {
         return false;
     }
     @extract(self::$vars);
     @extract($vars);
     content::start();
     require $file;
     return content::end($return);
 }
예제 #30
0
 static function language()
 {
     global $panel;
     $lang = $panel->user->language ? $panel->user->language : c::get('panel.language');
     $root = c::get('root.panel');
     $file = $root . '/languages/' . $lang . '.php';
     // load the fallback language
     require_once $root . '/languages/en.php';
     if ($lang && $lang != 'en' && file_exists($file)) {
         require_once $file;
     }
 }