當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Controller類代碼示例

本文整理匯總了PHP中Controller的典型用法代碼示例。如果您正苦於以下問題:PHP Controller類的具體用法?PHP Controller怎麽用?PHP Controller使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Controller類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Select

 public function Select($nombre, $obs, $fecha)
 {
     $Controller = new Controller();
     $arr1 = array("NOMBRE_RETIRO_CUSTODIA", "OBSERVACION_RETIRO_CUSTODIA", "FECHA_RETIRO_CUSTODIA");
     $arr2 = array("'{$nombre}'", "'{$obs}'", "'{$fecha}'");
     return $Controller->Select2($this->_tabla, $arr1, $arr2);
 }
開發者ID:robertoesteban,項目名稱:Sistema-de-Bodega,代碼行數:7,代碼來源:retiros_custodia.php

示例2: __construct

 /**
  * @param Controller $controller
  * @param Job $job (optional)
  */
 public function __construct($controller, $job = null)
 {
     if ($job) {
         $fields = $job->getFields();
         $required = $job->getValidator();
     } else {
         $fields = singleton('Job')->getFields();
         $required = singleton('Job')->getValidator();
     }
     $fields->merge(new FieldList(new LiteralField('Conditions', $controller->TermsAndConditionsText), new HiddenField('BackURL', '', $controller->Link('thanks')), new HiddenField('EmailFrom', '', $controller->getJobEmailFromAddress()), new HiddenField('EmailSubject', '', $controller->getJobEmailSubject()), $jobId = new HiddenField('JobID')));
     if ($job) {
         $jobId->setValue($job->ID);
         $actions = new FieldList(new FormAction('doEditJob', _t('Jobboard.EDITLISTING', 'Edit Listing')));
     } else {
         $actions = new FieldList(new FormAction('doAddJob', _t('JobBoard.CONFIRM', 'Confirm')));
     }
     parent::__construct($controller, 'AddJobForm', $fields, $actions, $required);
     $this->setFormAction('JobBoardFormProcessor/doJobForm');
     $this->setFormMethod('POST');
     if ($job) {
         $this->loadDataFrom($job);
     } else {
         $this->enableSpamProtection();
     }
 }
開發者ID:helpfulrobot,項目名稱:fullscreeninteractive-silverstripe-jobboard,代碼行數:29,代碼來源:JobBoardForm.php

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

示例4: get_numeric_identifier

 /**
  * Utility static to avoid repetition.
  * 
  * @param Controller $controller
  * @param string $identifier e.g. 'ParentID' or 'ID'
  * @retun number
  */
 public static function get_numeric_identifier($controller, $identifier = 'ID')
 {
     // Deal-to all types of incoming data
     if (!$controller->hasMethod('currentPageID')) {
         return 0;
     }
     // Use native SS logic to deal with an identifier of 'ID'
     if ($identifier == 'ID') {
         $useId = $controller->currentPageID();
         // Otherwise it's custom
     } else {
         $params = $controller->getRequest()->requestVars();
         $idFromFunc = function () use($controller, $params, $identifier) {
             if (!isset($params[$identifier])) {
                 if (!isset($controller->urlParams[$identifier])) {
                     return 0;
                 }
                 return $controller->urlParams[$identifier];
             }
             return $params[$identifier];
         };
         $useId = $idFromFunc();
     }
     // We may have a padded string e.g. "1217 ". Without first truncating, we'd return 0 and pass tests...
     $id = (int) trim($useId);
     return !empty($id) && is_numeric($id) ? $id : 0;
 }
開發者ID:deviateltd,項目名稱:silverstripe-advancedassets,代碼行數:34,代碼來源:SecuredFilesystem.php

示例5: onNotFound

 public function onNotFound(\Event $event)
 {
     $controller = new \Controller(\App::getInstance());
     $page = $controller->twigInit()->render(\Config::get('view::notfound_page'));
     $response = new \Response($page, 404);
     \Container::getInstance()->setResponse($response);
 }
開發者ID:fucongcong,項目名稱:framework,代碼行數:7,代碼來源:NotFoundListener.php

示例6: errors

 function errors($msg)
 {
     $controller = new Controller($this->request);
     $controller->Session = new Session();
     //  print_r($controller);
     $controller->e404($msg);
 }
開發者ID:ronaldodia,項目名稱:backend_al,代碼行數:7,代碼來源:Dispatcher.php

示例7: startup

 /**
  * startup
  * called after Controller::beforeFilter()
  * 
  * @param object $controller instance of controller
  * @return void
  * @access public
  */
 public function startup(Controller $controller)
 {
     // Maintenance mode OFF but on offline page -> redirect to root url
     if (!$this->isOn() && strpos($controller->here, Configure::read('Maintenance.site_offline_url')) !== false) {
         $controller->redirect(Router::url('/', true));
         return;
     }
     // Maintenance mode ON user logoout allowed
     if ($this->isOn() && strpos($controller->here, 'users/logout') !== false) {
         return;
     }
     // Maintenance mode ON but not in offline page requested - > redirect to offline page
     if ($this->isOn() && strpos($controller->here, Configure::read('Maintenance.site_offline_url')) === false) {
         // All users auto logged off if setting is true
         if (Configure::read('Maintenance.offline_destroy_session')) {
             $this->Session->destroy();
         }
         $controller->redirect(Router::url(Configure::read('Maintenance.site_offline_url'), true));
         return;
     }
     // Maintenance mode scheduled show message!!
     if ($this->hasSchedule()) {
         $this->Flash->maintenance(__('This application will be on maintenance mode at  %s ', Configure::read('Maintenance.start')));
     }
 }
