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


PHP Kohana::instance方法代码示例

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


在下文中一共展示了Kohana::instance方法的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

 /**
  * Loads URI, and Input into this controller.
  *
  * @return  void
  */
 public function __construct()
 {
     if (Kohana::$instance == NULL) {
         // Set the instance to the first controller loaded
         Kohana::$instance = $this;
     }
 }
开发者ID:assad2012,项目名称:gallery3-appfog,代码行数:12,代码来源:Controller.php

示例3: set_checkbox

 public static function set_checkbox($field = '', $value = '', $default = FALSE)
 {
     if ($_POST) {
         if (!Kohana::instance()->input->post($field)) {
             if (count($_POST) === 0) {
                 return ' checked="checked"';
             }
             return '';
         }
         $field = Kohana::instance()->input->post($field);
         if (is_array($field)) {
             if (!in_array($value, $field)) {
                 return '';
             } else {
                 return ' checked="checked"';
             }
         } else {
             if ($field == '' or $value == '' or $field != $value) {
                 return '';
             } else {
                 return ' checked="checked"';
             }
         }
     } elseif ($default) {
         return ' checked="checked"';
     }
 }
开发者ID:steamboy,项目名称:ds,代码行数:27,代码来源:MY_form.php

示例4: get_list

 /**
  * get the list of gallery items
  *
  * @param int $gid 
  * @return array
  * @author Andy Bennett
  */
 function get_list($gid)
 {
     $data = array('action' => 'list', 'name' => $this->name, 'role' => Steamauth::instance()->get_role());
     Event::run('steamcore.aclcheck', $data);
     // which model are we using? one passed through or the default?
     $model = $this->model;
     $controller = Kohana::instance()->uri->segment(1);
     $tdata = array();
     $limit = 10;
     $where = null;
     if ($this->uri->segment(3)) {
         $where = array('gallery' => $gid);
     }
     // query the model
     $pagination = pagination_helper::get_pagination($limit, $model->get_total($where));
     $l = steamcore::array_object(array('limit' => $limit, 'offset' => $pagination->sql_offset()));
     $data['query'] = $model->get_list($where, $order = null, $limit = $l);
     $data['controller'] = $controller;
     $data['pagination'] = $pagination->render();
     // pass the order direction
     // $data['od'] = (!isset($lc->query_config->order_dir) || $lc->query_config->order_dir == 'DESC')?'ASC':'DESC';
     // merge any passed data and the data returned from the model
     $tdata = array_merge($tdata, $data);
     // return the result
     return $tdata;
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:33,代码来源:gallery.php

示例5: __construct

 /**
  * Loads URI, and Input into this controller.
  *
  * @return  void
  */
 public function __construct()
 {
     if (Kohana::$instance == NULL) {
         // Set the instance to the first controller loaded
         Kohana::$instance = $this;
     }
     // URI should always be available
     $this->uri = URI::instance();
     // Input should always be available
     $this->input = Input::instance();
     $this->db = new Database();
     $this->user_model = ORM::factory('user');
     $this->supplier_model = ORM::factory('supplier');
     $this->category_model = ORM::factory('category');
     $this->item_model = ORM::factory('item');
     $this->item_stock_model = ORM::factory('item_stock');
     $this->district_model = ORM::factory('district');
     $this->office_model = ORM::factory('office');
     $this->budget_model = ORM::factory('office_budget');
     $this->purchase_model = ORM::factory('purchase');
     $this->request_model = ORM::factory('request');
     $this->transaction_model = ORM::factory('transaction');
     $this->setting_model = ORM::factory('setting');
     $this->log_model = ORM::factory('log');
     $this->email_model = ORM::factory('email');
 }
开发者ID:humbleBeginner,项目名称:inventory-pho2,代码行数:31,代码来源:Controller.php

示例6: error_404

function error_404()
{
    if (Kohana::$instance == NULL) {
        Kohana::$instance = new Errors_Controller();
    }
    Kohana::show_404(null, 'common/error_404');
}
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:7,代码来源:errors.php

示例7: error_404

function error_404()
{
    if (Kohana::$instance == NULL) {
        Kohana::$instance = new Errors_Controller();
    }
    Kohana::log('error', 'Error 404 (steam.core.hooks): ' . URI::instance()->string());
    Kohana::show_404(null, 'common/error_404');
}
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:8,代码来源:errors.php

示例8: get_upload_config

 public function get_upload_config()
 {
     // get the default upload config from appconf
     $uconf = Kohana::config('upload.upload');
     $s = Kohana::instance()->uri->segment(1);
     if (!isset($uconf->multi->{$s})) {
         throw new Exception("No config item for " . $s);
     }
     return $uconf->multi->{$s};
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:10,代码来源:gallery_helper.php

示例9: __construct

 /**
  * Loads URI, and Input into this controller.
  *
  * @return  void
  */
 public function __construct()
 {
     if (Kohana::$instance == NULL) {
         // Set the instance to the first controller loaded
         Kohana::$instance = $this;
     }
     // URI should always be available
     $this->uri = URI::instance();
     // Input should always be available
     $this->input = Input::instance();
 }
开发者ID:nebogeo,项目名称:borrowed-scenery,代码行数:16,代码来源:Controller.php

示例10: get_pagination

 function get_pagination($limit, $total)
 {
     $pagination = new Pagination();
     // pull the pagination config from the config/my_controller.php
     $config = Kohana::config('steam.pagination_config');
     // set the base url
     $config['base_url'] = Kohana::instance()->uri->string();
     $config['uri_segment'] = 'admin';
     $config['total_items'] = $total;
     $config['items_per_page'] = $limit;
     $config['style'] = 'custom';
     $pagination->initialize($config);
     return $pagination;
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:14,代码来源:pagination_helper.php

示例11: get_where

 /**
  * get the where query
  *
  * @param string $w 
  * @return array
  * @author Andy Bennett
  */
 function get_where($w = null)
 {
     $controller = Kohana::instance()->uri->segment(1);
     $where = array();
     #$where = array('s.title' => $controller);
     if (!is_null($w)) {
         $where = array_merge($w, $where);
     }
     $t = parent::get_table();
     if (!Acl::instance()->check(Steamauth::instance()->get_role(), 'gallery', 'moderate')) {
         $where[$t . '.status'] = '1';
     }
     return $where;
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:21,代码来源:gallery.php

示例12: get_list

 /**
  * return list
  *
  * @param object $lc 
  * @return array
  * @author Andy Bennett
  */
 public function get_list()
 {
     $data = array('action' => 'list', 'name' => $this->name, 'role' => User::instance()->get_role());
     Event::run('steamcore.aclcheck', $data);
     $tdata = array();
     $limit = 10;
     $page_num = $this->input->get('page', 1);
     $offset = ($page_num - 1) * $limit;
     $model = ORM::factory($this->setup['model'], null);
     $data['query'] = $model->where('role', URI::segment(1))->find_all($limit, $offset);
     $data['controller'] = Kohana::instance()->uri->segment(1);
     $data['pagination'] = Pagination::factory(array('style' => 'digg', 'items_per_page' => $limit, 'query_string' => 'page', 'total_items' => $model->count_last_query()));
     // merge any passed data and the data returned from the model
     $tdata = array_merge($tdata, $data);
     // return the result
     return $tdata;
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:24,代码来源:Authadmin.php

示例13: edit_inline

 /**
  * This produces a form for editing the copy and headers in a page
  *
  * @return void
  * @author Dan Chadwick
  **/
 function edit_inline()
 {
     // $d = array(
     // 	'model' => steamcore::get_controls_model( 'pages' ),
     // 	'form_name' => 'pages_edit',
     // 	'form_data' => array(),
     // 	'update' => ($r->count())?$r->current()->id:0
     // 	);
     // $setup = steamcore::array_object( $d );
     //
     // /* Clear events */
     // Event::clear('steamform_'.$setup->form_name.'.complete');
     // Event::clear('steamform_'.$setup->form_name.'.show_form');
     //
     // Event::add('steamform_'.$setup->form_name.'.complete', array('admin_helpers', 'response_complete_listener') );
     // Event::add('steamform_'.$setup->form_name.'.show_form', array('admin_helpers', 'show_form_listener') );
     //
     try {
         $p = Kohana::instance()->uri->segment(2, 'home');
         $p = str_replace('.html', '', $p);
         $m = ORM::factory('page')->where('name', $p)->find();
         $form = Xform::factory()->name('xpage_contents_edit');
         // create the form
         $form->set_form_data('current', $m);
         $form->run();
         // run the form
         // handle form completion
         if (!$form->complete) {
             return $form->render();
         } else {
             $cols = array_keys($m->table_columns);
             foreach ($form->final_data as $k => $v) {
                 if (!in_array($k, $cols)) {
                     continue;
                 }
                 $m->{$k} = $v;
             }
         }
     } catch (Exception $e) {
         throw new Kohana_User_Exception('SteamCore Add Error', $e->getMessage());
     }
     // Assets::instance()->add_javascript('/cache/js/steamform');
     // Assets::instance()->add_javascript('/steamform/index/steamform');
     return $e;
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:51,代码来源:template_editor_helper.php

示例14: get_list

 /**
  * return list
  *
  * @param object $lc 
  * @return array
  * @author Andy Bennett
  */
 public function get_list()
 {
     $data = array('action' => 'list', 'name' => $this->name, 'role' => User::instance()->get_role());
     Event::run('steamcore.aclcheck', $data);
     $tdata = array();
     $limit = -1;
     $page_num = Input::instance()->get('page', 1);
     $offset = ($page_num - 1) * $limit;
     $model = ORM::factory($this->setup['model'], null);
     $data['query'] = $model->find_all();
     $type = Input::instance()->get('type', false);
     $data['type'] = $type ? 'type=' . $type : '';
     $data['controller'] = Kohana::instance()->uri->segment(1);
     $data['pagination'] = '';
     $data['page'] = $page_num;
     // merge any passed data and the data returned from the model
     $tdata = array_merge($tdata, $data);
     // return the result
     return $tdata;
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:27,代码来源:Steam_ordered.php

示例15: render

 public static function render($content, $container_id = false, $dir = "containers/", $additional = array())
 {
     $container_id = $container_id ? $container_id : self::get_container();
     $kohana = Kohana::instance();
     $c = new Container($container_id);
     $view = new View($dir . $c->get_template());
     $view->header = $content->header;
     $view->sub_header = $content->sub_header;
     $view->main_content = $content->copy;
     $view->section_nav = current(self::return_column($c, array('column' => 'nav')));
     $view->left_column = self::return_column($c, array('column' => 'left-col'));
     $view->mid_column = self::return_column($c, array('column' => 'middle-col'));
     $view->right_column = self::return_column($c, array('column' => 'right-col'));
     if (is_array($additional)) {
         foreach ($additional as $a => $v) {
             $view->{$a} = $v;
         }
     }
     Display::instance()->display($view);
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:20,代码来源:containers_helper.php


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