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


PHP highlightfast函数代码示例

本文整理汇总了PHP中highlightfast函数的典型用法代码示例。如果您正苦于以下问题:PHP highlightfast函数的具体用法?PHP highlightfast怎么用?PHP highlightfast使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: output_html

 /**
  * Returns XHTML field(s) as required by choices
  *
  * Relies on data being an array should data ever be another valid vartype with
  * acceptable value this may cause a warning/error
  * if (!is_array($data)) would fix the problem
  *
  * @todo Add vartype handling to ensure $data is an array
  *
  * @param array $data An array of checked values
  * @param string $query
  * @return string XHTML field
  */
 public function output_html($data, $query = '')
 {
     if (!$this->load_choices() or empty($this->choices)) {
         return '';
     }
     $default = $this->get_defaultsetting();
     if (is_null($default)) {
         $default = array();
     }
     if (is_null($data)) {
         $data = array();
     }
     $options = array();
     $defaults = array();
     foreach ($this->choices as $key => $description) {
         if (!empty($data[$key])) {
             $checked = 'checked="checked"';
         } else {
             $checked = '';
         }
         if (!empty($default[$key])) {
             $defaults[] = $description;
         }
         //            $options[] = '<input type="checkbox" id="'.$this->get_id().'_'.$key.'" name="'.$this->get_full_name().'['.$key.']" value="1" '.$checked.' />'
         //                .'<label for="'.$this->get_id().'_'.$key.'">'.highlightfast($query, $description).'</label>';
         $options[] = '<input type="checkbox" id="' . $this->get_id() . '_' . $key . '" name="' . $this->get_full_name() . '[' . $key . ']" value="1" ' . $checked . ' />' . '<label for="' . $this->get_id() . '_' . $key . '">' . $this->icons[$key] . highlightfast($query, $description) . '</label>';
     }
     if (is_null($default)) {
         $defaultinfo = NULL;
     } elseif (!empty($defaults)) {
         $defaultinfo = implode(', ', $defaults);
     } else {
         $defaultinfo = get_string('none');
     }
     $return = '<div class="form-multicheckbox">';
     $return .= '<input type="hidden" name="' . $this->get_full_name() . '[xxxxx]" value="1" />';
     // something must be submitted even if nothing selected
     if ($options) {
         $return .= '<ul>';
         foreach ($options as $option) {
             $return .= '<li>' . $option . '</li>';
         }
         $return .= '</ul>';
     }
     $return .= '</div>';
     return format_admin_setting($this, $this->visiblename, $return, $this->description, false, '', $defaultinfo, $query);
 }
开发者ID:edurenye,项目名称:sharing_cart,代码行数:60,代码来源:settingslib.php

示例2: output_html

    /**
     * Returns XHTML field(s) as required by choices
     *
     * Relies on data being an array should data ever be another valid vartype with
     * acceptable value this may cause a warning/error
     * if (!is_array($data)) would fix the problem
     *
     * @todo Add vartype handling to ensure $data is an array
     *
     * @param array $data An array of checked values
     * @param string $query
     * @return string XHTML field
     */
    public function output_html($data, $query='') {
        global $OUTPUT;

        if (!$this->load_choices() or empty($this->choices)) {
            return '';
        }

        $default = $this->get_defaultsetting();
        if (is_null($default)) {
            $default = array();
        }
        if (is_null($data)) {
            $data = array();
        }

        $context = (object) [
            'id' => $this->get_id(),
            'name' => $this->get_full_name(),
        ];

        $options = array();
        $defaults = array();
        foreach ($this->choices as $key => $description) {
            if (!empty($default[$key])) {
                $defaults[] = $description;
            }

            $options[] = [
                'key' => $key,
                'checked' => !empty($data[$key]),
                'label' => highlightfast($query, $description)
            ];
        }

        if (is_null($default)) {
            $defaultinfo = null;
        } else if (!empty($defaults)) {
            $defaultinfo = implode(', ', $defaults);
        } else {
            $defaultinfo = get_string('none');
        }

        $context->options = $options;
        $context->hasoptions = !empty($options);

        $element = $OUTPUT->render_from_template('core_admin/setting_configmulticheckbox', $context);

        return format_admin_setting($this, $this->visiblename, $element, $this->description, false, '', $defaultinfo, $query);

    }
开发者ID:EsdrasCaleb,项目名称:moodle,代码行数:63,代码来源:adminlib.php


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