本文整理汇总了PHP中GO::request方法的典型用法代码示例。如果您正苦于以下问题:PHP GO::request方法的具体用法?PHP GO::request怎么用?PHP GO::request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GO
的用法示例。
在下文中一共展示了GO::request方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: runController
/**
* Runs a controller action with the given params
*
* @param array $params
*/
public function runController($params = false)
{
if (!$params) {
$params = array_merge($_REQUEST, \GO::request()->post);
}
$r = !empty($params['r']) ? explode('/', $params['r']) : array();
$this->_r = isset($params['r']) ? $params['r'] : "";
if (\GO::config()->debug || \GO::config()->debug_log) {
$log = 'Controller route r=';
if (isset($params['r'])) {
$log .= $params['r'];
} else {
$log = 'No r parameter given';
}
\GO::debug($log);
}
$first = isset($r[0]) ? ucfirst($r[0]) : 'Auth';
if (empty($r[2]) && file_exists(\GO::config()->root_path . 'controller/' . $first . 'Controller.php')) {
//this is a controller name that belongs to the Group-Office framework
$module = 'Core';
$controller = $first;
$action = isset($r[1]) ? $r[1] : '';
} else {
//it must be pointing to a module
$module = strtolower($r[0]);
$controller = isset($r[1]) ? ucfirst($r[1]) : 'Default';
$action = isset($r[2]) ? $r[2] : '';
}
$action = strtolower($action);
$controllerClass = 'GO\\';
if (!empty($module)) {
$controllerClass .= ucfirst($module) . '\\';
}
$controllerClass .= 'Controller\\' . $controller . 'Controller';
if (preg_match('/[^A-Za-z0-9_\\\\]+/', $controllerClass, $matches)) {
$err = "Only these charactes are allowed in controller names: A-Za-z0-9_";
echo $err;
trigger_error($err, E_USER_ERROR);
}
$this->_action = $action;
if (!class_exists($controllerClass)) {
if (!headers_sent()) {
header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");
}
if (empty($_SERVER['QUERY_STRING'])) {
$_SERVER['QUERY_STRING'] = "[EMPTY QUERY_STRING]";
}
$errorMsg = "Controller('" . $controllerClass . "') not found: " . $_SERVER['QUERY_STRING'] . " " . var_export($_REQUEST, true);
echo '<h1>404 Not found</h1>';
echo '<p>' . $errorMsg . '</p>';
if (\GO::config()->debug) {
trigger_error($errorMsg, E_USER_ERROR);
}
}
try {
$this->_controller = new $controllerClass();
$this->_controller->run($action, $params);
} catch (Exception\NotFound $e) {
header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");
if (empty($_SERVER['QUERY_STRING'])) {
$_SERVER['QUERY_STRING'] = "[EMPTY QUERY_STRING]";
}
$errorMsg = "Controller action '" . $action . " not found in controller class '" . $controllerClass . "': " . $_SERVER['QUERY_STRING'] . " " . var_export($_REQUEST, true);
echo '<h1>404 Not found</h1>';
echo '<p>' . $errorMsg . '</p>';
if (\GO::config()->debug) {
trigger_error($errorMsg, E_USER_ERROR);
}
}
}
示例2: isAjaxRequest
/**
* Check if the request was made with ajax.
*
* @return boolean
*/
public static function isAjaxRequest($withExtjsIframeHack = true)
{
//dirty hack with $_FILES for extjs iframe file upload
if (!empty($_REQUEST['ajax'])) {
return true;
}
if ($withExtjsIframeHack && self::isMultipartRequest()) {
return true;
}
if (isset($_SERVER["HTTP_X_REQUESTED_WITH"]) && $_SERVER["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest") {
return true;
}
if (\GO::request()->isJson()) {
return true;
}
return false;
}
示例3: renderSubmit
/**
* Render the JSON outbut for a submit action to be used by ExtJS Form submit
* @param \GO\Base\Db\ActiveRecord $$data['model']
* @return \GO\Base\Data\JsonResponse Response object
*/
public function renderSubmit($data)
{
$response = array('feedback' => '', 'success' => true, 'validationErrors' => array(), 'data' => array());
//Init data array
foreach ($data as $modelName => $model) {
if (is_array($model)) {
$response['data'][$modelName] = $model;
} else {
$response['data'][$modelName] = $model->getAttributes();
}
// $modelName cannot be the same as the reserved results
if ($modelName == 'feedback' || $modelName == 'success' || $modelName == 'validationErrors') {
throw new \Exception('Cannot use "' . $modelName . '" as key for your data. Please change the key.');
}
if (is_a($model, "\\GO\\Base\\Model")) {
//$ret = $this->beforeSubmit($response, $model, $params);
//$modifiedAttributes = $model->getModifiedAttributes();
if (!$model->hasValidationErrors() && !$model->isNew) {
//model was saved
$response['id'] = $model->pk;
//If the model has it's own ACL id then we return the newly created ACL id.
//The model automatically creates it.
if ($model->aclField() && !$model->isJoinedAclField) {
$response[$model->aclField()] = $model->{$model->aclField()};
}
//TODO: move the link saving to the model someday
if (!empty(\GO::request()->post['link']) && $model->hasLinks()) {
//a link is sent like \GO\Notes\Model\Note:1
//where 1 is the id of the model
$linkProps = explode(':', \GO::request()->post['link']);
$linkModel = \GO::getModel($linkProps[0])->findByPk($linkProps[1]);
$model->link($linkModel);
}
} else {
// model was not saved
$response['success'] = false;
//can't use <br /> tags in response because this goes wrong with the extjs fileupload hack with an iframe.
$response['feedback'] = sprintf(\GO::t('validationErrorsFound'), strtolower($model->localizedName)) . "\n\n" . implode("\n", $model->getValidationErrors()) . "\n";
if (\GO\Base\Util\Http::isAjaxRequest(false)) {
$response['feedback'] = nl2br($response['feedback']);
}
$response['errors'] = array(sprintf(\GO::t('validationErrorsFound'), strtolower($model->localizedName)) . "\n\n" . implode("\n", $model->getValidationErrors()) . "\n");
$response['validationErrors'][$modelName] = $model->getValidationErrors();
}
} else {
$response[$modelName] = $model;
}
}
return new \GO\Base\Data\JsonResponse($response);
}
示例4: actionLogout
protected function actionLogout()
{
\GO::session()->logout();
if (\GO::request()->isAjax()) {
$response['success'] = true;
return $response;
}
if (isset($_COOKIE['GO_FULLSCREEN']) && $_COOKIE['GO_FULLSCREEN'] == '1') {
?>
<script type="text/javascript">
window.close();
</script>
<?php
exit;
} else {
if (!empty(\GO::config()->logout_url)) {
header('Location: ' . \GO::config()->logout_url);
exit;
} else {
$this->redirect();
}
}
}