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


PHP Controller::run方法代码示例

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


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

示例1: render

 public function render($action, $params = [], $cacheTime = null)
 {
     if (empty($action)) {
         return '';
     }
     $path = explode(':', $action);
     $params = ['data' => $params, 'module' => $this->controller->params['module'], 'controller' => $this->controller->params['controller']];
     switch (count($path)) {
         case 1:
             $params['action'] = $path[0];
             break;
         case 2:
             $params['controller'] = $path[0];
             $params['action'] = $path[1];
             break;
         default:
             $params['module'] = $path[0];
             $params['controller'] = $path[1];
             $params['action'] = $path[2];
     }
     try {
         if ($params['controller'] == $this->controller->params['controller'] && $params['module'] == $this->controller->params['module']) {
             return $this->controller->run($params);
         }
         return $this->controller->app->runController($params, $cacheTime);
     } catch (\Exception $e) {
         if ('dev' == $this->controller->app->conf['env']) {
             return $e;
         }
         return '';
     }
 }
开发者ID:yagrysha,项目名称:mvc,代码行数:32,代码来源:TwigExtension.php

示例2: testException

 public function testException()
 {
     $except = false;
     try {
         $this->object->run('bogus');
     } catch (\PHPixie\Exception\PageNotFound $e) {
         $except = true;
     }
     $this->assertEquals($except, true);
 }
开发者ID:PermeAgility,项目名称:FrameworkBenchmarks,代码行数:10,代码来源:controllerTest.php

示例3: run

 /**
  * Run application 
  */
 public function run()
 {
     try {
         // Pre settings before run controller
         foreach (Command::getCommands() as $cmd) {
             $cmd->doing();
         }
         foreach (Plugin::getPlugins() as $plugin) {
             $plugin->doing();
         }
         // Run the controller
         $ret = $this->controller->run();
         // After run the controller
         foreach (Command::getCommands() as $cmd) {
             $cmd->done();
         }
         foreach (Plugin::getPlugins() as $plugin) {
             $plugin->done();
         }
         // Rendering
         Renderer::getInstance()->render($ret);
     } catch (MyException $exc) {
         $text['title'] = 'error';
         $text['body'] = $exc->getMessage();
         Renderer::getInstance()->render($text);
     }
 }
开发者ID:kaz6120,项目名称:BitWiki,代码行数:30,代码来源:BitWiki.php

示例4: run

 public function run($class_name)
 {
     $path = realpath(Yii::app()->basePath . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'upload' . DIRECTORY_SEPARATOR . $class_name);
     $class_name = ucfirst($class_name);
     if ($path && is_dir($path) && is_writable($path)) {
         $dir = key($_GET);
         $filename = $_GET[$dir];
         $pk = pathinfo($filename, PATHINFO_FILENAME);
         $image = Images::model()->findByPk($pk);
         if ($image != null) {
             $image->resize($dir);
         }
     } elseif (class_exists($class_name)) {
         $dir = key($_GET);
         $filename = $_GET[$dir];
         $size = explode('x', $dir);
         $path = realpath(Yii::app()->basePath . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'upload' . DIRECTORY_SEPARATOR . $class_name);
         if (YII_DEBUG && !file_exists($path . DIRECTORY_SEPARATOR . $dir)) {
             mkdir($path . DIRECTORY_SEPARATOR . $dir, 0777);
         }
         if ($path !== FALSE && file_exists($path . DIRECTORY_SEPARATOR . $dir) && is_file($path . DIRECTORY_SEPARATOR . $filename) && $size[0] > 0 && $size[1] > 0) {
             Yii::import('ext.iwi.Iwi');
             $image = new Iwi($path . DIRECTORY_SEPARATOR . $filename);
             $image->adaptive($size[0], $size[1]);
             $image->save($path . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR . $filename, 0644, TRUE);
             $mime = CFileHelper::getMimeType($path . DIRECTORY_SEPARATOR . $filename);
             header('Content-Type: ' . $mime);
             $image->render();
             exit;
         }
     }
     return parent::run($class_name);
 }
开发者ID:BGCX067,项目名称:facecom-svn-to-git,代码行数:33,代码来源:UploadController.php

