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


PHP format::id方法代码示例

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


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

示例1: render

 /**
  * Render
  *
  * @param object $object
  * @return string
  */
 public static function render($object)
 {
     $input = $object->options['input'];
     if (empty($input['sort'])) {
         $i = 0;
         foreach ($object->orderby as $k => $v) {
             $input['sort'][$i]['column'] = $k;
             $input['sort'][$i]['order'] = $v;
             $i++;
         }
     }
     // generating form
     $table = ['header' => ['row_number' => ' ', 'column' => i18n(null, 'Column'), 'order' => i18n(null, 'Order')], 'options' => []];
     $order_model = new object_data_model_order();
     $columns = [];
     // we need to skip certain columns
     foreach ($object->columns as $k => $v) {
         if (!in_array($k, ['row_number', 'offset_number', 'action'])) {
             $v['name'] = i18n(null, $v['name']);
             $columns[$k] = $v;
         }
     }
     // full text search goes last
     if (!empty($object->filter['full_text_search'])) {
         $columns['full_text_search'] = ['name' => i18n(null, 'Text Search')];
     }
     // render 5 rows
     for ($i = 0; $i < 5; $i++) {
         if (empty($input['sort'][$i]['column'])) {
             $input['sort'][$i]['order'] = SORT_ASC;
         }
         $column = html::select(['id' => 'sort_' . $i . '_column', 'name' => 'sort[' . $i . '][column]', 'options' => $columns, 'value' => $input['sort'][$i]['column'] ?? null]);
         $order = html::select(['id' => 'sort_' . $i . '_order', 'name' => 'sort[' . $i . '][order]', 'no_choose' => true, 'options' => $order_model->options(['i18n' => true]), 'value' => $input['sort'][$i]['order'] ?? null]);
         $table['options'][$i] = ['row_number' => ['value' => format::id($i + 1) . '.', 'width' => '1%', 'align' => 'right'], 'column' => ['value' => $column, 'width' => '25%', 'class' => 'list_sort_name'], 'order' => ['value' => $order, 'width' => '30%']];
     }
     $body = html::table($table);
     $footer = html::button2(['name' => 'submit_sort', 'value' => i18n(null, 'Submit'), 'type' => 'primary', 'onclick' => "numbers.modal.hide('list_{$object->list_link}_sort'); \$('#list_{$object->list_link}_form').attr('target', '_self'); \$('#list_{$object->list_link}_form').attr('no_ajax', ''); return true;"]);
     return html::modal(['id' => "list_{$object->list_link}_sort", 'class' => 'large', 'title' => i18n(null, 'Sort'), 'body' => $body, 'footer' => $footer]);
 }
开发者ID:volodymyr-volynets,项目名称:frontend,代码行数:45,代码来源:sort.php

示例2: id

 function id()
 {
     global $tree;
     if (is_array($tree->tree)) {
         reset($tree->tree);
         while (list($key, $item) = each($tree->tree)) {
             if ($item['navigation'] && ($tree->hasOverlap($this->id, $item['id']) || $item['id'] == $this->id)) {
                 return htmlspecialchars(format::id($item['slug']), ENT_QUOTES);
             }
         }
     }
 }
开发者ID:KasaiDot,项目名称:Dashboard2,代码行数:12,代码来源:theme.library.php

示例3: get

 /**
  * Get translation
  *
  * @param string $i18n
  * @param string $text
  * @param array $options
  * @return string
  */
 public static function get($i18n, $text, $options = [])
 {
     // try to ge it by i18n
     $i18n = abs(intval($i18n));
     $translated = false;
     if (empty($i18n)) {
         // some texts we skip
         if (in_array($text . '', [' ', '&nbsp;', '-', '', '  '])) {
             $result = $text;
             $skip_translation_symbol = true;
             goto finish;
         }
         // integers and floats
         if (is_numeric($text)) {
             $result = format::id($text);
             $skip_translation_symbol = true;
             goto finish;
         }
     }
     // if we have i18n
     if (!empty($i18n) && isset(self::$data['ids'][$i18n])) {
         $result = self::$data['hashes'][self::$data['ids'][$i18n]];
         goto finish;
     }
     // we translate if language is not system
     if (self::$language_code != 'sys') {
         // continue logic
         $hash = $text;
         if (strlen($hash) > 40) {
             $hash = sha1($hash);
         }
         if (array_key_exists($hash, self::$data['hashes'])) {
             $result = self::$data['hashes'][$hash];
             $translated = true;
         } else {
             $result = $text;
             // put data into missing
             if (self::$language_code != 'eng') {
                 if (!isset(self::$missing[$result])) {
                     self::$missing[$result] = 1;
                 } else {
                     self::$missing[$result] += 1;
                 }
             }
         }
     } else {
         $result = $text;
     }
     finish:
     // append translation symbol for system language
     if (debug::$debug && application::get('flag.global.__content_type') == 'text/html' && empty($skip_translation_symbol) && empty($options['skip_translation_symbol']) && self::$language_code == 'sys') {
         $color = $translated ? 'blue' : 'red';
         $result .= '<span style="color: ' . $color . '; font-weight: bold:"><span style="display:none"> (</span>i<span style="display:none">)</span></span>';
     }
     return $result;
 }
