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


PHP _stringify_attributes函数代码示例

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


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

示例1: img

/**
 * Image (REPLACES ORIGINAL)
 *
 * Generates an <img /> element
 *
 * @param	mixed
 * @param	bool
 * @param	mixed
 * @return	string
 */
function img($src = '', $index_page = FALSE, $attributes = '')
{
    if (!is_array($src)) {
        $src = array('src' => $src);
    }
    // If there is no alt attribute defined, set it to an empty string
    if (!isset($src['alt'])) {
        $src['alt'] = '';
    }
    $img = '<img';
    foreach ($src as $k => $v) {
        if ($k === 'src' && !preg_match('#^([a-z]+:)?//#i', $v)) {
            if ($index_page === TRUE) {
                $img .= ' src="' . get_instance()->config->site_url($v) . '"';
            } else {
                // prefix with assets/images/
                if (!preg_match('/^assets\\/images/', $v)) {
                    $v = 'assets/images/' . $v;
                }
                $img .= ' src="' . get_instance()->config->slash_item('base_url') . $v . '"';
            }
        } else {
            $img .= ' ' . $k . '="' . $v . '"';
        }
    }
    return $img . _stringify_attributes($attributes) . ' />';
}
开发者ID:velrino,项目名称:codeigniter,代码行数:37,代码来源:MY_html_helper.php

示例2: lang

 /**
  * Lang
  *
  * Fetches a language variable and optionally outputs a form label
  *
  * @param	string	$line		The language line
  * @param	string	$for		The "for" value (id of the form element)
  * @param	array	$attributes	Any additional HTML attributes
  * @return	string
  */
 function lang($line, $for = '', $attributes = array())
 {
     $line = get_instance()->lang->line($line);
     if ($for !== '') {
         $line = '<label for="' . $for . '"' . _stringify_attributes($attributes) . '>' . $line . '</label>';
     }
     return $line;
 }
开发者ID:SaiAshirwadInformatia,项目名称:TaskTracker,代码行数:18,代码来源:language_helper.php

示例3: test_stringify_js_attributes

 public function test_stringify_js_attributes()
 {
     $this->assertEquals('width=800,height=600', _stringify_attributes(array('width' => '800', 'height' => '600'), TRUE));
     $atts = new Stdclass();
     $atts->width = 800;
     $atts->height = 600;
     $this->assertEquals('width=800,height=600', _stringify_attributes($atts, TRUE));
 }
开发者ID:rishikeshwalawalkar,项目名称:GetARide,代码行数:8,代码来源:Common_test.php

示例4: countries_menu

 /**
  * Generates a html select with all countries
  *
  * @access 	public
  * @param 	string
  * @param 	string
  * @param 	string
  * @param 	mixed
  * @return 	string
  */
 function countries_menu($default = 'DZ', $class = '', $name = 'countries', $attributes = '')
 {
     $CI =& get_instance();
     $default or $default = 'DZ';
     $menu = '<select name="' . $name . '"';
     if ($class !== '') {
         $menu .= ' class="' . $class . '"';
     }
     $menu .= _stringify_attributes($attributes) . ">\n";
     //foreach (timezones() as $key => $val)
     foreach (countries() as $key => $val) {
         $selected = $default === $key ? ' selected="selected"' : '';
         $menu .= '<option value="' . $key . '"' . $selected . '>' . _dgettext("system", $val['name']) . "</option>\n";
     }
     return $menu . '</select>';
 }
开发者ID:bkader,项目名称:CodeIgniter-Extended,代码行数:26,代码来源:countries_helper.php

示例5: display_user

 function display_user($user_id, $photo_size = null, $attributes = null, $show_names = true)
 {
     $ci = get_instance();
     $ci->load->model('users');
     $ci->load->model('user_photo');
     $user_id = (int) $user_id;
     $photo_size = (int) $photo_size;
     if ($photo_size <= 0) {
         $photo_size = 24;
     }
     $user = $ci->users->with_deleted()->get($user_id);
     if (empty($user)) {
         return null;
     }
     $attributes = _stringify_attributes($attributes);
     if (!$show_names) {
         $attributes .= ' title="' . html_escape($user['first_name'] . ' ' . $user['last_name'] . ' (' . $user['username'] . ')') . '"';
     }
     $result = img($ci->user_photo->get($user, $photo_size), false, $attributes);
     if ($show_names) {
         $result .= ' ' . $user['first_name'] . ' ' . $user['last_name'] . ' (' . $user['username'] . ')';
     }
     return $result;
 }
开发者ID:aslijiasheng,项目名称:ciFramework,代码行数:24,代码来源:users_helper.php

