Example #1
0
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);
}
Example #2
0
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);
}
Example #3
0
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();
}
Example #4
0
 static function helperIdPrefix($template, $context, $args, $source)
 {
     return Q_Html::getIdPrefix();
 }
Example #5
0
 /**
  * @method toolReplace
  * @static
  * @param {boolean} [$toReplaceWith=true] Defaults to true. Whether to cache the tool being rendered.
  */
 static function toolReplace($toRetain = true)
 {
     $idPrefix = Q_Html::getIdPrefix();
     self::$toolReplace[$idPrefix] = $toRetain;
 }
Example #6
0
<?php

$prefix = Q_Html::getIdPrefix();
echo Q_Html::form(Q_Request::baseUrl() . '/action.php/Streams/basic', 'post');
echo Q_Html::formInfo(Q_Dispatcher::uri());
?>
 
<table>
	<tr>
		<td class="Q_field_title">
			<label for="<?php 
echo $prefix;
?>
firstName">First Name</label>
			<?php 
if ($showAccess) {
    ?>
 
				<?php 
    echo Q::tool('Streams/access', array('readLevel' => Streams::my('Streams/user/firstName', 'readLevel'), 'streamName' => 'Streams/user/firstName', 'input_id' => Q_Html::id('firstName_readLevel')), 'firstName');
    ?>
 
				<input type="hidden" name="firstName_readLevel"
					id="<?php 
    echo Q_Html::id('firstName_readLevel');
    ?>
"
					value="<?php 
    echo Streams::my('Streams/user/firstName', 'readLevel');
    ?>
">