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


PHP Kohana类代码示例

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


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

示例1: index

 /**
  * Displays all feeds.
  */
 public function index()
 {
     $this->template->header->this_page = Kohana::lang('ui_admin.feeds');
     $this->template->content = new View('feed/feeds');
     // Pagination
     $pagination = new Pagination(array('query_string' => 'page', 'items_per_page' => (int) Kohana::config('settings.items_per_page'), 'total_items' => ORM::factory('feed_item')->count_all()));
     $feeds = ORM::factory('feed_item')->orderby('item_date', 'desc')->find_all((int) Kohana::config('settings.items_per_page'), $pagination->sql_offset);
     $this->template->content->feeds = $feeds;
     //Set default as not showing pagination. Will change below if necessary.
     $this->template->content->pagination = '';
     // Pagination and Total Num of Report Stats
     $plural = $pagination->total_items == 1 ? '' : 's';
     if ($pagination->total_items > 0) {
         $current_page = $pagination->sql_offset / (int) Kohana::config('settings.items_per_page') + 1;
         $total_pages = ceil($pagination->total_items / (int) Kohana::config('settings.items_per_page'));
         if ($total_pages > 1) {
             // Paginate results
             $pagination_stats = Kohana::lang('ui_admin.showing_page') . ' ' . $current_page . ' ' . Kohana::lang('ui_admin.of') . ' ' . $total_pages . ' ' . Kohana::lang('ui_admin.pages');
             $this->template->content->pagination_stats = $pagination_stats;
             $this->template->content->pagination = $pagination;
         } else {
             // No pagination
             $this->template->content->pagination_stats = $pagination->total_items . ' ' . Kohana::lang('ui_admin.feeds');
         }
     } else {
         $this->template->content->pagination_stats = $pagination->total_items . ' ' . Kohana::lang('ui_admin.feeds');
     }
 }
开发者ID:niiyatii,项目名称:crowdmap,代码行数:31,代码来源:feeds.php

示例2: 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