示例5: run

 /**
  * アプリケーションの実行。
  */
 function run()
 {
     try {
         //コントローラの本体処理実行前動作
         foreach (Command::getCommands() as $cmd) {
             $cmd->doing();
         }
         foreach (Plugin::getPlugins() as $plugin) {
             $plugin->doing();
         }
         //本体処理実行
         $ret = $this->controller->run();
         //コントローラの本体処理実行後動作
         foreach (Command::getCommands() as $cmd) {
             $cmd->done();
         }
         foreach (Plugin::getPlugins() as $plugin) {
             $plugin->done();
         }
         //レンダリング
         Renderer::getinstance()->render($ret);
     } catch (MyException $exc) {
         $text['title'] = 'error';
         $text['body'] = $exc->getMessage();
         Renderer::getinstance()->render($text);
     }
 }
开发者ID:riaf,项目名称:kinowiki,代码行数:30,代码来源:kinowiki.inc.php

示例6: run

 public function run()
 {
     Utils::checkLogin();
     $msg = array();
     if (!empty($_POST['oldpassword'])) {
         if (!empty($_POST['newpassword']) && $_POST['newpassword'] == $_POST['confirmpassword']) {
             $password = '{crypt}' . Utils::encryptPassword($_POST['newpassword']);
             $sql = "\n                    UPDATE " . USERS . "\n                    SET password = '" . mysql_real_escape_string($password) . "'\n                    WHERE id ='" . $_SESSION['userid'] . "'";
             if (mysql_query($sql)) {
                 $msg[] = array("text" => "Password updated successfully!");
                 $to = $_SESSION['username'];
                 $subject = "Password Change";
                 $body = "<p>Congratulations!</p>";
                 $body .= "<p>You have successfully updated your password with " . SERVER_NAME . ".";
                 $body .= "</p><p>Love,<br/>Philip and Ryan</p>";
                 if (!Utils::send_email($to, $subject, $body)) {
                     error_log("PasswordController: Utils::send_email failed");
                 }
             } else {
                 $msg[] = array("text" => "Failed to update your password");
             }
         } else {
             $msg[] = array("text" => "New passwords don't match!");
         }
     }
     $this->write('msg', $msg);
     parent::run();
 }
开发者ID:MaitreyaBuddha,项目名称:worklist,代码行数:28,代码来源:Password.php

示例7: getView

 public function getView()
 {
     $gh_events = array();
     try {
         $this->client = new Github\Client(new Github\HttpClient\CachedHttpClient(array('cache_dir' => TEMP_DIR . DIRECTORY_SEPARATOR . 'github')));
         $this->client->authenticate(GITHUB_OAUTH2_CLIENT_ID, GITHUB_OAUTH2_CLIENT_SECRET, Github\Client::AUTH_URL_CLIENT_ID);
         // first: request github for 3 pages with 30 events data each
         $gh_events = array_merge($this->listGithubEvents(GITHUB_ORGANIZATION, 1), $this->listGithubEvents(GITHUB_ORGANIZATION, 2), $this->listGithubEvents(GITHUB_ORGANIZATION, 3));
         // then: find out $seconds_ago based on the last event in order to
         // use as date limit when looking for worklist entries
         $fromTime = strtotime(self::olderGithubEventDate($gh_events));
         $toTime = strtotime(Model::now());
     } catch (Exception $e) {
         error_log('StatusController::run exception: ' . $e->getMessage());
         $fromTime = strtotime('10 days ago');
         $toTime = strtotime(Model::now());
     }
     $seconds_ago = abs($toTime - $fromTime);
     $this->write('gh_events', $gh_events);
     // and, finally: fetches worklist data
     $entry = new EntryModel();
     $this->write('entries', $entry->latest($seconds_ago, 90));
     // alright, ready to go :)
     parent::run();
 }
开发者ID:MaitreyaBuddha,项目名称:worklist,代码行数:25,代码来源:Status.php

