本文整理汇总了PHP中Q_Html类的典型用法代码示例。如果您正苦于以下问题:PHP Q_Html类的具体用法?PHP Q_Html怎么用?PHP Q_Html使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Q_Html类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Websites_before_Streams_Stream_save_Websites_seo
function Websites_before_Streams_Stream_save_Websites_seo($params)
{
$stream = $params['stream'];
if (!$stream->wasModified('attributes')) {
return;
}
$uri = $stream->getAttribute('uri', null);
if (!$uri) {
return;
}
$url = $stream->getAttribute('url', null);
if (preg_match('/\\s/', $url)) {
throw new Q_Exception_WrongValue(array('field' => 'url', 'range' => "no spaces"));
}
$wp = new Websites_Permalink();
$wp->uri = $uri;
$wp->retrieve('*', array('ignoreCache' => true));
if ($url = $stream->getAttribute('url', null)) {
$url = Q_Html::themedUrl($url);
if (!isset($wp->url) or $wp->url !== $url) {
$wp->url = $url;
$wp->save();
}
} else {
$wp->remove();
}
}
示例2: 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'));
}
示例3: Streams_stream_response_Q_inplace
function Streams_stream_response_Q_inplace()
{
$stream = isset(Streams::$cache['stream']) ? Streams::$cache['stream'] : null;
if (!$stream) {
throw new Exception("No stream");
}
if (isset($_REQUEST['title'])) {
$result = $stream->title;
} else {
if (isset($_REQUEST['attributes'])) {
if (is_array($_REQUEST['attributes'])) {
reset($_REQUEST['attributes']);
$result = $stream->getAttribute(key($_REQUEST['attributes']));
} else {
$result = $stream->attributes;
}
} else {
$fieldNames = array_diff(Streams::getExtendFieldNames($stream->type), array('insertedTime', 'updatedTime'));
$field = 'content';
foreach ($fieldNames as $f) {
if (isset($_REQUEST[$f])) {
$field = $f;
break;
}
}
$result = $stream->{$field};
}
}
$convert = Q::ifset($_REQUEST, 'convert', '["\\n"]');
return Q_Html::text($result, json_decode($convert, true));
}
示例4: 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);
}
}
示例5: Users_avatar_tool
/**
* This tool renders a user avatar
*
* @param {array} $options An associative array of parameters, containing:
* @param {boolean} [$options.userId]
* "userId" => The user's id. Defaults to id of the logged-in user, if any.
* @param {boolean} [$options.icon]
* "icon" => Optional. Render icon before the username.
* @param {boolean} [$options.iconAttributes]
* "iconAttributes" => Optional. Array of attributes to render for the icon.
* @param {boolean} [$options.editable]
* "editable" => Optional. Whether to provide an interface for editing the user's info. Can be array containing "icon", "name".
* @param {array} [$options.inplaces] Additional fields to pass to the child Streams/inplace tools, if any
* @param {boolean} [$options.renderOnClient]
* If true, only the html container is rendered, so the client will do the rest.
*/
function Users_avatar_tool($options)
{
$defaults = array('icon' => false, 'editable' => false);
$options = array_merge($defaults, $options);
if (empty($options['userId'])) {
$user = Users::loggedInUser();
$options['userId'] = $user->id;
} else {
$user = Users_User::fetch($options['userId']);
}
Q_Response::addStylesheet('plugins/Q/css/Q.css');
Q_Response::setToolOptions($options);
if (!empty($options['renderOnClient'])) {
return '';
}
if (!$user) {
return '';
}
$user->addPreloaded();
$p = $options;
$p['userId'] = $user->id;
Q_Response::setToolOptions($p);
$result = '';
$icon = $options['icon'];
if ($icon) {
if ($icon === true) {
$icon = Q_Config::get('Users', 'icon', 'defaultSize', 40);
}
$attributes = isset($options['iconAttributes']) ? $options['iconAttributes'] : array();
$attributes['class'] = isset($attributes['class']) ? $attributes['class'] . ' Users_avatar_icon' : 'Users_avatar_icon';
$result .= Q_Html::img($user->iconUrl($icon), 'user icon', $attributes);
}
$result .= '<span class="Users_avatar_name">' . $user->username . '</span>';
return $result;
}
示例6: Q_before_Q_tool_render
function Q_before_Q_tool_render($params, &$result)
{
$info = $params['info'];
$extra = $params['extra'];
if (is_string($extra) or is_numeric($extra)) {
$extra_id = $extra;
$extra = array();
} else {
$extra_id = isset($extra['id']) ? $extra['id'] : '';
}
$cur_prefix = isset($extra['prefix']) ? $extra['prefix'] : Q_Html::getIdPrefix();
$tool_ids = array();
$tool_prefixes = array();
foreach ($info as $name => $options) {
$tool_id = Q_Html::id($name . ($extra_id === '' ? '' : "-{$extra_id}"), $cur_prefix);
$tool_ids[$name] = $tool_id;
$tool_prefix = $tool_id . '_';
if (isset(Q::$toolWasRendered[$tool_prefix])) {
trigger_error("A tool with prefix \"{$tool_prefix}\" was already rendered.", E_USER_NOTICE);
}
Q::$toolWasRendered[$tool_prefix] = true;
$tool_prefixes[$name] = $tool_prefix;
}
$prev_prefix = Q_Html::pushIdPrefix($tool_prefixes, $tool_ids);
}
示例7: Q_response_notices
function Q_response_notices()
{
$result = "";
$notices = Q_Response::getNotices();
// Get any notices that we should know about
if (!empty($notices)) {
$result .= "<ul class='Q_notices'>";
foreach ($notices as $k => $n) {
$key = Q_Html::text($k);
$result .= "<li data-key='{$key}'>{$n}</li>\n";
}
$result .= "</ul>";
}
// Get any errors that we should display
$errors = Q_Response::getErrors();
if (!empty($errors)) {
$result .= "<ul class='Q_errors'>";
foreach ($errors as $e) {
$field = '';
if ($e instanceof Q_Exception and $fields = $e->inputFields()) {
$field .= '<div class="Q_field_name">' . Q_Html::text(reset($fields)) . '</div>';
}
$result .= "<li>" . $e->getMessage() . "{$field}</li>";
}
$result .= "</ul>";
}
return $result ? "<div id='notices'>{$result}</div>" : '';
}
示例8: Q_before_Q_tool_render
function Q_before_Q_tool_render($params, &$result)
{
$info = $params['info'];
$extra = $params['extra'];
if (is_string($extra)) {
$extra_id = $extra;
$extra = array();
} else {
$extra_id = isset($extra['id']) ? $extra['id'] : '';
}
$cur_prefix = isset($extra['prefix']) ? $extra['prefix'] : Q_Html::getIdPrefix();
$tool_ids = array();
$tool_prefixes = array();
foreach ($info as $name => $options) {
$tool_id = implode('_', explode('/', $name));
if (!empty($extra_id)) {
$tool_id .= '-' . $extra_id;
}
$tool_id = $cur_prefix . $tool_id;
$tool_ids[$name] = $tool_id;
$tool_prefix = $tool_id . '_';
if (isset(Q::$toolWasRendered[$tool_prefix])) {
trigger_error("A tool with prefix \"{$tool_prefix}\" was already rendered.", E_USER_NOTICE);
}
Q::$toolWasRendered[$tool_prefix] = true;
$tool_prefixes[$name] = $tool_prefix;
}
$prev_prefix = Q_Html::pushIdPrefix($tool_prefixes, $tool_ids);
}
示例9: Users_avatar_tool
/**
* This tool renders a user avatar
*
* @param {array} $options An associative array of parameters, containing:
* @param {string} [$options.userId]
* The user's id. Defaults to id of the logged-in user, if any.
* Can be '' for a blank-looking avatar.
* @param {boolean} [options.short]
* Optional. Renders the short version of the display name.
* @param {boolean|integer} [options.icon=false]
* Optional. Pass the size in pixels of the (square) icon to render
* before the username. Or pass true to render the default size.
* @param {array} [options.iconAttributes]
* Optional. Array of attributes to render for the icon.
* @param {boolean|array} [options.editable=false]
* Optional. Whether to provide an interface for editing the user's info. Can be array containing one or more of "icon", "name".
* @param {boolean} [$options.show] The parts of the name to show. Can have the letters "f", "l", "u" in any order.
* @param {boolean} [options.cacheBust=null]
* Number of milliseconds to use for Q_Uri::cacheBust for combating unintended caching on some environments.
* @param {boolean} [options.renderOnClient]
* If true, only the html container is rendered, so the client will do the rest.
*/
function Users_avatar_tool($options)
{
$defaults = array('icon' => false, 'short' => false, 'cacheBust' => null, 'editable' => false);
$options = array_merge($defaults, $options);
Q_Response::addStylesheet('plugins/Users/css/Users.css');
$loggedInUser = Users::loggedInUser();
$loggedInUserId = $loggedInUser ? $loggedInUser->id : "";
if (empty($options['userId'])) {
$options['userId'] = $loggedInUserId;
}
unset($options['iconAttributes']);
if (empty($options['editable'])) {
$options['editable'] = array();
} else {
if (is_string($options['editable'])) {
$options['editable'] = array($options['editable']);
} else {
if ($options['editable'] === true) {
$options['editable'] = array('icon', 'name');
}
}
}
Q_Response::setToolOptions($options);
if (!empty($options['renderOnClient'])) {
return '';
}
$avatar = Streams_Avatar::fetch($loggedInUserId, $options['userId']);
if (!$avatar) {
return '';
}
$result = '';
if ($icon = $options['icon']) {
if ($icon === true) {
$icon = Q_Config::get('Users', 'icon', 'defaultSize', 40);
}
$attributes = isset($options['iconAttributes']) ? $options['iconAttributes'] : array();
$class = "Users_avatar_icon Users_avatar_icon_{$icon}";
$attributes['class'] = isset($attributes['class']) ? $attributes['class'] . ' ' . $class : $class;
if (isset($options['cacheBust'])) {
$attributes['cacheBust'] = $options['cacheBust'];
}
$result .= Q_Html::img(Users::iconUrl($avatar->icon, "{$icon}.png"), 'user icon', $attributes);
}
$o = $options['short'] ? array('short' => true) : array();
$o['html'] = true;
if (in_array('name', $options['editable'])) {
$o['show'] = 'fl';
$streams = Streams::fetch(null, $options['userId'], array('Streams/user/firstName', 'Streams/user/lastName', 'Streams/user/username'));
foreach ($streams as $s) {
$s->addPreloaded();
}
}
if (!empty($options['show'])) {
$o['show'] = $options['show'];
}
$displayName = $avatar->displayName($o, 'Someone');
$result .= "<span class='Users_avatar_name'>{$displayName}</span>";
return $result;
}
示例10: Streams_inplace_tool
/**
* This tool generates an inline editor to edit the content or attribute of a stream.
* @class Streams inplace
* @constructor
* @param {array} $options Options for the tool
* An associative array of parameters, containing:
* @param {string} [$options.inplaceType='textarea'] The type of the fieldInput. Can be "textarea" or "text"
* @param {array} [$options.convert] The characters to convert to HTML. Pass an array containing zero or more of "\n", " "
* @param {Streams_Stream} $options.stream A Streams_Stream object
* @param {string} [$options.field] Optional, name of an field to change instead of the content of the stream
* @param {string} [$options.attribute] Optional, name of an attribute to change instead of any field.
* @param {string} [$options.beforeSave] Reference to a callback to call after a successful save. This callback can cancel the save by returning false.
* @param {string} [$options.onSave] Reference to a callback or event to run after a successful save.
* @param {string} [$options.onCancel] Reference to a callback or event to run after cancel.
* @param {array} [$options.inplace=array()] Additional fields to pass to the child Q/inplace tool, if any
* @uses Q inplace
*/
function Streams_inplace_tool($options)
{
if (empty($options['stream'])) {
if (empty($options['publisherId']) or empty($options['streamName'])) {
throw new Q_Exception_RequiredField(array('field' => 'stream'));
}
$publisherId = $options['publisherId'];
$streamName = $options['streamName'];
$stream = Streams::fetchOne(null, $publisherId, $streamName);
if (!$stream) {
throw new Q_Exception_MissingRow(array('table' => 'stream', 'criteria' => "publisherId={$publisherId}, name={$streamName}"));
}
} else {
$stream = $options['stream'];
}
$inplaceType = Q::ifset($options, 'inplaceType', 'textarea');
$inplace = array('action' => $stream->actionUrl(), 'method' => 'PUT', 'type' => $inplaceType);
if (isset($options['inplace'])) {
$inplace = array_merge($options['inplace'], $inplace);
}
$convert = Q::ifset($options, 'convert', array("\n"));
$inplace['hidden']['convert'] = json_encode($convert);
if (!empty($options['attribute'])) {
$field = 'attributes[' . urlencode($options['attribute']) . ']';
$content = $stream->get($options['attribute'], '');
$maxlength = $stream->maxSize_attributes - strlen($stream->maxSize_attributes) - 10;
} else {
$field = !empty($options['field']) ? $options['field'] : 'content';
$content = $stream->{$field};
$maxlength = $stream->maxSizeExtended($field);
}
switch ($inplaceType) {
case 'text':
$inplace['fieldInput'] = Q_Html::input($field, $content, array('placeholder' => Q::ifset($input, 'placeholder', null), 'maxlength' => $maxlength));
$inplace['staticHtml'] = Q_Html::text($content);
break;
case 'textarea':
$inplace['fieldInput'] = Q_Html::textarea($field, 5, 80, array('placeholder' => Q::ifset($inplace, 'placeholder', null), 'maxlength' => $maxlength), $content);
$inplace['staticHtml'] = Q_Html::text($content, $convert);
break;
default:
return "inplaceType must be 'textarea' or 'text'";
}
if (!$stream->testWriteLevel('suggest')) {
if (!isset($options['classes'])) {
$options['classes'] = '';
}
Q_Response::setToolOptions(array('publisherId' => $stream->publisherId, 'streamName' => $stream->name));
$staticClass = $options['inplaceType'] === 'textarea' ? 'Q_inplace_tool_blockstatic' : 'Q_inplace_tool_static';
return "<span class='Q_inplace_tool_container {$options['classes']}' style='position: relative;'>" . "<div class='{$staticClass}'>{$inplace['staticHtml']}</div></span>";
}
$toolOptions = array('publisherId' => $stream->publisherId, 'streamName' => $stream->name, 'inplaceType' => $options['inplaceType']);
Q::take($options, array('attribute', 'field', 'convert'), $toolOptions);
$toolOptions['inplace'] = $inplace;
Q_Response::setToolOptions($toolOptions);
return Q::tool("Q/inplace", $inplace);
}
示例11: Streams_publish_Broadcast_tool
function Streams_publish_Broadcast_tool($options)
{
extract($options);
$publisherId = $stream->publisherId;
$streamName = $stream->name;
$type = 'Broadcast';
$input = Q_Html::input('content', '');
$button = Q_Html::tag('button', array(), 'Post');
return Q_Html::form('Streams/stream', 'post', array(), Q_Html::formInfo(true) . Q_Html::hidden(compact('publisherId', 'streamName', 'type')) . Q::tool('Q/form', array('fields' => array('message' => array('type' => 'text', 'message' => 'this message will appear as if the user typed it before posting'), 'link' => array('type' => 'text', 'message' => 'the address of the webpage to share'), 'picture' => array('type' => 'text', 'message' => 'if you enter a picture url here, it will override the picture that is posted'), 'description' => array('type' => 'textarea', 'message' => 'if you enter something here, it will override the description that facebook would have automatically grabbed from that page'), '' => array('type' => 'button', 'value' => 'Post')), 'onSuccess' => 'Q.plugins.Broadcast.onBroadcastSuccess')));
}
示例12: Q_columns_tool
/**
* This tool contains functionality to show things in columns
* @class Q columns
* @constructor
* @param {array} [options] Provide options for this tool
* @param {array} [options.animation] For customizing animated transitions
* @param {integer} [options.animation.duration] The duration of the transition in milliseconds, defaults to 500
* @param {array} [options.animation.hide] The css properties in "hide" state of animation
* @param {array} [options.animation.show] The css properties in "show" state of animation
* @param {array} [options.back] For customizing the back button on mobile
* @param {string} [options.back.src] The src of the image to use for the back button
* @param {boolean} [options.back.triggerFromTitle] Whether the whole title would be a trigger for the back button. Defaults to true.
* @param {boolean} [options.back.hide] Whether to hide the back button. Defaults to false, but you can pass true on android, for example.
* @param {array} [options.close] For customizing the back button on desktop and tablet
* @param {string} [options.close.src] The src of the image to use for the close button
* @param {string} [options.title] You can put a default title for all columns here (which is shown as they are loading)
* @param {string} [options.column] You can put a default content for all columns here (which is shown as they are loading)
* @param {array} [options.clickable] If not null, enables the Q/clickable tool with options from here. Defaults to null.
* @param {array} [options.scrollbarsAutoHide] If not null, enables Q/scrollbarsAutoHide functionality with options from here. Enabled by default.
* @param {boolean} [options.fullscreen] Whether to use fullscreen mode on mobile phones, using document to scroll instead of relying on possibly buggy "overflow" CSS implementation. Defaults to true on Android, false everywhere else.
* @param {array} [options.columns] In PHP only, an array of $name => $column pairs, where $column is in the form array('title' => $html, 'content' => $html, 'close' => true)
* @return {string}
*/
function Q_columns_tool($options)
{
$jsOptions = array('animation', 'back', 'close', 'title', 'scrollbarsAutoHide', 'fullscreen');
Q_Response::setToolOptions(Q::take($options, $jsOptions));
if (!isset($options['columns'])) {
return '';
}
Q_Response::addScript('plugins/Q/js/tools/columns.js');
Q_Response::addStylesheet('plugins/Q/css/columns.css');
$result = '<div class="Q_columns_container Q_clearfix">';
$columns = array();
$i = 0;
$closeSrc = Q::ifset($options, 'close', 'src', 'plugins/Q/img/x.png');
$backSrc = Q::ifset($options, 'back', 'src', 'plugins/Q/img/back-v.png');
foreach ($options['columns'] as $name => $column) {
$close = Q::ifset($column, 'close', $i > 0);
$Q_close = Q_Request::isMobile() ? 'Q_close' : 'Q_close Q_back';
$closeHtml = !$close ? '' : (Q_Request::isMobile() ? '<div class="Q_close Q_back">' . Q_Html::img($backSrc, 'Back') . '</div>' : '<div class="Q_close">' . Q_Html::img($closeSrc, 'Close') . '</div>');
$n = Q_Html::text($name);
$columnClass = 'Q_column_' . Q_Utils::normalize($name) . ' Q_column_' . $i;
if (isset($column['html'])) {
$html = $column['html'];
$columns[] = <<<EOT
\t<div class="Q_columns_column {$columnClass}" data-index="{$i}" data-name="{$n}">
\t\t{$html}
\t</div>
EOT;
} else {
$titleHtml = Q::ifset($column, 'title', '[title]');
$columnHtml = Q::ifset($column, 'column', '[column]');
$classes = $columnClass . ' ' . Q::ifset($column, 'class', '');
$attrs = '';
if (isset($column['data'])) {
$json = Q::json_encode($column['data']);
$attrs = 'data-more="' . Q_Html::text($json) . '"';
foreach ($column['data'] as $k => $v) {
$attrs .= 'data-' . Q_Html::text($k) . '="' . Q_Html::text($v) . '" ';
}
}
$data = Q::ifset($column, 'data', '');
$columns[] = <<<EOT
\t<div class="Q_columns_column {$classes}" data-index="{$i}" data-name="{$n}" {$attrs}>
\t\t<div class="Q_columns_title">
\t\t\t{$closeHtml}
\t\t\t<h2 class="Q_title_slot">{$titleHtml}</h2>
\t\t</div>
\t\t<div class="Q_column_slot">{$columnHtml}</div>
\t</div>
EOT;
}
++$i;
}
$result .= "\n" . implode("\n", $columns) . "\n</div>";
return $result;
}
示例13: Q_filter_tool
/**
* Implements an input that filters an associated list (like an autocomplete)
* @class Q filter
* @constructor
* @param {array} [$options] Override various options for this tool
* @param {String} [$options.name=filter] The name of the text input
* @param {String} [$options.value=''] The initial value of the text input
* @param {String} [$options.placeholder] Any placeholder text
* @param {array} [$options.placeholders={}] Options for Q/placeholders, or null to omit it
* @param {String} [$options.results=''] HTML to display in the results initially. If setting them later, remember to call stateChanged('results')
* @param {Q.Event} [$options.onFilter] Name of a JS event handler that is meant to fetch and update results by editing the contents of the element pointed to by the second argument. The first argument is the content of the text input.
* @return {string}
*/
function Q_filter_tool($options)
{
Q_Response::setToolOptions($options);
$name = Q::ifset($options, 'name', 'filter');
$value = Q::ifset($options, 'value', '');
$placeholder = Q::ifset($options, 'placeholder', 'filter');
$class = 'Q_filter_input';
Q_Response::addScript('plugins/Q/js/tools/filter.js');
Q_Response::addStylesheet('plugins/Q/css/filter.css');
return Q_Html::input($name, $value, compact('placeholder', 'class')) . '<div class="Q_filter_results"></div>';
}
示例14: Streams_userChooser_tool
/**
* userChooser tool
* @param array $options
* "maxResults" => the maximum number of results to show, defaults to 3
* "onSuccess" => the name of the function for what to do
* "placeholder" => override the default placeholder text,
* "exclude" => associative array of userId => true, where userId are the ids of the users
* to exclude from the results. Defaults to id of logged-in user, if logged in.
*/
function Streams_userChooser_tool($options)
{
$maxResults = Q_Config::get('Streams', 'userChooser', 'maxResults', 3);
$placeholder = "Start typing...";
extract($options);
if (!isset($exclude) and $user = Users::loggedInUser()) {
$exclude = array($user->id => true);
}
Q_Response::addScript('plugins/Streams/js/Streams.js');
Q_Response::setToolOptions(compact('onSuccess', 'maxResults', 'exclude'));
return Q_Html::input('query', '', array('class' => 'text', 'placeholder' => $placeholder, 'autocomplete' => 'off'));
}
示例15: Q_drawers_tool
/**
* Creates an area that behaves like position: fixed in most modern browsers,
* including ones on touchscreens. Often used for fixed areas that wind up
* covered by content as it scrolls over the areas.
* @class Q drawers
* @constructor
* @param {array} [$options] Provide options for this tool
* @param {array} [$options.drawers] Array of strings holding html for drawers
* @param {string} [$options.container=null] Optional jQuery selector for handling scrolling
* @param {array} [$options.initial] Information for the initial animation
* @param {integer} [$options.initial.index=1] The index of the drawer to show, either 0 or 1
* @param {integer} [$options.initial.delay=0] Delay before starting initial animation
* @param {integer} [$options.initial.duration=300] The duration of the initial animation
* @param {Function} [$options.initial.ease=Q.Animation.linear] The easing function of the initial animation
* @param {array} [$options.transition] Information for the transition animation
* @param {integer} [$options.transition.duration=300] The duration of the transition animation
* @param {Function} [$options.transition.ease=Q.Animation.linear] The easing function of the transition animation
* @param {Function} [$options.width] Override the function that computes the width of the drawers
* @param {Function} [$options.height] Override the function that computes the height drawers tool
* @param {array} [$options.heights=[100,100]] Array of [height0, height1] for drawers that are pinned
* @param {array} [$options.placeholders=['','']] Array of [html0, html1] for drawers that are pinned
* @param {array} [$options.behind=[true,false]] Array of [boolean0, boolean1] to indicate which drawer is behind the others
* @param {array} [$options.bottom=[false,false]] Array of [boolean0, boolean1] to indicate whether to scroll to the bottom of a drawer after switching to it
* @param {array} [$options.triggers=['plugins/Q/img/drawers/up.png', 'plugins/Q/img/drawers/down.png']] Array of [src0, src1] for img elements that act as triggers to swap drawers. Set array elements to false to avoid rendering a trigger.
* @param {array} [$options.trigger]] Options for the trigger elements
* @param {integer} [$options.trigger.rightMargin=10]] How many pixels from the right side of the drawers
* @param {integer} [$options.transition=300]] Number of milliseconds for fading in the trigger images
* @param {boolean} [$options.fullscreen=Q.info.isAndroidStock && Q.info.isAndroid(1000)]] Whether the drawers should take up the whole screen
* @param {integer} [$options.foregroundZIndex=50] The z-index of the drawer in the foreground
* @param {integer} [$options.beforeSwap=new Q.Event()] Occurs right before drawer swap
* @param {integer} [$options.onSwap=new Q.Event()] Occurs right after drawer swap
*/
function Q_drawers_tool($options)
{
$result = '';
foreach ($options['drawers'] as $i => $html) {
$result .= Q_Html::div("drawer_{$i}", "Q_drawers_drawer Q_drawers_drawer_{$i}", $html);
}
unset($options['drawers']);
Q_Response::addScript('plugins/Q/js/tools/drawers.js');
Q_Response::addStylesheet('plugins/Q/css/drawers.css');
Q_Response::setToolOptions($options);
return $result;
}