示例3: instance

 public static function instance()
 {
     if (!Kotwig::$instance) {
         Kotwig::$instance = new static();
         // Load Twig configuration
         Kotwig::$instance->config = Kohana::$config->load('kotwig');
         // Create the the loader
         $views = Kohana::include_paths();
         $look_in = array();
         foreach ($views as $key => $view) {
             $dir = $view . Kotwig::$instance->config->templates;
             if (is_dir($dir)) {
                 $look_in[] = $dir;
             }
         }
         $loader = new Twig_Loader_Filesystem($look_in);
         // Set up Twig
         Kotwig::$instance->twig = new Twig_Environment($loader, Kotwig::$instance->config->environment);
         foreach (Kotwig::$instance->config->extensions as $extension) {
             // Load extensions
             Kotwig::$instance->twig->addExtension(new $extension());
         }
         foreach (Kotwig::$instance->config->globals as $global => $object) {
             // Load globals
             Kotwig::$instance->twig->addGlobal($global, $object);
         }
         foreach (Kotwig::$instance->config->filters as $filter => $object) {
             // Load filters
             Kotwig::$instance->twig->addFilter($filter, $object);
         }
     }
     return Kotwig::$instance;
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:33,代码来源:Kotwig.php

示例4: execute

 public function execute($address)
 {
     Geocode_Yahoo::$_cacheKey = Geocode_Yahoo::CACHE_PREFIX . md5($address);
     $data = Kohana::cache(Geocode_Yahoo::$_cacheKey);
     if ($data === NULL) {
         try {
             $request = Geocode_Yahoo::API_URL . '?q=' . urlencode($address) . '&appid=' . $this->api_key . '&flags=' . $this->flags . '&locale=' . $this->locale;
             $sData = Request::factory($request)->execute()->body();
             $data = unserialize($sData);
             if ($data['ResultSet']['Error'] === 0 && $data['ResultSet']['Found'] > 0) {
                 $resultsArray = array();
                 foreach ($data['ResultSet']['Result'] as $k => $result) {
                     $resultsArray[] = array('lat' => (double) $result['latitude'], 'lng' => (double) $result['longitude'], 'zip' => (string) $result['postal'], 'city' => (string) $result['city'], 'state' => (string) $result['state'], 'country' => (string) $result['countrycode'], 'street_house' => (string) $result['street'] . ' ' . $result['house']);
                 }
                 $data = array('dataCount' => $data['ResultSet']['Found'], 'dataArray' => $resultsArray);
                 Kohana::cache(Geocode_Yahoo::$_cacheKey, $data, Geocode_Yahoo::CACHE_TIME);
             } else {
                 return FALSE;
             }
         } catch (Exception $e) {
             return FALSE;
         }
     }
     return $data;
 }
开发者ID:retio,项目名称:kohana-geocode,代码行数:25,代码来源:yahoo.php

示例5: 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

示例6: __construct

 /**
  * Loads encryption configuration and validates the data.
  *
  * @param   array|string      custom configuration or config group name
  * @throws  Kohana_Exception
  */
 public function __construct($config = FALSE)
 {
     if (!defined('MCRYPT_ENCRYPT')) {
         throw new Kohana_Exception('encrypt.requires_mcrypt');
     }
     if (is_string($config)) {
         $name = $config;
         // Test the config group name
         if (($config = Kohana::config('encryption.' . $config)) === NULL) {
             throw new Kohana_Exception('encrypt.undefined_group', $name);
         }
     }
     if (is_array($config)) {
         // Append the default configuration options
         $config += Kohana::config('encryption.default');
     } else {
         // Load the default group
         $config = Kohana::config('encryption.default');
     }
     if (empty($config['key'])) {
         throw new Kohana_Exception('encrypt.no_encryption_key');
     }
     // Find the max length of the key, based on cipher and mode
     $size = mcrypt_get_key_size($config['cipher'], $config['mode']);
     if (strlen($config['key']) > $size) {
         // Shorten the key to the maximum size
         $config['key'] = substr($config['key'], 0, $size);
     }
     // Find the initialization vector size
     $config['iv_size'] = mcrypt_get_iv_size($config['cipher'], $config['mode']);
     // Cache the config in the object
     $this->config = $config;
     Kohana::log('debug', 'Encrypt Library initialized');
 }
开发者ID:sydlawrence,项目名称:SocialFeed,代码行数:40,代码来源:Encrypt.php

示例7: __construct

 /**
  * Sets the config for the class.
  *
  * @param : array  - config passed from the payment library constructor
  */
 public function __construct($config)
 {
     $this->test_mode = $config['test_mode'];
     if ($this->test_mode) {
         $this->fields['USER'] = $config['SANDBOX_USER'];
         $this->fields['PWD'] = $config['SANDBOX_PWD'];
         $this->fields['SIGNATURE'] = $config['SANDBOX_SIGNATURE'];
         $this->fields['ENDPOINT'] = $config['SANDBOX_ENDPOINT'];
     } else {
         $this->fields['USER'] = $config['USER'];
         $this->fields['PWD'] = $config['PWD'];
         $this->fields['SIGNATURE'] = $config['SIGNATURE'];
         $this->fields['ENDPOINT'] = $config['ENDPOINT'];
     }
     $this->fields['VERSION'] = $config['VERSION'];
     $this->fields['CURRENCYCODE'] = $config['CURRENCYCODE'];
     $this->required_fields['USER'] = !empty($config['USER']);
     $this->required_fields['PWD'] = !empty($config['PWD']);
     $this->required_fields['SIGNATURE'] = !empty($config['SIGNATURE']);
     $this->required_fields['ENDPOINT'] = !empty($config['ENDPOINT']);
     $this->required_fields['VERSION'] = !empty($config['VERSION']);
     $this->required_fields['CURRENCYCODE'] = !empty($config['CURRENCYCODE']);
     $this->curl_config = $config['curl_config'];
     Kohana::log('debug', 'Paypalpro Payment Driver Initialized');
 }
开发者ID:darkcolonist,项目名称:kohana234-doctrine115,代码行数:30,代码来源:Paypalpro.php

示例8: save

 /**
  * Save an uploaded file to a new location. If no filename is provided,
  * the original filename will be used, with a unique prefix added.
  *
  * This method should be used after validating the $_FILES array:
  *
  *     if ($array->check())
  *     {
  *         // Upload is valid, save it
  *         Upload::save($_FILES['file']);
  *     }
  *
  * @param   array    uploaded file data
  * @param   string   new filename
  * @param   string   new directory
  * @param   integer  chmod mask
  * @return  string   on success, full path to new file
  * @return  FALSE    on failure
  */
 public static function save(array $file, $filename = NULL, $directory = NULL, $chmod = 0644)
 {
     if (!isset($file['tmp_name']) or !is_uploaded_file($file['tmp_name'])) {
         // Ignore corrupted uploads
         return FALSE;
     }
     if ($filename === NULL) {
         // Use the default filename, with a timestamp pre-pended
         $filename = uniqid() . $file['name'];
     }
     if (Upload::$remove_spaces === TRUE) {
         // Remove spaces from the filename
         $filename = preg_replace('/\\s+/', '_', $filename);
     }
     if ($directory === NULL) {
         // Use the pre-configured upload directory
         $directory = Upload::$default_directory;
     }
     if (!is_dir($directory) or !is_writable(realpath($directory))) {
         throw new Kohana_Exception('Directory :dir must be writable', array(':dir' => Kohana::debug_path($directory)));
     }
     // Make the filename into a complete path
     $filename = realpath($directory) . DIRECTORY_SEPARATOR . $filename;
     if (move_uploaded_file($file['tmp_name'], $filename)) {
         if ($chmod !== FALSE) {
             // Set permissions on filename
             chmod($filename, $chmod);
         }
         // Return new file path
         return $filename;
     }
     return FALSE;
 }
开发者ID:azuya,项目名称:Wi3,代码行数:52,代码来源:upload.php

示例9: login

 /**
  * 用户登陆
  * @method POST
  */
 public function login()
 {
     $post = $this->get_data();
     $mobile = trim($post['mobile']);
     $zone_code = $post['zone_code'] ? trim($post['zone_code']) : ($post['zonecode'] ? trim($post['zonecode']) : '86');
     $zone_code = str_replace('+', '', $zone_code);
     $password = trim($post['password']);
     if (empty($mobile)) {
         $this->send_response(400, NULL, '40001:手机号为空');
     }
     if (!international::check_is_valid($zone_code, $mobile)) {
         $this->send_response(400, NULL, '40002:手机号码格式不对');
     }
     if ($password == "") {
         $this->send_response(400, NULL, '40003:密码为空');
     }
     $user = $this->model->get_user_by_mobile($zone_code, $mobile);
     if (!$user) {
         $this->send_response(400, NULL, Kohana::lang('user.mobile_not_register'));
     }
     if (!password_verify($password, $user['password'])) {
         $this->send_response(400, NULL, Kohana::lang('user.username_password_not_match'));
     }
     $token = $this->model->create_token(3600, TRUE, array('zone_code' => $user['zone_code'], 'mobile' => $user['mobile'], 'id' => (int) $user['id']));
     $this->send_response(200, array('id' => (int) $user['uid'], 'name' => $user['username'], 'avatar' => sns::getavatar($user['uid']), 'access_token' => $token['access_token'], 'refresh_token' => $token['refresh_token'], 'expires_in' => $token['expires_in']));
 }
开发者ID:momoim,项目名称:momo-api,代码行数:30,代码来源:user.php

示例10: _execute

 /**
  * Generates a help list for all tasks
  *
  * @return null
  */
 protected function _execute(array $params)
 {
     $tasks = $this->_compile_task_list(Kohana::list_files('classes/task'));
     $view = new View('minion/help/list');
     $view->tasks = $tasks;
     echo $view;
 }
开发者ID:MenZil-Team,项目名称:cms,代码行数:12,代码来源:help.php

示例11: 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

示例12: __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

示例13: load

 /**
  * Returns the translation table for a given language.
  *
  * @param   string   language to load
  * @return  array
  */
 public static function load($lang)
 {
     if (!isset(I18n::$_cache[$lang])) {
         // Separate the language and locale
         list($language, $locale) = explode('-', strtolower($lang), 2);
         // Start a new translation table
         $table = array();
         // Add the non-specific language strings
         if ($files = Kohana::find_file('i18n', $language)) {
             foreach ($files as $file) {
                 // Merge the language strings into the translation table
                 $table = array_merge($table, require $file);
             }
         }
         // Add the locale-specific language strings
         if ($files = Kohana::find_file('i18n', $language . '/' . $locale)) {
             foreach ($files as $file) {
                 // Merge the locale strings into the translation table
                 $table = array_merge($table, require $file);
             }
         }
         // Cache the translation table locally
         I18n::$_cache[$lang] = $table;
     }
     return I18n::$_cache[$lang];
 }
开发者ID:ascseb,项目名称:core,代码行数:32,代码来源:i18n.php

示例14: index

 public function index()
 {
     role::check('user_charge_orders');
     /* 初始化默认查询条件 */
     $user_query_struct = array('where' => array(), 'like' => array(), 'orderby' => array('id' => "DESC"), 'limit' => array('per_page' => 20, 'offset' => 0));
     /* 用户列表模板 */
     $this->template->content = new View("user/user_charge_orders");
     /* 搜索功能 */
     $search_arr = array('order_num');
     $search_value = $this->input->get('search_value');
     $where_view = array();
     $user_query_struct['like']['order_num'] = $search_value;
     //$user_query_struct['like']['ret_order_num'] = $search_value;
     $where_view['search_value'] = $search_value;
     /* 每页显示条数 */
     $per_page = controller_tool::per_page();
     $user_query_struct['limit']['per_page'] = $per_page;
     /* 调用分页 */
     $this->pagination = new Pagination(array('total_items' => User_chargeService::get_instance()->query_count($user_query_struct), 'items_per_page' => $per_page));
     //d($this->pagination->sql_offset);
     $user_query_struct['limit']['offset'] = $this->pagination->sql_offset;
     $users = User_chargeService::get_instance()->lists($user_query_struct);
     $userobj = user::get_instance();
     foreach ($users as $key => $rowuser) {
         $users[$key]['userinfo'] = $userobj->get($rowuser['user_id']);
     }
     /* 调用列表 */
     $this->template->content->user_list = $users;
     $this->template->content->where = $where_view;
     $this->template->content->pay_banks = Kohana::config('pay_banks');
 }
开发者ID:RenzcPHP,项目名称:3dproduct,代码行数:31,代码来源:user_charge_orders.php

示例15: print_proxy

 public function print_proxy($site_key, $file_id)
 {
     // This function retrieves the full-sized image for fotomoto.
     //   As this function by-passes normal Gallery security, a private
     //   site-key is used to try and prevent people other then fotomoto
     //   from finding the URL.
     // If the site key doesn't match, display a 404 error.
     if ($site_key != module::get_var("fotomotorw", "fotomoto_private_key")) {
         throw new Kohana_404_Exception();
     }
     // Load the photo from the provided id.  If the id# is invalid, display a 404 error.
     $item = ORM::factory("item", $file_id);
     if (!$item->loaded()) {
         throw new Kohana_404_Exception();
     }
     // If the image file doesn't exist for some reason, display a 404 error.
     if (!file_exists($item->file_path())) {
         throw new Kohana_404_Exception();
     }
     // Display the image.
     header("Content-Type: {$item->mime_type}");
     Kohana::close_buffers(false);
     $fd = fopen($item->file_path(), "rb");
     fpassthru($fd);
     fclose($fd);
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:26,代码来源:fotomotorw.php


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