本文整理汇总了PHP中AppController::redirect方法的典型用法代码示例。如果您正苦于以下问题:PHP AppController::redirect方法的具体用法?PHP AppController::redirect怎么用?PHP AppController::redirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppController
的用法示例。
在下文中一共展示了AppController::redirect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
public static function render($params = [])
{
isset($_POST['idStructure']) ? $idStructure = $_POST['idStructure'] : ($idStructure = '');
isset($_POST['structure']) ? $structure = $_POST['structure'] : ($structure = '');
isset($_POST['translationToC']) ? $translationToC = $_POST['translationToC'] : ($translationToC = '');
isset($_POST['translationToJava']) ? $translationToJava = $_POST['translationToJava'] : ($translationToJava = '');
isset($_POST['translationToJavascript']) ? $translationToJavascript = $_POST['translationToJavascript'] : ($translationToJavascript = '');
isset($_POST['translationToPython']) ? $translationToPython = $_POST['translationToPython'] : ($translationToPython = '');
isset($_POST['translationToPhp']) ? $translationToPhp = $_POST['translationToPhp'] : ($translationToPhp = '');
isset($_POST['pseudoCodeToTest']) ? $pseudoCodeToTest = $_POST['pseudoCodeToTest'] : ($pseudoCodeToTest = '');
isset($_POST['test']) ? $hadToTranslate = true : ($hadToTranslate = false);
$user = AppController::getUser();
if (!$user) {
AppController::setMsg("warning", "Vous devez être connecté pour avoir accès à cette partie du site");
AppController::redirect('index');
}
if (isset($_POST['erase'])) {
unset($_POST['erase']);
self::erase();
die;
}
if (isset($_POST['save'])) {
unset($_POST['save']);
self::save(['idStructure' => $idStructure]);
die;
}
parent::render(['idStructure' => $idStructure, 'structure' => $structure, 'pseudoCodeToTest' => $pseudoCodeToTest, 'translationToC' => $translationToC, 'translationToJava' => $translationToJava, 'translationToJavascript' => $translationToJavascript, 'translationToPhp' => $translationToPhp, 'translationToPython' => $translationToPython, 'hadToTranslate' => $hadToTranslate]);
}
示例2:
/**
* リダイレクト処理を行う
* @param string $type $this->redirectUrlのキーまたはURLを指定する
* @param string $flashMessage リダイレクト先で表示したいメッセージ
* @param boolean $forceRedirect 強制リダイレクトフラグ
* @access private
*/
function _redirect($type, $flashMessage = null, $forceRedirect = false)
{
$redirectFlag = $this->redirect;
if ($redirectFlag === false && $forceRedirect === true) {
$redirectFlag = true;
}
if ($redirectFlag) {
$url = $type;
if (isset($this->redirectUrl[$type])) {
$url = $this->redirectUrl[$type];
if (is_null($url)) {
return null;
}
}
if (!is_null($flashMessage)) {
$this->Session->setFlash($flashMessage);
}
$this->_controller->redirect($url);
}
if ($forceRedirect) {
if (!is_null($flashMessage)) {
$this->Session->setFlash($flashMessage);
}
$this->_controller->redirect($type);
}
}
示例3: render
/**
* Fonction de rendu par défaut
* @param type $params
*/
public static function render($params = [])
{
$user = AppController::getUser();
if (!$user) {
AppController::setMsg("warning", "Vous devez être connecté pour avoir accès à cette zone.");
AppController::redirect("index");
}
if (isset($_POST['action'])) {
self::update();
$user = AppController::getUser();
}
parent::render(['id' => $user->getId(), 'name' => $user->getName(), 'email' => $user->getEmail(), 'avatar' => $user->getAvatar()]);
}
示例4: __construct
/**
* コンストラクタ
*
* @return void
*/
public function __construct($id = false, $table = null, $ds = null)
{
$db = ConnectionManager::getDataSource('baser');
if (isset($db->config['datasource'])) {
if ($db->config['datasource'] != '') {
parent::__construct($id, $table, $ds);
} elseif ($db->config['login'] == 'dummy' && $db->config['password'] == 'dummy' && $db->config['database'] == 'dummy' && Configure::read('BcRequest.pureUrl') == '') {
// データベース設定がインストール段階の状態でトップページへのアクセスの場合、
// 初期化ページにリダイレクトする
$AppController = new AppController();
session_start();
$_SESSION['Message']['flash'] = array('message' => 'インストールに失敗している可能性があります。<br />インストールを最初からやり直すにはbaserCMSを初期化してください。', 'layout' => 'default');
$AppController->redirect(BC_BASE_URL . 'installations/reset');
}
}
}
示例5: render
public static function render($params = [])
{
$user = AppController::getUser();
if (!$user) {
AppController::setMsg('warning', "La zone demandée n'est pas autorisé pour les personnes non inscrites.");
AppController::redirect('index');
}
$algorithms = \Root\Src\Model\AlgorithmModel::loadFunctionByUser($user->getId());
$structures = \Root\Src\Model\StructureModel::loadStructureByUser($user->getId());
$translationOfC = \Root\Src\Model\TranslationModel::loadTranslationByLanguage('c');
$translationOfJava = \Root\Src\Model\TranslationModel::loadTranslationByLanguage('java');
$translationOfJavascript = \Root\Src\Model\TranslationModel::loadTranslationByLanguage('javascript');
$translationOfPhp = \Root\Src\Model\TranslationModel::loadTranslationByLanguage('php');
$translationOfPython = \Root\Src\Model\TranslationModel::loadTranslationByLanguage('python');
parent::getHeader();
self::call('Render', ['algorithms' => $algorithms, 'structures' => $structures, 'translations' => ['c' => $translationOfC, 'java' => $translationOfJava, 'javascript' => $translationOfJavascript, 'php' => $translationOfPhp, 'python' => $translationOfPython]]);
parent::getFooter();
}
示例6: connect
/**
* redirect Twitter authorize page
*
* @see Twitter-API-Plugin TwitterAuthComponent::connect()
*/
public function connect()
{
$dataSource = $authorize = false;
if (!empty($this->controller->params['named']['datasource'])) {
$dataSource = $this->controller->params['named']['datasource'];
}
if (!empty($this->controller->params['named']['authorize'])) {
$authorize = $this->controller->params['named']['authorize'];
}
if ($dataSource !== false) {
$this->setTwitterSource($dataSource);
}
if ($authorize) {
$this->controller->redirect($this->getAuthorizeUrl());
} else {
$this->controller->redirect($this->getAuthenticateUrl());
}
}
示例7: elseif
/**
* コンストラクタ
*
* @return void
* @access private
*/
function __construct($id = false, $table = null, $ds = null)
{
if ($this->useDbConfig && ($this->name || !empty($id['name']))) {
// DBの設定がない場合、存在しないURLをリクエストすると、エラーが繰り返されてしまい
// Cakeの正常なエラーページが表示されないので、設定がある場合のみ親のコンストラクタを呼び出す。
$cm =& ConnectionManager::getInstance();
if (isset($cm->config->baser['driver'])) {
if ($cm->config->baser['driver'] != '') {
parent::__construct($id, $table, $ds);
} elseif ($cm->config->baser['login'] == 'dummy' && $cm->config->baser['password'] == 'dummy' && $cm->config->baser['database'] == 'dummy' && Configure::read('Baser.urlParam') == '') {
// データベース設定がインストール段階の状態でトップページへのアクセスの場合、
// 初期化ページにリダイレクトする
App::import('Controller', 'App');
$AppController = new AppController();
session_start();
$_SESSION['Message']['flash'] = array('message' => 'インストールに失敗している可能性があります。<br />インストールを最初からやり直すにはbaserCMSを初期化してください。', 'layout' => 'default');
$AppController->redirect(baseUrl() . 'installations/reset');
}
}
}
}
示例8: __construct
/**
* コンストラクタ
*
* @return void
*/
public function __construct($id = false, $table = null, $ds = null)
{
$db = ConnectionManager::getDataSource('default');
$request = new CakeRequest();
if (isset($db->config['datasource'])) {
if ($db->config['datasource'] != '') {
// @deprecated 5.0.0 since 4.0.0
if ($this->useDbConfig == 'plugin') {
$this->useDbConfig = 'default';
$this->log('モデル:' . $this->name . ' BcPluginAppModelの 継承は、バージョン 4.0.0 より非推奨となりました。バージョン 5.0.0 で BcPluginAppModel は削除される予定です。プラグインは AppModel を直接継承してください。', LOG_ALERT);
}
parent::__construct($id, $table, $ds);
} elseif ($db->config['login'] == 'dummy' && $db->config['password'] == 'dummy' && $db->config['database'] == 'dummy' && $request->url === false) {
// データベース設定がインストール段階の状態でトップページへのアクセスの場合、
// 初期化ページにリダイレクトする
$AppController = new AppController();
session_start();
$_SESSION['Message']['flash'] = ['message' => 'インストールに失敗している可能性があります。<br />インストールを最初からやり直すにはbaserCMSを初期化してください。', 'layout' => 'default'];
$AppController->redirect(BC_BASE_URL . 'installations/reset');
}
}
}
示例9: connect
/**
* Methode de connexion
*/
public static function connect()
{
if (AppController::getUser() != Null) {
AppController::setMsg("warning", "Vous êtes déjà connecté. Veuillez vous déconnecter pour changer de compte.");
} else {
$login = '';
$password = '';
if (isset($_POST['login']) && isset($_POST['password'])) {
$login = $_POST['login'];
$password = $_POST['password'];
}
$user = new \Root\Src\Model\UserModel($login, $password);
$user = $user->exist();
if ($user) {
AppController::setUser($user);
AppController::setMsg("success", "Vous avez bien été connecté.");
parent::redirect('index');
} else {
AppController::setMsg("warning", "Le mot de passe ou l'identifiant est incorrect.");
self::render();
}
}
}
示例10: redirect
/**
* Override the redirect function; if it's a view and there's only one division, view the league instead
*/
function redirect($url = null, $next = null)
{
if (isset($url['action']) && $url['action'] == 'view' && isset($url['controller']) && $url['controller'] == 'divisions') {
$league = $this->Division->league($url['division']);
$division_count = $this->requestAction(array('controller' => 'leagues', 'action' => 'division_count'), array('named' => compact('league')));
if ($division_count == 1) {
parent::redirect(array('controller' => 'leagues', 'action' => $url['action'], 'league' => $league), $next);
}
}
parent::redirect($url, $next);
}
示例11: resetPassword
public function resetPassword()
{
$this->view = new HTMLView();
if ($this->request->isPOST()) {
$post = $this->request->postData();
$user = new UserModel();
if ($this->request->isQueryArgSet('token')) {
if ($user->getUserForPasswordResetToken($this->request->queryArgValue('token'))) {
$user->password = @$post['password'];
if ($user->save()) {
$user->deletePasswordResetTokens();
$alert = new Alert(Alert::SUCCESS);
$alert->addMessage('Password Set, Please Login');
} else {
$alert = new Alert(Alert::ERROR);
$alert->addMessageArray($user->getErrors());
}
$this->view->includeTemplate('auth.reset-password.password', ['app_name' => AppConfig::getValue('app_name'), 'alert' => $alert]);
} else {
AppController::redirect(RouteController::fqURL('resetPassword'), ['status' => 'token-expired']);
}
} else {
if ($post['email'] && $user->find($post['email'], 'email')) {
$token = $user->getPasswordResetTokenData();
if ($token['last_email_timestamp'] <= Carbon::now()->subMinutes(pow(2, $token['email_attempts']))) {
$user->incrementPasswordResetEmailCount();
$link = addQueryParams(RouteController::fqURL('resetPassword'), ['token' => $token['token']]);
// Send Email
$mailer = new Mailer();
$mailer->setSubject('Password Reset Token');
$mailer->addAddress($user->email);
$mailer->includeHTMLTemplate('email.reset-password', ['link' => $link]);
$mailer->send();
// errors handled within
// Show Message
$alert = new Alert(Alert::SUCCESS);
$alert->addMessage('Email Sent');
} else {
$alert = new Alert(Alert::ERROR);
$alert->addMessage('Too Many Attempts, Please Try Again Later');
}
$this->view->includeTemplate('auth.reset-password.email', ['app_name' => AppConfig::getValue('app_name'), 'alert' => $alert]);
} else {
$alert = new Alert(Alert::ERROR);
$alert->addMessage('Email is Invalid/Non-Existent');
$this->view->includeTemplate('auth.reset-password.email', ['app_name' => AppConfig::getValue('app_name'), 'alert' => $alert]);
}
}
} else {
if ($this->request->isQueryArgSet('token')) {
$user = new UserModel();
if ($user->getUserForPasswordResetToken($this->request->queryArgValue('token'))) {
$this->view->includeTemplate('auth.reset-password.password', ['app_name' => AppConfig::getValue('app_name')]);
} else {
AppController::redirect(RouteController::fqURL('resetPassword'), ['status' => 'token-expired']);
}
} else {
if ($this->request->isQueryArgSet('status') && $this->request->queryArgValue('status') == 'token-expired') {
$alert = new Alert(Alert::ERROR);
$alert->addMessage('Token is Invalid/Expired, Please Request a New One');
}
$this->view->includeTemplate('auth.reset-password.email', ['app_name' => AppConfig::getValue('app_name'), 'alert' => isset($alert) ? $alert : null]);
}
}
$this->view->render(true);
}
示例12: redirect
public function redirect($url, $status = 302)
{
return parent::redirect(AutoxpRouter::url($url), $status);
}
示例13: redirect
/**
* Overload Redirect. Many actions are invoked via Xhr, most of these
* require a list of current favorites to be returned.
*
* @param string $url
* @param unknown $code
* @param boolean $exit
* @return void
*/
public function redirect($url, $code = null, $exit = true)
{
if ($code == -999) {
parent::redirect($url, null, $exit);
}
if (!empty($this->viewVars['authMessage']) && !empty($this->request->params['isJson'])) {
$this->RequestHandler->renderAs($this, 'json');
$this->set('message', $this->viewVars['authMessage']);
$this->set('status', 'error');
echo $this->render('add');
$this->_stop();
}
if (!empty($this->request->params['isAjax']) || !empty($this->request->params['isJson'])) {
return $this->setAction('short_list', $this->Favorite->model);
} else {
if (isset($this->viewVars['status']) && isset($this->viewVars['message'])) {
$this->Session->setFlash($this->viewVars['message'], 'default', array(), $this->viewVars['status']);
} elseif (!empty($this->viewVars['authMessage'])) {
$this->Session->setFlash($this->viewVars['authMessage']);
}
}
parent::redirect($url, $code, $exit);
}
示例14: redirect
/**
* Override the redirect function; if it's a view and there's only one division, view the league instead
*/
function redirect($url = null, $next = null)
{
if (is_array($url) && in_array($url['action'], array('edit', 'view')) && (!array_key_exists('controller', $url) || $url['controller'] == 'divisions')) {
$league = $this->Division->league($url['division']);
$division_count = $this->requestAction(array('controller' => 'leagues', 'action' => 'division_count'), array('named' => compact('league')));
if ($division_count == 1) {
parent::redirect(array('controller' => 'leagues', 'action' => $url['action'], 'league' => $league), $next);
}
}
parent::redirect($url, $next);
}
示例15: redirect
function redirect($url, $status = null, $exit = true)
{
return parent::redirect($this->__redirect_url($url), $status, $exit);
}