示例8: run

 public function run()
 {
     $msg = '';
     if (!empty($_POST['submit'])) {
         if (!empty($_POST['password'])) {
             $user = new User();
             if ($user->findUserByUsername($_POST['username'])) {
                 if ($user->getForgot_hash() == $_REQUEST['token']) {
                     $password = '{crypt}' . Utils::encryptPassword($_POST['password']);
                     $user->setPassword($password)->setForgot_hash(md5(uniqid()))->save();
                     Utils::sendTemplateEmail($_POST['username'], 'changed_pass', array('app_name' => APP_NAME));
                     Utils::redirect('./');
                 }
             } else {
                 $msg = 'The link to reset your password has expired or is invalid. <a href="./forgot">Please try again.</a>';
             }
         } else {
             $msg = "Please enter a password!";
         }
     }
     if (empty($_REQUEST['token'])) {
         // no required information specified, redirect user
         $this->view = null;
         Utils::redirect('./');
     }
     $this->write('msg', $msg);
     $this->write('un', isset($_REQUEST['un']) ? base64_decode($_REQUEST['un']) : "");
     $this->write('token', $_REQUEST['token']);
     parent::run();
 }
开发者ID:MaitreyaBuddha,项目名称:worklist,代码行数:30,代码来源:ResetPass.php

示例9: run

 public function run($a)
 {
     if (@Yii::app()->params['installer'] !== 'show') {
         return $this->missingAction($a);
     }
     return parent::run($a);
 }
开发者ID:Jmainguy,项目名称:multicraft_install,代码行数:7,代码来源:InstallController.php

示例10: run

 public function run($thumb)
 {
     $key = key($_GET);
     if (NULL == ($file = Files::model()->findByPk($key))) {
         throw new CException('Page not found', 404);
     }
     $path = Yii::getPathOfAlias('webroot') . DIRECTORY_SEPARATOR . 'upload' . DIRECTORY_SEPARATOR . 'photos';
     $src_file = $file->id . '.' . $file->extension;
     $in_file = $path . DIRECTORY_SEPARATOR . $src_file;
     $out_file = $path . DIRECTORY_SEPARATOR . $thumb . DIRECTORY_SEPARATOR . $src_file;
     if (is_file($out_file)) {
         $mime = CFileHelper::getMimeType($out_file);
         header('Content-Type: ' . $mime);
         readfile($out_file);
         exit;
     }
     if (is_file($in_file)) {
         $dir = $path . DIRECTORY_SEPARATOR . $thumb;
         if (YII_DEBUG && !file_exists($dir)) {
             mkdir($dir, 0777);
         }
         if (file_exists($dir)) {
             if (($out_file = $file->resize($thumb)) == 0) {
                 throw new CException('Page not found', 404);
             }
             $mime = CFileHelper::getMimeType($in_file);
             header('Content-Type: ' . $mime);
             readfile($out_file);
             exit;
         }
     }
     return parent::run($thumb);
 }
开发者ID:BGCX067,项目名称:facecom-svn-to-git,代码行数:33,代码来源:ImagesController.php

示例11: run

 public function run($action, $params)
 {
     if ($this->getAuthorizator()->canPerform($this, $action)) {
         return parent::run($action, $params);
     } else {
         $this->accessDenied();
     }
 }
开发者ID:kstep,项目名称:pnut,代码行数:8,代码来源:Restricted.php

示例12: search_header

 /**
  * Add search to your app.
  *
  * @return string
  */
 public static function search_header()
 {
     $conf = self::$conf;
     if ($conf['App Settings']['search']) {
         return self::$controller->run($conf['App Settings']['search'], array('header' => true));
     }
     return '';
 }
开发者ID:irismeijer,项目名称:test,代码行数:13,代码来源:App.php

