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


PHP i18n::rtl方法代码示例

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


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

示例1: calendar

 /**
  * see html::calendar()
  */
 public static function calendar($options = [])
 {
     // include js & css files
     if (empty($options['readonly'])) {
         layout::add_js('/numbers/media_submodules/numbers_frontend_components_calendar_numbers_media_js_base.js');
         layout::add_css('/numbers/media_submodules/numbers_frontend_components_calendar_numbers_media_css_base.css');
     }
     // font awesome icons
     library::add('fontawesome');
     // widget parameters
     $type = $options['calendar_type'] ?? $options['type'] ?? 'date';
     $widget_options = ['id' => $options['id'], 'type' => $type, 'format' => $options['calendar_format'] ?? format::get_date_format($type), 'date_week_start_day' => $options['calendar_date_week_start_day'] ?? 1, 'date_disable_week_days' => $options['calendar_date_disable_week_days'] ?? null, 'master_id' => $options['calendar_master_id'] ?? null, 'slave_id' => $options['calendar_slave_id'] ?? null];
     $options['type'] = 'text';
     // determine input size
     $placeholder = format::get_date_placeholder($widget_options['format']);
     $options['size'] = strlen($placeholder);
     // set placeholder
     if (!empty($options['placeholder']) && $options['placeholder'] == 'format::get_date_placeholder') {
         $options['placeholder'] = $placeholder;
         $options['title'] = ($options['title'] ?? '') . ' (' . $placeholder . ')';
     }
     if (isset($options['calendar_icon']) && ($options['calendar_icon'] == 'left' || $options['calendar_icon'] == 'right')) {
         $position = $options['calendar_icon'];
         if (i18n::rtl()) {
             if ($position == 'left') {
                 $position = 'right';
             } else {
                 $position = 'left';
             }
         }
         $icon_type = $type == 'time' ? 'clock-o' : 'calendar';
         unset($options['calendar_icon']);
         if (empty($options['readonly'])) {
             $icon_onclick = 'numbers_calendar_var_' . $options['id'] . '.show();';
         } else {
             $icon_onclick = null;
         }
         $icon_value = html::span(['onclick' => $icon_onclick, 'class' => 'numbers_calendar_icon numbers_prevent_selection', 'value' => html::icon(['type' => $icon_type])]);
         $result = html::input_group(['value' => html::input($options), $position => $icon_value, 'dir' => 'ltr']);
         $div_id = $options['id'] . '_div_holder';
         $result .= html::div(['id' => $div_id, 'class' => 'numbers_calendar_div_holder']);
         $widget_options['holder_div_id'] = $div_id;
     } else {
         $result = html::input($options);
     }
     // we do not render a widget if readonly
     if (empty($options['readonly'])) {
         layout::onload('numbers_calendar(' . json_encode($widget_options) . ');');
     }
     return $result;
 }
开发者ID:volodymyr-volynets,项目名称:frontend,代码行数:54,代码来源:base.php

