本文整理汇总了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);
}
示例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();
}
}
示例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 '';
}
}
示例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;
}
示例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);
}
示例6: errors
function errors($msg)
{
$controller = new Controller($this->request);
$controller->Session = new Session();
// print_r($controller);
$controller->e404($msg);
}
示例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')));
}
}
示例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'));
}
示例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";
}
}
示例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']);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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"];
}
示例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;
}