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


PHP Response::getInstance方法代码示例

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


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

示例1: invoke

 public function invoke(URLComponent $url)
 {
     $class_name = $url->getController();
     $method = $url->getAction();
     $class = $this->app . '\\action\\' . $class_name;
     //Response对象
     $response = Response::getInstance();
     //Request对象
     $request = Request::getInstance();
     #实例化控制器,使用反射
     $reflection = new \ReflectionClass($class);
     $instacne = $reflection->newInstance();
     //先执行初始化方法init
     if ($reflection->hasMethod('init')) {
         $init = $reflection->getMethod('init');
         $data = $init->invokeArgs($instacne, array($request, $response));
         if ($data) {
             //如果有返回数据则输出
             $response->setBody($data);
             $response->send();
             return true;
         }
     }
     if ($reflection->hasMethod($method)) {
         $method = $reflection->getMethod($method);
     } elseif ($reflection->hasMethod('getMiss')) {
         $method = $reflection->getMethod('getMiss');
     } else {
         throw new RouteException('Method does not exist.');
     }
     $data = $method->invokeArgs($instacne, array($request, $response));
     #输出
     $response->setBody($data);
     $response->send();
 }
开发者ID:qazzhoubin,项目名称:emptyphp,代码行数:35,代码来源:Route.php

示例2: js

    public function js()
    {
        $row = $this->input->getInt('row');
        $col = $this->input->getInt('col');
        $uid = $this->input->getInt('uid');
        $count = $row * $col;
        $sql = 'SELECT
		    ads.*
		  FROM ck_ads as ads
		  JOIN ck_packages as pack
		    ON(ads.package_id=pack.id)
		  WHERE
		    ads.status="approve"   AND
		    ads.clicked < pack.max_click
		  ORDER BY RAND()
		  LIMIT ' . $count;
        $query = $this->db->query($sql);
        $tmpl = Template::getInstance('empty.tpl');
        $tmpl->loadPage('jsAds');
        fb($col, 'row');
        for ($i = 0; $i < $row; ++$i) {
            $tmp = array();
            for ($j = 0; $j < $col; ++$j) {
                $tmp[] = $query->fetch();
            }
            $data[] = $tmp;
        }
        fb($data);
        $tmpl->assign('uid', $uid);
        $tmpl->assign('row', $row);
        $tmpl->assign('col', $col);
        $tmpl->assign('data', $data);
        Response::getInstance()->setTemplate($tmpl);
    }
开发者ID:redknight,项目名称:frot,代码行数:34,代码来源:ClickAdsService.php

示例3: __construct

 /**
  * ---
  */
 public function __construct()
 {
     $this->db = Db::getInstance();
     $this->request = Request::getInstance();
     $this->response = Response::getInstance();
     $this->session = Session::getInstance();
 }
开发者ID:joksnet,项目名称:php-old,代码行数:10,代码来源:Controller.php

示例4: exceptionHandler

 static function exceptionHandler(\Exception $exception)
 {
     self::$exception = $exception;
     $request = Request::getInstance();
     $refererURL = $request->getReferer();
     $requestURI = \ManiaLib\Utils\URI::getCurrent();
     $debug = \ManiaLib\Application\Config::getInstance()->debug;
     if ($exception instanceof SilentUserException) {
         $message = static::computeShortMessage($exception) . '  ' . $requestURI;
         $userMessage = $exception->getMessage();
     } elseif ($exception instanceof UserException) {
         $message = static::computeShortMessage($exception) . '  ' . $requestURI;
         \ManiaLib\Utils\Logger::user($message);
         $userMessage = $exception->getMessage();
     } else {
         $requestURILine = sprintf(static::$messageConfigs['default']['line'], 'Request URI', $requestURI);
         $message = static::computeMessage($exception, static::$messageConfigs['default'], array($requestURILine));
         \ManiaLib\Utils\Logger::error($message);
         $userMessage = null;
     }
     $response = Response::getInstance();
     if ($message) {
         $response->message = $debug ? $message : $userMessage;
     }
     if ($debug) {
         $response->width = 300;
         $response->height = 150;
     }
     $response->backLink = $refererURL;
     $response->registerErrorView();
     $response->registerException($exception);
 }