开发者ID:volodymyr-volynets,项目名称:backend,代码行数:64,代码来源:base.php

示例4: render_container_type_details_rows

 /**
  * Details - render table
  *
  * @param array $rows
  * @param array $values
  * @param array $options
  */
 public function render_container_type_details_rows($rows, $values, $options = [])
 {
     $result = '';
     // empty_warning_message
     if (empty($options['details_new_rows']) && empty($values) && isset($options['details_empty_warning_message'])) {
         if (empty($options['details_empty_warning_message'])) {
             return html::message(['type' => 'warning', 'options' => [object_content_messages::no_rows_found]]);
         } else {
             return html::message(['type' => 'warning', 'options' => [$options['details_empty_warning_message']]]);
         }
     }
     // building table
     $table = ['header' => ['row_number' => '', 'row_data' => '', 'row_delete' => ''], 'options' => [], 'skip_header' => true];
     if (!empty($options['details_11'])) {
         $table['class'] = 'table grid_table_details_11';
         $table['header'] = ['row_data' => ''];
     }
     // header rows for table
     if ($options['details_rendering_type'] == 'table') {
         foreach ($rows as $k => $v) {
             array_key_sort($v['elements'], ['order' => SORT_ASC]);
             // group by
             $groupped = [];
             foreach ($v['elements'] as $k2 => $v2) {
                 $groupped[$v2['options']['label_name'] ?? ''][$k2] = $v2;
             }
             foreach ($groupped as $k2 => $v2) {
                 $first = current($v2);
                 $first_key = key($v2);
                 foreach ($v2 as $k3 => $v3) {
                     // hidden row
                     if ($k === $this::hidden && !application::get('flag.numbers.frontend.html.form.show_field_settings')) {
                         $v3['options']['row_class'] = ($v3['options']['row_class'] ?? '') . ' grid_row_hidden';
                     }
                     $data['options'][$k][$k2][$k3] = ['label' => $this->render_element_name($first), 'options' => $v3['options'], 'row_class' => $v3['options']['row_class'] ?? null];
                 }
             }
         }
         // add a row to a table
         $table['options']['__header'] = ['row_number' => ['value' => '&nbsp;', 'width' => '1%'], 'row_data' => ['value' => html::grid($data), 'width' => !empty($options['details_11']) ? '100%' : '98%'], 'row_delete' => ['value' => '&nbsp;', 'width' => '1%']];
     }
     // we must sort
     array_key_sort($rows, ['order' => SORT_ASC]);
     // generating rows
     $row_number = 1;
     // 1 to 1
     if (!empty($options['details_11'])) {
         $max_rows = 1;
         $processing_values = 1;
     } else {
         $max_rows = count($values) + ($options['details_new_rows'] ?? 0);
         $processing_values = !empty($values);
     }
     do {
         // we exit if there's no rows and if we have no values
         if ($row_number > $max_rows) {
             break;
         }
         // render
         $data = ['options' => []];
         // grab next element from an array
         if ($processing_values) {
             if (!empty($options['details_11'])) {
                 $k0 = null;
                 $v0 = $values;
             } else {
                 $k0 = key($values);
                 $v0 = current($values);
             }
         } else {
             $k0 = $row_number;
             $v0 = [];
         }
         $i0 = $row_number;
         // we need to preset default values
         if (!empty($options['details_parent_key'])) {
             $fields = $this->sort_fields_for_processing($this->detail_fields[$options['details_parent_key']]['subdetails'][$options['details_key']]['elements'], $this->detail_fields[$options['details_parent_key']]['subdetails'][$options['details_key']]['options']);
         } else {
             $fields = $this->sort_fields_for_processing($this->detail_fields[$options['details_key']]['elements'], $this->detail_fields[$options['details_key']]['options']);
         }
         // todo: handle changed field
         foreach ($fields as $k19 => $v19) {
             if (array_key_exists('default', $v19['options']) && !isset($v0[$k19])) {
                 $temp = $this->process_default_value($k19, $v19['options']['default'], $v0[$k19] ?? null, $v0, true);
             }
         }
         // looping though rows
         foreach ($rows as $k => $v) {
             // row_id
             if (empty($options['details_parent_key'])) {
                 $row_id = "form_{$this->form_link}_details_{$options['details_key']}_{$row_number}_row";
             } else {
                 $row_id = "form_{$this->form_link}_subdetails_{$options['details_parent_key']}_{$options['__parent_row_number']}_{$options['details_key']}_{$row_number}_row";
//.........这里部分代码省略.........
开发者ID:volodymyr-volynets,项目名称:frontend,代码行数:101,代码来源:base.php

示例5: render_data_default

 /**
  * Data default renderer
  *
  * @return string
  */
 private final function render_data_default()
 {
     $result = '';
     // if we have no rows we display a messsage
     if ($this->num_rows == 0) {
         return html::message(['type' => 'warning', 'options' => [i18n(null, object_content_messages::no_rows_found)]]);
     }
     $counter = 1;
     $table = ['header' => [], 'options' => []];
     // action flags
     $actions = [];
     if (object_controller::can('record_view')) {
         $actions['view'] = true;
     }
     // generate columns
     foreach ($this->columns as $k => $v) {
         // if we can not view we skip action column
         if (empty($actions) && $k == 'action') {
             continue;
         }
         $table['header'][$k] = ['value' => i18n(null, $v['name']), 'nowrap' => true, 'width' => $v['width'] ?? null];
     }
     // generate rows
     foreach ($this->rows as $k => $v) {
         // process all columns first
         $row = [];
         foreach ($this->columns as $k2 => $v2) {
             // if we can not view we skip action column
             if (empty($actions) && $k2 == 'action') {
                 continue;
             }
             $value = [];
             // create cell properties
             foreach (['width', 'align'] as $v3) {
                 if (isset($v2[$v3])) {
                     $value[$v3] = $v2[$v3];
                 }
             }
             // process rows
             if ($k2 == 'action') {
                 $value['value'] = [];
                 if (!empty($actions['view'])) {
                     $mvc = application::get('mvc');
                     $pk = extract_keys($this->model_object->pk, $v);
                     $url = $mvc['controller'] . '/_edit?' . http_build_query2($pk);
                     $value['value'][] = html::a(['value' => i18n(null, 'View'), 'href' => $url]);
                 }
                 $value['value'] = implode(' ', $value['value']);
             } else {
                 if ($k2 == 'row_number') {
                     $value['value'] = format::id($counter) . '.';
                 } else {
                     if ($k2 == 'offset_number') {
                         $value['value'] = format::id($this->offset + $counter) . '.';
                     } else {
                         if (!empty($v2['options_model'])) {
                             if (strpos($v2['options_model'], '::') === false) {
                                 $v2['options_model'] .= '::options';
                             }
                             $params = $v2['options_params'] ?? [];
                             if (!empty($v2['options_depends'])) {
                                 foreach ($v2['options_depends'] as $k0 => $v0) {
                                     $params[$k0] = $v[$v0];
                                 }
                             }
                             $crypt_object = new crypt();
                             $hash = $crypt_object->hash($v2['options_model'] . serialize($params));
                             if (!isset($this->cached_options[$hash])) {
                                 $method = factory::method($v2['options_model'], null, true);
                                 $this->cached_options[$hash] = call_user_func_array($method, [['where' => $params]]);
                             }
                             if (isset($this->cached_options[$hash][$v[$k2]])) {
                                 $value['value'] = $this->cached_options[$hash][$v[$k2]]['name'];
                             } else {
                                 $value['value'] = null;
                             }
                         } else {
                             if (!empty($v2['options']) && !is_array($v[$k2])) {
                                 if (isset($v2['options'][$v[$k2]])) {
                                     $value['value'] = $v2['options'][$v[$k2]]['name'];
                                 } else {
                                     $value['value'] = null;
                                 }
                             } else {
                                 if (isset($v[$k2])) {
                                     $value['value'] = $v[$k2];
                                 } else {
                                     $value['value'] = null;
                                 }
                             }
                         }
                     }
                 }
             }
             // put value into row
//.........这里部分代码省略.........
开发者ID:volodymyr-volynets,项目名称:frontend,代码行数:101,代码来源:base.php


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