/** * Override startup of the Shell * * @return void */ public function startup() { parent::startup(); if (isset($this->params['connection'])) { $this->connection = $this->params['connection']; } $class = Configure::read('Acl.classname'); if (strpos($class, '\\') === false && strpos($class, '.') === false) { $className = App::classname('Acl.' . $class, 'Adapter'); } else { $className = App::classname($class, 'Adapter'); } if ($class !== 'DbAcl' && !is_subclass_of($className, 'Acl\\Adapter\\DbAcl')) { $out = "--------------------------------------------------\n"; $out .= __d('cake_acl', 'Error: Your current CakePHP configuration is set to an ACL implementation other than DB.') . "\n"; $out .= __d('cake_acl', 'Please change your core config to reflect your decision to use DbAcl before attempting to use this script') . "\n"; $out .= "--------------------------------------------------\n"; $out .= __d('cake_acl', 'Current ACL Classname: {0}', [$class]) . "\n"; $out .= "--------------------------------------------------\n"; $this->err($out); $this->_stop(); } if ($this->command) { if (Configure::check('Datasource') === null) { $this->out(__d('cake_acl', 'Your database configuration was not found. Take a moment to create one.')); $this->args = null; $this->DbConfig->execute(); return; } try { TableRegistry::get('Aros')->schema(); TableRegistry::remove('Aros'); } catch (\Cake\Database\Exception $e) { $this->out(__d('cake_acl', 'Acl database tables not found. To create them, run:')); $this->out(); $this->out(' bin/cake Migrations.migrations migrate -p Acl'); $this->out(); $this->_stop(); return; } $registry = new ComponentRegistry(); $this->Acl = new AclComponent($registry); } }
/** * Constructor * */ public function __construct() { parent::__construct(); if (Configure::check('Acl.cacheConfig')) { $this->_cacheConfig = Configure::read('Acl.cacheConfig'); } }
public function render(array $data, ContextInterface $context) { // debug($data); // debug($this->_templates); $date_data = ['type' => 'text', 'name' => $data['name'] . '__date__', 'id' => $this->get_dom_id($data['name'] . '-date'), 'language' => $data['language'], 'datepicker_format' => $data['datepicker_format'], 'upper_datepicker_id' => isset($data['upper_datepicker_name']) ? $this->get_dom_id($data['upper_datepicker_name'] . '-date') : null, 'upper_datepicker_name' => isset($data['upper_datepicker_name']) ? $data['upper_datepicker_name'] : null, 'format_on_blur' => $data['format_on_blur'], 'alaxos_js_format' => $data['alaxos_js_format'], 'class' => 'form-control inputDate']; // debug($date_data); $time_data = ['type' => 'text', 'name' => $data['name'] . '__time__', 'id' => $this->get_dom_id($data['name'] . '-time'), 'class' => 'form-control inputTime']; $hidden_data = ['type' => 'hidden', 'name' => $data['name'], 'id' => $this->get_dom_id($data['name'] . '-hidden')]; $display_timezone = null; if (Configure::check('display_timezone')) { $display_timezone = Configure::read('display_timezone'); } elseif (Configure::check('default_display_timezone')) { $display_timezone = Configure::read('default_display_timezone'); } /* * Case of posted data */ if (isset($data['val']) && !empty($data['val']) && is_string($data['val'])) { $data['val'] = Time::parse($data['val'], $display_timezone); } if (isset($data['val']) && (is_a($data['val'], 'Cake\\I18n\\Time') || is_a($data['val'], 'Cake\\I18n\\FrozenTime'))) { if (isset($display_timezone)) { $data['val']->setTimezone($display_timezone); //it doesn't change the timezone internally, but it changes the tz used for display } $datetime = $data['val']; $date_data['value'] = $datetime->format($data['php_date_format']); $time_data['value'] = $datetime->format('H:i'); $hidden_data['value'] = $date_data['value'] . ' ' . $time_data['value']; } $input = $this->get_html_code($date_data, $time_data, $hidden_data); $input .= $this->get_js_code($date_data, $time_data, $hidden_data); return $input; }
/** * Gets config values stored in the configuration. * It will first look in the MeCms configuration, then in the application configuration * @param string|null $key Configuration key * @return mixed Configuration value */ function config($key = null) { if ($key !== null && Configure::check(sprintf('MeCms.%s', $key))) { return Configure::read(sprintf('MeCms.%s', $key)); } return Configure::read($key); }
/** * Override startup of the Shell * * @return void */ public function startup() { parent::startup(); if (isset($this->params['connection'])) { $this->connection = $this->params['connection']; } $class = Configure::read('Acl.classname'); $className = App::classname('Acl.' . $class, 'Adapter'); if ($class !== 'DbAcl' && !is_subclass_of($className, 'Acl\\Adapter\\DbAcl')) { $out = "--------------------------------------------------\n"; $out .= __d('cake_acl', 'Error: Your current CakePHP configuration is set to an ACL implementation other than DB.') . "\n"; $out .= __d('cake_acl', 'Please change your core config to reflect your decision to use DbAcl before attempting to use this script') . "\n"; $out .= "--------------------------------------------------\n"; $out .= __d('cake_acl', 'Current ACL Classname: %s', $class) . "\n"; $out .= "--------------------------------------------------\n"; $this->err($out); return $this->_stop(); } if ($this->command) { if (Configure::check('Datasource') === null) { $this->out(__d('cake_acl', 'Your database configuration was not found. Take a moment to create one.')); $this->args = null; return $this->DbConfig->execute(); } if (!in_array($this->command, ['initdb'])) { $registry = new ComponentRegistry(); $this->Acl = new AclComponent($registry); $controller = new Controller(); } } }
/** * Initialization * @return void */ public function initialize() { parent::initialize(); $this->loadComponent('Math'); if (!Configure::check('twitter')) { throw new \LogicException('Configuration Twitter is not defined'); } }
/** * Initialize method * * @param array $config The configuration for the Table. * @return void */ public function initialize(array $config) { $table = Configure::check('CakephpBlueimpUpload.upload_table') ? Configure::read('CakephpBlueimpUpload.upload_table') : 'uploads'; $this->table($table); $this->displayField('id'); $this->primaryKey('id'); $this->addBehavior('Timestamp'); }
function read($key, $default = null) { $ret = $default; if (Configure::check($key)) { $ret = Configure::read($key); } return $ret; }
/** * Index method * * @return void */ public function index() { if (Configure::check('Notifications.default_language')) { $this->NotificationContents->locale(Configure::read('Notifications.default_language')); } else { $this->NotificationContents->locale('eng'); } $this->set('notificationContents', $this->paginate($this->NotificationContents)); }
/** * Creates a Transport instance * * @param array $config transport-specific configuration options */ public function __construct(array $config) { parent::__construct($config); $keys = Configure::read('Notifications.transports.push_message'); if (Configure::check('Notifications.transports.push_message.' . ENVIRONMENT)) { // prefer environment specific config keys $keys = Configure::read('Notifications.transports.push_message.' . ENVIRONMENT); } ParseClient::initialize($keys['app_id'], $keys['rest_key'], $keys['master_key']); }
/** * Display help for this console. * * @return ConsoleOptionParser */ public function getOptionParser() { $file = Runner::ROBOFILE; if (Configure::check('Path.robofile')) { $file = Configure::read('Path.robofile'); } $parser = new ConsoleOptionParser('robot', false); $parser->description('This shell provides a Robo runner.' . "\n\n" . 'You will need to have robo installed for this Shell to work. ')->addOption('config', ['help' => __d('cake_console', 'Path to your RoboFile class'), 'default' => $file]); return $parser; }
/** * @return LoopInterface */ function loopResolver() { if (Configure::check('WyriHaximus.Ratchet.loop') && Configure::read('WyriHaximus.Ratchet.loop') instanceof LoopInterface) { return Configure::read('WyriHaximus.Ratchet.loop'); } if (class_exists('PipingBag\\Di\\PipingBag') && Configure::check('WyriHaximus.Ratchet.pipingbag.loop')) { return PipingBag::get(Configure::read('WyriHaximus.Ratchet.pipingbag.loop')); } return Factory::create(); }
protected function _welcome() { if (!Configure::check('DelayedJobs')) { throw new Exception('Could not load config, check your load settings in bootstrap.php'); } $hostname = php_uname('n'); $this->clear(); $this->out('Hostname: <info>' . $hostname . '</info>'); $this->hr(); }
/** * Event * * @param Event $event event * @return void */ public function beforeFilter(\Cake\Event\Event $event) { $this->loadModel('Notifications.NotificationContents'); if (Configure::check('Notifications.default_language')) { $this->NotificationContents->locale(Configure::read('Notifications.default_language')); } else { $this->NotificationContents->locale('eng'); } parent::beforeFilter($event); }
/** * Asserts that a given key (and value) do not exist in the configuration. * * @param string|array $key Configuration key or array of key/values. * @param mixed $value Value to check for. If `NULL`, checks only key. */ public function dontSeeInConfig($key, $value = null) { if (is_array($key)) { array_walk($key, function ($v, $k) { $this->dontSeeInConfig($k, $v); }); return; } $message = "Unexpectedly managed to find the {$key} config key"; if (is_null($value)) { $this->assertFalse(Configure::check($key), $message); return; } $message .= ' with ' . json_encode($value); $this->assertNotEquals($value, Configure::read($key), $message); }
public function afterForgot($event, $user) { $email = new Email('default'); $resetUrl = ['prefix' => false, 'plugin' => 'Users', 'controller' => 'Users', 'action' => 'reset']; if (Configure::check('Users.resetUrl')) { $resetUrl = Configure::read('Users.resetUrl'); } $resetUrl[] = $user['email']; $resetUrl[] = $user['request_key']; $email->viewVars(['user' => $user, 'resetUrl' => Router::fullBaseUrl() . Router::url($resetUrl), 'baseUrl' => Router::fullBaseUrl(), 'loginUrl' => Router::fullBaseUrl() . '/login']); $email->from(Configure::read('Users.email.from')); $email->subject(Configure::read('Users.email.afterForgot.subject')); $email->emailFormat('both'); $email->transport(Configure::read('Users.email.transport')); $email->template('Users.afterForgot', 'Users.default'); $email->to($user['email']); $email->send(); }
public function to_display_timezone($field) { $table = TableRegistry::get($this->_registryAlias); $fieldtype = $table->schema()->column($field)['type']; $value = $this->get($field); $display_timezone = null; if ($fieldtype == 'datetime') { if (Configure::check('display_timezone')) { $display_timezone = Configure::read('display_timezone'); } elseif (Configure::check('default_display_timezone')) { $display_timezone = Configure::read('default_display_timezone'); } if (!empty($display_timezone) && isset($value) && is_a($value, 'Cake\\I18n\\Time')) { $value->setTimezone($display_timezone); //it doesn't change the timezone internally, but it changes the tz used for display return $value; } else { return $value; } } else { return $value; } }
<?php use Cake\Core\Configure; use Cake\Event\EventManager; use Schema\Shell\Task\SchemaSaveTask; $configKey = 'Schema.autoSaveSchemaAfterMigrate'; if (!Configure::check($configKey) || Configure::read($configKey) === true) { EventManager::instance()->on('Migration.afterMigrate', function () { $task = new SchemaSaveTask(); $task->interactive = false; $task->initialize(); $task->loadTasks(); $task->save(); }); }
/** * Builds a complete set of configuration settings by reading in several config arrays and merging them according to priority * This works by loading the configuration settings first for all emails, then the specific email type, then the email settings itself, and finally giving the testing-mode override and master settings the highest priority * This function supports the deprecated style of declaring the 'specific' email type settings in the Config array, but the preferred method is through an EmailTemplate * @param Entity $email email entity * @return array complete configuration array */ protected function _getConfig(EmailQueue $email) { # get the specific details for the email.type # either from the config file (for backward-compat) or the database if (Configure::check("EmailQueue.specific.{$email->type}")) { $specific = Configure::read('EmailQueue.specific.' . $email->type); # DEPRECATED } else { $specific = $this->EmailTemplates->find()->where(['EmailTemplates.email_type' => $email->type])->first(); if (!$specific) { throw new RecordNotFoundException("Cannot find config template for EmailQueue type '{$email->type}' anywhere."); } $specific = $specific->toArray(); } # merge all the configs into one final complete array $config = Hash::merge($this->_configDefault, $specific, $email->toArray(), $this->_configOverride, $this->_configMaster); # return a useable config array return $this->_formatConfig($config); }
/** * testCheckEmpty * * @return void */ public function testCheckEmpty() { $this->assertFalse(Configure::check('')); $this->assertFalse(Configure::check(null)); }
/** * */ public function initialize() { parent::initialize(); /** * Set copyright from Builder configs */ $copyright = Configure::check('Builder.copyright') ? Configure::read('Builder.copyright') : '[Builder.copyright]'; $this->assign('copyright', $copyright); /** * Set name from Builder configs */ $name = Configure::check('Builder.name') ? Configure::read('Builder.name') : '[Builder.name]'; $this->assign('name', $name); /** * Use Builder Helpers */ $this->loadHelper('Flash', ['className' => 'Builder.Flash']); /** * Set default layout for App using Layout/default */ if ($this->layout === 'default') { $this->layout('Builder.default'); } /** * Set form templates */ $_templates = ['dateWidget' => '<ul class="list-inline"><li class="year">{{year}}</li><li class="month">{{month}}</li><li class="day">{{day}}</li><li class="hour">{{hour}}</li><li class="minute">{{minute}}</li><li class="second">{{second}}</li><li class="meridian">{{meridian}}</li></ul>', 'error' => '<div class="help-block">{{content}}</div>', 'help' => '<div class="help-block">{{content}}</div>', 'inputContainer' => '<div class="form-group {{type}}{{required}}">{{content}}{{help}}</div>', 'inputContainerError' => '<div class="form-group {{type}}{{required}} has-error">{{content}}{{error}}{{help}}</div>', 'checkboxWrapper' => '<div class="checkbox"><label>{{input}}{{label}}</label></div>', 'multipleCheckboxWrapper' => '<div class="checkbox">{{label}}</div>', 'radioInlineFormGroup' => '{{label}}<div class="radio-inline-wrapper">{{input}}</div>', 'radioNestingLabel' => '<div class="radio">{{hidden}}<label{{attrs}}>{{input}}{{text}}</label></div>', 'staticControl' => '<p class="form-control-static">{{content}}</p>', 'inputGroupAddon' => '<span class="{{class}}">{{content}}</span>', 'inputGroupContainer' => '<div class="input-group">{{prepend}}{{content}}{{append}}</div>', 'input' => '<input class="form-control" type="{{type}}" name="{{name}}"{{attrs}}/>', 'textarea' => '<textarea class="form-control" name="{{name}}"{{attrs}}>{{value}}</textarea>', 'select' => '<select class="form-control" name="{{name}}"{{attrs}}>{{content}}</select>', 'selectMultiple' => '<select class="form-control" name="{{name}}[]" multiple="multiple"{{attrs}}>{{content}}</select>']; /** * */ $this->Form->templates($_templates); /** * Loader base styles using bower_components and default Builder settings */ $this->start('builder-css'); echo $this->Html->css(['/builder/bower_components/jquery-ui/themes/smoothness/jquery-ui.min.css', '/builder/bower_components/bootstrap/dist/css/bootstrap.min.css', '/builder/bower_components/fontawesome/css/font-awesome.min.css', '/builder/bower_components/datatables/media/css/dataTables.bootstrap.min.css', '/builder/bower_components/summernote/dist/summernote.css', '/builder/css/base.css']); $this->end(); /** * Laoder base scripts using bower_components and default Builder settings */ $this->start('builder-script'); echo $this->Html->script(['/builder/bower_components/jquery/dist/jquery.min.js', '/builder/bower_components/jquery-ui/jquery-ui.min.js', '/builder/bower_components/bootstrap/dist/js/bootstrap.min.js', '/builder/bower_components/datatables/media/js/jquery.dataTables.min.js', '/builder/bower_components/datatables/media/js/dataTables.bootstrap.js', '/builder/bower_components/summernote/dist/summernote.min.js', '/builder/js/base.js']); $this->end(); /** * Load Builder default constructor element form Builder/Element/Constructor */ $this->prepend('builder-element', $this->element('Builder.Constructor/default')); /** * If empty 'nav' block, set default navbar using Builder/Element */ if (!$this->fetch('nav')) { $this->assign('nav', $this->element('Builder.navbar-fixed-top')); } /** * If empty 'breadcrumb' block, set default breadcrumb using Builder/Element */ if (!$this->fetch('breadcrumb')) { $this->assign('breadcrumb', $this->element('Builder.breadcrumb')); } /** * Set default title for layout using controller name */ $this->assign('title', Inflector::humanize(Inflector::tableize($this->request->controller))); }
protected function url($options, $full = true) { if (!Configure::check('isLanguageByDomain')) { $options['language'] = $this->language; } return Router::url($options, $full); }
/** * Add reCaptcha to the form * @return mixed */ public function addReCaptcha() { if (!Configure::check('Users.Registration.reCaptcha')) { return false; } $this->Form->unlockField('g-recaptcha-response'); return $this->Html->tag('div', '', ['class' => 'g-recaptcha', 'data-sitekey' => Configure::read('reCaptcha.key')]); }
/** * @return array */ protected function readConfig() { if (!Configure::check(static::ENV_CONFIG)) { return []; } $config = Configure::read(static::ENV_CONFIG); if (!is_array($config)) { return []; } return $config; }
/** * Load configuration. * * If 'CakeResque' configuration key is not set, the default configuration is loaded. * * @param array $config Configuration options. * @return void */ public static function loadConfig($config = null) { if ($config !== null) { Configure::write('CakeResque', $config); } if (($hasCheck = method_exists('Configure', 'check')) && !Configure::check('CakeResque') || !$hasCheck && !self::checkConfig('CakeResque')) { Configure::load('CakeResque.config'); } }
<?php use Cake\Core\Configure; if (!Configure::check('PayPalIpn')) { Configure::load('PaypalIpn.paypal_ipn'); }
*/ Type::build('time')->useImmutable(); Type::build('date')->useImmutable(); Type::build('datetime')->useImmutable(); /** * Bootstrap & load Site plugin */ $Request = Request::createFromGlobals(); $url = explode('/', $Request->url); $website_dir = 'websites'; $website_default = 'default'; $website_name = trim($url[0]) != '' ? trim($url[0]) : $website_default; $website_fullpath = ROOT . DS . $website_dir . DS . $website_name . DS; if (file_exists($website_fullpath)) { $plugins = []; if (Configure::check(['plugins'])) { $plugins = Configure::read(['plugins']); } $plugins['Site'] = $website_fullpath; Configure::write('plugins', $plugins); // Define default Site variables define('APP_WEBROOT', $Request->webroot); define('APP_BASE_URL', $Request->base); define('WEBSITE_BASE_URL', $Request->webroot . '/' . $website_dir); define('SITE_NAME', $website_name); define('SITE_FULLPATH', $website_fullpath); define('SITE_BASE_URL', WEBSITE_BASE_URL . '/' . $website_name); // Load the appropriate Site plugin Plugin::load('Site', ['autoload' => true, 'bootstrap' => true, 'routes' => true]); } /**
<?php use Cake\Core\Configure; if (!Configure::check('WyriHaximus.MinifyHtml.factory')) { Configure::write('WyriHaximus.MinifyHtml.factory', 'WyriHaximus\\HtmlCompress\\Factory::constructFastest'); }
/** * Will load all the plugins located in the default plugin folder. * * If passed an options array, it will be used as a common default for all plugins to be loaded * It is possible to set specific defaults for each plugins in the options array. Examples: * * ``` * Plugin::loadAll([ * ['bootstrap' => true], * 'DebugKit' => ['routes' => true], * ]); * ``` * * The above example will load the bootstrap file for all plugins, but for DebugKit it will only load the routes file * and will not look for any bootstrap script. * * If a plugin has been loaded already, it will not be reloaded by loadAll(). * * @param array $options Options. * @return void */ public static function loadAll(array $options = []) { static::_loadConfig(); $plugins = []; foreach (App::path('Plugin') as $path) { if (!is_dir($path)) { continue; } $dir = new DirectoryIterator($path); foreach ($dir as $path) { if ($path->isDir() && !$path->isDot()) { $plugins[] = $path->getBaseName(); } } } if (Configure::check('plugins')) { $plugins = array_merge($plugins, array_keys(Configure::read('plugins'))); $plugins = array_unique($plugins); } foreach ($plugins as $p) { $opts = isset($options[$p]) ? $options[$p] : null; if ($opts === null && isset($options[0])) { $opts = $options[0]; } if (isset(static::$_plugins[$p])) { continue; } static::load($p, (array) $opts); } }
use Cake\Utility\Inflector; use Spider\Event\SpiderEventManager; use Spider\Lib\SpiderPlugin; use Spider\Lib\Spider; use Cake\Core\Plugin; //(new EventManager())->dispatch('Spider.bootstrap.start'); // //if (!Configure::check('Spider.installed')) { // return Plugin::load('Install', ['bootstrap' => true, 'routes' => true, 'autoload' => true]); //} /** * List of core plugins */ $corePlugins = ['Spider/Settings', 'Spider/AclManager', 'Spider/PluginManager', 'Spider/Users', 'Spider/Search']; Configure::write('Core.corePlugins', $corePlugins); if (!Configure::check('Hook.plugins')) { Configure::write('Hook.plugins', Configure::read('Core.corePlugins')); } $plugins = Spider::mergeConfig('Hook.plugins', \Cake\Utility\Hash::extract(SpiderPlugin::getPlugins(), '{n}.name')); //Configure::read('App.paths.plugins'); foreach ($plugins as $plugin) { $pluginName = Inflector::camelize($plugin); $pluginPath = APP . 'plugins' . DS . $pluginName; if (!file_exists($pluginPath) && strpos($pluginName, 'Spider/') === false) { $pluginFound = false; foreach (App::path('Plugin') as $path) { if (is_dir($path . $pluginName)) { $pluginFound = true; break; } }