示例13: run

 static function run()
 {
     $uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
     $appPath = config('app.path', dirname($_SERVER['PHP_SELF']));
     if ($appPath !== DIRECTORY_SEPARATOR && str_contains($uri, $appPath)) {
         $uri = substr($uri, strlen($appPath));
     }
     list($uri, ) = explode('?', $uri);
     $routes = array('/^\\/(\\d+)(\\/.*)?$/' => 'c=index&a=show&id=$1&v=$2', '/^\\/([\\w]+)\\/(\\d+)(\\/.*)?$/' => 'c=$1&a=show&id=$2&v=$3', '/^\\/([\\w]+)\\/([\\w]+)\\/(\\d+)(\\/.*)?$/' => 'c=$1&a=$2&id=$3&v=$4', '/^\\/([\\w]+)\\/([\\w%]+)(\\/.*)?$/' => 'c=$1&a=$2&v=$3', '/^\\/([\\w]+)\\/?$/' => 'c=$1&a=index&v=');
     if (is_array(self::$routes)) {
         $routes = array_merge(self::$routes, $routes);
         foreach (self::$routes as $k => $v) {
             $routes[$k] = $v;
         }
     }
     foreach ($routes as $rk => $rv) {
         if (preg_match($rk, $uri, $m)) {
             foreach ($m as $mk => $mv) {
                 if ($mk > 0) {
                     $rv = str_replace('$' . $mk, $mv, $rv);
                 }
             }
             parse_str($rv, $args);
             if (is_array($args)) {
                 self::$controller = $args['c'];
                 self::$action = $args['a'];
                 unset($args['c']);
                 unset($args['a']);
                 if ($args['v']) {
                     $moreArgs = explode('/', trim($args['v'], '/'));
                     unset($args['v']);
                     for ($i = 0; $i < count($moreArgs); $i = $i + 2) {
                         if (!is_numeric($moreArgs[$i]) && !(preg_match('/^\\$[1-9]$/', $moreArgs[$i]) && !$moreArgs[$i + 1])) {
                             $args[$moreArgs[$i]] = $moreArgs[$i + 1];
                         }
                     }
                 }
                 $_GET = array_merge($_GET, $args);
                 $_REQUEST = array_merge($_REQUEST, $args);
             }
             break;
         }
     }
     if (!self::$controller) {
         self::$controller = 'index';
     }
     if (!self::$action) {
         self::$action = 'index';
     }
     self::$route = self::$controller . '/' . self::$action;
     echo Controller::run();
 }
开发者ID:boofw,项目名称:phpole,代码行数:52,代码来源:Route.php

示例14: run

 public function run()
 {
     if (ENV == 'development') {
         $this->_Timestamp = microtime(true);
     }
     Logger::info('', false);
     $protocol = empty($_SERVER['HTTPS']) ? 'http://' : 'https://';
     Logger::debug($_SERVER['REQUEST_METHOD'] . " " . $protocol . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);
     Logger::info('App start...');
     session_start();
     // zistenie a spustenie daneho kontrolera
     $controllerName = CLASSES_PREFIX . "Controller" . Router::getControllerName();
     if (class_exists($controllerName)) {
         Logger::debug("Loading controller {$controllerName}...");
         $this->_Controller = new $controllerName();
         $this->_Controller->run();
         $this->_Controller->render();
     } else {
         throw new Exception('Unknown controller: ' . $controllerName);
     }
     if (ENV == 'development') {
         Logger::debug("Generated in " . round((microtime(true) - $this->_Timestamp) * 1000) . " msec.");
     }
 }
开发者ID:novacek78,项目名称:v4,代码行数:24,代码来源:Application.php

示例15: run

 public function run()
 {
     // @TODO: We extra the request but it seems we then don't use it?
     extract($_REQUEST);
     $msg = '';
     if (!empty($_POST['username'])) {
         $token = md5(uniqid());
         $user = new User();
         if ($user->findUserByUsername($_POST['username'])) {
             $user->setForgot_hash($token);
             $user->save();
             $resetUrl = SECURE_SERVER_URL . 'resetpass?un=' . base64_encode($_POST['username']) . '&amp;token=' . $token;
             $resetUrl = '<a href="' . $resetUrl . '" title="Password Recovery">' . $resetUrl . '</a>';
             Utils::sendTemplateEmail($_POST['username'], 'recovery', array('url' => $resetUrl));
             $msg = '<p class="LV_valid">Login information will be sent if the email address ' . $_POST['username'] . ' is registered.</p>';
         } else {
             $msg = '<p class="LV_invalid">Sorry, unable to send password reset information. Try again or contact an administrator.</p>';
         }
     }
     $this->write('msg', $msg);
     parent::run();
 }
开发者ID:MaitreyaBuddha,项目名称:worklist,代码行数:22,代码来源:Forgot.php


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