本文整理汇总了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) . ' />';
}
示例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;
}
示例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));
}
示例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>';
}
示例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;
}
示例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>';
}
示例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>';
}
示例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) . ' />';
}
示例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>';
}
示例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>';
}
示例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(' ', $level);
if ($item['icon'] != '') {
?>
<i class="<?php
echo $item['icon'];
?>
"></i> <?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);
}
}
}
示例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) . ' />';
}
示例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('@', '@', $email);
$email = str_replace('.', '.', $email);
$email = str_split($email, 5);
$text = str_replace('@', '@', $text);
$text = str_replace('.', '.', $text);
$text = str_split($text, 5);
$part1 = '<a href="ma';
$part2 = 'ilto:';
$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;
}
示例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']) : '') . ' />';
}
示例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) : '') . ' />';
}