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


PHP Uri::instance方法代码示例

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


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

示例1: getInstance

 /**
  *
  * Return URI instance
  *
  * @access public
  *
  * @return object
  *
  */
 public static function getInstance()
 {
     if (is_null(self::$instance)) {
         self::$instance = new uri();
     }
     return self::$instance;
 }
开发者ID:fallouseven,项目名称:projet_rpm,代码行数:16,代码来源:Uri.php

示例2: __construct

 function __construct($config = array())
 {
     parent::__construct();
     $name = Uri::instance()->segment(1, Kohana::config('controls.default_controller'));
     $setup = Kohana::config('controls.' . $name);
     if ($setup != false) {
         $this->setup = $setup;
     } else {
         $this->setup = array();
         $this->setup['name'] = $name;
         $this->setup['model'] = inflector::singular($name);
         $this->setup['table'] = $name;
         $this->setup['view'] = 'standard';
     }
     $this->name = $this->setup['name'];
     $this->set_listeners();
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:17,代码来源:Steam.php

示例3: get_page

 public function get_page()
 {
     $c = URI::instance()->segment(1, 'page');
     if ($c != 'page' and $c != 'auth') {
         return $c;
     }
     $p = Uri::instance()->segment(2, 'home');
     $pos = strrpos($p, '.');
     if ($pos !== false) {
         $p = substr($p, 0, $pos);
     }
     return $p;
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:13,代码来源:Sitemap_Base.php

示例4: __construct

 /**
  * Loads URI and Input objects into the controller.
  * Check if the requested environment supports by the system.
  * @throws Exception_Exido
  */
 public function __construct()
 {
     // Check environment
     if (!in_array(EXIDO_ENVIRONMENT_NAME, $this->_envs)) {
         throw new Exception_Exido('The requested environment %s does not supported by the system', array(EXIDO_ENVIRONMENT_NAME));
     }
     // URI should always be available
     $this->uri = Uri::instance();
     // Input should always be available
     $this->input = Input::instance();
     // Init a model loader object
     $this->_model = Registry::factory('Model');
     // Input should always be available
     $this->view = View::instance();
     // Session object
     $this->session = Registry::factory('Session');
     // Init layout view object
     $this->_viewLayout = Registry::factory('View_Layout');
     // Init action view object
     $this->_viewAction = Registry::factory('View_Action');
     // Get active components
     $this->_components = $this->model('Model_Component')->getActiveComponents();
     // Get session data
     $_user_key = $this->_getCurrentUser();
     // If current user is unknown so we should start guest session
     if (empty($_user_key)) {
         // Guest session id
         $_user_key = '5627a272bf2563cee5877539bd906e7cc3eb33afcefe2b570a08906f9a34ae48';
     }
     if ($r = $this->model('Model_User')->getUserByUniqueKey($_user_key)) {
         $this->_system_user = array('user_id' => $r->getUser_id(), 'user_name' => $r->getUser_name(), 'password' => $r->getPassword(), 'user_email' => $r->getUser_email(), 'owner_id' => $r->getOwner_id(), 'owner_name' => $r->getOwner_name(), 'group_id' => $r->getGroup_id(), 'group_name' => $r->getGroup_name(), 'role_name' => $r->getRole_key(), 'permissions' => array('owner' => $r->getPermissions_owner(), 'group' => $r->getPermissions_group(), 'other' => $r->getPermissions_other()), 'is_enabled' => $r->getIs_enabled(), 'is_dropped' => $r->getIs_dropped(), 'is_system' => $r->getIs_system());
         // User constants
         define('@SU.GROUP_ID', $r->getGroup_id());
         define('@SU.GROUP_NAME', $r->getGroup_name());
         define('@SU.USER_ID', $r->getUser_id());
         define('@SU.USER_NAME', $r->getUser_name());
         $this->_system_user_access = $this->model('Model_User')->getUserAccess($r->getUser_id(), EXIDO_ENVIRONMENT_NAME);
         $this->session->set('system_user', $_user_key);
     }
 }
开发者ID:esironal,项目名称:exidoengine,代码行数:45,代码来源:abstract.php

示例5: render

 /**
  * render an image from a title
  *
  * @return void
  * @author Andy Bennett
  */
 function render()
 {
     $c = Uri::instance()->segment(2, 'default');
     $config = Kohana::config('image_title.' . $c);
     if (!is_array($config)) {
         die('config error');
     }
     $using_ie6 = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6.') !== FALSE;
     $id = md5(serialize($_GET));
     $path = APPPATH . 'cache/images/titles/' . $id . '-' . ($using_ie6 ? '8b' : '24b') . '.png';
     if (!file_exists($path) or !Kohana::config('image_title.cache')) {
         $image_width = Kohana::instance()->input->get('width', false);
         $font_size = Kohana::instance()->input->get('size', false);
         if ($image_width == false) {
             $image_width = $config['width'];
         }
         if ($font_size == false) {
             $font_size = $config['size'];
         }
         $title = Kohana::instance()->input->get('title');
         $font_size = $font_size * 4;
         if ($title == false) {
             $title = 'Hello World!';
         }
         if ($image_width == false) {
             $image_width = strlen($title) * $font_size;
         } else {
             $image_width = $image_width * 4;
         }
         $fw = $font_size * 0.6;
         $w = floor($image_width / $fw);
         $title = wordwrap($title, $w, "\n");
         $c = count(explode("\n", $title));
         $image_height = $font_size * 1.5 * $c;
         $font_path = Kohana::find_file('fonts', $config['font'], TRUE, $config['format']);
         // Check GD lib support
         $freetype = FALSE;
         if (function_exists('gd_info')) {
             $libspecs = gd_info();
             $gif_create = $libspecs['GIF Create Support'];
             $jpg_support = (isset($libspecs['JPEG Support']) && $libspecs['JPEG Support'] or isset($libspecs['JPG Support']) && $libspecs['JPG Support']);
             $png_support = $libspecs['PNG Support'];
             $freetype = $libspecs['FreeType Support'];
         }
         $jpg_support = $jpg_support ? $jpg_support : imagetypes() & IMG_JPG;
         $png_support = $png_support ? $png_support : imagetypes() & IMG_PNG;
         if (!$jpg_support and !$png_support or !function_exists('imagetypes')) {
             Kohana::log('error', 'GD library is not installed');
             exit;
         }
         $w = $image_width / 4;
         $h = $image_height / 4;
         // Creates the image
         if (function_exists('imagecreatetruecolor') and !$using_ie6) {
             $new_image = imageCreateTrueColor($image_width, $image_height);
             $final_image = imageCreateTrueColor($w, $h);
         } else {
             $final_image = imageCreate($w, $h);
             $new_image = imageCreate($image_width, $image_height);
         }
         imageSaveAlpha($new_image, true);
         ImageAlphaBlending($new_image, false);
         imageSaveAlpha($final_image, true);
         ImageAlphaBlending($final_image, false);
         $transparentColor = imagecolorallocatealpha($new_image, 200, 200, 200, 127);
         imagefill($new_image, 0, 0, $transparentColor);
         $transparentColor = imagecolorallocatealpha($final_image, 200, 200, 200, 127);
         imagefill($final_image, 0, 0, $transparentColor);
         $r = $config['r'];
         $r = is_numeric($r) ? $r : 80;
         $g = $config['g'];
         $b = is_numeric($g) ? $g : 100;
         $b = $config['b'];
         $b = is_numeric($b) ? $b : 149;
         $black = imagecolorallocate($new_image, $r, $g, $b);
         imagettftext($new_image, $font_size, $angle = 0, $x = 0, $font_size, $black, $font_path, $title);
         imagecopyresampled($final_image, $new_image, 0, 0, 0, 0, $w, $h, $image_width, $image_height);
         imageDestroy($new_image);
         if (!file_exists(dirname($path))) {
             mkdir(dirname($path), 0777, true);
         }
         imagePNG($final_image, $path);
         imageDestroy($final_image);
     }
     // Outputs the image
     header('Expires: Tue, 1 Jan 1980 00:00:00 GMT');
     header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
     header('Cache-Control: no-store, no-cache, must-revalidate');
     header('Cache-Control: post-check=0, pre-check=0', false);
     header('Content-type: image/png');
     header('Content-Disposition: inline; filename=title.png');
     readfile($path);
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:99,代码来源:image_title.php


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