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>" : ''; }
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)); }
/** * 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); }
/** * 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; }
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)); } }
function Q_after_Q_tool_render($params, &$result) { $info = $params['info']; $extra = $params['extra']; if (!is_array($extra)) { $extra = array(); } $id_prefix = Q_Html::getIdPrefix(); $tool_ids = Q_Html::getToolIds(); $tag = Q::ifset($extra, 'tag', 'div'); if (empty($tag)) { Q_Html::popIdPrefix(); return; } $classes = ''; $data_options = ''; $count = count($info); foreach ($info as $name => $opt) { $classes = ($classes ? "{$classes} " : $classes) . implode('_', explode('/', $name)) . '_tool'; $options = Q_Response::getToolOptions($name); if (isset($options)) { $friendly_options = str_replace(array('"', '\\/'), array('"', '/'), Q_Html::text(Q::json_encode($options))); } else { $friendly_options = ''; } $normalized = Q_Utils::normalize($name, '-'); if (isset($options) or $count > 1) { $id = $tool_ids[$name]; $id_string = $count > 1 ? "{$id} " : ''; $data_options .= " data-{$normalized}='{$id_string}{$friendly_options}'"; } $names[] = $name; } if (isset($extra['classes'])) { $classes .= ' ' . $extra['classes']; } $attributes = isset($extra['attributes']) ? ' ' . Q_Html::attributes($extra['attributes']) : ''; $data_retain = !empty($extra['retain']) || Q_Response::shouldRetainTool($id_prefix) ? " data-Q-retain=''" : ''; $data_replace = !empty($extra['replace']) || Q_Response::shouldReplaceWithTool($id_prefix) ? " data-Q-replace=''" : ''; $names = $count === 1 ? ' ' . key($info) : 's ' . implode(" ", $names); $ajax = Q_Request::isAjax(); $result = "<{$tag} id='{$id_prefix}tool' " . "class='Q_tool {$classes}'{$data_options}{$data_retain}{$data_replace}{$attributes}>" . "{$result}</{$tag}>"; if (!Q_Request::isAjax()) { $result = "<!--\nbegin tool{$names}\n-->{$result}<!--\nend tool{$names} \n-->"; } Q_Html::popIdPrefix(); }
/** * This tool generates an inline editor, along with a form tag. * @class Q inplace * @constructor * @param {array} [$options] An associative array of parameters, containing: * @param {string} $options.fieldInput Required. HTML representing a text input, textarea, or select. * @param {string} $options.staticHtml Required. The static HTML to display when the input isn't showing. * @param {string} [$options.type='textarea'] The type of the input. Can be "textarea", "text" or "select" * @param {string} [$options.action=""] The uri or url to submit to * @param {string} [$options.method="put"] The method to use for submitting the form. * @param {boolean} [$options.editing] If true, then renders the inplace tool in editing mode. * @param {boolean} [$options.editOnClick=true] If true, then edit mode starts only if "Edit" button is clicked. * @param {boolean} [$options.selectOnEdit=true] If true, selects all the text when entering edit mode. * @param {string} [$options.placeholder] Text to show in the staticHtml or input field when the editor is empty * @param {array} [$options.hidden] An associative array of additional hidden fields to submit in the form * @param {integer} [$options.maxWidth] The maximum width for the Q/autogrow * @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. */ function Q_inplace_tool($options) { $action = ''; $method = 'put'; $fieldInput = ''; $staticHtml = ''; $type = 'textarea'; $editOnClick = true; $selectOnEdit = true; extract($options); if (isset($inplace)) { extract($inplace); } if (!isset($fieldInput)) { throw new Q_Exception_RequiredField(array('field' => 'fieldInput')); } $staticClass = $type === 'textarea' ? 'Q_inplace_tool_blockstatic' : 'Q_inplace_tool_static'; Q_Response::addScript('plugins/Q/js/tools/inplace.js'); Q_Response::addStylesheet('plugins/Q/css/inplace.css'); $formTag = Q_Html::form("{$action}", $method, array('class' => 'Q_inplace_tool_form')); $hiddenInputs = $options['hidden'] ? Q_Html::hidden($options['hidden']) : ''; $classes = !empty($editing) ? 'Q_editing Q_nocancel' : ''; $options = compact('editOnClick', 'selectOnEdit', 'showEditButtons', 'maxWidth', 'beforeSave', 'onSave', 'placeholder', 'type'); Q_Response::setToolOptions($options); $sh = $staticHtml ? $staticHtml : '<span class="Q_placeholder">' . Q_Html::text($placeholder) . '</span>'; return <<<EOT <div class='Q_inplace_tool_container {$classes} Q_inplace_{$type}' style="position: relative;"> \t<div class='Q_inplace_tool_editbuttons'> \t\t<button class='Q_inplace_tool_edit basic16 basic16_edit'>Edit</button> \t</div> \t<div class='{$staticClass}'>{$sh}</div> \t{$formTag} \t\t{$fieldInput} \t\t{$hiddenInputs} \t\t<div class='Q_inplace_tool_buttons'> \t\t\t<button class='Q_inplace_tool_cancel basic16 basic16_cancel'>Cancel</button> \t\t\t<button class='Q_inplace_tool_save basic16 basic16_save'>Save</button> \t\t</div> \t</form> </div> EOT; }
<p> This is just to let you know <?php echo Q_Html::text($user->displayName()); ?> , has started their subscription to <?php echo Q_Html::text($plan->title); ?> with <?php echo Q_Html::text($publisher->displayName()); ?> at <?php echo Q_Html::text("{$symbol}{$amount}"); ?> for <?php echo $months; ?> months. </p> <p> See you on <?php echo Q_Html::a($link, Q_Html::text($communityName)); ?> ! </p>
<div id="content"> <div class='Streams_stream_info_pane'> <?php if ($stream->icon) { ?> <div class='Streams_stream_icon'> <?php echo Q_Html::img($stream->iconUrl('80.png')); ?> </div> <?php } ?> <div class='Streams_stream_title'> <?php echo Q_Html::text($stream->title); ?> </div> <div class='Streams_stream_player'> <?php echo Q::tool('Streams/player', compact('stream')); ?> </div> </div> <div class='Streams_stream_activity_pane'> <div class='Streams_participants'> <?php echo Q::tool('Streams/participants', compact('stream')); ?> </div> <div class='Streams_stream_activity'>
/** * Takes some information out of an existing set of streams * @method take * @static * @param {array} $streams * @param {string} $name * @param {string} $readLevel * Test each stream for at least this read level. * If the test fails, return null in its stead. * @param {string|array} $field='content' * Optional. Defaults to "content". * Can be an array of fields, in which case the function returns an array. * @param {boolean} [$escape=false] * Defaults to false. If true, escapes the values as HTML * @return {mixed} * Returns the value of the field, or an array of values, depending on * whether $field is an array or a string */ static function take($streams, $name, $readLevel, $field = 'content', $escape = false) { if (!isset($streams[$name])) { return null; } $result = array(); $was_array = is_array($field); $arr = $was_array ? $field : array($field); foreach ($arr as $f) { if (!isset($streams[$name]->{$f})) { return null; } if (!$streams[$name]->testReadLevel($readLevel)) { return null; } $result[$f] = !$escape ? $streams[$name]->{$f} : Q_Html::text($streams[$name]->{$f}); } return $was_array ? $result : reset($result); }
<p> This is just to let you know <?php echo Q_Html::text($user->displayName()); ?> has been charged <?php Q_Html::text("{$symbol}{$amount}"); ?> for <?php echo Q_Html::text($description); ?> by <?php echo Q_Html::text($publisher->displayName()); ?> </p> <p> See all subscriptions for <?php echo Q_Html::a($link, Q_Html::text($publisher->displayName())); ?> </p>
/** * @method do_dump * @static * @private * @param {&mixed} $var * @param {string} $var_name=null * @param {string} $indent=null * @param {string} $reference=null * @param {boolean} $as_text=false */ private static function do_dump(&$var, $var_name = NULL, $indent = NULL, $reference = NULL, $as_text = false) { static $n = null; if (!isset($n)) { $n = Q_Config::get('Q', 'newline', "\n"); } $do_dump_indent = $as_text ? " " : "<span style='color:#eeeeee;'>|</span> "; $reference = $reference . $var_name; $keyvar = 'the_do_dump_recursion_protection_scheme'; $keyname = 'referenced_object_name'; $max_indent = self::$var_dump_max_levels; if (strlen($indent) >= strlen($do_dump_indent) * $max_indent) { echo $indent . $var_name . " (...){$n}"; return; } if (is_array($var) && isset($var[$keyvar])) { $real_var =& $var[$keyvar]; $real_name =& $var[$keyname]; $type = ucfirst(gettype($real_var)); if ($as_text) { echo "{$indent}{$var_name}<{$type}> = {$real_name}{$n}"; } else { echo "{$indent}{$var_name} <span style='color:#a2a2a2'>{$type}</span> = <span style='color:#e87800;'>&{$real_name}</span><br>"; } } else { $var = array($keyvar => $var, $keyname => $reference); $avar =& $var[$keyvar]; $type = ucfirst(gettype($avar)); if ($type == "String") { $type_color = "green"; } elseif ($type == "Integer") { $type_color = "red"; } elseif ($type == "Double") { $type_color = "#0099c5"; $type = "Float"; } elseif ($type == "Boolean") { $type_color = "#92008d"; } elseif ($type == "NULL") { $type_color = "black"; } else { $type_color = '#92008d'; } if (is_array($avar)) { $count = count($avar); if ($as_text) { echo "{$indent}" . ($var_name ? "{$var_name} => " : "") . "<{$type}>({$count}){$n}{$indent}({$n}"; } else { echo "{$indent}" . ($var_name ? "{$var_name} => " : "") . "<span style='color:#a2a2a2'>{$type} ({$count})</span><br>{$indent}(<br>"; } $keys = array_keys($avar); foreach ($keys as $name) { $value =& $avar[$name]; $displayName = is_string($name) ? "['" . addslashes($name) . "']" : "[{$name}]"; self::do_dump($value, $displayName, $indent . $do_dump_indent, $reference, $as_text); } if ($as_text) { echo "{$indent}){$n}"; } else { echo "{$indent})<br>"; } } elseif (is_object($avar)) { $class = get_class($avar); if ($as_text) { echo "{$indent}{$var_name}<{$type}>[{$class}]{$n}{$indent}({$n}"; } else { echo "{$indent}{$var_name} <span style='color:{$type_color}'>{$type} [{$class}]</span><br>{$indent}(<br>"; } if ($avar instanceof Exception) { $code = $avar->getCode(); $message = addslashes($avar->getMessage()); echo "{$indent}{$do_dump_indent}" . "code: {$code}, message: \"{$message}\""; if ($avar instanceof Q_Exception) { echo " inputFields: " . implode(', ', $avar->inputFields()); } echo $as_text ? $n : "<br />"; } if (class_exists('Q_Tree') and $avar instanceof Q_Tree) { $getall = $avar->getAll(); self::do_dump($getall, "", $indent . $do_dump_indent, $reference, $as_text); } else { if ($avar instanceof Q_Uri) { $arr = $avar->toArray(); self::do_dump($arr, 'fields', $indent . $do_dump_indent, $reference, $as_text); self::do_dump($route_pattern, 'route_pattern', $indent . $do_dump_indent, $reference, $as_text); } } if ($avar instanceof Db_Row) { foreach ($avar as $name => $value) { $modified = $avar->wasModified($name) ? "<span style='color:blue'>*</span>:" : ''; self::do_dump($value, "{$name}{$modified}", $indent . $do_dump_indent, $reference, $as_text); } } else { foreach ($avar as $name => $value) { self::do_dump($value, "{$name}", $indent . $do_dump_indent, $reference, $as_text); } } if ($as_text) { echo "{$indent}){$n}"; } else { echo "{$indent})<br>"; } } elseif (is_int($avar)) { $avar_len = strlen((string) $avar); if ($as_text) { echo sprintf("{$indent}{$var_name} = <{$type}(%d)>{$avar}{$n}", $avar_len); } else { echo sprintf("{$indent}{$var_name} = <span style='color:#a2a2a2'>{$type}(%d)</span>" . " <span style='color:{$type_color}'>{$avar}</span><br>", $avar_len); } } elseif (is_string($avar)) { $avar_len = strlen($avar); if ($as_text) { echo sprintf("{$indent}{$var_name} = <{$type}(%d)> ", $avar_len), $avar, "{$n}"; } else { echo sprintf("{$indent}{$var_name} = <span style='color:#a2a2a2'>{$type}(%d)</span>", $avar_len) . " <span style='color:{$type_color}'>" . Q_Html::text($avar) . "</span><br>"; } } elseif (is_float($avar)) { $avar_len = strlen((string) $avar); if ($as_text) { echo sprintf("{$indent}{$var_name} = <{$type}(%d)>{$avar}{$n}", $avar_len); } else { echo sprintf("{$indent}{$var_name} = <span style='color:#a2a2a2'>{$type}(%d)</span>" . " <span style='color:{$type_color}'>{$avar}</span><br>", $avar_len); } } elseif (is_bool($avar)) { $v = $avar == 1 ? "TRUE" : "FALSE"; if ($as_text) { echo "{$indent}{$var_name} = <{$type}>{$v}{$n}"; } else { echo "{$indent}{$var_name} = <span style='color:#a2a2a2'>{$type}</span>" . " <span style='color:{$type_color}'>{$v}</span><br>"; } } elseif (is_null($avar)) { if ($as_text) { echo "{$indent}{$var_name} = NULL{$n}"; } else { echo "{$indent}{$var_name} = " . " <span style='color:{$type_color}'>NULL</span><br>"; } } else { $avar_len = strlen((string) $avar); if ($as_text) { echo sprintf("{$indent}{$var_name} = <{$type}(%d)>{$avar}{$n}", $avar_len); } else { echo sprintf("{$indent}{$var_name} = <span style='color:#a2a2a2'>{$type}(%d)</span>", $avar_len) . " <span style='color:{$type_color}'>" . gettype($avar) . "</span><br>"; } } $var = $var[$keyvar]; } }
/** * This tool is meant to be wrapped in a <form> tag * @param {array} $options An associative array of parameters, containing: * @param {array} $options.fields an associative array of fieldname => fieldinfo pairs, * where fieldinfo contains the following: * "type" => the type of the field (@see Q_Html::smartTag()) * "attributes" => additional attributes for the field input * "value" => the initial value of the field input * "options" => options for the field input (if type is "select", "checkboxes" or "radios") * "message" => initial message, if any to put in the field's message space * "label" => the label for the field * "extra" => if set, this is html to replace the first cell, displacing the label * "placeholder" => if set, this is the placeholder text for the input * "fillFromRequest" => Defaults to true. * If true, uses $_REQUEST to fill any fields with same name. * Currently doesn't work for names which specify arrays, such as a[b]. * @param {string} [$options.onSubmit] Optional. Name of the javascript function or url to pass to Q.handle on submit * @param {string} [$options.onResponse] Name of the javascript function or url to pass to Q.handle on response * @param {string} [$options.onSuccess] Name of javascript function or url to pass to Q.handle on success * @param {string} [$options.loader] Optional. Name of a javascript function which takes (action, method, params, slots, callback) as arguments. * It should call the callback and pass it an object with the response info. Can be used to implement caching, etc. * instead of the default HTTP request. * If "loader" is Q.getter and request should be done bypasing cache, assign true to .ignoreCache property of the tool * @param {array|string} [$options.slotsToRequest] Optional. A string or array of slot names to request in response. Should include "form". * @param {array|string} [$options.contentElements] Optional. Array of $slotName => $cssSelector pairs for child element of the form to fill with HTML returned from the slot. */ function Q_form_tool($options) { if (empty($options['fields'])) { $options['fields'] = array(); } if (!array_key_exists('fillFromRequest', $options)) { $options['fillFromRequest'] = true; } if (empty($options['contentElements'])) { $options['contentElements'] = array(); } $field_defaults = array('type' => 'text', 'attributes' => array(), 'value' => null, 'options' => array(), 'message' => '', 'placeholder' => null); $tr_array = array(); $messages_td = false; $colspan = ''; foreach ($options['fields'] as $name => $field) { if (isset($field['message'])) { $messages_td = true; $colspan = "colspan='2'"; } } foreach ($options['fields'] as $name => $field) { if (!is_array($field)) { $name2 = '"' . addslashes($name) . '"'; throw new Q_Exception_WrongType(array('field' => "\$options[{$name2}]", 'type' => 'array')); } $field2 = array_merge($field_defaults, $field); $type = $field2['type']; if ($type === 'hidden') { continue; } $attributes = array('name' => $name, 'id' => $name); $value = $field2['value']; $o = $field2['options']; $message = $field2['message']; if (!empty($options['fillFromRequest']) and !in_array($type, array('button', 'submit'))) { if (isset($_REQUEST[$name])) { $value = $_REQUEST[$name]; } else { if ($type === 'static' or $type === 'date') { $parts = array($name . '_hour' => 0, $name . '_minute' => 0, $name . '_second' => 0, $name . '_month' => date('m'), $name . '_day' => date('d'), $name . '_year' => date('Y')); $provided = Q::ifset($_REQUEST, array_keys($parts), null); if (isset($provided)) { $mktime = Q::take($_REQUEST, $parts); $value = call_user_func_array('mktime', $mktime); } } } } if (isset($field2['placeholder'])) { $attributes['placeholder'] = $field2['placeholder']; } if ($field2['attributes']) { $attributes = array_merge($attributes, $field2['attributes']); } if (ctype_alnum($type)) { if (isset($attributes['class'])) { if (is_array($attributes['class'])) { foreach ($attributes['class'] as $k => $v) { $attributes['class'][$k] .= " {$type}"; } } else { $attributes['class'] .= " {$type}"; } } else { $attributes['class'] = " {$type}"; } } $label = isset($field['label']) ? $field['label'] : Q_Html::text($name); $label = Q_Html::tag('label', array('for' => $attributes['id']), $label); $name_text = Q_Html::text($name); $extra = isset($field['extra']) ? $field['extra'] : null; switch ($type) { case 'textarea': $tr_rest = "<td class='Q_form_fieldinput' data-fieldname=\"{$name_text}\" {$colspan}>" . ($extra ? "<div class='Q_form_label'>{$label}</div>" : '') . Q_Html::smartTag($type, $attributes, $value, $o) . "</td></tr><tr><td class='Q_form_placeholder'>" . "</td><td class='Q_form_undermessage Q_form_textarea_undermessage' {$colspan}>" . "<div class='Q_form_undermessagebubble'>{$message}</div></td>"; break; default: $tr_rest = "<td class='Q_form_fieldinput' data-fieldname=\"{$name_text}\">" . ($extra ? "<div class='Q_form_label'>{$label}</div>" : '') . Q_Html::smartTag($type, $attributes, $value, $o) . "</td>" . ($messages_td ? "<td class='Q_form_fieldmessage Q_form_{$type}_message'>{$message}</td>" : '') . "</tr><tr><td class='Q_form_placeholder'>" . "</td><td class='Q_form_undermessage Q_form_{$type}_undermessage' {$colspan}>" . "<div class='Q_form_undermessagebubble'></div></td>"; break; } $leftside = $extra ? $extra : $label; $tr_array[] = "<tr><td class='Q_form_fieldname'>{$leftside}</td>{$tr_rest}</tr>"; } $result = "<table class='Q_form_tool_table'>\n" . implode("\n\t", $tr_array) . "\n</table>"; foreach ($options['fields'] as $name => $field) { if (isset($field['type']) and $field['type'] === 'hidden') { $result .= Q_Html::hidden($field['value'], $name); } } $fields = array('onSubmit', 'onResponse', 'onSuccess', 'slotsToRequest', 'loader', 'contentElements'); Q_Response::setToolOptions(Q::take($options, $fields)); Q_Response::addScript('plugins/Q/js/tools/form.js'); Q_Response::addStylesheet('plugins/Q/css/form.css'); return $result; }
function Q_exception_native($params) { extract($params); /** * @var Exception $exception */ if ($is_ajax = Q_Request::isAjax()) { $json = @Q::json_encode(array('errors' => Q_Exception::toArray(array($exception)))); $callback = Q_Request::callback(); switch (strtolower($is_ajax)) { case 'iframe': // Render an HTML layout for ajax if (!Q_Response::$batch) { header("Content-type: text/html"); } echo <<<EOT <!doctype html><html lang=en> <head><meta charset=utf-8><title>Q Result</title></head> <body> <script type="text/javascript"> window.result = function () { return {$json} }; </script> </body> </html> EOT; break; case 'json': // Render a JSON layout for ajax // Render a JSON layout for ajax default: header("Content-type: " . ($callback ? "application/javascript" : "application/json")); echo $callback ? "{$callback}({$json})" : $json; } } else { if (Q::textMode()) { echo Q_Exception::coloredString($exception); exit; } $message = $exception->getMessage(); $file = $exception->getFile(); $line = $exception->getLine(); if (is_callable(array($exception, 'getTraceAsStringEx'))) { $trace_string = $exception->getTraceAsStringEx(); } else { $trace_string = $exception->getTraceAsString(); } if ($exception instanceof Q_Exception_PhpError or !empty($exception->messageIsHtml)) { // do not sanitize $message } else { $message = Q_Html::text($message); } $content = "<h1 class='exception_message'>{$message}</h1>"; if (Q_Config::get('Q', 'exception', 'showFileAndLine', true)) { $content .= "<h3 class='exception_fileAndLine'>in {$file} ({$line})</h3>"; } if (Q_Config::get('Q', 'exception', 'showTrace', true)) { $content .= "<pre class='exception_trace'>{$trace_string}</pre>"; } $content .= str_repeat(' ', 512); // because of chrome $title = "Exception occurred"; $dashboard = ""; echo Q::view('Q/layout/html.php', compact('content', 'dashboard', 'title')); } $app = Q_Config::get('Q', 'app', null); $colored = Q_Exception::coloredString($exception); Q::log("{$app}: Exception in " . ceil(Q::milliseconds()) . "ms:\n\n{$colored}\n", null, true, array('maxLength' => 10000)); }
<p> Hey <?php echo Q_Html::text($user->displayName(array('short' => true))); ?> , this is just a quick confirmation that you've successfully paid <?php Q_Html::text("{$symbol}{$amount}"); ?> to <?php echo Q_Html::a(Q_Request::baseUrl(), Q_Html::text($publisher->displayName())); ?> for <?php echo Q_Html::text($description); ?> . </p>
<p> Greetings from <?php echo Q_Html::text($communityName); ?> . </p> <p> Is this really your email address, <?php echo Q_Html::text($user->displayName()); ?> ? If so, click <?php echo Q_Html::a('Users/activate?code=' . urlencode($email->activationCode) . ' emailAddress=' . urlencode($email->address), 'here'); ?> to attach it to your account. </p> <p> See you on <a href="<?php echo Q_Request::baseUrl(); ?> "><?php echo Q_Html::text($communityName); ?> </a>! </p>
?> <input type="hidden" name="p" value="1"> <?php } ?> </form> </div> </div> <div class="Q_extra_pane"> <h2>Suggestions:</h2> <ul id='suggestions'> <?php foreach ($suggestions as $s) { ?> <li class="Users_fromServer"><?php echo Q_Html::text($s); ?> </li> <?php } ?> </ul> </div> <?php } } elseif (Users::loggedInUser()) { ?> <h1 class='Q_big_message'>If you feel something went wrong, <button id='activate_setIdentifier'>try again</button></h1> <?php } else { ?>
</div> </div> <div class='section Overlay_compressed'> <div class="margin-fixer"> </div> <h1 id="slogan"><div>Step 2. Select a picture to overlay</div></h1> <div class="overlays"> <select id="countries"> <?php foreach ($countries as $src => $title) { ?> <option value="<?php echo $src; ?> "><?php echo Q_Html::text($title); ?> </option> <?php } ?> </select> <div id="preview"> <?php echo Q_Html::img('', 'background', array('id' => 'background', 'crossorigin' => 'anonymous')); ?> <?php echo Q_Html::img($firstCountrySrc, 'foreground', array('id' => 'foreground')); ?> </div> </div>
<div id="widget"> <div class="Broadcast_initiate"> <button class="Broadcast_login Q_clickable"> <?php echo Q_Html::text($button); ?> </button> </div> <div class="Broadcast_manage" style="display: none"> <div class="Broadcast_explanation"> <?php echo Q_Html::text($explanation); ?> </div> <input type="checkbox" checked="checked" id="Broadcast_agreement_main"> <label for="Broadcast_agreement_main"> <?php echo Q_Html::text($checkbox); ?> </label> </div> </div>
<div id="Users_authorize_what"> <div class="Users_authorize_community"> In the <?php echo Q_Html::text(Users::communityName()); ?> community, </div> <?php foreach ($scope as $s) { ?> <div class="Users_authorize_scope"> <?php echo Q_Html::text($scopes[$s]); ?> </div> <?php } ?> </div> </div> </div> <div id="Users_authorize_act" class="Q_big_prompt"> <?php if ($user) { ?> <form action="" method="post"> <?php
?> <?php echo Q::tool('Q/form', array('fields' => array('passphrase' => array('label' => 'Enter your passphrase:', 'extra' => Q_Html::img($thumbnail_url, 'icon', array('title' => "You can change this later")), 'type' => 'password'), 'submit' => array('type' => 'submit_buttons', 'options' => array('join' => 'Join the chat'), 'label' => '')))); ?> <?php echo Q_Html::script("\n\t\t\t\t\t\t\$('#Q_form_passphrase').focus();\n\t\t\t\t\t"); ?> </form> </div> <?php } else { ?> <h2 class='notice' style='text-align: center'> Before you can log in, you must set a pass phrase by clicking the link in the message we sent to <?php echo Q_Html::text($address); ?> </h2> <div style='text-align: center' class='Q_big_prompt`'> <?php echo Q_Html::form(Q_Request::baseUrl() . '/action.php/Users/resend'); ?> <?php echo Q_Html::formInfo(Q_Request::url()); ?> <?php echo Q_Html::hidden(array('emailAddress' => $user->emailAddress)); ?> <button type="submit" class="Users_login_start Q_main_button">Re-send activation message</button> </form> </div>
/** * Calculate diplay name from avatar * @method displayName * @param {array} $options=array() * Associative array of options, which can include:<br/> * @param {boolean} [$options.short] Show one part of the name only * @param {boolean} [$options.show] The parts of the name to show. Can have the letters "f", "l", "u" in any order. * @param {boolean} [$options.html] If true, encloses the first name, last name, username in span tags. If an array, then it will be used as the attributes of the html. * @param {boolean} [$options.escape] If true, does HTML escaping of the retrieved fields * @param {string} [$fallback] What to return if there is no info to get displayName from. * @return {string|null} */ function displayName($options = array(), $fallback = null) { $fn = $this->firstName; $ln = $this->lastName; $u = $this->username; if (!empty($options['escape']) or !empty($options['html'])) { $fn = Q_Html::text($fn); $ln = Q_Html::text($ln); $u = Q_Html::text($u); } if (!empty($options['html'])) { $attributes = is_array($options['html']) ? $options['html'] : array(); $class = isset($attributes['class']) ? ' ' . $attributes['class'] : ''; $attributes['class'] = "Streams_firstName{$class}"; $attr = Q_Html::attributes($attributes); $fn2 = "<span {$attr}>{$fn}</span>"; $attributes['class'] = "Streams_lastName{$class}"; $attr = Q_Html::attributes($attributes); $ln2 = "<span {$attr}>{$ln}</span>"; $attributes['class'] = "Streams_username{$class}"; $attr = Q_Html::attributes($attributes); $u2 = "<span {$attr}>{$u}</span>"; $f2 = "<span {$attr}>{$fallback}</span>"; } else { $fn2 = $fn; $ln2 = $ln; $u2 = $u; $f2 = $fallback; } if (!empty($options['short'])) { return $fn ? $fn2 : ($u ? $u2 : $f2); } // $u = $u ? "\"$username\"" : ''; if (!empty($options['show'])) { $show = str_split($options['show']); $parts = array(); foreach ($show as $s) { $parts[] = $s == 'f' ? $fn2 : ($s == 'l' ? $ln2 : $u2); } return implode(' ', $parts); } if ($fn and $ln) { return "{$fn2} {$ln2}"; } else { if ($fn and !$ln) { return $u ? "{$fn2} {$u2}" : $fn2; } else { if (!$fn and $ln) { return $u ? "{$u2} {$ln2}" : $ln2; } else { return $u ? $u2 : $f2; } } } }
if (Q_Request::platform() == 'android') { ?> , target-densitydpi=medium-dpi<?php } ?> " /> <meta name="mobile-web-app-capable" content="yes" /> <link rel="manifest" href="<?php echo Q_Html::themedUrl('manifest.json'); ?> "> <meta name="theme-color" content="#f8f8f8"> <meta name="apple-mobile-web-app-status-bar-style" content="translucent" /> <meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-title" content="<?php echo Q_Html::text(Users::communityName()); ?> "> <meta name="mobile-web-app-capable" content="yes"> <?php if (Q_Request::platform() !== 'android') { ?> <link rel="apple-touch-icon-precomposed" sizes="76x76" href="<?php echo Q_Html::themedUrl('img/icon/76.png'); ?> " /> <link rel="apple-touch-icon-precomposed" sizes="120x120" href="<?php echo Q_Html::themedUrl('img/icon/120.png'); ?> " />
function Overlay_greeting_tool($options) { $defaults = array('greeting' => 'Default greeting'); extract(array_merge($defaults, $options)); return '<h1 class="Overlay_greeting_tool tool">' . Q_Html::text($greeting) . '</h1>'; }
<p> Thanks for visiting <?php echo Q_Html::text($communityName); ?> , <?php echo Q_Html::text($user->displayName()); ?> . </p> <p> You are receiving this email because someone entered your email address and clicked "forgot passphrase". If it wasn't you, simply ignore this message. To reset your passphrase, click <?php echo Q_Html::a($link, 'here'); ?> . </p> <p> See you on <a href="<?php echo Q_Request::baseUrl(); ?> "><?php echo $communityName; ?> </a>! </p> <script type="application/ld+json">
/** * Returns the string containing all the html attributes * @method htmlAttributes * @static * @return {string} */ static function htmlAttributes() { $touchscreen = Q_Request::isTouchscreen() ? 'Q_touchscreen' : 'Q_notTouchscreen'; $mobile = Q_Request::isMobile() ? 'Q_mobile' : 'Q_notMobile'; $cordova = Q_Request::isCordova() ? 'Q_cordova' : 'Q_notCordova'; $platform = 'Q_' . Q_Request::platform(); $ie = Q_Request::isIE() ? 'Q_ie' : 'Q_notIE'; $ie8 = Q_Request::isIE(0, 8) ? 'Q_ie8OrBelow' : 'Q_notIE8OrBelow'; $uri = Q_Dispatcher::uri(); $classes = "{$uri->module} {$uri->module}_{$uri->action}"; foreach (self::$htmlCssClasses as $k => $v) { $classes .= Q_Html::text(" {$k}"); } $language = self::language(); return 'lang="' . $language . '" ' . 'prefix="og: http://ogp.me/ns# object: http://ogp.me/ns/object#" ' . "class='{$touchscreen} {$mobile} {$cordova} {$platform} {$ie} {$ie8} {$classes}'"; }
<div class='Streams_stream_icon'> <?php echo Q_Html::img("plugins/Streams/img/icons/{$stream->icon}/80.png"); ?> </div> <?php } ?> <div class='Streams_stream_title'> <?php echo Q_Html::text($stream->title); ?> </div> <div class='Streams_stream_content'> <?php echo Q_Html::text($stream->content); ?> </div> <div><?php echo count($agreed_users); ?> people opted in so far</div> <table class='Streams_participant'> <?php foreach ($agreed_users as $u) { ?> <tr> <td><fb:profile-pic size="square" uid="<?php echo $u->fb_uid; ?> "></fb:profile-pic></td>