开发者ID:kremsy,项目名称:manialib,代码行数:32,代码来源:ErrorHandling.php

示例5: redirect

 public static function redirect($url)
 {
     if (!$url instanceof Url) {
         $url = new Url($url);
     }
     Response::getInstance()->setRedirect($url->__toString());
 }
开发者ID:joksnet,项目名称:php-old,代码行数:7,代码来源:Url.php

示例6: run

 function run()
 {
     if ($this->running) {
         throw new \Exception(get_called_class() . '::run() was previously called!');
     }
     $this->running = true;
     $request = Request::getInstance();
     if ($request->exists(self::PATH_INFO_OVERRIDE_PARAM)) {
         $this->pathInfo = $request->get(self::PATH_INFO_OVERRIDE_PARAM, '/');
         $request->delete(self::PATH_INFO_OVERRIDE_PARAM);
     } else {
         $this->pathInfo = \ManiaLib\Utils\Arrays::getNotNull($_SERVER, 'PATH_INFO', '/');
     }
     list($this->controller, $this->action) = Route::getActionAndControllerFromRoute($this->pathInfo);
     $this->calledURL = $request->createLink();
     $viewsNS =& Config::getInstance()->viewsNS;
     $currentViewsNS = Config::getInstance()->namespace . '\\Views\\';
     if (!in_array($currentViewsNS, $viewsNS)) {
         array_unshift($viewsNS, $currentViewsNS);
     }
     try {
         Controller::factory($this->controller)->launch($this->action);
         Response::getInstance()->render();
     } catch (\Exception $e) {
         call_user_func(Bootstrapper::$errorHandlingCallback, $e);
         Response::getInstance()->render();
     }
 }
开发者ID:maniaplanet,项目名称:manialib,代码行数:28,代码来源:Dispatcher.php

示例7: __construct

 final function __construct()
 {
     $this->request = Request::getInstance();
     $this->response = Response::getInstance();
     $this->session = Session::getInstance();
     $this->onConstruct();
 }
开发者ID:kremsy,项目名称:manialib,代码行数:7,代码来源:View.php

示例8: __construct

 /**
  * Instantiates the Request and Response variables (and Session if enabled in config file)
  */
 public function __construct()
 {
     $this->request = Request::getInstance();
     $this->response = Response::getInstance();
     // Use the 'use_sessions' setting to enable or disable the session class
     if (Config::get('use_sessions')) {
         $this->session = Session::getInstance();
     }
 }
开发者ID:priestd09,项目名称:sleekmvc,代码行数:12,代码来源:Base.php

示例9: __construct

 private function __construct()
 {
     include 'settings.php';
     date_default_timezone_set($settings->timezone);
     $this->request = Request::getInstance();
     $this->session = Session::getInstance();
     $this->response = Response::getInstance();
     $this->user = User::getUserById($this->session->userID);
 }
开发者ID:BackupTheBerlios,项目名称:frameorm-svn,代码行数:9,代码来源:Context.class.php

示例10: sendValues

 public static function sendValues($type_send = 'json')
 {
     $response = Response::getInstance();
     if ($type_send == 'json') {
         $response->sendJsonData();
     } elseif ($type_send == 'print') {
         $response->sendPrintData();
     } else {
         throw new \Exception("send type [" . $type_send . "] not found");
         //'"
     }
 }
开发者ID:Okhremchuk,项目名称:Ingenum,代码行数:12,代码来源:class.Response.php

示例11: send

 public static function send($path)
 {
     $response = Response::getInstance();
     $last_modified_time = filemtime($path);
     $etag = md5_file($path);
     if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $last_modified_time || trim($_SERVER['HTTP_IF_NONE_MATCH']) == '"' . $etag . '"') {
         $response->addHeader('ETag', '"' . $etag . '"');
         $response->httpCode = 304;
         $response->body = '';
         return;
     }
     $response->addHeader('ETag', '"' . $etag . '"');
     $response->addHeader("Last-Modified", gmdate("D, d M Y H:i:s", $last_modified_time) . " GMT");
     return file_get_contents($path);
 }
