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


PHP Kohana::modules方法代码示例

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


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

示例1: cache

 /**
  * More feature-rich caching using the optional cache library if available. The default
  * Kohana cache doesn't support all the use cases below as expected. The default cache checks lifetime 
  * when getting based on the file modified time.
  * 
  * Simplified usage for both internal Kohana cache and cache module:
  * - cache() - Get/set.
  * - cache(true, 60) - Get/set.
  * - cache(true, 0) - Delete.
  * - cache(false) - Refresh.
  * - cache(false, 60) - Refresh.
  * - cache(false, 0) - Delete.
  * 
  * Specific usage for cache module:
  * - cache() - Get or set cache. Get cache. If empty, set cache using default lifetime.
  * - cache(true, 60) - Get or set cache. Same as above cache() but using specified lifetime.
  * - cache(true, 0) - Delete cache. Check and return cache if it exists, but also delete cache. 
  * 	  	for this query. If a cached result doesn't exist, then same effect as not using cache().
  * - cache(false) - Refresh cache. Don't check cache, but cache the new results using the default lifetime.
  * - cache(false, 60) - Refresh cache. Same as above cache(false) but using specified lifetime.
  * - cache(false, 0) - Delete cache. Don't check cache and delete cache for this query if it was previously cached.
  *
  * Specific usage if no cache module. Note that lifetime is meaningless when setting cache:
  * - cache() - 	1) Get cache. If cache exists and is younger than default lifetime, then get cache. 
  * 					If older than default time, delete cache.
  * 				2) Else set cache. Lifetime not used when setting.
  * - cache(true, 60) - 	Same as above cache(), but use specified lifetime instead of default lifetime.
  * - cache(true, 0) - Delete cache. Doesn't get or set cache.
  * - cache(false) - Refresh cache. Don't check cache, but cache the new results ignoring lifetime.
  * - cache(false, 60) - Refresh cache. Same as above cache(false).
  * - cache(false, 0) - Delete cache. Same as cache(true, 0);
  * 
  * @param boolean $check [optional] Check cache and return cached result if available.
  * @param integer $specific_lifetime [optional] Set cache lifetime. If null, use default. If "0", delete.
  * @param string $type [optional] Cache type name if using cache module. If null use default.
  * @return object $this
  */
 public function cache($check = TRUE, $specific_lifetime = NULL, $type = NULL)
 {
     if (!isset($this->_cache)) {
         // TODO: is this the best way to check for the "cache" module?
         $modules = Kohana::modules();
         if (isset($modules['cache'])) {
             // Use the "unofficial" Kohana cache module.
             $this->_cache = Cache::instance($type);
         } else {
             // Default internal Kohana cache.
             $this->_cache = true;
         }
     }
     if ($specific_lifetime === NULL) {
         if (is_object($this->_cache)) {
             // Use the default internal Kohana cache lifetime which is 60 seconds.
             $this->_cache_lifetime = 60;
         } else {
             // Use the default lifetime from the Cache module.
             $this->_cache_lifetime = Kohana::config('cache.default-expire');
         }
     } else {
         $this->_cache_lifetime = $specific_lifetime;
     }
     $this->_cache_check = $check;
     return $this;
 }
开发者ID:approots,项目名称:xdatabase,代码行数:64,代码来源:query.php

示例2: setUp

 public function setUp()
 {
     parent::setUp();
     $this->environment()->backup_and_set(array('Request::$client_ip' => '127.0.0.1', 'Request::$user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.162 Safari/535.19', 'functest.modules' => array('functest', 'test'), 'functest.apptests' => FALSE));
     $this->modpath = Arr::get(Kohana::modules(), 'functest');
     $this->test_folder = 'tests' . DIRECTORY_SEPARATOR . 'test_data' . DIRECTORY_SEPARATOR . 'test_folder' . DIRECTORY_SEPARATOR;
 }
开发者ID:openbuildings,项目名称:functest,代码行数:7,代码来源:Internal.php

示例3: init

 /**
  * Application initialization
  *     - Loads the plugins
  *     - Sets the cookie configuration
  */
 public static function init()
 {
     // Set defaule cache configuration
     Cache::$default = Kohana::$config->load('site')->get('default_cache');
     try {
         $cache = Cache::instance()->get('dummy' . rand(0, 99));
     } catch (Exception $e) {
         // Use the dummy driver
         Cache::$default = 'dummy';
     }
     // Load the plugins
     Swiftriver_Plugins::load();
     // Add the current default theme to the list of modules
     $theme = Swiftriver::get_setting('site_theme');
     if (isset($theme) and $theme != "default") {
         Kohana::modules(array_merge(array('themes/' . $theme->value => THEMEPATH . $theme->value), Kohana::modules()));
     }
     // Clean up
     unset($active_plugins, $theme);
     // Load the cookie configuration
     $cookie_config = Kohana::$config->load('cookie');
     Cookie::$httponly = TRUE;
     Cookie::$salt = $cookie_config->get('salt', Swiftriver::DEFAULT_COOKIE_SALT);
     Cookie::$domain = $cookie_config->get('domain') or '';
     Cookie::$secure = $cookie_config->get('secure') or FALSE;
     Cookie::$expiration = $cookie_config->get('expiration') or 0;
     // Set the default site locale
     I18n::$lang = Swiftriver::get_setting('site_locale');
 }