開發者ID:felix-koehler,項目名稱:phkapa,代碼行數:33,代碼來源:MaintenanceComponent.php

示例8: beforeRender

 public function beforeRender(Controller $controller)
 {
     if ($this->isBrwPanel) {
         $controller->set(array('companyName' => Configure::read('brwSettings.companyName'), 'brwHideMenu' => $controller->Session->read('brw.hideMenu')));
     }
     $this->controller->set('brwSettings', Configure::read('brwSettings'));
 }
開發者ID:maniekx1984,項目名稱:new_va_dev_copy_GITHUB,代碼行數:7,代碼來源:BrwPanelComponent.php

示例9: main

function main()
{
    $controller = new Controller();
    $response = null;
    switch ($_POST["cmd"]) {
        case "RPC":
            $username = $_POST["user"];
            if ($username == null) {
                $username = $_SESSION['user'];
            }
            $pw = $_POST["pw"];
            $plantname = $_POST["plant"];
            $code = $_POST["code"];
            $plantid = $_POST["id"];
            $response = $controller->HandleRemoteProcedureCall($_POST["func"], $username, $pw, $plantname, $code, $plantid);
            break;
        case "ContentRequest":
            if ($controller->IsLoggedIn() != "false") {
                $response = new ContentMessage($_POST["content"], $_POST["plantid"]);
            } else {
                $func = "function() { this.showLoginDialog(); this.showMessage('Sie sind nicht eingeloggt bitte einloggen', 'error'); }";
                $response = new RemoteProcedureCall($func);
            }
            break;
        default:
            $response = new Message('error', 'unknown Command');
            break;
    }
    if ($response != null) {
        $response->send();
    } else {
        echo "Error! no response was generated";
    }
}
開發者ID:nomeata,項目名稱:L-seed,代碼行數:34,代碼來源:Communication.php

示例10: startup

 public function startup(Controller $controller)
 {
     if (isset($controller->request->params['prefix']) && $controller->request->params['prefix'] == 'admin' && !$this->isLoggedIn()) {
         $this->Session->setFlash(__d('micro_auth', 'You need to login to access this page'));
         $controller->redirect($this->config['loginAction']);
     }
 }
開發者ID:Onasusweb,項目名稱:MicroAuth,代碼行數:7,代碼來源:MicroAuthComponent.php

示例11: setController

 /**
  * Attach Recaptcha helper to Controller.
  *
  * @param Controller $controller Controller.
  *
  * @return void
  */
 public function setController($controller)
 {
     // Add the helper on the fly
     if (!in_array('Recaptcha.Recaptcha', $controller->viewBuilder()->helpers())) {
         $controller->viewBuilder()->helpers(['Recaptcha.Recaptcha'], true);
     }
 }
開發者ID:cakephp-fr,項目名稱:recaptcha,代碼行數:14,代碼來源:RecaptchaComponent.php

示例12: preRequest

 public function preRequest(SS_HTTPRequest $request, Session $session, DataModel $model)
 {
     // Bootstrap session so that Session::get() accesses the right instance
     $dummyController = new Controller();
     $dummyController->setSession($session);
     $dummyController->setRequest($request);
     $dummyController->pushCurrent();
     // Block non-authenticated users from setting the stage mode
     if (!Versioned::can_choose_site_stage($request)) {
         $permissionMessage = sprintf(_t("ContentController.DRAFT_SITE_ACCESS_RESTRICTION", 'You must log in with your CMS password in order to view the draft or archived content. ' . '<a href="%s">Click here to go back to the published site.</a>'), Controller::join_links(Director::baseURL(), $request->getURL(), "?stage=Live"));
         // Force output since RequestFilter::preRequest doesn't support response overriding
         $response = Security::permissionFailure($dummyController, $permissionMessage);
         $session->inst_save();
         $dummyController->popCurrent();
         // Prevent output in testing
         if (class_exists('SapphireTest', false) && SapphireTest::is_running_test()) {
             throw new SS_HTTPResponse_Exception($response);
         }
         $response->output();
         die;
     }
     Versioned::choose_site_stage();
     $dummyController->popCurrent();
     return true;
 }
開發者ID:jacobbuck,項目名稱:silverstripe-framework,代碼行數:25,代碼來源:VersionedRequestFilter.php

示例13: setController

 /**
  * @param  Controller $controller
  * @param  bool       $stopPropagation
  * @return $this
  */
 public function setController(Controller $controller, $stopPropagation = false)
 {
     if (!$stopPropagation) {
         $controller->addMethod($this, true);
     }
     $this->controller = $controller;
     return $this;
 }
開發者ID:saxulum,項目名稱:saxulum-controller-provider,代碼行數:13,代碼來源:Method.php

示例14: GetMayor

 public function GetMayor()
 {
     $Controller = new Controller();
     $sql = "select max(ID_MERMA) as mayor from " . $this->tabla;
     $result = $Controller->ejecute($sql);
     $row = mysql_fetch_array($result);
     return $row["mayor"];
 }
開發者ID:robertoesteban,項目名稱:Sistema-de-Bodega,代碼行數:8,代碼來源:merma.php

示例15: handler

 /**
  * @access   public
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public function handler()
 {
     header('HTTP/1.0 ' . $this->sHeaderContent);
     $oController = new Controller();
     $oView = View::factory('base/error_pages/' . $this->iHttpCode);
     echo $oController->independentResponse($oView);
     exit;
 }
開發者ID:ktrzos,項目名稱:plethora,代碼行數:13,代碼來源:Exception.php


注:本文中的Controller類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。