示例2: grid

 /**
  * @see html::grid()
  */
 public static function grid($options = [])
 {
     $rtl = i18n::rtl();
     $grid_columns = application::get('flag.numbers.framework.html.options.grid_columns') ?? 12;
     $rows = isset($options['options']) ? $options['options'] : [];
     unset($options['options']);
     $result = '';
     foreach ($rows as $k => $v) {
         // we need to determine field sizes
         $field_sizes = [];
         foreach ($v as $k2 => $v2) {
             foreach ($v2 as $k3 => $v3) {
                 $field_sizes[] = $v3['options']['percent'] ?? null;
             }
         }
         $field_new_sizes = html::percentage_to_grid_columns($field_sizes);
         // count number of fields
         $count_fields = count($v);
         //$count_class = html::number_to_word($count_fields);
         // find all row classes
         $row_class = '';
         foreach ($v as $k2 => $v2) {
             foreach ($v2 as $k3 => $v3) {
                 if (!empty($v3['row_class'])) {
                     $row_class .= ' ' . $v3['row_class'];
                 }
             }
         }
         $result .= '<div class="row' . $row_class . '">';
         // we need to determine if we have label in the row
         $flag_have_label = false;
         foreach ($v as $k2 => $v2) {
             foreach ($v2 as $k3 => $v3) {
                 if (($v3['label'] ?? '') . '' != '') {
                     $flag_have_label = true;
                 }
             }
         }
         // we need to fill up empty columns if rtl
         if ($rtl) {
             $index = 0;
             $current_grid_columns = 0;
             foreach ($v as $k2 => $v2) {
                 foreach ($v2 as $k3 => $v3) {
                     // if we are mannually set field sizes we skip
                     if (!empty($v3['options']['field_size'])) {
                         $current_grid_columns = 12;
                         break;
                     }
                     $current_grid_columns += $field_new_sizes['data'][$index];
                     $v[$k2][$k3]['options']['field_size'] = 'col-sm-' . $field_new_sizes['data'][$index];
                     // a must
                     $index++;
                 }
             }
             if ($current_grid_columns != $grid_columns) {
                 $v['__empty_column_fill__']['__empty_column_fill__'] = ['value' => ' '];
                 $field_new_sizes['data'][$index] = $grid_columns - $current_grid_columns;
             }
             $v = array_reverse($v, true);
         }
         // loop though each field and render it
         $index = 0;
         foreach ($v as $k2 => $v2) {
             $flag_first_field = true;
             if ($rtl) {
                 $v2 = array_reverse($v2, true);
             }
             foreach ($v2 as $k3 => $v3) {
                 $error_class = '';
                 if (!empty($v3['error']['type'])) {
                     if ($v3['error']['type'] == 'danger') {
                         $v3['error']['type'] = 'error';
                     }
                     $error_class = 'has-' . $v3['error']['type'];
                 }
                 // style
                 $style = '';
                 if (isset($v3['options']['style'])) {
                     $style = ' style="' . $v3['options']['style'] . '"';
                 }
                 $field_size = $v3['options']['field_size'] ?? 'col-sm-' . $field_new_sizes['data'][$index];
                 $class = $v3['class'] ?? '';
                 $result .= '<div class="' . $field_size . ' form-group ' . $error_class . ' ' . $class . '"' . $style . '>';
                 // label
                 if ($flag_first_field) {
                     if (($v3['label'] ?? '') . '' != '') {
                         $result .= $v3['label'];
                     } else {
                         if ($flag_have_label) {
                             $result .= '<label>&nbsp;</label>';
                         }
                     }
                     $flag_first_field = false;
                 } else {
                     if ($flag_have_label) {
                         $result .= '<label>&nbsp;</label>';
//.........这里部分代码省略.........
开发者ID:volodymyr-volynets,项目名称:frontend,代码行数:101,代码来源:base.php

示例3: input

 /**
  * @see html::input()
  */
 public static function input($options = [])
 {
     $options['type'] = $options['input_type'] ?? $options['type'] ?? 'text';
     if (!empty($options['checked'])) {
         $options['checked'] = 'checked';
     } else {
         unset($options['checked']);
     }
     if (!empty($options['multiple'])) {
         $options['multiple'] = 'multiple';
     } else {
         unset($options['multiple']);
     }
     if (!empty($options['readonly'])) {
         $options['readonly'] = 'readonly';
     } else {
         unset($options['readonly']);
     }
     if (!empty($options['disabled'])) {
         $options['disabled'] = 'disabled';
     } else {
         unset($options['disabled']);
     }
     if (!isset($options['autocomplete'])) {
         $options['autocomplete'] = 'off';
     }
     if (!empty($options['autofocus'])) {
         $options['autofocus'] = 'autofocus';
     } else {
         unset($options['autofocus']);
     }
     // rtl
     $rtl = i18n::rtl(false);
     if (i18n::rtl()) {
         if (isset($options['style'])) {
             $options['style'] = str_replace(['text-align:right;', 'text-align: right;'], 'text-align:left;', $options['style']);
         }
         // let browser decide the direction based on content
         $rtl = ' dir="auto" ';
     }
     // generate html
     $options['value'] = isset($options['value']) ? htmlspecialchars($options['value']) : '';
     return '<input ' . self::generate_attributes($options, 'input') . $rtl . ' />';
 }
开发者ID:volodymyr-volynets,项目名称:frontend,代码行数:47,代码来源:base.php


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