开发者ID:aliyubash23,项目名称:SwiftRiver,代码行数:34,代码来源:Swiftriver.php

示例4: instance

 /**
  * @return Kohana_Twig
  */
 public static function instance()
 {
     if (!static::$instance) {
         static::$instance = new self();
         // Load Twig configuration
         static::$instance->config = Kohana::$config->load('twig');
         // Array of template locations in cascading filesystem
         $templatesDir = static::$instance->config->templates_dir;
         $templatePaths = [APPPATH . $templatesDir];
         foreach (Kohana::modules() as $modulePath) {
             $tempPath = $modulePath . $templatesDir;
             if (is_dir($tempPath)) {
                 $templatePaths[] = $tempPath;
             }
         }
         // Create the the loader
         $loader = new Twig_Loader_Filesystem($templatePaths);
         // Set up Twig
         static::$instance->twig = new Twig_Environment($loader, static::$instance->config->environment);
         foreach (static::config('extensions', []) as $extension) {
             // Load extensions
             static::$instance->twig->addExtension(new $extension());
         }
     }
     return static::$instance;
 }
开发者ID:vspvt,项目名称:kohana-twig,代码行数:29,代码来源:Twig.php

示例5: before

 public function before()
 {
     // We need to load all theme modules
     foreach (scandir(MODPATH) as $modulePath) {
         if (substr($modulePath, 0, 5) == 'theme') {
             Kohana::modules(array($modulePath => MODPATH . $modulePath) + Kohana::modules());
         }
     }
 }
开发者ID:rockymontana,项目名称:kohana-module-pajas,代码行数:9,代码来源:media.php

示例6: _fetch_controllers

 private static function _fetch_controllers()
 {
     $paths = Kohana::modules() + array(APPPATH);
     $paths = array_values($paths);
     foreach ($paths as $index => $path) {
         $paths[$index] = rtrim($path, '/') . '/';
     }
     $paths = Kohana::list_files('classes/controller', $paths);
     return self::_path_to_controller($paths);
 }
开发者ID:pedma,项目名称:kohana-rbac,代码行数:10,代码来源:core.php

