本文整理汇总了PHP中Config::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::getInstance方法的具体用法?PHP Config::getInstance怎么用?PHP Config::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Config
的用法示例。
在下文中一共展示了Config::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
private function __construct()
{
$this->appSchemaMap = array();
$this->appNamespaceUriMap = array();
$this->appContextRootMap = array();
$config = Config::getInstance();
foreach ($config->getSection('db') as $propertyId => $value) {
$prefix = 'schema-for-app.';
if (strpos($propertyId, $prefix) === 0) {
$this->appSchemaMap[substr($propertyId, strlen($prefix))] = new Schema($value);
}
}
foreach ($config->getSection('xml') as $propertyId => $value) {
$prefix = 'namespaceUri-for-app.';
if (strpos($propertyId, $prefix) === 0) {
$this->appNamespaceUriMap[substr($propertyId, strlen($prefix))] = $value;
}
}
foreach ($config->getSection('url') as $propertyId => $value) {
$prefix = 'context-root-for-app.';
if (strpos($propertyId, $prefix) === 0) {
$this->appContextRootMap[substr($propertyId, strlen($prefix))] = $value;
}
}
}
示例2: doesTextMatchImage
/**
* Check the $_POST'ed CAPTCHA inputs match the contents of the CAPTCHA.
* @return bool
*/
public function doesTextMatchImage()
{
//if in test mode, assume check is good if user_code is set to 123456
if (Utils::isTest()) {
if (isset($_POST['user_code']) && $_POST['user_code'] == '123456') {
return true;
} else {
return false;
}
}
switch ($this->type) {
case self::RECAPTCHA_CAPTCHA:
$config = Config::getInstance();
$priv_key = $config->getValue('recaptcha_private_key');
$resp = recaptcha_check_answer($priv_key, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
return false;
} else {
return true;
}
break;
default:
if (strcmp(md5($_POST['user_code']), SessionCache::get('ckey'))) {
return false;
} else {
return true;
}
break;
}
}
示例3: setUp
public function setUp()
{
parent::setUp();
$webapp_plugin_registrar = PluginRegistrarWebapp::getInstance();
$webapp_plugin_registrar->registerPlugin('twitter', 'TwitterPlugin');
$this->config = Config::getInstance();
}
示例4: authControl
public function authControl()
{
$config = Config::getInstance();
Loader::definePathConstants();
$this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/facebook/view/facebook.account.index.tpl');
$this->view_mgr->addHelp('facebook', 'userguide/settings/plugins/facebook');
/** set option fields **/
// Application ID text field
$this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'facebook_app_id', 'label' => 'App ID', 'size' => 18));
// add element
// set a special required message
$this->addPluginOptionRequiredMessage('facebook_app_id', 'The Facebook plugin requires a valid App ID.');
// Application Secret text field
$this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'facebook_api_secret', 'label' => 'App Secret', 'size' => 37));
// add element
// set a special required message
$this->addPluginOptionRequiredMessage('facebook_api_secret', 'The Facebook plugin requires a valid App Secret.');
$max_crawl_time_label = 'Max crawl time in minutes';
$max_crawl_time = array('name' => 'max_crawl_time', 'label' => $max_crawl_time_label, 'default_value' => '20', 'advanced' => true, 'size' => 3);
$this->addPluginOption(self::FORM_TEXT_ELEMENT, $max_crawl_time);
$this->addToView('thinkup_site_url', Utils::getApplicationURL());
$facebook_plugin = new FacebookPlugin();
if ($facebook_plugin->isConfigured()) {
$this->setUpFacebookInteractions($facebook_plugin->getOptionsHash());
$this->addToView('is_configured', true);
} else {
$this->addInfoMessage('Please complete plugin setup to start using it.', 'setup');
$this->addToView('is_configured', false);
}
return $this->generateView();
}
示例5: write
public function write($id, $data)
{
$sessionTimeout = (int) Config::getInstance()->get("session_timeout", 3600);
$redis = Redis::get();
$redis->setex("sess:{$id}", $sessionTimeout, $data);
return true;
}
示例6: __construct
/**
*
*/
private function __construct()
{
$this->pool = array();
$obj = Config::getInstance();
$this->config = $obj->config["databases"];
return $this;
}
示例7: setUp
public function setUp()
{
parent::setUp();
$config = Config::getInstance();
$this->prefix = $config->getValue('table_prefix');
$this->builders = self::buildData();
}
示例8: authControl
public function authControl()
{
$config = Config::getInstance();
Utils::defineConstants();
$this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/geoencoder/view/geoencoder.account.index.tpl');
$this->view_mgr->addHelp('geoencoder', 'userguide/settings/plugins/geoencoder');
$this->addToView('message', 'This is the GeoEncoder plugin configuration page for ' . $this->owner->email . '.');
/** set option fields **/
// gmaps_api_key text field
$name_field = array('name' => 'gmaps_api_key', 'label' => 'Google Maps API Key', 'size' => 55);
$this->addPluginOption(self::FORM_TEXT_ELEMENT, $name_field);
$this->addPluginOptionRequiredMessage('gmaps_api_key', 'Please enter your Google Maps API Key');
// distance_unit radio field
$distance_unit_field = array('name' => 'distance_unit', 'label' => 'Unit of Distance');
$distance_unit_field['values'] = array('Kilometers' => 'km', 'Miles' => 'mi');
$distance_unit_field['default_value'] = 'km';
$this->addPluginOption(self::FORM_RADIO_ELEMENT, $distance_unit_field);
$plugin = new GeoEncoderPlugin();
if (!$plugin->isConfigured()) {
$this->addInfoMessage('Please complete plugin setup to start using it.', 'setup');
$this->addToView('is_configured', false);
} else {
$this->addToView('is_configured', true);
}
return $this->generateView();
}
示例9: reportVersion
/**
* Report installation version back to thinkup.com. If usage reporting is enabled, include instance username
* and network.
* @param Instance $instance
* @return array ($report_back_url, $referer_url, $status, $contents)
*/
public static function reportVersion(Instance $instance)
{
//Build URLs with appropriate parameters
$config = Config::getInstance();
$report_back_url = 'http://thinkup.com/version.php?v=' . $config->getValue('THINKUP_VERSION');
//Explicity set referer for when this is called by a command line script
$referer_url = Utils::getApplicationURL();
//If user hasn't opted out, report back username and network
if ($config->getValue('is_opted_out_usage_stats') === true) {
$report_back_url .= '&usage=n';
} else {
$referer_url .= "?u=" . urlencode($instance->network_username) . "&n=" . urlencode($instance->network);
}
$in_test_mode = isset($_SESSION["MODE"]) && $_SESSION["MODE"] == "TESTS" || getenv("MODE") == "TESTS";
if (!$in_test_mode) {
//only make live request if we're not running the test suite
//Make the cURL request
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $report_back_url);
curl_setopt($c, CURLOPT_REFERER, $referer_url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$contents = curl_exec($c);
$status = curl_getinfo($c, CURLINFO_HTTP_CODE);
curl_close($c);
} else {
$contents = '';
$status = 200;
}
return array($report_back_url, $referer_url, $status, $contents);
}
示例10: get_available_domains
public static function get_available_domains()
{
$domain_configuration = Config::getInstance()->getConfig('domains');
$configuration_keys = array_keys($domain_configuration);
$available_domains = array_filter($configuration_keys, "self::is_domain");
return $available_domains;
}
示例11: addAction
public function addAction()
{
$config = Config::getInstance();
$config = $config->getConfig();
$Cars = new Cars();
$this->view->data = $Cars->getCategory();
$model = $this->request->getPost('model');
$marka = $this->request->getPost('marka_id');
$opis = $this->request->getPost('opis');
$zdjecie = $this->request->getFiles('zdjecie');
if ($model == NULL && $marka == NULL && $opis == NULL && $zdjecie == NULL) {
$this->view->display('add');
} else {
if ($model == NULL || $marka == NULL || $opis == NULL || $zdjecie == NULL) {
echo "Uzupelnij wszystkie pola";
} else {
$podpis = date("Y-m-d G:i:s", time());
$zdjecie = WideImage::loadFromUpload('zdjecie');
$zdjecie->saveToFile($config['DOC_ROOT'] . $config['CUSTOM_IMG_DIR'] . $podpis . '.png');
$Car = new Cars();
$Car->saveCar($model, $marka, $opis, $podpis);
header('location: ' . Url::getUrl('car', 'list', array('status' => 8)));
}
}
}
示例12: run
function run()
{
if ($this->running) {
throw new \Exception(get_called_class() . '::run() was previously called!');
}
$this->running = true;
$request = Request::getInstance();
if ($request->exists(self::PATH_INFO_OVERRIDE_PARAM)) {
$this->pathInfo = $request->get(self::PATH_INFO_OVERRIDE_PARAM, '/');
$request->delete(self::PATH_INFO_OVERRIDE_PARAM);
} else {
$this->pathInfo = \ManiaLib\Utils\Arrays::getNotNull($_SERVER, 'PATH_INFO', '/');
}
list($this->controller, $this->action) = Route::getActionAndControllerFromRoute($this->pathInfo);
$this->calledURL = $request->createLink();
$viewsNS =& Config::getInstance()->viewsNS;
$currentViewsNS = Config::getInstance()->namespace . '\\Views\\';
if (!in_array($currentViewsNS, $viewsNS)) {
array_unshift($viewsNS, $currentViewsNS);
}
try {
Controller::factory($this->controller)->launch($this->action);
Response::getInstance()->render();
} catch (\Exception $e) {
call_user_func(Bootstrapper::$errorHandlingCallback, $e);
Response::getInstance()->render();
}
}
示例13: __construct
/**
* Constructor
*
* Sets default values all view templates have access to:
*
* <code>
* //path of the ThinkUp installation site root as defined in config.inc.php
* {$site_root_path}
* //file the ThinkUp logo links to, 'index.php' by default
* {$logo_link}
* //application name
* {$app_title}
* </code>
* @param array $config_array Defaults to null; Override source_root_path, site_root_path, app_title, cache_pages,
* debug
*
*/
public function __construct($config_array=null) {
if ($config_array==null) {
$config = Config::getInstance();
$config_array = $config->getValuesArray();
}
$src_root_path = $config_array['source_root_path'];
$site_root_path = $config_array['site_root_path'];
$app_title = $config_array['app_title'];
$cache_pages = $config_array['cache_pages'];
$debug = $config_array['debug'];
Utils::defineConstants();
$this->Smarty();
$this->template_dir = array( THINKUP_WEBAPP_PATH.'_lib/view', $src_root_path.'tests/view');
$this->compile_dir = THINKUP_WEBAPP_PATH.'_lib/view/compiled_view/';
$this->plugins_dir = array('plugins', THINKUP_WEBAPP_PATH.'_lib/view/plugins/');
$this->cache_dir = THINKUP_WEBAPP_PATH.'_lib/view/compiled_view/cache';
$this->caching = ($cache_pages)?1:0;
$this->cache_lifetime = 300;
$this->debug = $debug;
$this->assign('app_title', $app_title);
$this->assign('site_root_path', $site_root_path);
$this->assign('logo_link', 'index.php');
}
示例14: generateInsight
public function generateInsight(Instance $instance, $last_week_of_posts, $number_days)
{
parent::generateInsight($instance, $last_week_of_posts, $number_days);
$this->logger->logInfo("Begin generating insight", __METHOD__ . ',' . __LINE__);
$post_dao = DAOFactory::getDAO('PostDAO');
$user_dao = DAOFactory::getDAO('UserDAO');
$service_user = $user_dao->getDetails($instance->network_user_id, $instance->network);
$share_verb = $instance->network == 'twitter' ? 'retweeted' : 'reshared';
foreach ($last_week_of_posts as $post) {
$big_reshares = $post_dao->getRetweetsByAuthorsOverFollowerCount($post->post_id, $instance->network, $service_user->follower_count);
if (isset($big_reshares) && sizeof($big_reshares) > 0) {
if (!isset($config)) {
$config = Config::getInstance();
}
$post_link = '<a href="' . $config->getValue('site_root_path') . 'post/?t=' . $post->post_id . '&n=' . $post->network . '&v=fwds">';
if (sizeof($big_reshares) > 1) {
$notification_text = "People with lots of followers {$share_verb} " . $post_link . "{$this->username}'s post</a>.";
} else {
$follower_count_multiple = intval($big_reshares[0]->follower_count / $service_user->follower_count);
if ($follower_count_multiple > 1) {
$notification_text = "Someone with <strong>" . $follower_count_multiple . "x</strong> more followers than {$this->username} {$share_verb} " . $post_link . "this post</a>.";
} else {
$notification_text = "Someone with lots of followers {$share_verb} " . $post_link . "{$this->username}'s post</a>.";
}
}
//Replace each big resharer's bio line with the text of the post
foreach ($big_reshares as $sharer) {
$sharer->description = '"' . $post->post_text . '"';
}
$simplified_post_date = date('Y-m-d', strtotime($post->pub_date));
$this->insight_dao->insertInsight("big_reshare_" . $post->id, $instance->id, $simplified_post_date, "Big reshare!", $notification_text, basename(__FILE__, ".php"), Insight::EMPHASIS_HIGH, serialize($big_reshares));
}
}
$this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
}
示例15: setUp
/**
* Set up
* Initializes Config and Webapp objects
*/
function setUp()
{
$config = Config::getInstance();
$webapp = Webapp::getInstance();
$crawler = Crawler::getInstance();
parent::setUp();
}