当前位置: 首页>>代码示例>>PHP>>正文


PHP Q_Html::smartTag方法代码示例

本文整理汇总了PHP中Q_Html::smartTag方法的典型用法代码示例。如果您正苦于以下问题:PHP Q_Html::smartTag方法的具体用法?PHP Q_Html::smartTag怎么用?PHP Q_Html::smartTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Q_Html的用法示例。


在下文中一共展示了Q_Html::smartTag方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Streams_form_tool

/**
 * Generates a form with inputs that modify various streams
 * @class Streams form
 * @constructor
 * @param {array} $options
 *  An associative array of parameters, containing:
 * @param {array} [$options.fields] an associative array of $id => $fieldinfo pairs,
 *   where $id is the id to append to the tool's id, to generate the input's id,
 *   and fieldinfo is either an associative array with the following fields,
 *   or a regular array consisting of fields in the following order:
 *     "publisherId" => Required. The id of the user publishing the stream
 *     "streamName" => Required. The name of the stream
 *     "field" => The stream field to edit, or "attribute:$attributeName" for an attribute.
 *     "input" => The type of the input (@see Q_Html::smartTag())
 *     "attributes" => Additional attributes for the input
 *     "options" => options for the input (if type is "select", "checkboxes" or "radios")
 *     "params" => array of extra parameters to Q_Html::smartTag
 */
function Streams_form_tool($options)
{
    $fields = Q::ifset($options, 'fields', array());
    $defaults = array('publisherId' => null, 'streamName' => null, 'field' => null, 'type' => 'text', 'attributes' => array(), 'value' => array(), 'options' => array(), 'params' => array());
    $sections = array();
    $hidden = array();
    $contents = '';
    foreach ($fields as $id => $field) {
        if (Q::isAssociative($field)) {
            $r = Q::take($field, $defaults);
        } else {
            $c = count($field);
            if ($c < 4) {
                throw new Q_Exception("Streams/form tool: field needs at least 4 values");
            }
            $r = array('publisherId' => $field[0], 'streamName' => $field[1], 'field' => $field[2], 'type' => $field[3], 'attributes' => isset($field[4]) ? $field[4] : array(), 'value' => isset($field[5]) ? $field[5] : '', 'options' => isset($field[6]) ? $field[6] : null, 'params' => isset($field[7]) ? $field[7] : null);
        }
        $r['attributes']['name'] = "input_{$id}";
        if (!isset($r['type'])) {
            var_dump($r['type']);
            exit;
        }
        $stream = Streams::fetchOne(null, $r['publisherId'], $r['streamName']);
        if ($stream) {
            if (substr($r['field'], 0, 10) === 'attribute:') {
                $attribute = trim(substr($r['field'], 10));
                $value = $stream->get($attribute, $r['value']);
            } else {
                $field = $r['field'];
                $value = $stream->{$field};
            }
        } else {
            $value = $r['value'];
        }
        $tag = Q_Html::smartTag($r['type'], $r['attributes'], $value, $r['options'], $r['params']);
        $class1 = 'publisherId_' . Q_Utils::normalize($r['publisherId']);
        $class2 = 'streamName_' . Q_Utils::normalize($r['streamName']);
        $contents .= "<span class='Q_before {$class1} {$class2}'></span>" . Q_Html::tag('span', array('data-publisherId' => $r['publisherId'], 'data-streamName' => $r['streamName'], 'data-field' => $r['field'], 'data-type' => $r['type'], 'class' => "{$class1} {$class2}"), $tag);
        $hidden[$id] = array(!!$stream, $r['publisherId'], $r['streamName'], $r['field']);
    }
    $contents .= Q_Html::hidden(array('inputs' => Q::json_encode($hidden)));
    return Q_Html::form('Streams/form', 'post', array(), $contents);
    //
    // $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;
}
开发者ID:dmitriz,项目名称:Platform,代码行数:67,代码来源:tool.php

示例2: array

	</div>
	<?php 
}
?>
	<div class="Shipping_panel">
		<h2>Shipments History</h2>
		<div class="Shipping_section" style="padding: 10px 20px;">
			<label for="shipping_state">Shipping State:</label>
			<?php 
echo Q_Html::smartTag('select', array('name' => 'shipping_state', 'id' => 'shipping_state', 'autocomplete' => 'off'), $defaultState, $shippingStates);
?>
		</div>
		<div class="Shipping_section" style="padding: 10px 20px;">
			<label for="filter_carrier">Carrier Filter:</label>
			<?php 
echo Q_Html::smartTag('select', array('name' => 'filter_carrier', 'id' => "filter_carrier", 'autocomplete' => 'off'), "", $shippingCarriers);
?>
		</div>
		<div class="Shipping_section" style="padding: 10px 20px;">
			<label for="shipping_state">Tracking Id Filter:</label>
			<input type="text" name="trackingIdFilter" />
		</div>
		<hr>
		<?php 
echo Q::tool("Streams/related", array("publisherId" => $env->communityId, "streamName" => $env->shipmentsStreamName, "relationType" => $defaultState, "editable" => false, "relatedOptions" => array("ascending" => "desc")), "history");
?>
		<?php 
//echo Q::tool("Shipping/history");
?>
	</div>
</div>
开发者ID:AndreyTepaykin,项目名称:Platform,代码行数:31,代码来源:history.php

示例3: Q_form_tool


//.........这里部分代码省略.........
 *    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;
}
开发者ID:dmitriz,项目名称:Platform,代码行数:101,代码来源:tool.php


注:本文中的Q_Html::smartTag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。