示例7: init

 /**
  * Инициализация модуля.
  * 
  * При инициализации активированные плагины подключаются через
  * Kohana::modules
  * 
  */
 public static function init()
 {
     self::$_activated = self::_load_from_db();
     $plugins = array();
     foreach (self::$_activated as $plugin_id => $tmp) {
         if (is_dir(PLUGPATH . $plugin_id)) {
             $plugins['plugin_' . $plugin_id] = PLUGPATH . $plugin_id;
         }
     }
     Kohana::modules($plugins + Kohana::modules());
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:18,代码来源:plugins.php

示例8: get_modules

 public static function get_modules()
 {
     if (self::$modules === null) {
         foreach (Kohana::modules() as $module => $path) {
             if (stripos($module, 'cms_') === 0) {
                 self::$modules[$module] = $path;
             }
         }
     }
     return self::$modules;
 }
开发者ID:eok8177,项目名称:shopCMS,代码行数:11,代码来源:Module.php

示例9: _execute

 protected function _execute(array $options)
 {
     $db = $this->db_params(Kohana::TESTING);
     Minion_Task::factory(array('task' => 'db:structure:load', 'database' => Kohana::TESTING, 'force' => NULL, 'file' => NULL))->execute();
     $structure_files = array_filter(array_map(function ($dir) use($db) {
         $file = $dir . 'tests' . DIRECTORY_SEPARATOR . 'database' . DIRECTORY_SEPARATOR . 'structure' . DIRECTORY_SEPARATOR . strtolower($db['type']) . '.sql';
         return is_file($file) ? $file : NULL;
     }, Kohana::modules()));
     foreach ($structure_files as $schema) {
         Minion_Task::factory(array('task' => 'db:structure:load', 'database' => Kohana::TESTING, 'force' => NULL, 'file' => $schema))->execute();
     }
 }
开发者ID:openbuildings,项目名称:timestamped-migrations,代码行数:12,代码来源:Load.php

示例10: __toString

 public function __toString()
 {
     // $attr = $this->_html_attr;
     // $attr['class'] = $this->css_class();
     // $attr['type'] = $this->field_type();
     // return Form::checkbox($this->name(), null, (bool)$this->value(), $attr);
     if (array_key_exists('recaptcha', Kohana::modules())) {
         $recap = Recaptcha::instance();
         return $recap->get_html();
     } else {
         return "";
     }
 }
开发者ID:hkilter,项目名称:OpenSupplyChains,代码行数:13,代码来源:recaptcha.php

示例11: on

 public static function on($name)
 {
     if (isset(self::$modules[$name])) {
         return;
     }
     foreach (self::$paths as $path) {
         if (is_dir($path . $name)) {
             self::$modules[$name] = $path . DS . $name;
             Kohana::modules(self::$modules);
             break;
         }
     }
 }
开发者ID:slik,项目名称:Kohana-depends,代码行数:13,代码来源:depends.php

示例12: generateJS

 private function generateJS($cacheFileName = 'leaflet-package.js')
 {
     $modulePath = Arr::get(Kohana::modules(), 'kohana-leaflet');
     $dir = $modulePath . 'media/js/';
     $jsContent = '/* Created :' . date('Y-m-d H:i:s') . ' */';
     foreach ($this->_jsFiles as $jsFile) {
         $fJSFile = $modulePath . $jsFile;
         if (file_exists($fJSFile)) {
             $jsFileContent = preg_replace('/\\s+/', ' ', file_get_contents($fJSFile));
             $jsContent .= "\n\n" . '/* JS from: ' . basename($fJSFile) . ' */' . "\n" . $jsFileContent;
         }
     }
     file_put_contents($dir . $cacheFileName, $jsContent);
 }
开发者ID:retio,项目名称:kohana-leaflet,代码行数:14,代码来源:leaflet.php

示例13: install

 /**
  * Run Plugin Installer Script if Available
  *
  * @param   string   plugin namespace
  * @return  bool
  */
 public static function install($plugin)
 {
     // Dynamically load the new module into the system
     Kohana::modules(array_merge(array(PLUGINPATH . $plugin), Kohana::modules()));
     // Does the plugin have an installer script?
     if (isset(self::$_installers[$plugin])) {
         try {
             call_user_func(self::$_installers[$plugin]);
             return TRUE;
         } catch (Exception $e) {
             Kohana::$log->add(Log::ERROR, "Could not execute plugin installer callback function :callback", array(':callback' => self::$_installers[$plugin]));
             return FALSE;
         }
     }
     return FALSE;
 }
开发者ID:aliyubash23,项目名称:SwiftRiver,代码行数:22,代码来源:Plugins.php

示例14: _execute

    protected function _execute(array $options)
    {
        $module_name = $options['module'];
        $module_dir = Arr::get(Kohana::modules(), $module_name);
        $author = $options['author'];
        switch ($options['type']) {
            case 'number':
                $parent = 'Stats_Widget_Number';
                break;
            case 'chart':
                $parent = 'Stats_Widget_Chart';
                break;
            default:
                $parent = 'Stats_Widget';
        }
        $name = $options['name'];
        $title = Jam::capitalize_class_name(str_replace('_', ' ', $name));
        $path = str_replace('_', DIRECTORY_SEPARATOR, $title);
        $dir = $module_dir . 'classes' . DIRECTORY_SEPARATOR . 'Stats' . DIRECTORY_SEPARATOR . 'Widget';
        $file = $dir . DIRECTORY_SEPARATOR . $path . EXT;
        $class = 'Stats_Widget_' . str_replace(' ', '_', $title);
        if (!is_dir(dirname($file))) {
            mkdir(dirname($file), 0777, TRUE);
        }
        $widget_content = <<<WIDGET
<?php defined('SYSPATH') OR die('No direct script access.');

/**
 * Stats Widget: {$title}
 *
 * @package {$module_name}
 * @author {$author}
 * @copyright  (c) 2011-2013 Despark Ltd.
 */
class {$class} extends {$parent} {

\tprotected \$_title = '{$title}';

\tpublic function retrieve(\$start_date, \$end_date)
\t{
\t\t// return 0;
\t}
}
WIDGET;
        Minion_Jam_Generate::modify_file($file, $widget_content, $options['force'] !== FALSE);
    }
开发者ID:openbuildings,项目名称:jam-tart,代码行数:46,代码来源:Widget.php

示例15: set_theme

 /**
  * Sets active theme if none supplied or uses the supplied one 
  *
  * @param  boolean|string  $theme  Theme name [Optional]
  */
 public static function set_theme($theme = FALSE)
 {
     if (!empty($theme)) {
         Theme::$active = $theme;
     }
     $modules = Kohana::modules();
     // Check if the active theme is not loaded already
     if (!empty(Theme::$active) and !in_array(Theme::$active, array_keys($modules))) {
         // Make sure the theme is available
         if ($theme = self::getTheme()) {
             //set absolute theme path and load the request theme as kohana module
             Kohana::modules(array('theme' => $theme->path) + $modules);
         } else {
             Log::error('Missing site theme: :theme', array(':theme' => Theme::$active));
         }
     }
     unset($modules);
 }
开发者ID:ultimateprogramer,项目名称:cms,代码行数:23,代码来源:theme.php


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