本文整理汇总了PHP中Q_Request::slotNames方法的典型用法代码示例。如果您正苦于以下问题:PHP Q_Request::slotNames方法的具体用法?PHP Q_Request::slotNames怎么用?PHP Q_Request::slotNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Q_Request
的用法示例。
在下文中一共展示了Q_Request::slotNames方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Excecute web request
* @method execute
* @static
*/
static function execute()
{
// Fixes for different platforms:
if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
// ISAPI 3.0
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
}
// Get the base URL
$base_url = Q_Request::baseUrl();
if (Q::$controller === 'Q_ActionController') {
// we detected action.php in the URL, but
// a misconfigured web server executed index.php instead
return Q_ActionController::execute();
}
// Set the controller that is being used
if (!isset(Q::$controller)) {
Q::$controller = 'Q_WebController';
}
try {
$slots = Q_Request::slotNames(false);
$slots = $slots ? ' slots: (' . implode(',', $slots) . ') from' : '';
$method = Q_Request::method();
Q::log("{$method}{$slots} url: " . Q_Request::url(true), null, null, array('maxLength' => 10000));
Q_Dispatcher::dispatch();
$dispatchResult = Q_Dispatcher::result();
if (!isset($dispatchResult)) {
$dispatchResult = 'Ran dispatcher';
}
$uri = Q_Request::uri();
$module = $uri->module;
$action = $uri->action;
if ($module and $action) {
$slotNames = Q_Request::slotNames();
$returned_slots = empty($slotNames) ? '' : implode(',', $slotNames);
Q::log("~" . ceil(Q::milliseconds()) . 'ms+' . ceil(memory_get_peak_usage() / 1000) . 'kb.' . " {$dispatchResult} for {$module}/{$action}" . " ({$returned_slots})", null, null, array('maxLength' => 10000));
} else {
Q::log("~" . ceil(Q::milliseconds()) . 'ms+' . ceil(memory_get_peak_usage() / 1000) . 'kb.' . " {$dispatchResult} No route for " . $_SERVER['REQUEST_URI'], null, null, array('maxLength' => 10000));
}
} catch (Exception $exception) {
/**
* @event Q/exception
* @param {Exception} exception
*/
Q::event('Q/exception', compact('exception'));
}
}
示例2: execute
/**
* The standard action front controller
* @method execute
* @static
* @throws {Q_Exception_BadUrl}
* @throws {Q_Exception}
* @throws {Q_Exception_MissingConfig}
*/
static function execute($url = null)
{
// Fixes for different platforms:
if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
// ISAPI 3.0
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
}
// Set the controller that is being used
if (!isset(Q::$controller)) {
Q::$controller = 'Q_ActionController';
}
try {
$slots = Q_Request::slotNames(false);
$slots = $slots ? ' slots: (' . implode(',', $slots) . ') from' : '';
$method = Q_Request::method();
Q::log("{$method}{$slots} url: " . Q_Request::url(true));
$tail = Q_Request::tail($url);
if (!isset($tail)) {
// Bad url was requested somehow
$url = Q_Request::url(true);
$base_url = Q_Request::baseUrl(true);
throw new Q_Exception_BadUrl(compact('base_url', 'url'));
}
$parts = explode('/', $tail);
$parts_len = count($parts);
if ($parts_len >= 1) {
$module = $parts[0];
}
if ($parts_len >= 2) {
$action = $parts[1];
}
if (empty($module) or empty($action)) {
throw new Q_Exception("Not implemented");
}
// Make sure the 'Q'/'web' config fields are set,
// otherwise URLs will be formed pointing to the wrong
// controller script.
$ar = Q_Config::get('Q', 'web', 'appRootUrl', null);
if (!isset($ar)) {
throw new Q_Exception_MissingConfig(array('fieldpath' => 'Q/web/appRootUrl'));
}
// Dispatch the request
$uri = Q_Uri::from(compact('module', 'action'));
Q_Dispatcher::dispatch($uri);
$dispatchResult = Q_Dispatcher::result();
if (!isset($dispatchResult)) {
$dispatchResult = 'Ran dispatcher';
}
if ($module and $action) {
$slotNames = Q_Request::slotNames();
$requestedSlots = empty($slotNames) ? '' : implode(',', $slotNames);
Q::log("~" . ceil(Q::milliseconds()) . 'ms+' . ceil(memory_get_peak_usage() / 1000) . 'kb.' . " {$dispatchResult} for {$module}/{$action}" . " ({$requestedSlots})");
} else {
Q::log("~" . ceil(Q::milliseconds()) . 'ms+' . ceil(memory_get_peak_usage() / 1000) . 'kb.' . " No route for " . $_SERVER['REQUEST_URI']);
}
} catch (Exception $exception) {
/**
* @event Q/exception
* @param {Exception} exception
*/
Q::event('Q/exception', compact('exception'));
}
}
示例3: Streams_related_response
function Streams_related_response()
{
if (!Q_Request::slotName('relations') and !Q_Request::slotName('streams')) {
return;
}
$user = Users::loggedInUser();
$asUserId = $user ? $user->id : '';
$publisherId = Streams::requestedPublisherId(true);
$streamName = Streams::requestedName(true, 'original');
$isCategory = !empty($_REQUEST['isCategory']);
$slotNames = Q_Request::slotNames();
$streams_requested = in_array('relatedStreams', $slotNames);
$options = array('relationsOnly' => !$streams_requested, 'orderBy' => !empty($_REQUEST['ascending']));
if (isset($_REQUEST['limit'])) {
$options['limit'] = $_REQUEST['limit'];
}
if (isset($_REQUEST['offset'])) {
$options['offset'] = $_REQUEST['offset'];
}
if (isset($_REQUEST['min'])) {
$options['min'] = $_REQUEST['min'];
}
if (isset($_REQUEST['max'])) {
$options['max'] = $_REQUEST['max'];
}
if (isset($_REQUEST['type'])) {
$options['type'] = $_REQUEST['type'];
}
if (isset($_REQUEST['prefix'])) {
$options['prefix'] = $_REQUEST['prefix'];
}
$result = Streams::related($asUserId, $publisherId, $streamName, $isCategory, $options);
if ($streams_requested) {
$rel = Db::exportArray($result[0], array('numeric' => true));
} else {
$rel = Db::exportArray($result, array('numeric' => true));
}
if (!empty($_REQUEST['omitRedundantInfo'])) {
if ($isCategory) {
foreach ($rel as &$r) {
unset($r['toPublisherId']);
unset($r['toStreamName']);
}
} else {
foreach ($rel as &$r) {
unset($r['fromPublisherId']);
unset($r['fromStreamName']);
}
}
}
Q_Response::setSlot('relations', $rel);
if (!$streams_requested) {
return;
}
$streams = $result[1];
$arr = Db::exportArray($streams, array('numeric' => true));
foreach ($arr as $k => $stream) {
if (!$stream) {
continue;
}
$s = $streams[$stream['name']];
$arr[$k]['access'] = array('readLevel' => $s->get('readLevel', $s->readLevel), 'writeLevel' => $s->get('writeLevel', $s->writeLevel), 'adminLevel' => $s->get('adminLevel', $s->adminLevel));
}
Q_Response::setSlot('relatedStreams', $arr);
$stream = $result[2];
if (is_array($stream)) {
Q_Response::setSlot('streams', Db::exportArray($stream));
return;
} else {
if (is_object($stream)) {
Q_Response::setSlot('stream', $stream->exportArray());
} else {
Q_Response::setSlot('stream', false);
}
}
if (!empty($_REQUEST['messages'])) {
$max = -1;
$limit = $_REQUEST['messages'];
$messages = false;
$type = isset($_REQUEST['messageType']) ? $_REQUEST['messageType'] : null;
if ($stream->testReadLevel('messages')) {
$messages = Db::exportArray($stream->getMessages(compact('type', 'max', 'limit')));
}
Q_Response::setSlot('messages', $messages);
}
if (!empty($_REQUEST['participants'])) {
$limit = $_REQUEST['participants'];
$offset = -1;
$participants = false;
if ($stream->testReadLevel('participants')) {
$participants = Db::exportArray($stream->getParticipants(compact('limit', 'offset')));
}
Q_Response::setSlot('participants', $participants);
}
}
示例4: handleForwardException
protected static function handleForwardException($e)
{
$slotNames = Q_Request::slotNames(true);
foreach ($slotNames as $slotName) {
Q_Response::clearSlot($slotName);
}
// Go again, this time with a different URI.
Q::$toolWasRendered = array();
self::$uri = Q_Uri::from($e->uri);
if (is_array($e->skip)) {
self::$skip = $e->skip;
} else {
// Don't process any non-GET methods this time around,
// Do not collect any analytics
// And also ignore any accumulated errors
self::$skip = array('Q/method' => true, 'Q/analytics' => true, 'Q/errors' => true);
}
// We'll be handling errors anew
self::$handling_errors = false;
}
示例5: slots
/**
* Returns array of all the slots that have been filled
* @method slots
* @static
* @param {boolean} [$requestedOnesOnly=true] Set to true in order to return only the slots that were requested
* @return {array}
*/
static function slots($requestedOnesOnly = true)
{
if (!$requestedOnesOnly) {
return self::$slots;
}
$result = array();
$slotNames = Q_Request::slotNames(true);
foreach ($slotNames as $sn) {
$result[$sn] = isset(self::$slots[$sn]) ? self::$slots[$sn] : null;
}
return $result;
}
示例6: Streams_message_response
function Streams_message_response()
{
foreach (Q_Request::slotNames() as $sn) {
Q_Response::setSlot($sn, Q::event("Streams/message/response/{$sn}"));
}
}
示例7: Streams_participant_response
function Streams_participant_response()
{
foreach (Q_Request::slotNames() as $sn) {
Q_Response::setSlot($sn, Q::event("Streams/participant/response/{$sn}"));
}
}
示例8: slotName
/**
* Returns whether a given slot name was requested.
* @method slotNames
* @static
* @param {string} $slotName The name of the slot
* @return {boolean}
*/
static function slotName($slotName)
{
return in_array($slotName, Q_Request::slotNames(true));
}
示例9: Q_response
/**
* Default Q/response handler.
* 1. Gets some slots, depending on what was requested.
* 2. Renders them in a layout
* The layout expects "title", "dashboard" and "contents" slots to be filled.
*/
function Q_response($params)
{
extract($params);
/**
* @var Exception $exception
* @var array $errors
*/
if (empty($errors)) {
$errors = Q_Response::getErrors();
}
if (!empty($_GET['Q_ct'])) {
Q_Response::setCookie('Q_ct', $_GET['Q_ct']);
}
// If output is set, use that
$output = Q_Response::output();
if (isset($output)) {
if ($output === true) {
return;
}
if (is_string($output)) {
echo $output;
}
return;
}
// Redirect to success page, if requested.
$isAjax = Q_Request::isAjax();
if (empty($errors) and empty($exception)) {
if (!$isAjax and null !== Q_Request::special('onSuccess', null)) {
$onSuccess = Q_Request::special('onSuccess', null);
if (Q_Config::get('Q', 'response', 'onSuccessShowFrom', true)) {
$onSuccess = Q_Uri::url($onSuccess . '?Q.fromSuccess=' . Q_Dispatcher::uri());
}
Q_Response::redirect($onSuccess);
return;
}
}
// Get the requested module
$uri = Q_Dispatcher::uri();
if (!isset($module)) {
$module = $uri->module;
if (!isset($module)) {
$module = 'Q';
Q_Dispatcher::uri()->module = 'Q';
}
}
if (!$isAjax || Q_Request::isLoadExtras()) {
Q::event('Q/responseExtras', array(), 'before');
}
// Get the main module (the app)
$app = Q_Config::expect('Q', 'app');
$action = $uri->action;
if (Q::canHandle("{$module}/{$action}/response")) {
if (false === Q::event("{$module}/{$action}/response") and !$isAjax) {
return;
}
}
$slotNames = Q_Request::slotNames(true);
$idPrefixes = array();
if ($temp = Q_Request::special('idPrefixes', null)) {
foreach (explode(',', $temp) as $i => $prefix) {
if (!isset($slotNames[$i])) {
throw new Q_Exception("More id prefixes than slot names", "Q.idPrefixes");
}
$idPrefixes[$slotNames[$i]] = $prefix;
}
}
// What to do if this is an AJAX request
if ($isAjax) {
$to_encode = array();
if (Q_Response::$redirected) {
// We already called Q_Response::redirect
$to_encode['redirect']['url'] = Q_Uri::url(Q_Response::$redirected);
try {
$to_encode['redirect']['uri'] = Q_Uri::from(Q_Response::$redirected)->toArray();
} catch (Exception $e) {
// couldn't get internal URI
}
} else {
if (is_array($slotNames)) {
foreach ($slotNames as $slotName) {
Q_Response::fillSlot($slotName, 'default', Q::ifset($idPrefixes, $slotName, null));
}
// Go through the slots again, because other handlers may have overwritten
// their contents using Q_Response::setSlot()
foreach ($slotNames as $sn) {
Q_Response::fillSlot($sn, 'default', Q::ifset($idPrefixes, $slotName, null));
}
if (Q_Response::$redirected) {
// While rendering the slots we called Q_Redirect
$to_encode['redirect']['url'] = Q_Uri::url(Q_Response::$redirected);
try {
$to_encode['redirect']['uri'] = Q_Uri::from(Q_Response::$redirected)->toArray();
} catch (Exception $e) {
// couldn't get internal URI
//.........这里部分代码省略.........