开发者ID:BackupTheBerlios,项目名称:frameorm-svn,代码行数:15,代码来源:ETag.class.php

示例12: show

 function show()
 {
     $this->respond->article_id = $this->input->getInt("article_id");
     $query = "SELECT name, content, time, email FROM wb_comment\n\t\t\t\t\tWHERE (article_id={$this->respond->article_id}\n\t\t\t\t\tAND private=0  AND status='approve')";
     fb($query);
     $result = $this->db->query($query)->fetchAll();
     $article_query = "SELECT title FROM wb_articles\n\t\t\t\t\t\t\tWHERE id={$this->respond->article_id}";
     $article_title = $this->db->query($article_query)->fetch()->title;
     fb($result, 'comments');
     $tmpl = Template::getInstance('empty.tpl');
     $tmpl->loadPage('comment');
     $tmpl->assign('comment_list', $result);
     $tmpl->assign('article_title', $article_title);
     $tmpl->assign('post_id', $this->respond->article_id);
     //require 'temp/comment_template.php';
     Session::getInstance()->Captcha = $this->randomString();
     Response::getInstance()->setTemplate($tmpl);
 }
开发者ID:redknight,项目名称:frot,代码行数:18,代码来源:CommentService.php

示例13: widget

 public static function widget($name, $request = NULL, $params = NULL, $allowResponse = true)
 {
     $className = $name;
     if (!isset(self::$_widgetPool[$name])) {
         if (!class_exists($className)) {
             throw new HandleException($className);
         }
         if (!empty($request)) {
             $requestObject = new Request();
         } else {
             $requestObject = Request::getInstance();
         }
         $responseObject = $allowResponse ? Response::getInstance() : NULL;
         $widget = new $className($requestObject, $responseObject, $params);
         $widget->execute();
         self::$_widgetPool[$name] = $widget;
     }
     return self::$_widgetPool[$name];
 }
开发者ID:javanprettycool,项目名称:jblog,代码行数:19,代码来源:Widget.php

示例14: show

 public function show()
 {
     Response::getInstance()->setContent('image/png');
     $str = $this->randomString();
     Session::getInstance()->Captcha = $str;
     $image_x = 100;
     $image_y = 40;
     $im = imagecreatetruecolor($image_x, $image_y);
     $bgcoolor = imagecolorallocate($im, rand(177, 255), rand(177, 255), rand(177, 255));
     imagefill($im, 0, 0, $bgcoolor);
     $cl = imagecolorallocate($im, rand(0, 100), rand(0, 100), rand(0, 100));
     $f = imageloadfont('hadi.gdf');
     imagestring($im, $f, 10, 10, $str, $cl);
     $lineCount = rand(7, 12);
     while ($lineCount--) {
         $cl = imagecolorallocate($im, rand(0, 127), rand(0, 127), rand(0, 127));
         imageline($im, rand(0, $image_x), rand(0, $image_y), rand(0, $image_x), rand(0, $image_y), $cl);
     }
     imagepng($im);
 }
开发者ID:redknight,项目名称:frot,代码行数:20,代码来源:CaptchaService.php

示例15: init

 /**
  * Initialize the application
  */
 public function init()
 {
     // Load the application configuration
     $this->singleton('conf', Conf::getInstance());
     // Load the application error Handler
     $this->singleton('errorHandler', ErrorHandler::getInstance());
     // Load the application logger
     $this->singleton('logger', Logger::getInstance());
     // Load the filesystem library
     $this->singleton('fs', FileSystem::getInstance());
     // Load the application session
     $this->singleton('session', Session::getInstance());
     // Load the application router
     $this->singleton('router', Router::getInstance());
     // Load the application HTTP request
     $this->singleton('request', Request::getInstance());
     // Load the application HTTP response
     $this->singleton('response', Response::getInstance());
     // Load the application cache
     $this->singleton('cache', Cache::getInstance());
 }
开发者ID:elvyrra,项目名称:hawk,代码行数:24,代码来源:App.php


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