本文整理汇总了PHP中Q::canHandle方法的典型用法代码示例。如果您正苦于以下问题:PHP Q::canHandle方法的具体用法?PHP Q::canHandle怎么用?PHP Q::canHandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Q
的用法示例。
在下文中一共展示了Q::canHandle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Overlay_before_Q_responseExtras
function Overlay_before_Q_responseExtras()
{
$app = Q_Config::expect('Q', 'app');
Q_Response::addStylesheet('plugins/Q/css/Q.css');
Q_Response::addStylesheet('css/Overlay.css', '@end');
Q_Response::addStylesheet('http://fonts.googleapis.com/css?family=Open+Sans:400italic,400,300,700');
if (Q_Config::get('Q', 'firebug', false)) {
Q_Response::addScript("https://getfirebug.com/firebug-lite-debug.js");
}
Q_Response::addScript('js/Overlay.js');
Q_Response::setMeta("title", "Customize My Pic!");
Q_Response::setMeta("description", "Make a statement on Facebook by customizing your profile picture, even from your smartphone.");
Q_Response::setMeta("image", Q_Html::themedUrl('img/icon/icon.png'));
if (Q_Request::isIE()) {
header("X-UA-Compatible", "IE=edge");
}
header('Vary: User-Agent');
// running an event for loading action-specific extras (if there are any)
$uri = Q_Dispatcher::uri();
$module = $uri->module;
$action = $uri->action;
$event = "{$module}/{$action}/response/responseExtras";
if (Q::canHandle($event)) {
Q::event($event);
}
}
示例2: Q_post
function Q_post($params)
{
$uri = Q_Dispatcher::uri();
$module = $uri->module;
$action = $uri->action;
if (!Q::canHandle("{$module}/{$action}/post")) {
throw new Q_Exception_MethodNotSupported(array('method' => 'POST'));
}
if (isset($_SERVER['CONTENT_LENGTH'])) {
$contentLength = (int) $_SERVER['CONTENT_LENGTH'];
foreach (array('upload_max_filesize', 'post_max_size') as $name) {
$value = ini_get($name);
switch (substr($value, -1)) {
case 'K':
$value *= 1024;
break;
case 'M':
$value *= 1024 * 1024;
break;
case 'B':
$value *= 1024 * 1024 * 1024;
break;
}
if ($contentLength > $value) {
throw new Q_Exception_ContentLength(array('contentLength' => $contentLength, 'exceeds' => $name));
}
}
}
return Q::event("{$module}/{$action}/post", $params);
}
示例3: Streams_publisher_validate
function Streams_publisher_validate($params)
{
// Protect against CSRF attacks:
Q_Valid::nonce(true);
$type = Streams::requestedType();
if ($type && Q::canHandle("Streams/validate/{$type}")) {
return Q::event("Streams/validate/{$type}", $params);
}
}
示例4: Users_importContacts_validate
function Users_importContacts_validate()
{
Q_Valid::nonce(true);
if (empty($_GET['provider'])) {
throw new Q_Exception('No provider specified');
}
if (!Q::canHandle('Users/importContacts/providers/' . $_GET['provider'])) {
throw new Q_Exception('Unsupported provider specified: ' . $_GET['provider']);
}
}
示例5: Q_validate
function Q_validate($params)
{
$uri = Q_Dispatcher::uri();
$module = $uri->module;
$action = $uri->action;
if (!Q::canHandle("{$module}/{$action}/validate")) {
return null;
}
return Q::event("{$module}/{$action}/validate", $params);
}
示例6: Q_put
function Q_put($params)
{
$uri = Q_Dispatcher::uri();
$module = $uri->module;
$action = $uri->action;
if (!Q::canHandle("{$module}/{$action}/put")) {
throw new Q_Exception_MethodNotSupported(array('method' => 'PUT'));
}
return Q::event("{$module}/{$action}/put", $params);
}
示例7: Q_delete
function Q_delete($params)
{
$uri = Q_Dispatcher::uri();
$module = $uri->module;
$action = $uri->action;
if (!Q::canHandle("{$module}/{$action}/delete")) {
throw new Q_Exception_MethodNotSupported(array('method' => 'DELETE'));
}
Q_Request::requireValidNonce();
return Q::event("{$module}/{$action}/delete", $params);
}
示例8: Streams_player_tool
/**
* This tool generates an interface used for publishing messages to streams
* It basically renders the Streams/player/$type tool, where $type is the stream's type.
*
* @param array $options
* An associative array of parameters, containing:
* "publisherId" => required. The id of the publisher of the stream to which to post the message.
* "streamName" => required. The name of the stream to which to post the message.
*/
function Streams_player_tool($options)
{
extract($options);
if (empty($stream)) {
throw new Q_Exception("Missing stream object");
}
if (!Q::canHandle('Streams/player/' . $stream->type . '/tool')) {
throw new Q_Exception("No player tool has been implemented for streams of type {$stream->type}.");
}
return Q::tool('Streams/player/' . $stream->type, $options);
}
示例9: Streams_stream_validate
function Streams_stream_validate($params)
{
// Protect against CSRF attacks:
if (Q_Request::method() !== 'GET') {
Q_Valid::nonce(true);
}
$type = Streams::requestedType();
if ($type && Q::canHandle("Streams/validate/{$type}")) {
return Q::event("Streams/validate/{$type}", $params);
}
}
示例10: Streams_player_tool
function Streams_player_tool($options)
{
extract($options);
if (!isset($stream)) {
throw new Q_Exception_MissingObject(array('name' => 'stream'));
}
if (!$stream->testReadLevel('content')) {
$streamName_html = Q_Html::text($stream->name);
return "<a href='#{$streamName_html}'>hidden</a>";
}
$options['streamName'] = $stream->name;
$parts = explode('/', $stream->type);
switch ($parts[0]) {
case 'Streams/text/small':
case 'Streams/text/medium':
case 'Streams/text':
return $stream->content;
case 'Streams/date':
// TODO: localize
if (isset($parts[1]) and $parts[1] === 'birthday') {
return date('M j', strtotime($stream->content));
}
return date('M j, Y', strtotime($stream->content));
case 'Streams/number':
if (isset($parts[1]) and $parts[1] === 'age') {
if (!empty($streams['Streams/user/birthday']->content)) {
return Db::ageFromDateTime($streams['Streams/user/birthday']->content);
}
return null;
}
return $strem->content;
case 'Streams/category':
// TODO: implement
// TODO: implement
case 'Streams/chat':
// TODO: implement
// TODO: implement
case 'Streams/community':
// TODO: implement
// TODO: implement
default:
$event = $stream->type . "/tool";
if (Q::canHandle($event)) {
return Q::tool($stream->type, $options);
}
return Q_Html::tag('div', array('class' => 'Streams_player_stream_content'), Q_Html::text($stream->content));
}
}
示例11: Q_response_content
function Q_response_content()
{
$app = Q_Config::expect('Q', 'app');
$url = Q_Request::url();
$module = Q_Dispatcher::uri()->module;
if (empty($module)) {
return Q::event("{$app}/notFound/response/content");
}
$action = Q_Dispatcher::uri()->action;
$event = "{$module}/{$action}/response/content";
if (!Q::canHandle($event)) {
return Q::event("{$app}/notFound/response/content");
}
// Go ahead and fire the event, returning the result.
return Q::event($event);
}
示例12: Q_response_content
function Q_response_content()
{
$app = Q_Config::expect('Q', 'app');
$url = Q_Request::url();
$module = Q_Dispatcher::uri()->module;
if (empty($module)) {
return Q::event("{$app}/notFound/response/content");
}
$action = Q_Dispatcher::uri()->action;
$event = "{$module}/{$action}/response/content";
if (!Q::canHandle($event)) {
return Q::event("{$app}/notFound/response/content");
}
Q_Response::setMeta('format-detection', 'telephone=no,date=no,address=no,email=no,url=no');
// Go ahead and fire the event, returning the result.
return Q::event($event);
}
示例13: Trump_before_Q_responseExtras
function Trump_before_Q_responseExtras()
{
$app = Q_Config::expect('Q', 'app');
Q_Response::addStylesheet('plugins/Q/css/Q.css');
Q_Response::addStylesheet('css/html.css', '@end');
if (Q_Config::get('Q', 'firebug', false)) {
Q_Response::addScript("https://getfirebug.com/firebug-lite-debug.js");
}
Q_Response::addScript('js/Trump.js');
if (Q_Request::isIE()) {
header("X-UA-Compatible: IE=edge");
}
header('Vary: User-Agent');
// running an event for loading action-specific extras (if there are any)
$uri = Q_Dispatcher::uri();
$module = $uri->module;
$action = $uri->action;
$event = "{$module}/{$action}/response/responseExtras";
if (Q::canHandle($event)) {
Q::event($event);
}
}
示例14: Q_response_default
function Q_response_default($params)
{
if (!isset($params['slotName'])) {
throw new Q_Exception_RequiredField(array('field' => '$slotName'));
}
$slotName = $params['slotName'];
$uri = Q_Dispatcher::uri();
$module = $uri->module;
$action = $uri->action;
if (!$module or !$action) {
return "{$module}/{$action} is not a valid URI";
}
$event = "{$module}/{$action}/response/{$slotName}";
$function_name = $module . '_' . $action . '_response_' . $slotName;
if (function_exists($function_name)) {
$result = Q::event($event);
$result = isset($result) ? $result : "Don't return null from {$function_name}";
}
if (Q::canHandle($event)) {
return Q::event($event);
}
throw new Q_Exception_MissingSlot(compact('event'));
}
示例15: 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
//.........这里部分代码省略.........