public function load() { if (Cache::read('qe.dbconfig_' . hash("md5", "qe_dbconfig"), QEResp::QUICK_EMAILER_CACHE)) { return true; } if (Configure::check('qe.dbconfig')) { if (!file_exists(APP . 'Config' . DS . 'database.php')) { return QEResp::RESPOND(QEResp::ERROR, QuickEmailerErrorDefinitions::NO_DATABASE_CONFIGURED()); } try { $datasource = ConnectionManager::getDataSource(Configure::read('qe.dbconfig')); if ($datasource->connected) { $this->CheckTables($datasource); Cache::write('qe.dbconfig_' . hash("md5", "qe_dbconfig"), true, QEResp::QUICK_EMAILER_CACHE); return true; } return QEResp::RESPOND(QEResp::ERROR, QuickEmailerErrorDefinitions::NO_DATABASE_CONFIGURED()); } catch (Exception $e) { $excep_message = QuickEmailerResponseHandler::AddExceptionInfo(QuickEmailerErrorDefinitions::NO_DATABASE_CONFIGURED(), $e); //TODO: Log errors return QEResp::RESPOND(QEResp::ERROR, $excep_message); } } else { return QEResp::RESPOND(QEResp::ERROR, QuickEmailerErrorDefinitions::NO_DATABASE_CONFIGURED()); } }
/** * Set config * @param array $config */ private function _setConfig(array $config) { if (Configure::check('MediaPost')) { $config = array_merge($config, Configure::read('MediaPost')); } $this->config = $config; }
protected function loadTwitter() { if (isset($this->Twitter)) { if ($this->Twitter) { return $this->Twitter; } } if (!class_exists('Endroid\\Twitter\\Twitter')) { App::uses('endroid/twitter/src/endroid/twitter', 'Vendor'); } if (!class_exists('Endroid\\Twitter\\Twitter')) { return false; } if (!is_file(APP . DS . 'Config' . DS . 'twitter.php')) { return false; } if (!Configure::load('twitter')) { return false; } if (!Configure::check('Twitter')) { return false; } $settings = Configure::read('Twitter'); if (empty($settings)) { return false; } extract($settings); $this->controller->Twitter = new Endroid\Twitter\Twitter($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret); return $this->controller->Twitter ?: !$this->log(array("InitializeComponent->twitter" => array('request->here' => $this->controller->request->here, 'request->params' => $this->controller->request->params) + compact('settings')), 'debug'); }
/** * Scans SVN for changes, and queues those plugins for update and refresh. * * @return int Shell return code. */ function main() { $max = 100; if (isset($this->args[0]) && is_numeric($this->args[0]) && $this->args[0] > 0) { $max = (int) $this->args[0]; } $this->out(__('Checking latest revision from SVN...')); $latest_revision = $this->_getLatestRevision(); if (!Configure::check('App.svn_revision')) { $this->out(__('<info>First update detected, skipping to revision %d.</info>', $latest_revision)); $this->Setting->write('App.svn_revision', $latest_revision); $this->_unlock(); return 0; } $revision = Configure::read('App.svn_revision'); $last_revision = $revision + $max; if ($last_revision > $latest_revision) { $last_revision = $latest_revision; } if ($revision == $latest_revision) { $this->out(__('<info>No new changes, finished scanning.</info>')); $this->_unlock(); return 0; } $this->out(__('Scanning SVN revisions %d through %d...', $revision, $last_revision)); $plugin_slugs = $this->_getModifiedPlugins($revision, $last_revision); $this->_refreshPlugins($plugin_slugs); $this->_updatePlugins($plugin_slugs); $this->out(__('<info>Finished scanning.</info>')); $this->Setting->write('App.svn_revision', $last_revision); $this->_unlock(); return 0; }
public function __construct(View $View, $settings = array()) { if (!Configure::check('Ipay')) { throw new NotFoundException('Ipay config is not found'); } $this->config = Configure::read('Ipay'); parent::__construct($View, $settings); }
/** * {@inheritdoc} */ public function send($content, array $records) { $email = 'CakeEmail'; if (Configure::check('Email.classname')) { $email = Configure::read('Email.classname'); } $email::deliver($this->_to, $this->_subject, $content, $this->_config); }
protected function _checkComplete() { if (!Configure::check('Users.data')) { $this->setErrorMessage(__('Users configure settings is absent')); return true; } return false; }
/** * 名前をキーとしてインスタンスを探す * * @param string $name 名前 * @return BcAbstractDetector|null */ public static function find($name) { $key = static::$_configName . ".{$name}"; if (!Configure::check($key)) { return null; } return new static($name, Configure::read($key)); }
public function getConfig() { $key = 'Socialites.Providers.' . $this->_providerId; if (Configure::check($key)) { return Configure::read($key); } return false; }
/** * Constructor * * @return ProPayProcessor */ public function __construct() { $url = 'http://protectpaytest.propay.com/api/sps.svc?wsdl'; if (Configure::check('ProPay.wsdlUrl')) { $url = Configure::read('ProPay.wsdlUrl'); } $this->initialize(new SPS(array(), $url), new ID(Configure::read('ProPay.authenticationToken'), Configure::read('ProPay.billerAccountId'))); }
/** * 名前をキーとしてインスタンスを探す * * @param string $name 名前 * @return BcAgent|null */ public static function find($name) { $key = "BcAgent.{$name}"; if (!Configure::check($key)) { return null; } return new static($name, Configure::read($key)); }
/** * Checks wether given $path is deletable * * A file is deleteable when it resides under directories registered in * FileManager.deletablePaths * * @param string $path Path to check * @return boolean true when file is deletable */ public function isDeletable($path) { $deletablePaths = Configure::check('FileManager.deletablePaths') ? Configure::read('FileManager.deletablePaths') : array(); foreach ($deletablePaths as $deletablePath) { if ($this->_isWithinPath($deletablePath, $path)) { return true; } } return false; }
/** * Initialize the configuration * * Priority: env(WAKATIME_API_KEY) > config('wakatime.api_key') * @throws InvalidArgumentException if no WakaTime API key is detected. * @see WakaTimeComponent::initialize() * @return void */ public function init() { if (getenv('WAKATIME_API_KEY')) { $this->WakaTime->setApiKey(getenv('WAKATIME_API_KEY')); } elseif (Configure::check('wakatime.api_key')) { $this->WakaTime->setApiKey(Configure::read('wakatime.api_key')); } else { throw new InvalidArgumentException('WakaTime config file required for tests.'); } }
/** * List of themes */ public function admin_index() { $this->set('title_for_layout', __d('hurad', 'Themes')); $currentTheme = array(); $themes = HuradTheme::getThemeData(); $current = Configure::read('template'); if (Configure::check('template') && !empty($current)) { $currentTheme = $themes[Configure::read('template')]; } $this->set(compact('themes', 'currentTheme')); }
/** * Return configured main image resize attributes * @return array */ public function getResizeToSize() { $width = $height = 0; if (Configure::check('GalleryOptions.Pictures.resize_to.0')) { $width = Configure::read('GalleryOptions.Pictures.resize_to.0'); } if (Configure::check('GalleryOptions.Pictures.resize_to.1')) { $height = Configure::read('GalleryOptions.Pictures.resize_to.1'); } $crop = Configure::read('GalleryOptions.Pictures.resize_to.2'); $action = $crop ? "crop" : ""; return array('width' => $width, 'height' => $height, 'action' => $action); }
/** * Overrides initialize * * Overrides applied before the controller’s beforeFilter method. * * @param Controller $controller * @return boolean|void */ public function initialize(Controller $controller) { parent::initialize($controller); $settings = $this->settings; if (isset($settings['api_key'])) { $this->WakaTime->setApiKey($settings['api_key']); } elseif (Configure::check('wakatime.api_key')) { $this->WakaTime->setApiKey(Configure::read('wakatime.api_key')); } else { throw new InvalidArgumentException('WakaTime API key is required.'); } return true; }
/** * Put webmaster tools config on header * * @param CakeEvent $event Represents the transport class of events across the system. * * @return string */ public function putWebmasterToolsConfigOnHeader(CakeEvent $event) { $router = Router::getParams(); if ($router['controller'] == 'posts' && $router['action'] == 'index') { $meta = []; if (Configure::check('HuradSeo')) { $verification = Configure::read('HuradSeo.google_webmaster_verification'); if (Configure::check('HuradSeo.google_webmaster_verification') && !empty($verification)) { $meta[] = $event->subject()->Html->meta(['name' => 'google-site-verification', 'content' => $verification]); } } echo implode("\n", $meta); } }
public static function __getcrudMapping($module, $name) { if (!$module) { $module = 'Core'; } if (Configure::check('CrudMapping.' . ucfirst($module))) { foreach (Configure::read('CrudMapping.' . ucfirst($module)) as $val) { if (strtolower($val['c']) == strtolower($name)) { return $val['a']; } } } return array(); }
public function listaeventos($idcalendario) { if (Configure::check('GC_email') && Configure::check('GC_keyfile')) { //Google Calendar $horario = Configure::read('datosevento.horario'); $temp = array(); foreach ($horario as $k => $v) { $temp[$k] = strtotime($k); } return $this->_GC_getEventlist($this->_GC_getService(), $idcalendario); } else { //Sin calendario externo return array(); } }
/** * List of posts */ public function index() { if ($this->RequestHandler->isRss()) { $posts = $this->Post->find('all', array('limit' => 20, 'order' => 'Post.created DESC', 'conditions' => array('Post.status' => Post::STATUS_PUBLISH, 'Post.type' => 'post'))); $this->set(compact('posts')); } else { if (Configure::check('Read.show_posts_per_page')) { $limit = Configure::read('Read.show_posts_per_page'); } else { $limit = 5; } $this->Paginator->settings = Hash::merge($this->paginate, ['Post' => ['conditions' => ['Post.status' => Post::STATUS_PUBLISH], 'limit' => $limit, 'contain' => ['Category', 'User', 'Tag', 'Comment'], 'order' => ['Post.sticky' => 'DESC']]]); $this->set('posts', $this->Paginator->paginate('Post')); } }
/** * returns the url to the image * * @param $path - string - path to the image file * @param $timthumbOptions - array - options for modifying the image * @return string - url for the image with added query string parameters */ private function getTimthumbImageUrl($path, $timthumbOptions = array()) { $action = '/timthumb'; $basePath = Configure::read('TimthumbBasePath'); if (empty($path) || !file_exists($basePath . $path) && Configure::check('TimthumbDefaultImg')) { $path = Configure::read('TimthumbDefaultImg'); } $webBase = $this->request->base; if (Configure::read('App.baseUrl') && strlen($webBase) > 0) { $lastPart = strrpos($webBase, '/'); $webBase = substr($webBase, 0, $lastPart); } $timthumbOptions = array_merge(array('src' => $webBase . $basePath . $path), $this->_defaults, $timthumbOptions); $url = $this->Html->url(array('controller' => 'timthumb', 'action' => 'image', '?' => $this->getOptionQueryString($timthumbOptions)), true); return $url; }
public function __construct() { $aws = Configure::read('Session.handler.aws'); $dynamoDB = $aws->get('dynamodb'); $config = array('dynamodb_client' => $dynamoDB, 'session_lifetime' => Configure::read('Session.timeout') * 60, 'table_name' => DynamoDBSession::DEFAULT_TABLE_NAME, 'locking_strategy' => 'pessimistic'); if (Configure::check('Session.handler.table_name')) { $config['table_name'] = Configure::read('Session.handler.table_name'); } if (Configure::check('Session.handler.locking_strategy')) { $config['locking_strategy'] = Configure::read('Session.handler.locking_strategy'); } $this->_sessionHandler = SessionHandler::factory($config); if (Configure::check('Session.handler.session_name')) { $this->_sessionName = Configure::read('Session.handler.session_name'); } }
function getOauthUri($apiName, $path, $extra = array()) { if (Configure::check('Copula.' . $apiName . '.Auth')) { $config = Configure::read('Copula.' . $apiName . '.Auth'); if ($config['authMethod'] == 'OAuth') { return $config['scheme'] . '://' . $config['host'] . '/' . $config[$path]; } elseif ($config['authMethod'] == 'OAuthV2') { $uri = $config['scheme'] . '://' . $config['host'] . '/' . $config[$path]; $query = array('redirect_uri' => $config['callback'], 'client_id' => ConnectionManager::getDataSource($apiName)->config['login']); if (!empty($config['scope'])) { $query['scope'] = $config['scope']; } return $uri . Router::queryString($query, $extra); } } else { return false; } }
public function admin_index() { $apiKey = Configure::read('Akismet.api_key'); if (Configure::check('Akismet.api_key') && !empty($apiKey)) { $data = ['blog' => Configure::read('General.site_url'), 'key' => Configure::read('Akismet.api_key')]; $this->set('isValid', Akismet::isVerifyAPIKey($data)); } if (!empty($this->request->data)) { if (isset($this->request->data['Akismet']['api_key'])) { if ($this->Option->write('Akismet.api_key', $this->request->data['Akismet']['api_key'])) { $this->Session->setFlash(__d('akismet', 'Akismet config have been updated!'), 'flash_message', ['class' => 'success']); $this->redirect($this->referer()); } else { $this->Session->setFlash(__d('akismet', 'Unable to update config.'), 'flash_message', ['class' => 'danger']); } } } else { $this->request->data['Akismet'] = Configure::read('Akismet'); } }
public function sidebar($sidebarId = null) { if (is_null($sidebarId) && !in_array($sidebarId, Configure::read('sidebars'))) { return false; } $sidebar_widgets = unserialize(Configure::read(Configure::read('template') . '.widgets')); $widgets = Configure::read('widgets'); if (Configure::check(Configure::read('template') . '.widgets') && !is_null(Configure::read(Configure::read('template') . '.widgets'))) { $this->_View->start($sidebarId); foreach ($sidebar_widgets[$sidebarId] as $widget) { $sidebar = Configure::read('sidebars')[$sidebarId]; echo sprintf($sidebar['before_widget'], $widget['unique-id'], $sidebar['class']); echo $sidebar['before_title']; echo isset($widget['title']) && !empty($widget['title']) ? $widget['title'] : $widgets[$widget['widget-id']]['title']; echo $sidebar['after_title']; echo $this->_View->element('Widgets/' . $widgets[$widget['widget-id']]['element'], array('data' => HuradWidget::getWidgetData($widget['unique-id']))); echo $sidebar['after_widget']; } $this->_View->end(); } echo $this->_View->fetch($sidebarId); }
/** * Locale */ Configure::write('Config.language', Configure::read('Site.locale')); /** * Timezone */ $timezone = Configure::read('Site.timezone'); if (!$timezone) { $timezone = 'UTC'; } date_default_timezone_set($timezone); /** * Assets */ if (Configure::check('Site.asset_timestamp')) { $timestamp = Configure::read('Site.asset_timestamp'); Configure::write('Asset.timestamp', is_numeric($timestamp) ? (bool) $timestamp : $timestamp); unset($timestamp); } /** * Extensions */ CakePlugin::load(array('Extensions'), array('bootstrap' => true, 'routes' => true)); Configure::load('Extensions.events'); App::uses('CroogoPlugin', 'Extensions.Lib'); /** * Setup custom paths */ $croogoPath = CakePlugin::path('Croogo'); App::build(array('Console/Command' => array($croogoPath . 'Console' . DS . 'Command' . DS), 'View' => array($croogoPath . 'View' . DS), 'View/Helper' => array($croogoPath . 'View' . DS . 'Helper' . DS), 'Locale' => array(APP . 'Vendor' . DS . 'croogo' . DS . 'locale' . DS)), App::APPEND);
/** * testCheckEmpty * * @return void */ public function testCheckEmpty() { $this->assertFalse(Configure::check('')); $this->assertFalse(Configure::check(null)); }
/** * Processes registered configuration options for a form. * Configuration available levels are: * 1. Default options defined in $this->myFormDefaults and $this->myInputDefaults * 2. Form style options (if any) defined in Bs3.Form.styles.STYLE.formDefaults/inputDefaults * 3. inputDefaults passed on Form::create() options * 4. (For input) Options passed on Form::input() * * @param array $options * @return array */ protected function _processConfig($options) { // Get form style $options = $this->_detectFormStyle($options); $styleFormDefaults = $styleInputDefaults = array(); if ($this->formStyle) { $styleFormDefaults = (array) Configure::read('Bs3.Form.styles.' . $this->formStyle . '.formDefaults'); $styleInputDefaults = (array) Configure::read('Bs3.Form.styles.' . $this->formStyle . '.inputDefaults'); } // Process input configuration $this->inputOptions = Hash::merge($this->_myInputDefaults, Configure::check('Bs3.Form.inputDefaults') ? Configure::read('Bs3.Form.inputDefaults') : array(), $this->_processCustomConfig('input', $styleInputDefaults), $this->_processCustomConfig('input', $this->_extractOption('inputDefaults', $options, array()))); // Process form configuration unset($options['inputDefaults']); $this->formOptions = Hash::merge($this->_myFormDefaults, Configure::check('Bs3.Form.formDefaults') ? Configure::read('Bs3.Form.formDefaults') : array(), $this->_processCustomConfig('form', $styleFormDefaults), $this->_processCustomConfig('form', $options)); //dd($this->formOptions); if ($this->formStyle && empty($this->formOptions['class'])) { $this->formOptions['class'] = 'form-' . $this->formStyle; } }
/** * Execution method always used for tasks * * @return void */ public function execute() { if (!Configure::check('PHP')) { try { Configure::load('requirements', Common::read('Common.reader.id', 'default')); } catch (ConfigureException $e) { $this->out(); $this->out(__d('webmaster', "No requirements defined. See %s for more info.", Common::wiki('requirements')), 2); return; } } $width = 20; $reqs = Configure::read('PHP'); $this->hr(true); $this->out(__d('webmaster', "Checking system defined requirements:")); $this->hr(true); $this->out(__d('webmaster', "PHP Extensions:")); $this->out(__d('webmaster', "Whether or not required PHP extensions are loaded.")); $this->hr(true); if (empty($reqs['extensions'])) { $reqs['extensions'] = array(); $this->out(__d('webmaster', "None required.")); } foreach ($reqs['extensions'] as $ext) { $out = $ext; $out .= str_repeat(' ', $width - strlen($ext)); $out .= ': '; if (!extension_loaded($ext)) { $out .= __d('webmaster', "Missing"); } else { $out .= __d('webmaster', "Loaded"); } $this->out($out); } unset($reqs['extensions']); $this->hr(true); $this->out(__d('webmaster', "PHP Runtime Settings:")); $this->out(__d('webmaster', "Whether or not required 'php.ini' directives are modifiable.")); $this->hr(true); if (empty($reqs['runtime'])) { $reqs['runtime'] = array(); $this->out(__d('webmaster', "None required.")); } else { $all = ini_get_all(); } foreach ($reqs['runtime'] as $varname) { $out = $varname; $out .= str_repeat(' ', $width - strlen($varname)); $out .= ': '; if (!isset($all[$varname])) { continue; } if ($all[$varname]['access'] < 6) { $out .= __d('webmaster', "No"); } else { $out .= __d('webmaster', "Yes"); } $this->out($out); } unset($reqs['runtime']); $this->hr(true); $this->out(__d('webmaster', "PHP Settings:")); $this->out(__d('webmaster', "Whether or not required 'php.ini' directives are correctly set.")); $this->hr(true); if (empty($reqs)) { $this->out(__d('webmaster', "None required.")); } foreach ($reqs as $var => $val) { $out = $var; $out .= str_repeat(' ', $width - strlen($var)); $out .= ': '; $ini = ini_get($var); if (is_bool($val)) { if ((bool) $ini !== $val) { $out .= __d('webmaster', "Invalid (value: %s, expects: %s)", $ini, (int) $val); } else { $out .= __d('webmaster', "Valid (value: %s)", $ini); } continue; } if ($this->__inBytes($ini) < $this->__inBytes($val)) { $out .= __d('webmaster', "Invalid (value: %s, expects: %s)", $ini, $val); } else { $out .= __d('webmaster', "Valid (value: %s)", $ini); } $this->out($out); } $this->hr(true); }
/** * Get the value of a parameter * * Inspects * 1. The CLI parameters, e.g. "--records" * 2. The seeder specific configuration, e.g. "FakeSeeder.Article.records" * 3. The general seeder configuration, e.g "FakeSeeder.records" * 4. The seeder shell task class properties, e.g. "$_records" * 4. Falls back to an optional default value * * @param string $configKey The name of the config key to check. * @param string $propertyName The name of the class property to check. * @param string $defaultValue The default value to use as fallback, optional. * @return mixed The value of the parameter. */ protected function _getParameter($configKey, $propertyName, $defaultValue = null) { // If given as CLI parameter, use that value if ($this->params[$configKey]) { $this->out(__('Parameter "%s" given through CLI parameter: "%s"', $configKey, $this->params[$configKey]), 1, Shell::VERBOSE); return $this->params[$configKey]; } // If set in the seeder specific configuration, use that value $localeConfigKey = sprintf('%s.%s', $this->_getSeederConfigKey(), $configKey); if (Configure::check($localeConfigKey)) { $this->out(__('Parameter "%s" configured in seeder specific configuration: "%s"', $configKey, Configure::read($localeConfigKey)), 1, Shell::VERBOSE); return Configure::read($localeConfigKey); } // If set in the general FakeSeeder configuration, use that value $localeConfigKey = sprintf('%s.%s', $this->_getSeederShellName(), $configKey); if (Configure::check($localeConfigKey)) { $this->out(__('Parameter "%s" configured in general seeder configuration: "%s"', $configKey, Configure::read($localeConfigKey)), 1, Shell::VERBOSE); return Configure::read($localeConfigKey); } // If set in the seeder class, use that value if ($this->{$propertyName}) { $this->out(__('Parameter "%s" set in class: "%s"', $configKey, $this->{$propertyName}), 1, Shell::VERBOSE); return $this->{$propertyName}; } $this->out(__('Parameter "%s" not given/configured, falling back to default "%s".', $configKey, $defaultValue), 1, Shell::VERBOSE); // Otherwise use the default value as fallback return $defaultValue; }