本文整理汇总了PHP中Q::view方法的典型用法代码示例。如果您正苦于以下问题:PHP Q::view方法的具体用法?PHP Q::view怎么用?PHP Q::view使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Q
的用法示例。
在下文中一共展示了Q::view方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Q_errors_native
function Q_errors_native($params)
{
echo Q::view('Q/errors.php', $params);
$app = Q_Config::expect('Q', 'app');
Q::log("{$app}: Errors in " . ceil(Q::milliseconds()) . "ms\n");
Q::log($params);
}
示例2: Streams_category_response_player
/**
* Provide player content to view the members of category listing
* Uses Streams/$type/category.php view (Streams/$streamType/category/get.php can be used for viewing the category
* stream itself if type of category is $streamType/category)
* and Streams::related to retrieve streams data
*
**/
function Streams_category_response_player()
{
$user = Users::loggedInUser();
$userId = $user ? $user->id : 0;
// These are PK of the category!
$publisherId = Streams::requestedPublisherId(true);
$name = Streams::requestedName(true);
// need to know publisher and type of the streams to list
$streamType = Streams::requestedType();
if ($streamType) {
$prefix = "{$streamType}/";
}
$stream_publisherId = Q::expect('Streams', $streamType, 'publisher');
if (substr($name, -1) === '/') {
throw new Q_Exception("Player cannot show listing for multiple categories", compact('publisherId', 'name'));
}
/*
* Get shall return only streams which user is authorized to see.
*/
$categories = Streams::fetch($userId, $publisherId, $name);
if (empty($categories)) {
throw new Q_Exception_MissingRow(array('table' => 'stream', 'criteria' => compact('publisherId', 'name')));
}
$category = reset($categories);
// Are you authorized to see category content?
if (!$category->testReadLevel('content')) {
throw new Users_Exception_NotAuthorized();
}
// get all the streams which are members of this category
// as Streams::get verifies access rights, it's safe to show all streams' content
list($relations, $streams) = Streams::related($userId, $publisherId, $name, true, array('prefix' => $prefix, 'skipAccess' => true));
Q::view("Stream/{$type}/category.php", compact('relations', 'streams', 'userId'));
}
示例3: Shipping_supplies_response_content
function Shipping_supplies_response_content($params)
{
// Do controller stuff here. Prepare variables
$tabs = array("foo" => "bar");
$description = "this is a description";
return Q::view('Shipping/content/supplies.php', compact('tabs', 'description'));
}
示例4: Assets_subscription_tool
/**
* Standard tool for starting or managing subscriptions.
* @class Assets subscription
* @constructor
* @param {array} $options Override various options for this tool
* @param {string} $options.payments can be "authnet" or "stripe"
* @param {string} $options.planStreamName the name of the subscription plan's stream
* @param {string} [$options.publisherId=Q.Users.communityId] the publisher of the subscription plan's stream
* @param {string} [$options.subscribeButton] Can override the title of the subscribe button
* @param {array} [$options=array()] Any additional options
* @param {string} [$options.token=null] required unless the user is an existing customer
*/
function Assets_subscription_tool($options)
{
if (empty($options['payments'])) {
throw new Q_Exception_RequiredField(array('field' => 'payments'), 'payments');
}
$payments = ucfirst($options['payments']);
$lcpayments = strtolower($payments);
$currency = strtolower(Q::ifset($options, 'currency', 'usd'));
if ($payments === 'Authnet' and $currency !== 'usd') {
throw new Q_Exception("Authnet doesn't support currencies other than USD", 'currency');
}
$className = "Assets_Payments_{$payments}";
switch ($payments) {
case 'Authnet':
$adapter = new $className($options);
$token = $options['token'] = $adapter->authToken();
$testing = $options['testing'] = Q_Config::expect('Assets', 'payments', $lcpayments, 'testing');
$action = $options['action'] = $testing ? "https://test.authorize.net/profile/manage" : "https://secure.authorize.net/profile/manage";
break;
case 'Stripe':
$publishableKey = Q_Config::expect('Assets', 'payments', 'stripe', 'publishableKey');
break;
}
$titles = array('Authnet' => 'Authorize.net', 'Stripe' => 'Stripe');
$subscribeButton = Q::ifset($options, 'subscribeButton', "Subscribe with " . $titles[$payments]);
Q_Response::setToolOptions($options);
return Q::view("Assets/tool/subscription/{$payments}.php", compact('token', 'publishableKey', 'action', 'paymentButton', 'subscribeButton', 'planStreamName'));
}
示例5: 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;
}
示例6: Assets_payment_tool
/**
* Standard tool for making payments.
* @class Assets payment
* @constructor
* @param {array} $options Override various options for this tool
* @param {string} $options.payments can be "authnet" or "stripe"
* @param {string} $options.amount the amount to pay.
* @param {double} [$options.currency="usd"] the currency to pay in. (authnet supports only "usd")
* @param {string} [$options.payButton] Can override the title of the pay button
* @param {String} [$options.publisherId=Users::communityId()] The publisherId of the Assets/product or Assets/service stream
* @param {String} [$options.streamName] The name of the Assets/product or Assets/service stream
* @param {string} [$options.name=Users::communityName()] The name of the organization the user will be paying
* @param {string} [$options.image] The url pointing to a square image of your brand or product. The recommended minimum size is 128x128px.
* @param {string} [$options.description=null] A short name or description of the product or service being purchased.
* @param {string} [$options.panelLabel] The label of the payment button in the Stripe Checkout form (e.g. "Pay {{amount}}", etc.). If you include {{amount}}, it will be replaced by the provided amount. Otherwise, the amount will be appended to the end of your label.
* @param {string} [$options.zipCode] Specify whether Stripe Checkout should validate the billing ZIP code (true or false). The default is false.
* @param {boolean} [$options.billingAddress] Specify whether Stripe Checkout should collect the user's billing address (true or false). The default is false.
* @param {boolean} [$options.shippingAddress] Specify whether Checkout should collect the user's shipping address (true or false). The default is false.
* @param {string} [$options.email=Users::loggedInUser(true)->emailAddress] You can use this to override the email address, if any, provided to Stripe Checkout to be pre-filled.
* @param {boolean} [$options.allowRememberMe=true] Specify whether to include the option to "Remember Me" for future purchases (true or false).
* @param {boolean} [$options.bitcoin=false] Specify whether to accept Bitcoin (true or false).
* @param {boolean} [$options.alipay=false] Specify whether to accept Alipay ('auto', true, or false).
* @param {boolean} [$options.alipayReusable=false] Specify if you need reusable access to the customer's Alipay account (true or false).
*/
function Assets_payment_tool($options)
{
Q_Valid::requireFields(array('payments', 'amount'), $options, true);
if (empty($options['name'])) {
$options['name'] = Users::communityName();
}
if (!empty($options['image'])) {
$options['image'] = Q_Html::themedUrl($options['image']);
}
$options['payments'] = strtolower($options['payments']);
if (empty($options['email'])) {
$options['email'] = Users::loggedInUser(true)->emailAddress;
}
$payments = ucfirst($options['payments']);
$currency = strtolower(Q::ifset($options, 'currency', 'usd'));
if ($payments === 'Authnet' and $currency !== 'usd') {
throw new Q_Exception("Authnet doesn't support currencies other than USD", 'currency');
}
$className = "Assets_Payments_{$payments}";
switch ($payments) {
case 'Authnet':
$adapter = new $className($options);
$token = $options['token'] = $adapter->authToken();
$testing = $options['testing'] = Q_Config::expect('Assets', 'payments', $lcpayments, 'testing');
$action = $options['action'] = $testing ? "https://test.authorize.net/profile/manage" : "https://secure.authorize.net/profile/manage";
break;
case 'Stripe':
$publishableKey = Q_Config::expect('Assets', 'payments', 'stripe', 'publishableKey');
break;
}
$titles = array('Authnet' => 'Authorize.net', 'Stripe' => 'Stripe');
Q_Response::setToolOptions($options);
$payButton = Q::ifset($options, 'payButton', "Pay with " . $titles[$payments]);
return Q::view("Assets/tool/payment/{$payments}.php", compact('token', 'publishableKey', 'action', 'payButton'));
}
示例7: 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;
}
示例8: 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'));
}
示例9: 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'));
}
示例10: Broadcast_control_response_content
function Broadcast_control_response_content($params)
{
$user = Users::loggedInUser(true);
$organizations = Broadcast_Agreement::select('a.userId, a.publisherId, u.organization_title, u.organization_domain', 'a')->join(Broadcast_User::table() . ' u', array('a.publisherId' => 'u.userId'))->where(array('a.userId' => $user->id))->fetchAll(PDO::FETCH_ASSOC);
foreach ($organizations as $k => $org) {
$messages = Streams_Message::select('content')->where(array('publisherId' => $org['publisherId'], 'streamName' => 'Broadcast/main'))->orderBy('sentTime')->fetchAll(PDO::FETCH_ASSOC);
$organizations[$k]['messages'] = array();
foreach ($messages as $msg) {
$content = json_decode($msg['content'], true);
if (isset($content['link'])) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $content['link']);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; U; Linux i686; cs-CZ; rv:1.7.12) Gecko/20050929");
$page_contents = curl_exec($ch);
curl_close($ch);
preg_match('/<title>([^<]+)<\\/title>/', $page_contents, $matches);
if (isset($matches[1])) {
$content['link_title'] = $matches[1];
}
}
$organizations[$k]['messages'][] = $content;
}
}
Q_Config::set('Q', 'response', 'Broadcast', 'layout_html', 'Broadcast/layout/canvas.php');
Q_Response::addStylesheet('css/canvas.css');
Q_Response::addScript('http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js');
Q_Response::addScript('js/canvas.js');
return Q::view('Broadcast/content/control.php', compact('organizations'));
}
示例11: MyApp_welcome_response_content
function MyApp_welcome_response_content($params)
{
// Do controller stuff here. Prepare variables
$tabs = array("foo" => "bar");
$description = "this is a description";
return Q::view('MyApp/content/welcome.php', compact('tabs', 'description'));
}
示例12: Q_response_dashboard
function Q_response_dashboard()
{
$app = Q_Config::expect('Q', 'app');
$slogan = "Powered by Q.";
$user = Users::loggedInUser();
return Q::view("{$app}/dashboard.php", compact('slogan', 'user'));
}
示例13: 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'));
}
示例14: Websites_article_tool
/**
* This tool generates an HTML article viewer that lets authorized users edit the article.
* @class Websites article
* @constructor
* @param {Object} [$options] parameters for the tool
* @param {String} $options.publisherId The article publisher's user id
* @param {String} $options.streamName The article's stream name
* @param {String} $options.stream The article's stream, if it is already fetched
* @param {String} [$options.html=array()] Any additional for the Streams/html editor
* @param {String} [$options.getintouch=array()] Additional options for the Users/getintouch tool, in case it's rendered
*/
function Websites_article_tool($options)
{
$publisherId = $options['publisherId'];
$streamName = $options['streamName'];
$article = Q::ifset($options, 'stream', Streams::fetchOne(null, $publisherId, $streamName));
if (!$article) {
throw new Q_Exception_MissingRow(array('table' => 'article', 'criteria' => $streamName));
}
$getintouch = array_merge(array('user' => $article->userId, 'email' => true, 'sms' => true, 'call' => true, 'between' => "", 'emailSubject' => 'Reaching out from your website', 'class' => 'Q_button Q_clickable'), Q::ifset($options, 'getintouch', array()));
$canView = $article->testReadLevel('content');
$canEdit = $article->testWriteLevel('edit');
if ($article->getintouch) {
if (is_array($git = json_decode($article->getintouch, true))) {
$getintouch = array_merge($getintouch, $git);
}
}
$getintouch['class'] = 'Q_button';
if (!$canView) {
throw new Users_Exception_NotAuthorized();
}
$html = Q::ifset($options, 'html', array());
$article->addPreloaded();
Q_Response::addStylesheet('plugins/Websites/css/Websites.css');
Q_Response::addScript("plugins/Websites/js/Websites.js");
Q_Response::setToolOptions($options);
return Q::view("Websites/tool/article.php", compact('article', 'getintouch', 'canEdit', 'canView', 'html'));
}
示例15: 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;
}