本文整理汇总了PHP中Kohana::config_set方法的典型用法代码示例。如果您正苦于以下问题:PHP Kohana::config_set方法的具体用法?PHP Kohana::config_set怎么用?PHP Kohana::config_set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kohana
的用法示例。
在下文中一共展示了Kohana::config_set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup
public static function setup()
{
language::$available_languages = Kohana::config('locale.languages');
if (Router::$language === NULL) {
$redirect = NULL;
if (empty(Router::$current_uri)) {
if (($lang = language::browser_language()) !== '') {
$redirect = $lang;
} else {
reset(language::$available_languages);
$redirect = key(language::$available_languages);
}
} else {
if (($lang = language::browser_language()) !== '') {
$redirect = $lang . '/' . Router::$current_uri;
} else {
reset(language::$available_languages);
$redirect = key(language::$available_languages) . '/' . Router::$current_uri;
}
}
url::redirect($redirect);
}
Kohana::config_set('locale.language', language::$available_languages[Router::$language]['language']);
I18n::$lang = language::$available_languages[Router::$language]['language'][0];
}
示例2: add
public static function add($controller_name, $method_name, $parameters = array(), $priority = 5, $application_path = '')
{
if ($priority < 1 or $priority > 10) {
Kohana::log('error', 'The priority of the task was out of range!');
return FALSE;
}
$application_path = empty($application_path) ? APPPATH : $application_path;
$old_module_list = Kohana::config('core.modules');
Kohana::config_set('core.modules', array_merge($old_module_list, array($application_path)));
// Make sure the controller name and method are valid
if (Kohana::auto_load($controller_name)) {
// Only add it to the queue if the controller method exists
if (Kohana::config('queue.validate_methods') and !method_exists($controller_name, $method_name)) {
Kohana::log('error', 'The method ' . $controller_name . '::' . $method_name . ' does not exist.');
return FALSE;
}
// Add the action to the run queue with the priority
$task = new Task_Model();
$task->set_fields(array('application' => $application_path, 'class' => $controller_name, 'method' => $method_name, 'params' => serialize($parameters), 'priority' => $priority));
$task->save();
// Restore the module list
Kohana::config_set('core.modules', $old_module_list);
return TRUE;
}
Kohana::log('error', 'The class ' . $controller_name . ' does not exist.');
return FALSE;
}
示例3: register
/**
* Loads all ushahidi plugins
*/
public function register()
{
$db = Database::instance();
$plugins = array();
// Get the list of plugins from the db
foreach ($db->getwhere('plugin', array('plugin_active' => 1, 'plugin_installed' => 1)) as $plugin) {
$plugins[$plugin->plugin_name] = PLUGINPATH . $plugin->plugin_name;
}
// Now set the plugins
Kohana::config_set('core.modules', array_merge(Kohana::config('core.modules'), $plugins));
// We need to manually include the hook file for each plugin,
// because the additional plugins aren't loaded until after the application hooks are loaded.
foreach ($plugins as $key => $plugin) {
if (file_exists($plugin . '/hooks')) {
$d = dir($plugin . '/hooks');
// Load all the hooks
while (($entry = $d->read()) !== FALSE) {
if ($entry[0] != '.') {
// $plugin_base Variable gives plugin hook access to the base location of the plugin
$plugin_base = url::base() . "plugins/" . $key . "/";
include $plugin . '/hooks/' . $entry;
}
}
}
}
}
示例4: verify_https_mode
/**
* Verifies if the WebServer is HTTPS enabled and that the certificate is valid
* If not, $config['site_protocol'] is set back to 'http' and a redirect is
* performed
*/
public function verify_https_mode()
{
// Is HTTPS enabled, check if Web Server is HTTPS capable
$this->https_enabled = Kohana::config('core.site_protocol') == 'https' ? TRUE : FALSE;
if ($this->https_enabled) {
// URL to be used for fetching the headers
/**
* Comments By: E.Kala - 21/02/2011
* Not an optimal solution but works for now; index.php with cause get_headers to follow the "Location:"
* headers and this has an impedance on the page load time
*/
$url = url::base() . 'media/css/error.css';
// Initialize session and set cURL
$ch = curl_init();
// Set URL to test HTTPS connectivity
curl_setopt($ch, CURLOPT_URL, url::base());
// Disable following every "Location:" that is sent as part of the HTTP(S) header
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
// Suppress verification of the SSL certificate
/**
* E.Kala - 17th Feb 2011
* This currently causes an inifinte re-direct loop therefore
*/
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
// Disable checking of the Common Name (CN) in the SSL certificate; Certificate may not be X.509
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
// Suppress the header in the output
curl_setopt($ch, CURLOPT_HEADER, FALSE);
// Perform cURL session
curl_exec($ch);
// Get the cURL error no. returned; 71 => Connection failed, 0 => Success, 601=>SSL Cert validation failed
$curl_error_no = curl_errno($ch);
// Get the HTTP return code
$http_return_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Close the cURL resource
curl_close($ch);
unset($ch);
// Check if connection succeeded or there was an error (except authentication of cert with known CA certificates)
if ($curl_error_no > 0 and $curl_error_no != 60 or $http_return_code == 404) {
// Set the protocol in the config
Kohana::config_set('core.site_protocol', 'http');
// Re-write the config file and set $config['site_protocol'] back to 'http'
$config_file = @file('application/config/config.php');
$handle = @fopen('application/config/config.php', 'w');
if (is_array($config_file) and $handle) {
// Read each line in the file
foreach ($config_file as $line_number => $line) {
if (strpos(" " . $line, "\$config['site_protocol'] = 'https';") != 0) {
fwrite($handle, str_replace("https", "http", $line));
} else {
fwrite($handle, $line);
}
}
// Close the file
@fclose($handle);
}
}
}
}
示例5: register
/**
* Loads ushahidi themes
*/
public function register()
{
// Array to hold all the CSS files
$theme_css = array();
// 1. Load the default theme
Kohana::config_set('core.modules', array_merge(array(THEMEPATH . "default"), Kohana::config("core.modules")));
$css_url = Kohana::config("cache.cdn_css") ? Kohana::config("cache.cdn_css") : url::base();
// HACK: don't include the default style.css if using the ccnz theme
if (Kohana::config("settings.site_style") != "ccnz") {
$theme_css[] = $css_url . "themes/default/css/style.css";
}
// 2. Extend the default theme
if (Kohana::config("settings.site_style") != "default") {
$theme = THEMEPATH . Kohana::config("settings.site_style");
Kohana::config_set('core.modules', array_merge(array($theme), Kohana::config("core.modules")));
if (is_dir($theme . '/css')) {
$css = dir($theme . '/css');
// Load all the themes css files
while (($css_file = $css->read()) !== FALSE) {
if (preg_match('/\\.css/i', $css_file)) {
$theme_css[] = url::base() . "themes/" . Kohana::config("settings.site_style") . "/css/" . $css_file;
}
}
}
}
Kohana::config_set('settings.site_style_css', $theme_css);
}
示例6: package
public static function package($path)
{
Package_Message::log('debug', 'Attempting to import package ' . $path);
$filename = basename($path);
if (self::is_url($path)) {
$path = Package_Import_Remote::fetch($path);
}
$importPath = MODPATH . pathinfo($path, PATHINFO_FILENAME);
if (!class_exists('ZipArchive')) {
$return = FALSE;
Package_Message::log('debug', 'Attempting to unzip with: /usr/bin/unzip ' . $path . ' -d ' . MODPATH);
@system('/usr/bin/unzip ' . $path . ' -d ' . $importPath, $return);
if ($return !== 0) {
throw new Package_Import_Exception('System does not have zip archive support or could not extract ' . $path);
}
} else {
Package_Message::log('debug', 'Attempting to unzip with: ZipArchive->open(' . $path . ', ZIPARCHIVE::CHECKCONS)');
$zip = new ZipArchive();
if (!($error = $zip->open($path, ZIPARCHIVE::CHECKCONS))) {
switch ($error) {
case ZIPARCHIVE::ER_EXISTS:
throw new Package_Import_Exception('Package archive already exists: ' . $error);
case ZIPARCHIVE::ER_INCONS:
throw new Package_Import_Exception('Consistency check on the package archive failed: ' . $error);
case ZIPARCHIVE::ER_INVAL:
throw new Package_Import_Exception('Invalid argument while opening package archive: ' . $error);
case ZIPARCHIVE::ER_MEMORY:
throw new Package_Import_Exception('Memory allocation failure while opening package archive: ' . $error);
case ZIPARCHIVE::ER_NOENT:
throw new Package_Import_Exception('Could not locate package archive: ' . $error);
case ZIPARCHIVE::ER_NOZIP:
throw new Package_Import_Exception('Package archive is not a zip: ' . $error);
case ZIPARCHIVE::ER_OPEN:
throw new Package_Import_Exception('Cant open package archive: ' . $error);
case ZIPARCHIVE::ER_READ:
throw new Package_Import_Exception('Package archive read error: ' . $error);
case ZIPARCHIVE::ER_SEEK:
throw new Package_Import_Exception('Package archive seek error: ' . $error);
default:
throw new Package_Import_Exception('Unknown error while opening package archive: ' . $error);
}
}
if (is_dir($importPath)) {
throw new Package_Import_Exception('Import path `' . $importPath . '` already exists');
}
if (!@$zip->extractTo($importPath)) {
throw new Package_Import_Exception('Failed to extract package archive ' . $filename . ' or no permissions to unzip to ' . MODPATH);
}
$zip->close();
}
kohana::log('debug', 'Dynamically adding `' . $importPath . '` to kohana');
$loadedModules = Kohana::config('core.modules');
$modules = array_unique(array_merge($loadedModules, array($importPath)));
Kohana::config_set('core.modules', $modules);
Package_Catalog::disableRemote();
Package_Catalog::buildCatalog();
Package_Catalog::enableRemote();
return $importPath;
}
示例7: setUp
public function setUp()
{
if (($config = Kohana::config('cache.testing.file')) === NULL) {
$this->markTestSkipped('No cache.testing.file config found.');
}
Kohana::config_set('cache.testing.file.requests', 1);
$this->cache = Cache::instance('testing.file');
parent::setUp();
}
示例8: __construct
public function __construct()
{
parent::__construct();
if (IN_PRODUCTION) {
throw new Kohana_Exception('controller.not_found');
}
Kohana::config_set('database.default', Kohana::config('database.test'));
$this->profiler = new Profiler();
}
示例9: route_products_and_categories
/**
* Add routes for products
* @Developer brandon
* @Date Oct 19, 2010
*/
public static function route_products_and_categories()
{
foreach (ORM::factory('product')->find_all() as $object) {
Kohana::config_set('routes.' . $object->show_path(false), inflector::plural($object->object_name) . '/show/' . $object);
}
foreach (ORM::factory('category')->find_all() as $object) {
Kohana::config_set('routes.' . $object->show_path(false), inflector::plural($object->object_name) . '/show/' . $object);
}
}
示例10: nearest_city_locations
/**
* get the nearest locations by city
*
* @param string $city
* @param string $model
* @param integer $limit
* @param integer $offset
* @return array
* @author Andy Bennett
*/
public function nearest_city_locations($city, $model, $limit = null, $offset = null)
{
$ll = latlon::latlon_from_city($city);
if ($ll == false or empty($ll->latitude) or empty($ll->longitude)) {
return false;
}
Kohana::config_set('distance.lat', $ll->latitude);
Kohana::config_set('distance.lon', $ll->longitude);
return ORM::factory($model)->find_all($limit, $offset);
}
示例11: load_themes
static function load_themes()
{
$modules = Kohana::config("core.modules");
array_unshift($modules, THEMEPATH);
Kohana::config_set("core.modules", $modules);
theme::$name = config::get('s7n.theme');
if (strpos(Router::$current_uri, 'admin') === 0) {
theme::$name = 'admin';
}
}
示例12: load_themes
/**
* Load the active theme. This is called at bootstrap time. We will only ever have one theme
* active for any given request.
*/
static function load_themes()
{
$modules = Kohana::config("core.modules");
if (Router::$controller == "admin") {
array_unshift($modules, THEMEPATH . module::get_var("gallery", "active_admin_theme"));
} else {
array_unshift($modules, THEMEPATH . module::get_var("gallery", "active_site_theme"));
}
Kohana::config_set("core.modules", $modules);
}
示例13: load_themes
/**
* Load the active theme. This is called at bootstrap time. We will only ever have one theme
* active for any given request.
*/
static function load_themes()
{
$modules = Kohana::config("core.modules");
if (Router::$controller == "admin") {
array_unshift($modules, THEMEPATH . "admin_default");
} else {
array_unshift($modules, THEMEPATH . "default");
}
Kohana::config_set("core.modules", $modules);
}
示例14: group
public function group($group = FALSE, $config = 'default')
{
if ($group) {
$ut = new PHPUnit(array($group));
} else {
Kohana::config_set('phpunit.default.listGroups', TRUE);
$ut = new PHPUnit();
}
$ut->execute($config);
}
示例15: load
public static function load()
{
$query = Database::instance()->select('context, key, value')->get('config');
$result = $query->result();
foreach ($result as $item) {
if (Kohana::find_file('config', $item->context)) {
Kohana::config_set($item->context . '.' . $item->key, $item->value);
}
}
}