当前位置: 首页>>代码示例>>PHP>>正文


PHP Kohana::config方法代码示例

本文整理汇总了PHP中Kohana::config方法的典型用法代码示例。如果您正苦于以下问题:PHP Kohana::config方法的具体用法?PHP Kohana::config怎么用?PHP Kohana::config使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Kohana的用法示例。


在下文中一共展示了Kohana::config方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_form_xml

 /**
  * generate xml for a form from a table
  *
  * @param object $setup 
  * @return string
  * @author Andy Bennett
  */
 function get_form_xml($setup)
 {
     $file_name = $setup->form_name;
     $dir = DATAPATH . '/xml/forms/';
     $path = $dir . $file_name . '.xml';
     if (file_exists($path)) {
         return file_get_contents($path);
     }
     if (!isset($setup->model) || !is_object($setup->model)) {
         $config = Kohana::config('controls.controllers');
         $name = Kohana::instance()->uri->segment(1);
         if (!isset($config->{$name})) {
             throw new Exception("No controller set up");
         }
         $this->set_table($config->{$name}['table']);
     } else {
         $this->set_table($setup->model->get_table());
         $name = $setup->form_name;
     }
     $field_data = $this->db->field_data($this->table);
     // print_r($field_data);
     $view = new View('xml/form');
     $view->field_data = $field_data;
     $view->name = Kohana::instance()->uri->segment(1);
     $view->action = Kohana::instance()->uri->segment(2);
     $data = $view->render();
     if (file_exists($dir)) {
         file_put_contents($path, $data);
     }
     return $data;
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:38,代码来源:steamform.php

示例2: __construct

 /**
  * Twitter class constructor
  *
  * @param  string  $username	Twitter username
  * @param  string  $password	Twitter password for username
  * @param  string  $application	Twitter application name
  * @param  string  $format		Encoding format
  */
 function __construct($username, $password, $application = FALSE, $format = FALSE)
 {
     $this->login = "{$username}:{$password}";
     $this->application = $application ? $application : Kohana::config('twitter.application');
     $this->application = urlencode($this->application);
     $this->format = $format ? $format : Kohana::config('twitter.format');
 }
开发者ID:sydlawrence,项目名称:SocialFeed,代码行数:15,代码来源:Twitter.php

示例3: before

 public function before()
 {
     parent::before();
     // Borrowed from userguide
     if (isset($_GET['lang'])) {
         $lang = $_GET['lang'];
         // Make sure the translations is valid
         $translations = Kohana::message('langify', 'translations');
         if (in_array($lang, array_keys($translations))) {
             // Set the language cookie
             Cookie::set('langify_language', $lang, Date::YEAR);
         }
         // Reload the page
         $this->request->redirect($this->request->uri());
     }
     // Set the translation language
     I18n::$lang = Cookie::get('langify_language', Kohana::config('langify')->lang);
     // Borrowed from Vendo
     // Automaticly load a view class based on action.
     $view_name = $this->view_prefix . Request::current()->action();
     if (Kohana::find_file('classes', strtolower(str_replace('_', '/', $view_name)))) {
         $this->view = new $view_name();
         $this->view->set('version', $this->version);
     }
 }
开发者ID:Hinton,项目名称:langify,代码行数:25,代码来源:base.php

示例4: 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;
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:27,代码来源:Task_Queue.php

示例5: __construct

 /**
  * Tests that the storage location is a directory and is writable.
  */
 public function __construct($filename)
 {
     // Get the directory name
     $directory = str_replace('\\', '/', realpath(pathinfo($filename, PATHINFO_DIRNAME))) . '/';
     // Set the filename from the real directory path
     $filename = $directory . basename($filename);
     // Make sure the cache directory is writable
     if (!is_dir($directory) or !is_writable($directory)) {
         throw new Kohana_Exception('cache.unwritable', $directory);
     }
     // Make sure the cache database is writable
     if (is_file($filename) and !is_writable($filename)) {
         throw new Kohana_Exception('cache.unwritable', $filename);
     }
     // Open up an instance of the database
     $this->db = new SQLiteDatabase($filename, '0666', $error);
     // Throw an exception if there's an error
     if (!empty($error)) {
         throw new Kohana_Exception('cache.driver_error', sqlite_error_string($error));
     }
     $query = "SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'caches'";
     $tables = $this->db->query($query, SQLITE_BOTH, $error);
     // Throw an exception if there's an error
     if (!empty($error)) {
         throw new Kohana_Exception('cache.driver_error', sqlite_error_string($error));
     }
     if ($tables->numRows() == 0) {
         Kohana::log('error', 'Cache: Initializing new SQLite cache database');
         // Issue a CREATE TABLE command
         $this->db->unbufferedQuery(Kohana::config('cache_sqlite.schema'));
     }
 }
开发者ID:momoim,项目名称:momo-api,代码行数:35,代码来源:Sqlite.php

示例6: _dump_database

 private function _dump_database()
 {
     // We now have a clean install with just the packages that we want.  Make sure that the
     // database is clean too.
     $i = 1;
     foreach (array("dashboard_sidebar", "dashboard_center", "site_sidebar") as $key) {
         $blocks = array();
         foreach (unserialize(module::get_var("gallery", "blocks_{$key}")) as $rnd => $value) {
             $blocks[++$i] = $value;
         }
         module::set_var("gallery", "blocks_{$key}", serialize($blocks));
     }
     Database::instance()->query("TRUNCATE {caches}");
     Database::instance()->query("TRUNCATE {sessions}");
     Database::instance()->query("TRUNCATE {logs}");
     db::build()->update("users")->set(array("password" => ""))->where("id", "in", array(1, 2))->execute();
     $dbconfig = Kohana::config('database.default');
     $conn = $dbconfig["connection"];
     $sql_file = DOCROOT . "installer/install.sql";
     if (!is_writable($sql_file)) {
         print "{$sql_file} is not writeable";
         return;
     }
     $command = sprintf("mysqldump --compact --skip-extended-insert --add-drop-table %s %s %s %s > {$sql_file}", escapeshellarg("-h{$conn['host']}"), escapeshellarg("-u{$conn['user']}"), $conn['pass'] ? escapeshellarg("-p{$conn['pass']}") : "", escapeshellarg($conn['database']));
     exec($command, $output, $status);
     if ($status) {
         print "<pre>";
         print "{$command}\n";
         print "Failed to dump database\n";
         print implode("\n", $output);
         return;
     }
     // Post-process the sql file
     $buf = "";
     $root = ORM::factory("item", 1);
     $root_created_timestamp = $root->created;
     $root_updated_timestamp = $root->updated;
     $table_name = "";
     foreach (file($sql_file) as $line) {
         // Prefix tables
         $line = preg_replace("/(CREATE TABLE|IF EXISTS|INSERT INTO) `{$dbconfig['table_prefix']}(\\w+)`/", "\\1 {\\2}", $line);
         if (preg_match("/CREATE TABLE {(\\w+)}/", $line, $matches)) {
             $table_name = $matches[1];
         }
         // Normalize dates
         $line = preg_replace("/,{$root_created_timestamp},/", ",UNIX_TIMESTAMP(),", $line);
         $line = preg_replace("/,{$root_updated_timestamp},/", ",UNIX_TIMESTAMP(),", $line);
         // Remove ENGINE= specifications execpt for search records, it always needs to be MyISAM
         if ($table_name != "search_records") {
             $line = preg_replace("/ENGINE=\\S+ /", "", $line);
         }
         // Null out ids in the vars table since it's an auto_increment table and this will result in
         // more stable values so we'll have less churn in install.sql.
         $line = preg_replace("/^INSERT INTO {vars} VALUES \\(\\d+/", "INSERT INTO {vars} VALUES (NULL", $line);
         $buf .= $line;
     }
     $fd = fopen($sql_file, "wb");
     fwrite($fd, $buf);
     fclose($fd);
 }
开发者ID:HarriLu,项目名称:gallery3,代码行数:60,代码来源:packager.php

示例7: action_index

 /**
  * Processes incoming text
  */
 public function action_index()
 {
     $this->request->headers['Content-type'] = 'image/png';
     // Grab text and styles
     $text = arr::get($_GET, 'text');
     $styles = $_GET;
     $hover = FALSE;
     try {
         // Create image
         $img = new PNGText($text, $styles);
         foreach ($styles as $key => $value) {
             if (substr($key, 0, 6) == 'hover-') {
                 // Grab hover associated styles and override existing styles
                 $hover = TRUE;
                 $styles[substr($key, 6)] = $value;
             }
         }
         if ($hover) {
             // Create new hover image and stack it
             $hover = new PNGText($text, $styles);
             $img->stack($hover);
         }
         echo $img->draw();
     } catch (Exception $e) {
         if (Kohana::config('pngtext.debug')) {
             // Dump error message in an image form
             $img = imagecreatetruecolor(strlen($e->getMessage()) * 6, 16);
             imagefill($img, 0, 0, imagecolorallocate($img, 255, 255, 255));
             imagestring($img, 2, 0, 0, $e->getMessage(), imagecolorallocate($img, 0, 0, 0));
             echo imagepng($img);
         }
     }
 }
开发者ID:andygoo,项目名称:kohana-pngtext,代码行数:36,代码来源:pngtext.php

示例8: run_install

    /**
     * Creates the required database tables for the smssync plugin
     */
    public function run_install()
    {
        // Create the database tables.
        // Also include table_prefix in name
        $this->db->query('CREATE TABLE IF NOT EXISTS `' . Kohana::config('database.default.table_prefix') . 'densitymap_geometry` (
				  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
				  `category_id` int(11) NOT NULL,
				  `kml_file` varchar(200) default NULL,
				  `label_lat` double NOT NULL DEFAULT \'0\',
  				  `label_lon` double NOT NULL DEFAULT \'0\',
				  PRIMARY KEY (`id`)
				) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1');
        //check and see if the densitymap_geometry table already has the label_lat and label_lon columns. If not make it
        $result = $this->db->query('DESCRIBE `' . Kohana::config('database.default.table_prefix') . 'densitymap_geometry`');
        $has_lat = false;
        $has_lon = false;
        foreach ($result as $row) {
            if ($row->Field == "label_lat") {
                $has_lat = true;
            }
            if ($row->Field == "label_lon") {
                $has_lon = true;
            }
        }
        if (!$has_lat) {
            $this->db->query('ALTER TABLE `' . Kohana::config('database.default.table_prefix') . 'densitymap_geometry` ADD `label_lat` double NOT NULL DEFAULT \'0\'');
        }
        if (!$has_lon) {
            $this->db->query('ALTER TABLE `' . Kohana::config('database.default.table_prefix') . 'densitymap_geometry` ADD `label_lon` double NOT NULL DEFAULT \'0\'');
        }
    }
开发者ID:rjmackay,项目名称:densitymap,代码行数:34,代码来源:densitymap_install.php

示例9: instance

 /**
  * Creates a new request cache decorator of the type defined. If no decorator type
  * is supplied, the `vitesse.default_decorator` configuration setting will be used.
  * 
  *     // Create a new memcache decorator
  *     $decorator = Request_Cache_Decorator::instance('Memcache');
  *
  *     // Create a new default decorator
  *     $default_decorator = Request_Cache_Decorator::instance();
  *
  * @param   string   decorator class name
  * @return  Request_Cache_Adaptor
  * @throws  Kohana_Request_Exception
  */
 public static function instance($decorator = NULL)
 {
     // Load the vitesse config
     $config = Kohana::config('vitesse');
     // If the adaptor isn't defined
     if ($decorator === NULL) {
         // Set it to the default adaptor
         $decorator = Request_Cache_Decorator::$default;
     }
     // Create the full adaptor class name
     $decorator_class = 'Request_Cache_Decorator_' . $decorator;
     // If an instance already exists
     if (isset(Request_Cache_Decorator::$_instances[$decorator_class])) {
         // Return the instance
         return Request_Cache_Decorator::$_instances[$decorator_class];
     }
     // Create a new decorator class
     $decorator = new $decorator_class($config->cache_configuration_groups);
     // If the decorator is not of the correct type
     if (!$decorator instanceof Request_Cache_Decorator) {
         // Throw an exception
         throw new Kohana_Request_Exception('Decorator supplied is not an instance of Request_Cache_Decorator : :class', array(':class' => get_class($decorator)));
     }
     // Set the instance to the class
     Request_Cache_Decorator::$_instances[$decorator_class] = $decorator;
     // Return the decorator
     return $decorator;
 }
开发者ID:samsoir,项目名称:vitesse,代码行数:42,代码来源:decorator.php

示例10: index

 public function index($feedtype = 'rss2')
 {
     if (!Kohana::config('settings.allow_feed')) {
         throw new Kohana_404_Exception();
     }
     if ($feedtype != 'atom' and $feedtype != 'rss2') {
         throw new Kohana_404_Exception();
     }
     $feedpath = $feedtype == 'atom' ? 'feed/atom/' : 'feed/';
     $site_url = url::base();
     $incidents = ORM::factory('incident')->where('incident_active', '1')->orderby('incident_date', 'desc')->limit(20)->find_all();
     $items = array();
     foreach ($incidents as $incident) {
         $item = array();
         $item['title'] = $incident->incident_title;
         $item['link'] = $site_url . 'reports/view/' . $incident->id;
         $item['description'] = $incident->incident_description;
         $item['date'] = $incident->incident_date;
         if ($incident->location_id != 0 and $incident->location->longitude and $incident->location->latitude) {
             $item['point'] = array($incident->location->latitude, $incident->location->longitude);
             $items[] = $item;
         }
     }
     header("Content-Type: text/xml; charset=utf-8");
     $view = new View('feed_' . $feedtype);
     $view->feed_title = htmlspecialchars(Kohana::config('settings.site_name'));
     $view->site_url = $site_url;
     $view->georss = 1;
     // this adds georss namespace in the feed
     $view->feed_url = $site_url . $feedpath;
     $view->feed_date = gmdate("D, d M Y H:i:s T", time());
     $view->feed_description = 'Incident feed for ' . Kohana::config('settings.site_name');
     $view->items = $items;
     $view->render(TRUE);
 }
开发者ID:sclode,项目名称:Ushahidi_Web,代码行数:35,代码来源:feed.php

示例11: queryRepositories

 public static function queryRepositories($repos = NULL)
 {
     if (is_null($repos)) {
         $repos = Kohana::config('core.repositories');
     }
     if (!is_array($repos)) {
         $repos = array($repos);
     }
     if (empty($repos)) {
         return array();
     }
     $remoteCatalogs = array();
     foreach ($repos as $repo) {
         if (!($repoXMLCatalog = self::fetch($repo))) {
             continue;
         }
         $remoteCatalog = self::fromXML($repoXMLCatalog);
         foreach ($remoteCatalog as $package) {
             Package_Catalog_Standardize::packageData($package, NULL);
             Package_Catalog_Standardize::navigation($package);
             if (empty($package['identifier'])) {
                 Package_Message::log('alert', 'Remote repo ' . $repo . ' provided an invalid package, ignoring!');
                 continue;
             }
             if (array_key_exists($package['identifier'], Package_Catalog::getCatalog())) {
                 Package_Message::log('debug', 'Remote repo ' . $repo . ' provided existing package ' . $package['packageName'] . ' version ' . $package['version'] . ', ignoring');
                 continue;
             }
             Package_Message::log('debug', 'Remote repo ' . $repo . ' provided new package ' . $package['packageName'] . ' version ' . $package['version']);
             $package['status'] = Package_Manager::STATUS_UNINSTALLED;
             $remoteCatalogs[$package['identifier']] = $package;
         }
     }
     return $remoteCatalogs;
 }
开发者ID:swk,项目名称:bluebox,代码行数:35,代码来源:Remote.php

示例12: connect

 public static function connect()
 {
     if (!is_object(self::$cnn)) {
         self::$cnn = new AMQPConnect(Kohana::config('uap.rabbitmq'));
     }
     return self::$cnn;
 }
开发者ID:momoim,项目名称:momo-api,代码行数:7,代码来源:mq.php

示例13: before

 public function before()
 {
     if ($this->request->action === 'media') {
         // Do not template media files
         $this->auto_render = FALSE;
     } else {
         // Grab the necessary routes
         $this->media = Route::get('docs/media');
         $this->api = Route::get('docs/api');
         $this->guide = Route::get('docs/guide');
         if (isset($_GET['lang'])) {
             $lang = $_GET['lang'];
             // Load the accepted language list
             $translations = array_keys(Kohana::message('userguide', 'translations'));
             if (in_array($lang, $translations)) {
                 // Set the language cookie
                 Cookie::set('userguide_language', $lang, Date::YEAR);
             }
             // Reload the page
             $this->request->redirect($this->request->uri);
         }
         // Set the translation language
         I18n::$lang = Cookie::get('userguide_language', Kohana::config('userguide')->lang);
         // Use customized Markdown parser
         define('MARKDOWN_PARSER_CLASS', 'Kodoc_Markdown');
         // Load Markdown support
         require Kohana::find_file('vendor', 'markdown/markdown');
         // Set the base URL for links and images
         Kodoc_Markdown::$base_url = URL::site($this->guide->uri()) . '/';
         Kodoc_Markdown::$image_url = URL::site($this->media->uri()) . '/';
     }
     parent::before();
 }
开发者ID:banks,项目名称:userguide,代码行数:33,代码来源:userguide.php

示例14: __construct

    public function __construct($api_service)    
    {    
        $this->db = new Database();
        
        $this->api_settings = new Api_Settings_Model(1);

        // Set the list limit
        $this->list_limit = ((int) $this->api_settings->default_record_limit > 0)
            ? $this->api_settings->default_record_limit
            : (int) Kohana::config('settings.items_per_api_request');
        
        $this->domain = url::base();
        $this->record_count = 1;
        $this->table_prefix = Kohana::config('database.default.table_prefix');
        $this->api_service = $api_service;
        
        // Check if the response type for the API service has already been set
        if ( ! is_null($api_service->get_response_type()))
        {
            $this->request = $api_service->get_request();
            $this->response_type = $api_service->get_response_type();
        }
        else
        {
            $this->set_request($api_service->get_request());
        }
    }
开发者ID:nurous,项目名称:bushfireconnect,代码行数:27,代码来源:Api_Object.php

示例15: __construct

 public function __construct($group = 'default')
 {
     $this->config = Kohana::config('migrations');
     $this->group = $group;
     $this->config['path'] = $this->config['path'][$group];
     $this->config['info'] = $this->config['path'] . $this->config['info'] . '/';
 }
开发者ID:bosoy83,项目名称:kohana-3-migrations,代码行数:7,代码来源:migrations.php


注:本文中的Kohana::config方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。