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


PHP Q_Html::attributes方法代码示例

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


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

示例1: Q_after_Q_tool_render

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();
}
开发者ID:dmitriz,项目名称:Platform,代码行数:47,代码来源:render.php

示例2: displayName

 /**
  * 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;
             }
         }
     }
 }
开发者ID:dmitriz,项目名称:Platform,代码行数:67,代码来源:Avatar.php


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