示例6: timezone_menu

 /**
  * Timezone Menu
  *
  * Generates a drop-down menu of timezones.
  *
  * @param	string	timezone
  * @param	string	classname
  * @param	string	menu name
  * @param	mixed	attributes
  * @return	string
  */
 function timezone_menu($default = 'UTC', $class = '', $name = 'timezones', $attributes = '')
 {
     $CI =& get_instance();
     $CI->lang->load('date');
     $default = $default === 'GMT' ? 'UTC' : $default;
     $menu = '<select name="' . $name . '"';
     if ($class !== '') {
         $menu .= ' class="' . $class . '"';
     }
     $menu .= _stringify_attributes($attributes) . ">\n";
     foreach (timezones() as $key => $val) {
         $selected = $default === $key ? ' selected="selected"' : '';
         $menu .= '<option value="' . $key . '"' . $selected . '>' . $CI->lang->line($key) . "</option>\n";
     }
     return $menu . '</select>';
 }
开发者ID:ndy40,项目名称:dashwebsvc,代码行数:27,代码来源:date_helper.php

示例7: mailto

 /**
  * Mailto Link
  *
  * @param	string	the email address
  * @param	string	the link title
  * @param	mixed	any attributes
  * @return	string
  */
 function mailto($email, $title = '', $attributes = '')
 {
     $title = (string) $title;
     if ($title === '') {
         $title = $email;
     }
     return '<a href="mailto:' . $email . '"' . _stringify_attributes($attributes) . '>' . $title . '</a>';
 }
开发者ID:ram-izaap,项目名称:got-safety,代码行数:16,代码来源:url_helper.php

示例8: img

 /**
  * Image
  *
  * Generates an <img /> element
  *
  * @param	mixed
  * @param	bool
  * @param	mixed
  * @return	string
  */
 function img($src = '', $index_page = FALSE, $attributes = '')
 {
     if (!is_array($src)) {
         $src = array('src' => $src);
     }
     // If there is no alt attribute defined, set it to an empty string
     if (!isset($src['alt'])) {
         $src['alt'] = '';
     }
     $img = '<img';
     foreach ($src as $k => $v) {
         if ($k === 'src' && strpos($v, '://') === FALSE) {
             $CI =& get_instance();
             if ($index_page === TRUE) {
                 $img .= ' src="' . $CI->config->site_url($v) . '"';
             } else {
                 $img .= ' src="' . $CI->config->slash_item('base_url') . $v . '"';
             }
         } else {
             $img .= ' ' . $k . '="' . $v . '"';
         }
     }
     return $img . _stringify_attributes($attributes) . ' />';
 }
开发者ID:BryceHappy,项目名称:Oauth2-SocialAuth-for-CodeIgniter,代码行数:34,代码来源:html_helper.php

示例9: timezone_menu

 /**
  * Timezone Menu
  *
  * Generates a drop-down menu of timezones.
  *
  * @param	string	timezone
  * @param	string	classname
  * @param	string	menu name
  * @param	mixed	attributes
  * @return	string
  */
 function timezone_menu($default = 'UTC', $class = '', $name = 'timezones', $attributes = '')
 {
     $CI =& get_instance();
     include_once BASEPATH . 'vendor/timezones.php';
     $default = $default === 'GMT' ? 'UTC' : $default;
     $menu = '<select name="' . $name . '"';
     if ($class !== '') {
         $menu .= ' class="' . $class . '"';
     }
     $menu .= _stringify_attributes($attributes) . ">\n";
     //foreach (timezones() as $key => $val)
     foreach ($timezones as $key => $val) {
         $selected = $default === $key ? ' selected="selected"' : '';
         $menu .= '<option value="' . $key . '"' . $selected . '>' . _dgettext("system", $val) . "</option>\n";
     }
     return $menu . '</select>';
 }
开发者ID:bkader,项目名称:CodeIgniter-Extended,代码行数:28,代码来源:date_helper.php

示例10: secure_anchor

/**
 * Secure Anchor Link
 *
 * Creates a secure anchor based on the local URL, and if USE_SSL is 'on'.
 *
 * @param  string  the URL
 * @param  string  the link title
 * @param  mixed   any attributes
 */
function secure_anchor($uri = '', $title = '', $attributes = '')
{
    $title = (string) $title;
    $site_url = is_array($uri) ? secure_site_url($uri) : preg_match('#^(\\w+:)?//#i', $uri) ? $uri : secure_site_url($uri);
    if ($title === '') {
        $title = $site_url;
    }
    if ($attributes !== '') {
        $attributes = _stringify_attributes($attributes);
    }
    return '<a href="' . $site_url . '"' . $attributes . '>' . $title . '</a>';
}
开发者ID:ducthang128,项目名称:VPS_v2,代码行数:21,代码来源:MY_url_helper.php

示例11: _main_menu_widget_display_children

function _main_menu_widget_display_children($items, $level = 0)
{
    foreach ($items as $item) {
        if (empty($item['blank'])) {
            ?>

                                <li<?php 
            if (!empty($item['is_active'])) {
                ?>
 class="active"<?php 
            }
            ?>
><a href="<?php 
            echo $item['link'];
            ?>
"<?php 
            echo _stringify_attributes($item['attributes']);
            ?>
><?php 
            echo str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $level);
            if ($item['icon'] != '') {
                ?>
<i class="<?php 
                echo $item['icon'];
                ?>
"></i>&nbsp; <?php 
            }
            echo $item['label'];
            ?>
</a></li>

<?php 
        } else {
            ?>

                                <li class="divider"></li>

<?php 
        }
        if (!empty($item['children'])) {
            _main_menu_widget_display_children($item['children'], $level + 1);
        }
    }
}
开发者ID:rhizalpatrax64bit,项目名称:starter-public-edition-4,代码行数:44,代码来源:main_menu_widget.php

