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


PHP Q::t方法代码示例

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


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

示例1: text

 /**
  * Escapes a string, converting all HTML entities
  * into plain text equivalents.
  * @method text
  * @static
  * @param {string} $content The string to escape
  * @param {string} [$convert=array()] An array of additional characters to convert. Can include "\n" and " ".
  * @param {string} [$unconvert=array()] An array of from => to pairs to unconvert back.
  * @return {string}
  */
 static function text($content, $convert = array(), $unconvert = array())
 {
     if (!is_array($convert)) {
         $convert = array();
     }
     $result = htmlentities(Q::t($content), ENT_QUOTES, 'UTF-8');
     if ($convert or $unconvert) {
         $conversions = array("\n" => "<br>", " " => "&nbsp;");
         foreach ($convert as $c) {
             $convert_to[] = $conversions[$c];
         }
         foreach ($unconvert as $from => $to) {
             $convert[] = $from;
             $convert_to[] = $to;
         }
         $result = str_replace($convert, $convert_to, $result);
     }
     return $result;
 }
开发者ID:AndreyTepaykin,项目名称:Platform,代码行数:29,代码来源:Html.php

示例2: date

 /**
  * Renders a date selector
  * @method date
  * @static
  * @param {string} $name The name of the input
  * @param {string} [$value=null] You can put a date here, as a string
  * @param {array} [$options=null] Options include the following:
  *
  * * "year_from" => the first year in the selector
  * * "year_to" => the last year in the selector
  *
  * @param {array} [$attributes=array()] An array of additional attributes to render. Consists of name => value pairs.
  * @return {string} The generated markup
  */
 static function date($name, $value = null, $options = null, $attributes = array())
 {
     if (empty($value)) {
         $value = null;
     }
     $id = isset($attributes['id']) ? $attributes['id'] : '';
     $year_from = isset($options['year_from']) ? $options['year_from'] : 1900;
     $year_to = isset($options['year_to']) ? $options['year_to'] : date('Y');
     for ($i = $year_to; $i >= $year_from; --$i) {
         $years[$i] = (string) $i;
     }
     $months = array("01" => 'January', "02" => 'February', "03" => 'March', "04" => 'April', "05" => 'May', "06" => 'June', "07" => 'July', "08" => 'August', "09" => 'September', "10" => 'October', "11" => 'November', "12" => 'December');
     $days = array();
     for ($i = 1; $i <= 31; ++$i) {
         $days[sprintf("%02d", $i)] = (string) $i;
     }
     if (!isset($value)) {
         $year = $month = $day = null;
     } else {
         $v = is_numeric($value) ? $value : strtotime($value);
         $dp = getdate($v);
         $year = isset($dp['year']) ? sprintf("%02d", $dp['year']) : null;
         $month = isset($dp['mon']) ? sprintf("%02d", $dp['mon']) : null;
         $day = isset($dp['mday']) ? sprintf("%02d", $dp['mday']) : null;
     }
     $attributes['name'] = $name . '_year';
     if ($id) {
         $attributes['id'] = $id . '_year';
     }
     $year_select = self::tag('select', $attributes) . self::options($years, $id, $year, Q::t('year')) . "</select>";
     $attributes['name'] = $name . '_month';
     if ($id) {
         $attributes['id'] = $id . '_month';
     }
     $month_select = self::tag('select', $attributes) . self::options($months, $id, $month, Q::t('month')) . "</select>";
     $attributes['name'] = $name . '_day';
     if ($id) {
         $attributes['id'] = $id . '_day';
     }
     $day_select = self::tag('select', $attributes) . self::options($days, $id, $day, Q::t('day')) . "</select>";
     $language = Q::ifset($_SERVER, 'HTTP_ACCEPT_LANGUAGE', 'en-US');
     $mdy_countries = array('en-us', 'en-bz');
     if (in_array(strtolower(substr($language, 0, 5)), $mdy_countries) !== false) {
         return "{$month_select}{$day_select}{$year_select}";
     } else {
         $ymd_countries = array('ch', 'ko', 'hu', 'fa', 'ja', 'lt', 'mn');
         if (in_array(strtolower(substr($language, 0, 2)), $ymd_countries) !== false) {
             return "{$year_select}{$day_select}{$month_select}";
         } else {
             return "{$day_select}{$month_select}{$year_select}";
         }
     }
 }
开发者ID:dmitriz,项目名称:Platform,代码行数:67,代码来源:Html.php


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