本文整理汇总了PHP中Q_Response::addScript方法的典型用法代码示例。如果您正苦于以下问题:PHP Q_Response::addScript方法的具体用法?PHP Q_Response::addScript怎么用?PHP Q_Response::addScript使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Q_Response
的用法示例。
在下文中一共展示了Q_Response::addScript方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Q_expandable_tool
/**
* This tool implements expandable containers that work on most modern browsers,
* including ones on touchscreens.
* @class Q expandable
* @constructor
* @param {array} $options Options for the tool
* @param {string} $options.title Required. The title for the expandable.
* @param {string} $options.content The content. Required unless you pass "items" instead.
* @param {array} [$options.items] An array of strings to wrap in <span> elements and render in the content
* @param {string} [$options.class] If you use "items", optionally specify the class of the container elements for each item
* @param {integer} [$options.title] A number, if any, to display when collapsed
* @param {boolean} [$options.autoCollapseSiblings] Whether, when expanding an expandable, its siblings should be automatically collapsed.
*/
function Q_expandable_tool($options)
{
if (isset($options['items'])) {
$classString = isset($options['class']) ? "class='{$options['class']}'" : '';
$lines = array();
foreach ($options['items'] as $key => $value) {
$lines[] = "<span {$classString}>{$key}</span>";
}
$between = Q::ifset($options, 'between', '');
$options['content'] = implode($between, $lines);
}
foreach (array('title', 'content') as $field) {
if (!isset($options[$field])) {
throw new Q_Exception_RequiredField(compact('field'));
}
}
Q_Response::addScript('plugins/Q/js/tools/expandable.js');
Q_Response::addStylesheet('plugins/Q/css/expandable.css');
$count = Q::ifset($options, 'count', '');
$style = empty($options['expanded']) ? '' : 'style="display:block"';
$h2 = "<h2>\n\t<span class='Q_expandable_count'>{$count}</span>\n\t{$options['title']}\n</h2>";
$div = "<div class='Q_expandable_container' {$style}><div class='Q_expandable_content'>\n\t{$options['content']}\n</div></div>";
Q_Response::setToolOptions($options);
return $h2 . $div;
}
示例2: Websites_presentation_tool
/**
* Renders a Websites/presentation stream,
* including an interface to edit the presentation
* for users who have the permissions to do so.
* @param {array} $options
* @param {string} $options.publisherId
* @param {string} $options.streamName
*/
function Websites_presentation_tool($options)
{
Q_Response::addStylesheet('plugins/Websites/css/Websites.css');
Q_Response::addScript('plugins/Websites/js/Websites.js');
Q_Response::setToolOptions($options);
return '';
}
示例3: 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");
}
示例4: Streams_photoSelector_tool
/**
* Renders a photo selector tool
* @param $options
* An associative array of parameters, which can include:
* @param {Object} [$options] this object contains function parameters
* @param {Q.Event} $options.onSelect Required string naming the callback to be called when the user selects a photo.
* @param {Q.Event} [$options.beforePhotos] Triggered when photos are about to be rendered.
* @param {Q.Event} [$options.onPhotos] Triggered when photos have been rendered.
* @param {String} [$options.uid='me'] Optional. The uid of the user on the provider whose photos should be shown. Facebook only allows 'me' or a page id as a value.
* @param {String} [$options.fetchBy='album'] The tool supports different algoriths for fetching photos. Can be either by 'album' or 'tags'. Maybe more will be added later.
* @param {String} [$options.preprocessAlbums] Optional function to process the albums array before presenting it in the select. Receives a reference to the albums array as the first parameter, and a callback to call when it's done as the second.
* @param {String} [$options.preprocessPhotos] Optional function to process the photos array before presenting it in the select. Receives a reference to the albums array as the first parameter, and a callback to call when it's done as the second.
* @param {Q.Event} [$options.onLoad] Q.Event, callback or callback string name which is called when bunch of photos has been loaded.
* @param {Q.Event} [$options.onError] Q.Event, callback or callback string which will be called for each image that is unable to load. Image DOM element will be passed as first argument.
* @param {String} [$options.provider='facebook'] Has to be "facebook" for now.
* @param {String} [$options.prompt=false]
* Specifies type of prompt if user is not logged in or didn't give required permission for the tool.
* Can be either 'button', 'dialog' or null|false.
* In first case just shows simple button which opens facebook login popup.
* In second case shows Users.facebookDialog prompting user to login.
* In third case will not show any prompt and will just hide the tool.
* @param {String} [$options.promptTitle] Used only when 'prompt' equals 'dialog' - will be title of the dialog.
* @param {String} [$options.promptText] Used either for button caption when 'prompt' equals 'button' or dialog text when 'prompt' equals 'dialog'.
* @param {Boolean} [$options.oneLine] If true, all the images are shown in a large horizontally scrolling line.
* @return {void}
*/
function Streams_photoSelector_tool($options)
{
Q_Response::addScript('plugins/Streams/js/Streams.js');
Q_Response::addStylesheet('plugins/Streams/css/Streams.css');
Q_Response::setToolOptions($options);
return '';
}
示例5: 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'));
}
示例6: Q_ticker_tool
/**
* Ticker that scrolls its contents with various speeds and pauses
* @class Q ticker
* @constructor
* @param {array} $options
* An associative array of fields, possibly including:
*
* "content" => string
* The content of the ticker. The first top-level element
* should contain sub-elements, and their sizes determine where
* the ticker would pause between automatically scrolling.
* The ticker animates by scrolling its inner contents.
*
* "vertical" => bool
* Defaults to true. If false, the ticker scrolls horizontally.
*
* "speed" => integer
* The scrolling speed.
* This is the number of items that would scroll by in 1 second,
* if there were no pauses.
* When the speed is positive, vertical tickers scroll down, and
* horizontal tickers scroll to the right. New content seems to come in
* from the bottom (for vertical tickers) or right (for horizontal tickers)
* as the ticker scrolls. The element inside the ticker will start out
* aligned with the top side of the ticker (for vertical tickers),
* or the left side of the ticker (for horizontal tickers).
* When the speed is negative, all this faces the other way.
*
* "pause_ms" => int
* Defaults to 2000. This is the number of milliseconds to wait
* after each second-level element of $content is automatically
* scrolled completely into view.
*
* "pause_ms_min" => int
* If set, then the number of milliseconds to pause is a random
* integer between $pause_ms_min and $pause_ms.
*
* "scrollbars" => bool
* Defaults to true. If true, shows scrollbars, otherwise doesn't.
* (Note: this will let the user know how much content is left,
* and be able to see it before it would automatically scroll into view.)
*
* "scrollbars_pause_ms" => int
* Defaults to 500. The ticker pauses its automatic scrolling when the user
* starts using the scrollbars. This is the number of milliseconds to wait
* until resuming the automatic scrolling.
*
* "anim_ms" => int
* Defaults to 100. This is the number of milliseconds between calls to
* autoScroll.
*
* "initial_scroll_mode" => string
* Defaults to 'auto'. This is the mode that scrolling starts out in.
* Possible values are 'auto' and 'paused'.
*
* "ease" => string
* Optional. If set, specifies the name of the ease function
*/
function Q_ticker_tool($options = array())
{
$defaults = array('vertical' => true, 'speed' => 1, 'pause_ms' => 2000, 'scrollbars' => true, 'scrollbars_pause_ms' => 500, 'anim_ms' => 100);
$fields2 = array_merge($defaults, $options);
if (!isset($fields2['pause_ms_min'])) {
$fields2['pause_ms_min'] = $fields2['pause_ms'];
}
if (!isset($fields2['content'])) {
$li_array = array();
for ($i = 0; $i < 100; ++$i) {
$li_array[] = '<li><div style="background-color:#' . dechex(rand(0, 16)) . dechex(rand(0, 16)) . dechex(rand(0, 16)) . dechex(rand(0, 16)) . dechex(rand(0, 16)) . dechex(rand(0, 16)) . '">Missing $content parameter. This is just example #' . $i . '</div></li>';
}
$default_content = implode("\n", $li_array);
if ($fields2['vertical']) {
$fields2['content'] = "<ul class='error'>{$default_content}</ul>";
} else {
$fields2['content'] = "<ul class='error'>{$default_content}</ul>";
}
}
Q_Response::addStylesheet('plugins/Q/css/ticker.css');
Q_Response::addScript('plugins/Q/js/tools/ticker.js');
Q_Response::setToolOptions($fields2);
$direction_class = $fields2['vertical'] ? 'vertical' : 'horizontal';
$scrollbars_class = $fields2['scrollbars'] ? 'scrollbars' : '';
return Q_Html::tag('div', array('class' => "Q_ticker {$direction_class} {$scrollbars_class}"), $fields2['content']);
}
示例7: 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'));
}
示例8: 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);
}
}
示例9: 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'));
}
示例10: Websites_seo_tool
/**
* Tool for admins to edit the url, title, keywords, description of the current page
* @class Websites seo
* @constructor
* @param {Object} [$options] Options for the tool
* @param {String} [$options.skipIfNotAuthorized=true] Whether to skip rendering the contents of the tool if the logged-in user is not authorized to edit the SEO information for this page.
*/
function Websites_seo_tool($options)
{
$skipIfNotAuthorized = Q::ifset($options, 'skipIfNotAuthorized', true);
if ($skipIfNotAuthorized) {
$websitesUserId = Users::communityId();
$sha1 = sha1(Q_Dispatcher::uri());
$seoStreamName = "Websites/seo/{$sha1}";
$stream = Streams::fetchOne(null, $websitesUserId, $seoStreamName);
$user = Users::loggedInUser();
if (!$user or $stream and !$stream->testWriteLevel('suggest')) {
$options['skip'] = true;
}
if (!$stream and !Streams::isAuthorizedToCreate($user->id, $websitesUserId, 'Websites/seo')) {
$options['skip'] = true;
}
}
unset($options['skipIfNotAuthorized']);
Q_Response::addStylesheet('plugins/Websites/css/Websites.css');
Q_Response::addScript("plugins/Websites/js/Websites.js");
Q_Response::setToolOptions($options);
$user = Users::loggedInUser(false, false);
$userId = $user ? $user->id : "";
$communityId = Users::communityId();
$sha1 = sha1(Q_Dispatcher::uri());
$seoStreamName = "Websites/seo/{$sha1}";
$streams = Streams::fetch($userId, $communityId, array("Websites/header", "Websites/title", "Websites/slogan", $seoStreamName));
foreach ($streams as $name => $s) {
if ($s) {
$s->addPreloaded($userId);
}
}
}
示例11: Places_before_Q_responseExtras
function Places_before_Q_responseExtras()
{
Q_Response::addScript('plugins/Places/js/Places.js');
Q_Response::addStylesheet("plugins/Places/css/Places.css");
if ($key = Q_Config::get('Places', 'google', 'keys', 'web', null)) {
Q_Response::setScriptData("Q.Places.loadGoogleMaps.key", $key);
}
}
示例12: 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";
Q_Response::addScript('js/pages/welcome.js');
return Q::view('MyApp/content/welcome.php', compact('tabs', 'description'));
}
示例13: Trump_floor_response_content
function Trump_floor_response_content()
{
$app = Q_Config::expect('Q', 'app');
$action = 'about';
Q_Response::addStylesheet('plugins/Websites/css/Websites.css');
Q_Response::addScript("plugins/Websites/js/Websites.js");
return Q::view("Trump/content/floor.php", compact('app', 'action'));
}
示例14: Shipping_templates_response_content
function Shipping_templates_response_content($params)
{
// Do controller stuff here. Prepare variables
$env = Shipping::getVars();
Q_Response::addStylesheet('css/ShipmentTemplates.css');
Q_Response::addScript('js/date.js', "");
return Q::view('Shipping/content/templates.php', compact('env'));
}
示例15: Q_bookmarklet_tool
/**
* Makes an infomation block for adding a bookmarklet on the browser's bookmarks bar
* the way similar to how facebook does: https://www.facebook.com/share_options.php .
* Main purpose of the tool is to present in cross-browser way how bookmarklet button will look, how bookmarklet will
* look on browser panel and instructions how to add bookmarklet to that panel.
* @param {array} $options An associative array of parameters, which can include:
* @param {array} [$options.scripts] Array of one or more urls of javascript files (will be run through Q_Html::themedUrl) to be executed in order.
* @param {string} [$options.content] Literal Javascript code to execute. If scripts option is provided, this code is executed after the scripts have been loaded.
* @param {Object} [$options.skip] Object of {url: path.to.object} pairs to avoid loading script at the url if path.to.object is already defined. Typically names an object which has been defined by the loaded script.
* @param {string} $options.title Required. Title for the button which will be added to user's browser bar.
* @param {string} $options.usage Text which is appended to instructions, identifying purpose and usage of this bookmarklet.
* @param {string} [$options.icon] Icon for the button which will be added to user's browser bar. Can contain placeholders supported by strftime() and also few special placeholders with specific functionality.
* @return {string}
*/
function Q_bookmarklet_tool($options)
{
$options = array_merge(array('icon' => null), $options);
Q_Response::addScript('plugins/Q/js/tools/bookmarklet.js');
Q_Response::addStylesheet('plugins/Q/css/bookmarklet.css');
Q_Response::setToolOptions($options);
return '';
}