本文整理汇总了PHP中Configure::read方法的典型用法代码示例。如果您正苦于以下问题:PHP Configure::read方法的具体用法?PHP Configure::read怎么用?PHP Configure::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Configure
的用法示例。
在下文中一共展示了Configure::read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeFilter
public function beforeFilter()
{
$this->loadModel('User');
parent::beforeFilter();
// Disable content cache for Chrome
$this->response->disableCache();
// Delete the default auth message. Just show them the login page
// people will get the idea pretty quickly.
$this->Session->delete('Message.auth');
/*if ($this->RequestHandler->isMobile()) {
$this->layout = 'mobile';
$this->isMobile = true;
} else {
$this->layout = 'mobile';
$this->isMobile = true;
}*/
if ($this->request->is('ajax')) {
$this->layout = 'ajax';
}
$this->Auth->allow('index', 'view', 'display');
// Let everyone know about the user
$this->set('loggedIn', $this->Auth->loggedIn());
$user = $this->Auth->user();
$this->isAdmin = $this->User->isAdmin($user);
$this->isEditor = $this->User->isEditor($user);
$this->set('loggedInuserId', $this->Auth->user('id'));
$this->set('isAdmin', $this->isAdmin);
$this->set('isEditor', $this->isEditor);
$this->set('allowAccountCreation', Configure::read('App.allowPublicAccountCreation'));
}
示例2: display
/**
* Displays a view
*
* @param mixed What page to display
* @return void
* @throws NotFoundException When the view file could not be found
* or MissingViewException in debug mode.
*/
public function display()
{
$path = func_get_args();
//debug($path);
$count = count($path);
//debug($count);
if (!$count) {
return $this->redirect('/');
}
$page = $subpage = $title_for_layout = null;
//debug(Inflector::humanize($path[$count - 1]));
if (!empty($path[0])) {
$page = $path[0];
}
if (!empty($path[1])) {
$subpage = $path[1];
}
if (!empty($path[$count - 1])) {
$title_for_layout = Inflector::humanize($path[$count - 1]);
}
$this->set(compact('page', 'subpage', 'title_for_layout'));
//debug($this->render(implode('/', $path)));
//debug($page);
//debug($subpage);
//debug($title_for_layout);
try {
$this->render(implode('/', $path));
} catch (MissingViewException $e) {
if (Configure::read('debug')) {
throw $e;
}
throw new NotFoundException();
}
}
示例3: __construct
/**
* Setup the config based on either the Configure::read() values
* or the PaypalIpnConfig in config/paypal_ipn_config.php
*
* Will attempt to read configuration in the following order:
* Configure::read('PaypalIpn')
* App::import() of config/paypal_ipn_config.php
* App::import() of plugin's config/paypal_ipn_config.php
*/
function __construct()
{
$this->config = Configure::read('PaypalIpn');
if (empty($this->config)) {
$importConfig = array('type' => 'File', 'name' => 'PaypalIpn.PaypalIpnConfig', 'file' => CONFIGS . 'paypal_ipn_config.php');
if (!class_exists('PaypalIpnConfig')) {
App::import($importConfig);
}
if (!class_exists('PaypalIpnConfig')) {
// Import from paypal plugin configuration
$importConfig['file'] = 'config' . DS . 'paypal_ipn_config.php';
App::import($importConfig);
}
if (!class_exists('PaypalIpnConfig')) {
trigger_error(__d('paypal_ipn', 'PaypalIpnConfig: The configuration could not be loaded.', true), E_USER_ERROR);
}
if (!PHP5) {
$config =& new PaypalIpnConfig();
} else {
$config = new PaypalIpnConfig();
}
$vars = get_object_vars($config);
foreach ($vars as $property => $configuration) {
if (strpos($property, 'encryption_') === 0) {
$name = substr($property, 11);
$this->encryption[$name] = $configuration;
} else {
$this->config[$property] = $configuration;
}
}
}
parent::__construct();
}
示例4: __construct
public function __construct($id = false, $table = null, $ds = null)
{
if (!Configure::read('Backend.Acl.enabled')) {
unset($this->actsAs['Acl']);
}
parent::__construct($id, $table, $ds);
}
示例5: end
function end()
{
$this->Transition->checkPrev(array('index', 'confirm'), '不正なページ遷移です。', array('action' => 'index'));
$data = $this->Transition->data('index');
$c =& $this->Contact;
// $c->requireCaptcha(!$this->Ktai->is_ktai());
$c->answerCaptcha = $this->Session->read('captcha');
$c->set($data);
if (!$c->validates()) {
$this->Session->setFlash('送信内容に不備があります。');
$this->redirect(array('action' => 'index'));
}
extract($data['Contact']);
$this->toAddr = Configure::read('Site.contact_mail');
$this->fromAddr = $email;
if (!empty($company_name)) {
$company_name .= ' : ';
}
if (DS != "\\") {
if (!$this->_send($company_name . $name, 'contact_collect', compact('name', 'email', 'company_name', 'statement'))) {
$this->Session->setFlash('送信に失敗しました。お手数ですが、時間を空けてから再度入力してください。');
$this->redirect(array('action' => 'index'));
} else {
// 送信完了のメール?
}
}
$this->Transition->clearData();
$this->pageTitle = '送信完了';
}
示例6: startup
/**
* 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');
list($plugin, $class) = pluginSplit($class, true);
App::uses($class, $plugin . 'Controller/Component/Acl');
if (!in_array($class, array('DbAcl', 'DB_ACL')) && !is_subclass_of($class, 'DbAcl')) {
$out = "--------------------------------------------------\n";
$out .= __d('cake_console', 'Error: Your current Cake configuration is set to an ACL implementation other than DB.') . "\n";
$out .= __d('cake_console', 'Please change your core config to reflect your decision to use DbAcl before attempting to use this script') . "\n";
$out .= "--------------------------------------------------\n";
$out .= __d('cake_console', 'Current ACL Classname: %s', $class) . "\n";
$out .= "--------------------------------------------------\n";
$this->err($out);
$this->_stop();
}
if ($this->command) {
if (!config('database')) {
$this->out(__d('cake_console', 'Your database configuration was not found. Take a moment to create one.'), true);
$this->args = null;
return $this->DbConfig->execute();
}
require_once APP . 'Config' . DS . 'database.php';
if (!in_array($this->command, array('initdb'))) {
$collection = new ComponentCollection();
$this->Acl = new AclComponent($collection);
$controller = new Controller();
$this->Acl->startup($controller);
}
}
}
示例7: buildCss
public function buildCss()
{
App::import('Vendor', 'AssetMinify.JSMinPlus');
// Ouverture des fichiers de config
$dir = new Folder(Configure::read('App.www_root') . 'css' . DS . 'minified');
if ($dir->path !== null) {
foreach ($dir->find('config_.*.ini') as $file) {
preg_match('`^config_(.*)\\.ini$`', $file, $grep);
$file = new File($dir->pwd() . DS . $file);
$ini = parse_ini_file($file->path, true);
$fileFull = new File($dir->path . DS . 'full_' . $grep[1] . '.css', true, 0644);
$fileGz = new File($dir->path . DS . 'gz_' . $grep[1] . '.css', true, 0644);
$contentFull = '';
foreach ($ini as $data) {
// On a pas de version minifié
if (!($fileMin = $dir->find('file_' . md5($data['url'] . $data['md5']) . '.css'))) {
$fileMin = new File($dir->path . DS . 'file_' . md5($data['url'] . $data['md5']) . '.css', true, 0644);
$this->out("Compression de " . $data['file'] . ' ... ', 0);
$fileMin->write(MinifyUtils::compressCss(MinifyUtils::cssAbsoluteUrl($data['url'], file_get_contents($data['file']))));
$this->out('OK');
} else {
$fileMin = new File($dir->path . DS . 'file_' . md5($data['url'] . $data['md5']) . '.css');
}
$contentFull .= $fileMin->read() . PHP_EOL;
}
// version full
$fileFull->write($contentFull);
$fileFull->close();
// compression
$fileGz->write(gzencode($contentFull, 6));
}
}
}
示例8: startup
/**
* Override startup of the Shell
*
* @access public
*/
function startup()
{
$this->dataSource = 'default';
if (isset($this->params['datasource'])) {
$this->dataSource = $this->params['datasource'];
}
if (Configure::read('Acl.classname') != 'DB_ACL') {
$out = "--------------------------------------------------\n";
$out .= __("Error: Your current Cake configuration is set to", true) . "\n";
$out .= __("an ACL implementation other than DB. Please change", true) . "\n";
$out .= __("your core config to reflect your decision to use", true) . "\n";
$out .= __("DB_ACL before attempting to use this script", true) . ".\n";
$out .= "--------------------------------------------------\n";
$out .= sprintf(__("Current ACL Classname: %s", true), Configure::read('Acl.classname')) . "\n";
$out .= "--------------------------------------------------\n";
$this->err($out);
exit;
}
if ($this->command && !in_array($this->command, array('help'))) {
if (!config('database')) {
$this->out(__("Your database configuration was not found. Take a moment to create one.", true), true);
$this->args = null;
return $this->DbConfig->execute();
}
require_once CONFIGS . 'database.php';
if (!in_array($this->command, array('initdb'))) {
$this->Acl = new AclComponent();
$controller = null;
$this->Acl->startup($controller);
}
}
}
示例9: send
/**
* Send email via Mailgun
*
* @param CakeEmail $email
* @return array
* @throws Exception
*/
public function send(CakeEmail $email)
{
if (Configure::read('Mailgun.preventManyToRecipients') !== false && count($email->to()) > 1) {
throw new Exception('More than one "to" recipient not allowed (set Mailgun.preventManyToRecipients = false to disable check)');
}
$mgClient = new Mailgun($this->_config['mg_api_key']);
$headersList = array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc', 'subject');
$params = [];
foreach ($email->getHeaders($headersList) as $header => $value) {
if (isset($this->_paramMapping[$header]) && !empty($value)) {
$key = $this->_paramMapping[$header];
$params[$key] = $value;
}
}
$params['text'] = $email->message(CakeEmail::MESSAGE_TEXT);
$params['html'] = $email->message(CakeEmail::MESSAGE_HTML);
$attachments = array();
foreach ($email->attachments() as $name => $info) {
$attachments['attachment'][] = '@' . $info['file'];
}
try {
$result = $mgClient->sendMessage($this->_config['mg_domain'], $params, $attachments);
if ($result->http_response_code != 200) {
throw new Exception($result->http_response_body->message);
}
} catch (Exception $e) {
throw $e;
}
return $result;
}
示例10: before
/**
* Before migration callback
*
* @param string $direction, up or down direction of migration process
* @return boolean Should process continue
* @access public
*/
public function before($direction)
{
if ($direction == 'down') {
return Configure::read('debug') > 0;
}
return true;
}
示例11: _app_getUsers
public function _app_getUsers($data)
{
$conditions['sqrt(pow(69.1 * (UsersOnline.latitude - ' . $data['UsersOnline']['latitude'] . '), 2) + pow(53.0 * (UsersOnline.longitude - ' . $data['UsersOnline']['latitude'] . '), 2)) <'] = Configure::read('DistanceToGetUsers') / 1.609344;
//Calculate if distance is lower than input. (Convertion miles to kilometres)
$conditions['UsersOnline.user_id <>'] = $data['UsersOnline']['user_id'];
$conditions['TIMEDIFF(ADDTIME(UsersOnline.modified, SEC_TO_TIME(UsersOnline.duration)), NOW()) >'] = 0;
$conditions['UsersBanned.id'] = null;
$joins = array(array('table' => 'allowed_profiles', 'alias' => 'AllowedProfile', 'type' => 'LEFT', 'conditions' => array('AllowedProfile.user_allowed_id = ' . $data['UsersOnline']['user_id'], 'AllowedProfile.user_profile_id = UsersOnline.user_id')), array('table' => 'users_banned', 'alias' => 'UsersBanned', 'type' => 'LEFT', 'conditions' => array('UsersBanned.user_to_id = ' . $data['UsersOnline']['user_id'], 'UsersBanned.user_from_id = UsersOnline.user_id')));
$fields = array('User.id', 'User.auth_token', 'User.email', 'User.username', 'User.name', 'User.surname', 'User.headline', 'User.picture', 'User.show_name', 'User.show_headline', 'User.show_picture', 'User.show_skills', 'User.show_jobs', 'User.show_in_searches', 'UsersOnline.*', 'AllowedProfile.id');
$users = $this->UsersOnline->find('all', array('fields' => $fields, 'joins' => $joins, 'conditions' => $conditions));
foreach ($users as $key => $user) {
if (empty($user['AllowedProfile']['id'])) {
if (!$user['User']['show_name']) {
unset($user['User']['name']);
unset($user['User']['surname']);
}
if (!$user['User']['show_headline']) {
unset($user['User']['headline']);
}
if (!$user['User']['show_picture']) {
unset($user['User']['picture']);
}
}
unset($user['AllowedProfile']);
$users[$key] = $user;
}
return $users;
}
示例12: instance
public static function instance()
{
if (is_null(self::$instance)) {
App::import('Vendor', 'Smarty', array('file' => 'autoload.php'));
$smarty = new Smarty();
$smarty->template_dir = APP . 'View' . DS;
//plugins dir(s) must be set by array
$smarty->plugins_dir = array(APP . 'View' . DS . 'SmartyPlugins', VENDORS . 'smarty' . DS . 'smarty' . DS . 'distribution' . DS . 'libs' . DS . 'plugins');
$smarty->config_dir = APP . 'View' . DS . 'SmartyConfigs' . DS;
$smarty->compile_dir = TMP . 'smarty' . DS . 'compile' . DS;
$smarty->cache_dir = TMP . 'smarty' . DS . 'cache' . DS;
$smarty->error_reporting = 'E_ALL & ~E_NOTICE';
$smarty->default_modifiers = array('escape:"html"');
$smarty->caching = true;
$smarty->compile_check = true;
$smarty->cache_lifetime = 3600;
$smarty->cache_modified_check = false;
$smarty->force_compile = Configure::read('debug') > 0 ? true : false;
/*
$smarty->autoload_filters = array(
'pre' => array('hoge'),
'output' => array('escape')
);
$smarty->left_delimiter = '{';
$smarty->right_delimiter = '}';
//for development
$smarty->debugging = (Configure::read('debug') == 0) ? false : true;
*/
self::$instance = $smarty;
}
return self::$instance;
}
示例13: testIgnoreRequests
public function testIgnoreRequests()
{
$ignored = Configure::read('NewRelic.ignoreRoutes');
Configure::write('NewRelic.ignoreRoutes', array('/admin/:controller/:action/*', '/:controller/edit/*', '/new_relic_user_test/:action/5'));
$testSucceed = array('/new_relic_test/index', '/new_relic_user_test/view/3');
foreach ($testSucceed as $testUrl) {
$filter = $this->_getNewRelicMock();
$filter->expects($this->once())->method('hasNewRelic')->will($this->returnValue(true));
$filter->expects($this->never())->method('ignoreTransaction');
$response = $this->getMock('CakeResponse', array('_sendHeader'));
$request = new CakeRequest($testUrl);
$request->addParams(Router::parse($testUrl));
$event = new CakeEvent('Dispatcher.beforeRequest', $this, compact('request', 'response'));
$this->assertTrue($filter->beforeDispatch($event));
$this->assertFalse($event->isStopped());
}
$testFail = array('/admin/new_relic_test/index', '/new_relic_user_test/edit', '/new_relic_user_test/edit/3', '/new_relic_user_test/view/5');
foreach ($testFail as $testUrl) {
$filter = $this->_getNewRelicMock();
$filter->expects($this->once())->method('hasNewRelic')->will($this->returnValue(true));
$filter->expects($this->once())->method('ignoreTransaction');
$response = $this->getMock('CakeResponse', array('_sendHeader'));
$request = new CakeRequest($testUrl);
$request->addParams(Router::parse($testUrl));
$event = new CakeEvent('Dispatcher.beforeRequest', $this, compact('request', 'response'));
$this->assertTrue($filter->beforeDispatch($event));
$this->assertFalse($event->isStopped());
}
Configure::write('NewRelic.ignoreRoutes', $ignored);
}
示例14: onEdit
function onEdit($record, $old_record)
{
$auth_model = Configure::read('security.auth_model');
$username_field = $this->_controller->Auth->authenticate->userField;
$email_field = $this->_controller->Auth->authenticate->emailField;
// phpBB3 files need these
global $phpbb_root_path, $phpEx;
$phpbb_root_path = Configure::read('phpbb3.root_path');
$phpEx = 'php';
include $phpbb_root_path . 'config.php';
$bb3_class = "{$table_prefix}users";
$bb3_model = ClassRegistry::init($bb3_class);
$bb3_user = $bb3_model->find('first', array('conditions' => array('username' => $old_record[$auth_model][$username_field])));
// We only care about username and email address changes
if (empty($bb3_user) || $bb3_user[$bb3_class]['username'] == $record[$auth_model][$username_field] && $bb3_user[$bb3_class]['user_email'] == $record[$auth_model][$email_field]) {
return;
}
// Includ a couple of things needed for function definitions
define('IN_PHPBB', true);
include $phpbb_root_path . 'includes/functions.php';
include $phpbb_root_path . 'includes/utf/utf_tools.php';
$clean = utf8_clean_string($record[$auth_model][$username_field]);
$hash = phpbb_email_hash($record[$auth_model][$email_field]);
$bb3_model->updateAll(array('username' => "'{$record[$auth_model][$username_field]}'", 'username_clean' => "'{$clean}'", 'user_email' => "'{$record[$auth_model][$email_field]}'", 'user_email_hash' => "'{$hash}'"), array('user_id' => $bb3_user[$bb3_class]['user_id']));
}
示例15: testImages
/**
* @access public
* @return void
* 2009-07-30 ms
*/
function testImages()
{
$is = $this->Gravatar->image(GARBIGE_TEST_EMAIL);
echo $is;
$this->assertTrue(!empty($is));
$is = $this->Gravatar->image(Configure::read('Config.admin_email'));
echo $is;
$this->assertTrue(!empty($is));
$is = $this->Gravatar->image(VALID_TEST_EMAIL);
echo $is;
$this->assertTrue(!empty($is));
$is = $this->Gravatar->image(VALID_TEST_EMAIL, array('size' => '200'));
echo $is;
$this->assertTrue(!empty($is));
$is = $this->Gravatar->image(VALID_TEST_EMAIL, array('size' => '20'));
echo $is;
$this->assertTrue(!empty($is));
$is = $this->Gravatar->image(VALID_TEST_EMAIL, array('rating' => 'X'));
# note the capit. x
echo $is;
$this->assertTrue(!empty($is));
$is = $this->Gravatar->image(VALID_TEST_EMAIL, array('ext' => true));
echo $is;
$this->assertTrue(!empty($is));
$is = $this->Gravatar->image(VALID_TEST_EMAIL, array('default' => 'none'));
echo $is;
$this->assertTrue(!empty($is));
$is = $this->Gravatar->image(GARBIGE_TEST_EMAIL, array('default' => 'none'));
echo $is;
$this->assertTrue(!empty($is));
$is = $this->Gravatar->image(GARBIGE_TEST_EMAIL, array('default' => 'http://2.gravatar.com/avatar/8379aabc84ecee06f48d8ca48e09eef4?d=identicon'));
echo $is;
$this->assertTrue(!empty($is));
}