本文整理汇总了PHP中Q_Request类的典型用法代码示例。如果您正苦于以下问题:PHP Q_Request类的具体用法?PHP Q_Request怎么用?PHP Q_Request使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Q_Request类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Streams_invitations_response
/**
* Displays an HTML document that can be printed, ideally with line breaks.
* Uses a particular view for the layout.
* @param {array} $_REQUEST
* @param {string} $_REQUEST.invitingUserId Required. The id of the user that generated the invitations with a call to Streams::invite.
* @param {string} $_REQUEST.batch Required. The name of the batch under which invitations were saved during a call to Streams::invite.
* @param {string} [$_REQUEST.limit=100] The maximum number of invitations to show on the page
* @param {string} [$_REQUEST.offset=0] Used for paging
* @param {string} [$_REQUEST.title='Invitations'] Override the title of the document
* @param {string} [$_REQUEST.layout='default'] The name of the layout to use for the HTML document
* @see Users::addLink()
*/
function Streams_invitations_response()
{
Q_Request::requireFields(array('batch', 'invitingUserId'), true);
$invitingUserId = $_REQUEST['invitingUserId'];
$batch = $_REQUEST['batch'];
$title = Q::ifset($_REQUEST, 'layout', 'title');
$layoutKey = Q::ifset($_REQUEST, 'layout', 'default');
$limit = min(1000, Q::ifset($_REQUEST, 'limit', 100));
$offset = Q::ifset($_REQUEST, 'offset', 0);
$layout = Q_Config::expect('Streams', 'invites', 'layout', $layoutKey);
$app = Q_Config::expect('Q', 'app');
$pattern = Streams::invitationsPath($invitingUserId) . DS . $batch . DS . "*.html";
$filenames = glob($pattern);
$parts = array();
foreach ($filenames as $f) {
if (--$offset > 0) {
continue;
}
$parts[] = file_get_contents($f);
if (--$limit == 0) {
break;
}
}
$content = implode("\n\n<div class='Q_pagebreak Streams_invitations_separator'></div>\n\n", $parts);
echo Q::view($layout, compact('content', 'parts'));
return false;
}
示例2: Users_label_put
/**
* Edits a label in the system. Fills the "label" (and possibly "icon") slot.
* @param {array} $_REQUEST
* @param {string} $_REQUEST.label The label
* @param {string} [$_REQUEST.title] The title of the label
* @param {string} [$_REQUEST.icon] Optional path to an icon
* @param {string} [$_REQUEST.userId=Users::loggedInUser(true)->id] You can override the user id, if another plugin adds a hook that allows you to do this
*/
function Users_label_put($params = array())
{
$req = array_merge($_REQUEST, $params);
Q_Request::requireFields(array('label'), $req, true);
$loggedInUserId = Users::loggedInUser(true)->id;
$userId = Q::ifset($req, 'userId', $loggedInUserId);
$l = $req['label'];
$icon = Q::ifset($req, 'icon', null);
$title = Q::ifset($req, 'title', null);
Users::canManageLabels($loggedInUserId, $userId, $l, true);
$label = new Users_Label();
$label->userId = $userId;
$label->label = $l;
if (!$label->retrieve()) {
throw new Q_Exception_MissingRow(array('table' => 'Label', 'criteria' => json_encode($label->fields)));
}
if (isset($title)) {
$label->title = $title;
}
if (is_array($icon)) {
// Process any icon data
$icon['path'] = 'uploads/Users';
$icon['subpath'] = "{$userId}/label/{$label}/icon";
$data = Q::event("Q/image/post", $icon);
Q_Response::setSlot('icon', $data);
$label->icon = Q_Request::baseUrl() . '/' . $data[''];
}
$label->save();
Q_Response::setSlot('label', $label->exportArray());
}
示例3: 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));
}
}
}
Q_Request::requireValidNonce();
return Q::event("{$module}/{$action}/post", $params);
}
示例4: Users_user_response_data
function Users_user_response_data($params)
{
// Get Gravatar info
// WARNING: INTERNET_REQUEST
$hash = md5(strtolower(trim($identifier)));
$thumbnailUrl = Q_Request::baseUrl() . "/action.php/Users/thumbnail?hash={$hash}&size=80&type=" . Q_Config::get('Users', 'login', 'iconType', 'wavatar');
$json = @file_get_contents("http://www.gravatar.com/{$hash}.json");
$result = json_decode($json, true);
if ($result) {
if ($type === 'email') {
$result['emailExists'] = !empty($exists);
} else {
if ($type === 'mobile') {
$result['mobileExists'] = !empty($exists);
}
}
return $result;
}
// otherwise, return default
$email_parts = explode('@', $identifier, 2);
$result = array("entry" => array(array("id" => "571", "hash" => "357a20e8c56e69d6f9734d23ef9517e8", "requestHash" => "357a20e8c56e69d6f9734d23ef9517e8", "profileUrl" => "http://gravatar.com/test", "preferredUsername" => ucfirst($email_parts[0]), "thumbnailUrl" => $thumbnailUrl, "photos" => array(), "displayName" => "", "urls" => array())));
if ($type === 'email') {
$result['emailExists'] = !empty($exists);
} else {
$result['mobileExists'] = !empty($exists);
}
if ($terms_label = Users::termsLabel('register')) {
$result['termsLabel'] = $terms_label;
}
return $result;
}
示例5: Users_label_post
/**
* Adds a label to the system. Fills the "label" (and possibly "icon") slot.
* @param {array} $_REQUEST
* @param {string} $_REQUEST.title The title of the label
* @param {string} [$_REQUEST.label] You can override the label to use
* @param {string} [$_REQUEST.icon] Optional path to an icon
* @param {string} [$_REQUEST.userId=Users::loggedInUser(true)->id] You can override the user id, if another plugin adds a hook that allows you to do this
*/
function Users_label_post($params = array())
{
$req = array_merge($_REQUEST, $params);
Q_Request::requireFields(array('title'), $req, true);
$loggedInUserId = Users::loggedInUser(true)->id;
$userId = Q::ifset($req, 'userId', $loggedInUserId);
$icon = Q::ifset($req, 'icon', null);
$title = $req['title'];
$l = Q::ifset($req, 'label', 'Users/' . Q_Utils::normalize($title));
Users::canManageLabels($loggedInUserId, $userId, $l, true);
$label = new Users_Label();
$label->userId = $userId;
$label->label = $l;
if ($label->retrieve()) {
throw new Users_Exception_LabelExists();
}
$label->title = $title;
if (is_array($icon)) {
// Process any icon that was posted
$icon['path'] = 'uploads/Users';
$icon['subpath'] = "{$userId}/label/{$label}/icon";
$data = Q::event("Q/image/post", $icon);
Q_Response::setSlot('icon', $data);
$label->icon = Q_Request::baseUrl() . '/' . $data[''];
} else {
$label->icon = 'default';
}
$label->save();
Q_Response::setSlot('label', $label->exportArray());
}
示例6: Streams_invite_validate
function Streams_invite_validate()
{
if (Q_Request::method() === 'PUT') {
return;
}
if (Q_Request::method() !== 'GET') {
Q_Valid::nonce(true);
}
$fields = array('publisherId', 'streamName');
if (Q_Request::method() === 'POST') {
if (Q_Valid::requireFields($fields)) {
return;
}
foreach ($fields as $f) {
if (strlen(trim($_REQUEST[$f])) === 0) {
Q_Response::addError(new Q_Exception("{$f} can't be empty", $f));
}
}
}
if (isset($_REQUEST['fullName'])) {
$length_min = Q_Config::get('Streams', 'inputs', 'fullName', 'lengthMin', 5);
$length_max = Q_Config::get('Streams', 'inputs', 'fullName', 'lengthMax', 30);
if (strlen($_REQUEST['fullName']) < $length_min) {
throw new Q_Exception("A user's full name can't be that short.", 'fullName');
}
if (strlen($_REQUEST['fullName']) > $length_max) {
throw new Q_Exception("A user's full name can't be that long.", 'fullName');
}
}
}
示例7: 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);
}
}
示例8: Streams_invitations_response
/**
* Displays an HTML document that can be printed, ideally with line breaks.
* Uses a particular view for the layout.
* @param {array} $_REQUEST
* @param {string} $_REQUEST.invitingUserId Required. The id of the user that generated the invitations with a call to Streams::invite.
* @param {string} $_REQUEST.batch Required. The name of the batch under which invitations were saved during a call to Streams::invite.
* @param {string} [$_REQUEST.limit=100] The maximum number of invitations to show on the page
* @param {string} [$_REQUEST.offset=0] Used for paging
* @param {string} [$_REQUEST.title='Invitations'] Override the title of the document
* @param {string} [$_REQUEST.layout='default'] The name of the layout to use for the HTML document
* @see Users::addLink()
*/
function Streams_invitations_response()
{
Q_Request::requireFields(array('batch', 'invitingUserId'), true);
$invitingUserId = $_REQUEST['invitingUserId'];
$batch = $_REQUEST['batch'];
$user = Users::loggedInUser(true);
$stream = Streams::fetchOne(null, $invitingUserId, 'Streams/invitations', true);
if (!$stream->testReadLevel('content')) {
throw new Users_Exception_NotAuthorized();
}
$title = Q::ifset($_REQUEST, 'layout', 'title');
$layoutKey = Q::ifset($_REQUEST, 'layout', 'default');
$limit = min(1000, Q::ifset($_REQUEST, 'limit', 100));
$offset = Q::ifset($_REQUEST, 'offset', 0);
$layout = Q_Config::expect('Streams', 'invites', 'layout', $layoutKey);
$pattern = Streams::invitationsPath($invitingUserId) . DS . $batch . DS . "*.html";
$filenames = glob($pattern);
$parts = array();
foreach ($filenames as $f) {
if (--$offset > 0) {
continue;
}
$parts[] = file_get_contents($f);
if (--$limit == 0) {
break;
}
}
$content = implode("\n\n<div class='Q_pagebreak Streams_invitations_separator'></div>\n\n", $parts);
echo Q::view($layout, compact('title', 'content', 'parts'));
return false;
}
示例9: Shipping_scheduled_response_content
function Shipping_scheduled_response_content($params)
{
// redirect to home page if not logged in
if (!Users::loggedInUser()) {
header("Location: " . Q_Request::baseUrl());
exit;
}
// get "Shipping/shipments" stream
$publisherId = Users::communityId();
$streamName = 'Shipping/shipment/' . Q_Request::uri()->shipmentStreamName;
$stream = Streams::fetchOne($publisherId, $publisherId, $streamName);
//$xml = simplexml_load_file(APP_DIR.'/classes/dhl/response.xml');
//$xml = simplexml_load_string(str_replace('req:', '', file_get_contents(APP_DIR.'/classes/dhl/response.xml')));
//print_r($xml); exit;
// test pickup
//$carrier = new Shipping_Carrier_DHL();
//$carrier->createAWBBarCode($stream, 'iVBORw0KGgoAAAANSUhEUgAAAYwAAABeAQMAAAAKdrGZAAAABlBMVEX///8AAABVwtN+AAAAaklEQVR42mNkYGBIyL8wZcutG2wTzVMZfG99eep7y1tp5oIokaMMOtabG6PuTflrnnHqVfI013vzlRYwMDAxkAxGtYxqGdUyqmVUy6iWUS2jWka1jGoZ1TKqZVTLqJZRLaNaRrWMaiEVAABqDRe8DYfcJgAAAABJRU5ErkJggg==', "AWBBarCode");
// -----------
//echo Shipping::getShipmentRelation($stream, true);
//unlink("/tmp/dhl-api-autoload.php");
if (!$stream || !$stream->testReadLevel('see')) {
throw new Users_Exception_NotAuthorized();
}
return Q::view('Shipping/content/scheduled.php', compact('streamName'));
}
示例10: Streams_after_Q_image_save
function Streams_after_Q_image_save($params)
{
$user = Users::loggedInUser(true);
$path = $subpath = $data = $save = null;
extract($params, EXTR_OVERWRITE);
if (isset(Users::$cache['iconUrlWasChanged']) and Users::$cache['iconUrlWasChanged'] === false) {
// the logged-in user's icon was changed without the url changing
$stream = Streams::fetchOne($user->id, $user->id, "Streams/user/icon");
} else {
if (!empty(Streams::$cache['canWriteToStream'])) {
// some stream's icon was being changed
$stream = Streams::$cache['canWriteToStream'];
}
}
if (empty($stream)) {
return;
}
$url = $data[''];
$stream->icon = Q_Valid::url($url) ? $url : Q_Request::baseUrl() . '/' . $url;
$sizes = array();
foreach ($save as $k => $v) {
$sizes[] = "{$k}";
}
sort($sizes);
$stream->setAttribute('sizes', $sizes);
if (empty(Streams::$beingSavedQuery)) {
$stream->changed($user->id);
} else {
$stream->save();
}
}
示例11: Streams_before_Q_responseExtras
function Streams_before_Q_responseExtras()
{
Q_Response::addScript('plugins/Streams/js/Streams.js');
$host = Q_Config::get('Streams', 'node', 'host', Q_Config::get('Q', 'node', 'host', null));
$port = Q_Config::get('Streams', 'node', 'port', Q_Config::get('Q', 'node', 'port', null));
$user = Users::loggedInUser();
if ($user) {
Q_Response::setScriptData('Q.plugins.Users.loggedInUser.displayName', Streams::displayName($user));
}
if (!Q_Request::isAjax()) {
$invite_url = Q_Config::get('Streams', 'invite', 'url', "http://invites.to");
Q_Response::setScriptData('Q.plugins.Streams.invite.url', $invite_url);
if (isset($host) && isset($port)) {
Q_Response::setScriptData('Q.plugins.Streams.node', array("http://{$host}:{$port}"));
}
if ($sizes = Q_Config::expect('Streams', 'types', 'Streams/image', 'sizes')) {
sort($sizes);
Q_Response::setScriptData('Q.plugins.Streams.image.sizes', $sizes);
}
$defaults = array('readLevel' => Streams::$READ_LEVEL['messages'], 'writeLevel' => Streams::$WRITE_LEVEL['join'], 'adminLevel' => Streams::$ADMIN_LEVEL['invite']);
Q_Response::setScriptData('Q.plugins.Streams.defaults', $defaults);
if ($froalaKey = Q_Config::get('Streams', 'froala', 'key', null)) {
Q_Response::setScriptData('Q.plugins.Streams.froala.key', $froalaKey);
}
}
Q_Response::addStylesheet("plugins/Streams/css/Streams.css");
}
示例12: Q_dir
/**
* Default Q/dir handler.
* Just displays a simple directory listing,
* and prevents further processing by returning true.
*/
function Q_dir()
{
$filename = Q_Request::filename();
// TODO: show directory listing
echo Q::view('Q/dir.php', compact('filename'));
return true;
}
示例13: Shipping_shipment_response_content
function Shipping_shipment_response_content($params)
{
$user = Users::loggedInUser(true);
// copy from shipment
$useTemplate = Q_Request::uri()->template ? "Shipping/shipment/" . Q_Request::uri()->template : false;
// Check if stream "Shipping/shipments" exists for current user. If no -> create one.
Shipping::shipments();
// Check if stream "Shipping/templates" exists for current user. If no -> create one.
Shipping::createTemplatesStream();
// Collect streams for shipments. Relations: "describing", "scheduled", "confirmed", "shipping", "canceled", "returned"
$shipment = Shipping::shipment();
//$shipment->addPreloaded($userId);
// test for UPS pickup
//$stream = Streams::fetchOne("Shipping", "Shipping", "Shipping/shipment/Qdqpcspny");
//$carrier = new Shipping_Carrier_UPS();
//$carrier->pickupCreate($stream);
//-------------------------------
// add main style
Q_Response::addStylesheet('css/Shipment.css');
// set communityId
Q_Response::setScriptData("Q.info.communityId", Users::communityId());
Q_Response::setScriptData("Q.info.useTemplate", $useTemplate);
Q_Response::addScript('js/shipment.js');
Q_Response::addScript('js/date.js');
// add jquery UI
//Q_Response::addStylesheet('//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css');
//Q_Response::addScript('//code.jquery.com/ui/1.11.4/jquery-ui.js');
// add pickadate as date picker
Q_Response::addStylesheet('js/pickadate/compressed/themes/default.css');
Q_Response::addStylesheet('js/pickadate/compressed/themes/default.date.css');
Q_Response::addScript('js/pickadate/compressed/picker.js');
Q_Response::addScript('js/pickadate/compressed/picker.date.js');
return Q::view('Shipping/content/shipment.php', compact('user', 'shipment', 'useTemplate'));
}
示例14: Streams_interest_validate
function Streams_interest_validate($params)
{
// Protect against CSRF attacks:
if (Q_Request::method() !== 'GET') {
Q_Valid::nonce(true);
}
}
示例15: Q_notFound
/**
* Default Q/notFound handler.
* Just displays Q/notFound.php view.
*/
function Q_notFound($params)
{
header("HTTP/1.0 404 Not Found");
Q_Dispatcher::result("Nothing found");
$url = Q_Request::url();
echo Q::view('Q/notFound.php', compact('url'));
}