/** * Object initializer. Adds a content handler for the `wrap` key in the `field()` method, which * converts an array of properties to an attribute string. * * @return void */ protected function _init() { parent::_init(); if ($this->_context) { $this->_context->handlers(array('wrap' => '_attributes')); } }
public function _init() { parent::_init(); $this->_config = Libraries::get('li3_frontender'); $defaults = array('compress' => false, 'assets_root' => LITHIUM_APP_PATH . "/webroot", 'production' => Environment::get() == 'production', 'locations' => array('node' => '/usr/bin/node', 'coffee' => '/usr/bin/coffee')); $this->_config += $defaults; $this->_production = $this->_config['production']; // remove extra slash if it was included in the library config $this->_config['assets_root'] = substr($this->_config['assets_root'], -1) == "/" ? substr($this->_config['assets_root'], 0, -1) : $this->_config['assets_root']; $this->_paths['styles'] = $this->_config['assets_root'] . "/css/"; $this->_paths['scripts'] = $this->_config['assets_root'] . "/js/"; }
/** * Initializes helpers when used in a layout */ public function _init() { parent::_init(); // Force helper static configuration if (!static::$config) { static::config(); } $this->styleAssetCollection = new AssetCollection(); $this->styleAssetManager = new AssetManager(); // Initialize static assets writer $this->styleAssetWriter = new AssetWriter(static::$config['stylesPath']); $this->scriptAssetCollection = new AssetCollection(); $this->scriptAssetManager = new AssetManager(); // Initialize static assets writer $this->scriptAssetWriter = new AssetWriter(static::$config['scriptsPath']); // If we wanted to tap-into li3's generic helpers, that would be the way to achieve it using filters /*$this->_context->helper('html')->applyFilter('style', function($self, $params, $chain) { $params['path'] = $this->processParams($params['path'], $params['options']); $result = $chain->next($self, $params, $chain); return $result; });*/ }
public function _init() { $this->_sections = Trackers::get(); parent::_init(); }
/** * Initializes the new instance of the Pagination class. * * Called immediately after construction, used to setup the new class with default values gathered from the current * _context. * * @see \lithium\template\View::_renderer */ protected function _init() { parent::_init(); $this->_request = $this->_context->_config['request']; // If there is only one compatible records set in the view, we catch it if (!empty($this->_context->_config['data'])) { $document = null; foreach ($this->_context->_config['data'] as $key => $value) { if ($value instanceof PaginableSet) { // More than one : we cannot do this automatically if (isset($document)) { unset($document); break; } else { $document = $value; } } } $this->_documents = $document; } }
public function _init() { parent::_init(); $this->_pdf = new $this->_classes['pdf'](PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); }
protected function _init() { parent::_init(); $this->_pdf = new $this->_classes['pdf']($this->orientation, $this->unit, $this->format, $this->unicode, $this->encoding, $this->diskcache, $this->pdfa); }
/** * Initialisation : remember the current request. */ public function _init() { parent::_init(); $this->request = $this->_context ? $this->_context->request() : null; }
/** * Initializes the new instance of the Paginator class. * * Called immediately after construction, used to setup the new class with default values gathered from the current * _context. * * @see li3_paginate\extensions\helper\Paginator::__construct() * @see \lithium\template\View::_renderer */ protected function _init() { parent::_init(); // setting up the _config array for use in links etc. with our string templates $this->_library = isset($this->_context->_config['request']->params['library']) ? $this->_context->_config['request']->params['library'] : null; $this->_controller = $this->_context->_config['request']->params['controller']; $this->_action = $this->_context->_config['request']->params['action']; $this->_page = $this->_context->_config['data']['page'] + 0 ?: 1; $this->_total = $this->_context->_config['data']['total']; $this->_limit = $this->_context->_config['data']['limit']; }
/** * initialize and check for scaffold data * */ protected function _init() { if ($this->_engine) { return; } parent::_init(); $this->_engine = new Engine(); $context = $this->_context; $this->addHelper('page', function ($a, $b, $c, $d) use($context) { return $context->page->get($c); }); $this->addHelper('content', function ($a, $b, $c, $d) use($context) { return $context->content->get($c); }); $this->addHelper('gravatar', function ($a, $b, $c, $d) use($context) { return 'http://www.gravatar.com/avatar/' . md5($b->get($c)) . '.jpg'; }); $this->addHelper('url', function ($a, $b, $c, $d) use($context) { return $context->url($c); }); $this->addHelper('number_format', function ($a, $b, $c, $d) { $params = explode(' ', $c, 4); $params += array(null, 2, '.', ','); $params[0] = $b->get($params[0]); return call_user_func_array('number_format', $params); }); $this->addHelper('colorlabel', function ($a, $b, $c, $d) use($context) { $useClass = array('active', 'inactive', 'online', 'offline'); $text = $b->get($c); if (in_array($text, $useClass)) { $html = '<span class="label label-primary label-%s">%s</span>'; return sprintf($html, $text, $text); } $bgcolor = substr(dechex(crc32($text)), 0, 6); $c_r = hexdec(substr($bgcolor, 0, 2)); $c_g = hexdec(substr($bgcolor, 2, 2)); $c_b = hexdec(substr($bgcolor, 4, 2)); $lightness = ($c_r * 299 + $c_g * 587 + $c_b * 114) / 1000; $txcolor = $lightness > 200 ? '666666' : 'ffffff'; $html = '<span class="label label-primary" style="background-color: #%s; color: #%s">%s</span>'; return sprintf($html, $bgcolor, $txcolor, $text); }); $this->addHelper('muted_if_comment', function ($a, $b, $c, $d) { if (substr($b->get($c), 0, 2) == '//' || substr($b->get($c), 0, 2) == '/*') { return ' class=text-muted'; } return ''; }); $this->addHelper('scaffold', function ($a, $b, $c, $d) use($context) { if (isset($context->scaffold->{$c}) && is_callable(array($context->scaffold->{$c}, '\\lithium\\data\\Collection'))) { return $context->scaffold->{$c}->data(); } if (isset($context->scaffold->{$c})) { return $context->scaffold->{$c}; } return $context->scaffold->{$c}; }); $this->addHelper('date_time', function ($a, $b, $c, $d) use($context) { list($format, $field) = str_getcsv($c, ' '); return date(defined($format) ? constant($format) : $format, $b->get($field)); }); }
/** * initialize and check for scaffold data * */ protected function _init() { parent::_init(); $this->_scaffold = Environment::get('scaffold'); $this->_data = $this->_context->data(); if (!$this->_scaffold) { return; } $actions = call_user_func(array($this->_scaffold['model'], 'actions')); if (isset($this->_data['object'])) { $this->_scaffold['object'] = $this->_data['object']; $this->_scaffold['actions'] = $actions['first']; } if (isset($this->_data['objects'])) { $this->_scaffold['objects'] = $this->_data['objects']; $this->_scaffold['actions'] = $actions['all']; } }
/** * Initializes the new instance of the Paginator class. * * Called immediately after construction, used to setup the new class with default values gathered from the current * _context. * * @see li3_paginate\extensions\helper\Paginator::__construct() * @see \lithium\template\View::_renderer */ protected function _init() { parent::_init(); $this->_url = array( 'library' => $this->_context->_config['request']->params['library'], 'controller' => $this->_context->_config['request']->params['controller'], 'action' => $this->_context->_config['request']->params['action'] ); $this->_page = ($this->_context->_config['data']['page'] + 0) ?: 1; $this->_total = $this->_context->_config['data']['total']; $this->_limit = $this->_context->_config['data']['limit']; }
/** * Imports page from request object, if available * * @return void */ protected function _init() { parent::_init(); $this->_page = $this->_context->request()->page ?: null; }