示例12: img

 /**
  * Image.
  *
  * Generates an <img /> element
  *
  * @param	mixed
  * @param	bool
  * @param	mixed
  *
  * @return string
  */
 function img($src = '', $index_page = false, $attributes = '')
 {
     if (!is_array($src)) {
         $src = ['src' => $src];
     }
     // If there is no alt attribute defined, set it to an empty string
     if (!isset($src['alt'])) {
         $src['alt'] = '';
     }
     $img = '<img';
     foreach ($src as $k => $v) {
         if ($k === 'src' && !preg_match('#^([a-z]+:)?//#i', $v)) {
             if ($index_page === true) {
                 $img .= ' src="' . get_instance()->config->site_url($v) . '"';
             } else {
                 $img .= ' src="' . get_instance()->config->slash_item('base_url') . $v . '"';
             }
         } else {
             $img .= ' ' . $k . '="' . $v . '"';
         }
     }
     return $img . _stringify_attributes($attributes) . ' />';
 }
开发者ID:recca0120,项目名称:laraigniter,代码行数:34,代码来源:html_helper.php

示例13: encode_emailto

 /**
  * Encodes any email address into HTML entities so that spam bots do not find it.
  *
  * @author 	Kader Bouyakoub <http://www.bkader.com/>
  * @link 	@bkader <github>
  * @link 	@KaderBouyakoub <twitter>
  *
  * @access 	public
  * @param 	string
  * @param 	string
  * @param 	mixed
  * @param 	string
  * @return 	string
  */
 function encode_emailto($email, $text = null, $attr = null, $subject = null)
 {
     $text or $text = $email;
     // remplazar aroba y puntos
     $email = str_replace('@', '&#64;', $email);
     $email = str_replace('.', '&#46;', $email);
     $email = str_split($email, 5);
     $text = str_replace('@', '&#64;', $text);
     $text = str_replace('.', '&#46;', $text);
     $text = str_split($text, 5);
     $part1 = '<a href="ma';
     $part2 = 'ilto&#58;';
     $part3 = '"' . _stringify_attributes($attr) . '>';
     $part4 = '</a>';
     $encoded = '<script type="text/javascript">';
     $encoded .= "document.write('{$part1}');";
     $encoded .= "document.write('{$part2}');";
     foreach ($email as $e) {
         $encoded .= "document.write('{$e}');";
     }
     $encoded .= "document.write('{$part3}');";
     foreach ($text as $l) {
         $encoded .= "document.write('{$l}');";
     }
     $encoded .= "document.write('{$part4}');";
     $encoded .= '</script>';
     return $encoded;
 }
开发者ID:bkader,项目名称:CodeIgniter-Extended,代码行数:42,代码来源:url_helper.php

示例14: img_alt

 /**
  * Generates an image using placehold.it
  *
  * @access  public
  * @param   mixed
  * @param   integer
  * @param   string
  * @param   string
  * @param   string
  * @param   mixed
  * @return  string
  */
 function img_alt($width, $height = null, $text = null, $background = null, $foreground = null, $attr = null)
 {
     if (is_array($width)) {
         $params = $width;
     } else {
         $params = array();
         $params['width'] = $width;
         $params['height'] = $height;
         $params['text'] = $text;
         $params['background'] = $background;
         $params['foreground'] = $foreground;
         $params['attr'] = $attr;
     }
     $params['height'] = empty($params['height']) ? $params['width'] : $params['height'];
     $params['text'] = empty($params['text']) ? $params['width'] . ' x ' . $params['height'] : $params['text'];
     $params['background'] = empty($params['background']) ? 'CCCCCC' : $params['height'];
     $params['foreground'] = empty($params['foreground']) ? '969696' : $params['foreground'];
     return '<img src="http://placehold.it/' . $params['width'] . 'x' . $params['height'] . '/' . $params['background'] . '/' . $params['foreground'] . '&text=' . $params['text'] . '" alt="Placeholder"' . (isset($params['attr']) ? _stringify_attributes($params['attr']) : '') . ' />';
 }
开发者ID:bkader,项目名称:CodeIgniter-Extended,代码行数:31,代码来源:asset_helper.php

示例15: audio

 /**
  * Generates a html5 audio tag
  * It is required that you set html5 as the doctype to use this method
  *
  * @param	mixed 	one or multiple audio sources
  * @param	mixed 	tag attributes
  * @return	string
  */
 function audio($src = '', $attr = null)
 {
     if (is_array($src)) {
         $output = '';
         foreach ($src as $elem) {
             $output[] = audio($elem);
         }
         return implode("\n", $output);
     }
     return '<source src="' . $src . '"' . ($attr ? _stringify_attributes($attr) : '') . ' />';
 }
开发者ID:bkader,项目名称:CodeIgniter-Extended,代码行数:19,代码来源:html_helper.php


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