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


PHP array_to_attr函数代码示例

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


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

示例1: ul

 public static function ul($data)
 {
     //  echo "<pre>";        var_dump($data); exit;
     $output = "<ul " . array_to_attr($data['attr']) . ">";
     foreach ($data['links'] as $link) {
         $output .= "<li " . array_to_attr($link['attr']) . ">";
         if (array_key_exists('href', $link)) {
             $output .= Html::anchor($link['href'], $link['text']);
         } else {
             $output .= "<span>" . $link['text'] . "</span>";
         }
         if (array_key_exists('children', $link)) {
             // if ($link['attr']['class'] == 'leaf last') {
             $output .= "<ul>";
             foreach ($link['children'] as $ch => $child) {
                 if (array_key_exists('href', $child)) {
                     $output .= "<li>";
                     $output .= Html::anchor($child['href'], $child['text']);
                     $output .= "</li>";
                 } else {
                     $output .= "<li" . array_to_attr($link['attr']) . ">";
                     $output .= "<span>" . $child['text'] . "</span>";
                     $output .= "</li>";
                 }
             }
             $output .= "</ul>";
             // }
         }
         $output .= "</li>";
     }
     //$output .= "</ul>"; //closed in navigation.php
     return $output;
 }
开发者ID:sajans,项目名称:cms,代码行数:33,代码来源:html.php

示例2: displayForm

 /** inheritdoc */
 public static function displayForm($value, &$settings, $model)
 {
     $class = get_called_class();
     $settings = static::settings($settings);
     $include_label = isset($settings['label']) ? $settings['label'] : true;
     $required = isset($settings['required']) ? $settings['required'] : false;
     $errors = $model->getErrorsForField($settings['mapping']['fieldName']);
     $has_errors = count($errors) > 0;
     $input_attributes = isset($settings['input_attributes']) ? $settings['input_attributes'] : array('class' => 'input-xxlarge form-control');
     if (!isset($input_attributes['id'])) {
         $input_attributes['id'] = 'form_' . $settings['mapping']['fieldName'];
     }
     $attributes = array('class' => 'controls control-group' . ($has_errors ? ' error' : '') . ' field-type-' . $class::type($settings));
     $label_text = $settings['title'] . ($required ? ' *' : '');
     // Build the input
     $input = '<input type="text" name="' . $settings['mapping']['fieldName'] . '" ' . array_to_attr($input_attributes) . ' value="' . \Security::htmlentities(strval($value), ENT_QUOTES) . '" />';
     // Build the label
     $label = !$include_label ? '' : \Form::label($label_text . ($has_errors ? ' - ' . $errors[0] : ''), $settings['mapping']['fieldName'], array('class' => 'item-label'));
     // Wrap it in an input group
     $input = html_tag('div', array('class' => 'input-append'), $input . html_tag('span', array('class' => 'add-on'), ' '));
     // Don't wrap the input if wrap is set to false
     if (isset($settings['wrap']) && $settings['wrap'] === false) {
         return $label . $input;
     }
     return html_tag('div', $attributes, $label . $input);
 }
开发者ID:soundintheory,项目名称:fuel-cmf,代码行数:27,代码来源:Color.php

示例3: displayForm

 /**
  * Renders the field's form element for editing in the admin site
  */
 public static function displayForm($value, &$settings, $model)
 {
     $class = get_called_class();
     $settings = static::settings($settings);
     $include_label = isset($settings['label']) ? $settings['label'] : true;
     $required = isset($settings['required']) ? $settings['required'] : false;
     $errors = $model->getErrorsForField($settings['mapping']['fieldName']);
     $has_errors = count($errors) > 0;
     $input_attributes = isset($settings['input_attributes']) ? $settings['input_attributes'] : array('class' => 'input-xxlarge');
     if (!isset($input_attributes['id'])) {
         $input_attributes['id'] = 'form_' . $settings['mapping']['fieldName'];
     }
     $attributes = array('class' => 'controls control-group' . ($has_errors ? ' error' : '') . ' field-type-' . $class::type($settings));
     $label_text = $settings['title'] . ($required ? ' *' : '');
     if (empty($value)) {
         $value = substr(\Security::generate_token(), 0, 16);
     }
     // Description?
     $description = isset($settings['description']) ? '<span class="help-block">' . $settings['description'] . '</span>' : '';
     // Build the input
     $input = '<input type="text" name="' . $settings['mapping']['fieldName'] . '" ' . array_to_attr($input_attributes) . ' value="' . \Security::htmlentities(strval($value), ENT_QUOTES) . '" />';
     // Build the label
     $label = !$include_label ? '' : html_tag('label', array('class' => 'item-label', 'for' => $settings['mapping']['fieldName']), $label_text . ($has_errors ? ' - ' . $errors[0] : ''));
     // Don't wrap the input if wrap is set to false
     if (isset($settings['wrap']) && $settings['wrap'] === false) {
         return $label . $input;
     }
     return html_tag('div', $attributes, $label . $description . $input);
 }
开发者ID:soundintheory,项目名称:fuel-cmf,代码行数:32,代码来源:RandomKey.php

示例4: html_tag

 /**
  * Create a XHTML tag
  *
  * @param   string          The tag name
  * @param   array|string    The tag attributes
  * @param   string|bool     The content to place in the tag, or false for no closing tag
  * @return  string
  */
 function html_tag($tag, $attr = array(), $content = false)
 {
     $has_content = (bool) ($content !== false and $content !== null);
     $html = '<' . $tag;
     $html .= !empty($attr) ? ' ' . (is_array($attr) ? array_to_attr($attr) : $attr) : '';
     $html .= $has_content ? '>' : ' />';
     $html .= $has_content ? $content . '</' . $tag . '>' : '';
     return $html;
 }
开发者ID:younes0,项目名称:laravel-casset,代码行数:17,代码来源:helpers.php

示例5: displayForm

 /**
  * Renders the field's form element for editing in the admin site
  * @see \Admin::getFieldSettings()
  * @param mixed $value The current value of the property, if there is one
  * @param array $settings Field settings, created through \Admin::getFieldSettings()
  * @param object $model The model, if it is being edited.
  * @return string The form control
  */
 public static function displayForm($value, &$settings, $model)
 {
     $class = get_called_class();
     $settings = static::settings($settings);
     $include_label = isset($settings['label']) ? $settings['label'] : true;
     $required = isset($settings['required']) ? $settings['required'] : false;
     $errors = $model->getErrorsForField($settings['mapping']['fieldName']);
     $has_errors = count($errors) > 0;
     $input_attributes = isset($settings['input_attributes']) ? $settings['input_attributes'] : array('class' => 'input-xxlarge');
     if (!isset($input_attributes['id'])) {
         $input_attributes['id'] = 'form_' . $settings['mapping']['fieldName'];
     }
     $attributes = array('class' => 'controls control-group' . ($has_errors ? ' error' : '') . ' field-type-' . $class::type($settings));
     $label_text = $settings['title'] . ($required ? ' *' : '');
     // Translation?
     if (\CMF::$lang_enabled && !\CMF::langIsDefault() && isset($settings['mapping']['columnName']) && $model->isTranslatable($settings['mapping']['columnName'])) {
         // If there is no translation
         if (!$model->hasTranslation($settings['mapping']['columnName'])) {
             $attributes['class'] .= ' no-translation';
             $input_attributes['class'] .= ' no-translation';
             $label_text = '<img class="lang-flag" src="' . \Uri::create('/admin/assets/img/lang/' . \CMF::defaultLang() . '.png') . '" />&nbsp; ' . $label_text;
         } else {
             $label_text = '<img class="lang-flag" src="' . \Uri::create('/admin/assets/img/lang/' . \CMF::lang() . '.png') . '" />&nbsp; ' . $label_text;
         }
     }
     // Description?
     $description = isset($settings['description']) ? '<span class="help-block">' . $settings['description'] . '</span>' : '';
     // Build the input
     $input = '<input type="text" name="' . $settings['mapping']['fieldName'] . '" ' . array_to_attr($input_attributes) . ' value="' . \Security::htmlentities(strval($value), ENT_QUOTES) . '" />';
     // Build the label
     $label = !$include_label ? '' : html_tag('label', array('class' => 'item-label', 'for' => $settings['mapping']['fieldName']), $label_text . ($has_errors ? ' - ' . $errors[0] : ''));
     // Prepend or append things...
     if (isset($settings['prepend'])) {
         $input = html_tag('div', array('class' => 'input-prepend'), html_tag('span', array('class' => 'add-on'), $settings['prepend']) . $input);
     }
     if (isset($settings['append'])) {
         $input = html_tag('div', array('class' => 'input-append'), $input . html_tag('span', array('class' => 'add-on'), $settings['append']));
     }
     // Don't wrap the input if wrap is set to false
     if (isset($settings['wrap']) && $settings['wrap'] === false) {
         return $label . $input;
     }
     // Add the 'keep updated' control if the field has a template
     if (isset($settings['template']) && !empty($settings['template'])) {
         $attributes['class'] .= ' field-with-controls field-with-template';
         $auto_update_setting = 'settings[' . $settings['mapping']['fieldName'] . '][auto_update]';
         $auto_update_content = \Form::hidden($auto_update_setting, '0', array()) . html_tag('label', array('class' => 'checkbox auto-update-label'), \Form::checkbox($auto_update_setting, '1', \Arr::get($settings, 'auto_update', true), array('class' => 'auto-update')) . strtolower(\Lang::get('admin.common.auto_update')));
         $auto_update = html_tag('div', array('class' => 'controls-top'), $auto_update_content);
         $label .= $auto_update;
         return array('content' => html_tag('div', $attributes, $label . $description . $input) . '<div class="clear"><!-- --></div>', 'widget' => false, 'assets' => array('js' => array('/admin/assets/js/twig.min.js', '/admin/assets/js/fields/template.js')), 'js_data' => $settings);
     }
     return html_tag('div', $attributes, $label . $description . $input);
 }
开发者ID:soundintheory,项目名称:fuel-cmf,代码行数:61,代码来源:Base.php

示例6: mail_to_safe

 /**
  * Creates a mailto link with Javascript to prevent bots from picking up the
  * email address.
  *
  * @param	string	the email address
  * @param	string	the text value
  * @param	string	the subject
  * @param	array	attributes for the tag
  * @return	string	the javascript code containg email
  */
 public static function mail_to_safe($email, $text, $subject = null, $attr = array())
 {
     $text or $text = str_replace('@', '[at]', $email);
     $email = explode("@", $email);
     $subject and $subject = '?subject=' . $subject;
     $attr = array_to_attr($attr);
     $attr = ($attr == '' ? '' : ' ') . $attr;
     $output = '<script type="text/javascript">';
     $output .= 'var user = "' . $email[0] . '";';
     $output .= 'var at = "@";';
     $output .= 'var server = "' . $email[1] . '";';
     $output .= "document.write('<a href=\"' + 'mail' + 'to:' + user + at + server + '{$subject}\"{$attr}>{$text}</a>');";
     $output .= '</script>';
     return $output;
 }
开发者ID:hymns,项目名称:fuel,代码行数:25,代码来源:html.php

示例7: attr_to_string

 /**
  * Attr to String
  *
  * Wraps the global attributes function and does some form specific work
  *
  * @param   array  $attr
  * @return  string
  */
 protected function attr_to_string($attr)
 {
     unset($attr['label']);
     return array_to_attr($attr);
 }
开发者ID:highestgoodlikewater,项目名称:webspider-1,代码行数:13,代码来源:instance.php

示例8: attr_to_string

 /**
  * Attr to String
  *
  * Wraps the global attributes function and does some form specific work
  *
  * @access	private
  * @param	array	$attr
  * @return	string
  */
 private static function attr_to_string($attr)
 {
     unset($attr['label']);
     return array_to_attr($attr);
 }
开发者ID:bryanheo,项目名称:FuelPHP-Auth-AJAX,代码行数:14,代码来源:form.php

示例9: render

 /**
  * renders the navigation
  *
  * @param   array   array with tag attribute settings
  * @access	public
  * @return	void
  */
 public static function render($type = 'default', array $attributes = array(), $header = false)
 {
     if (empty($type)) {
         return;
     }
     $links = \Config::get('navigation.' . $type, false);
     if (empty($links)) {
         throw new BootstrapException('Missing navigation links in config');
         return;
     }
     $callback = \Config::get('bootstrap.navigation_links_callback', null);
     if ($callback != null) {
         $links = $callback($links);
     }
     foreach ($links as $key => &$link) {
         if (empty($link['url'])) {
             $link['url'] = \Inflector::friendly_title($link['title'], '-', true);
         }
         // Set link to active if it matches the current page URI.
         if (!isset($link['active'])) {
             $link['active'] = $link['url'] == ltrim(\Input::uri(), '/');
         }
         if (empty($link['attributes'])) {
             $link['attributes'] = array();
         }
         $anchor_classs = \Config::get('bootstrap.navigation.anchor_class', true);
         if ($anchor_classs) {
             if (!isset($link['attributes']['class'])) {
                 $link['class'] = \Inflector::friendly_title($link['title'], '-', true);
             }
             $anchor_prefix = \Config::get('bootstrap.navigation.anchor_prefix', 'nav-');
             if (!empty($anchor_prefix)) {
                 $link['class'] = $anchor_prefix . $link['class'];
             }
         }
         if (!empty($link['class'])) {
             $link['attributes']['class'] = $link['class'];
         }
     }
     if (isset($attributes['class'])) {
         $attributes['class'] = 'nav ' . $attributes['class'];
     } else {
         $attributes['class'] = 'nav';
     }
     echo \View::forge('navigation', array('header' => $header, 'links' => $links, 'attributes' => array_to_attr($attributes)))->render();
 }
开发者ID:joel-depiltech,项目名称:fuel-bootstrap,代码行数:53,代码来源:navigation.php

示例10: array

    $btn_group_attrs = array();
}
$default_btn_group_attrs = array('class' => 'btn-group');
$btn_group_attrs = Util_toolkit::convert_to_attr($btn_group_attrs, $default_btn_group_attrs);
if (!isset($btn_attrs)) {
    $btn_attrs = array();
}
$default_btn_attrs = array('data-toggle' => 'dropdown');
$btn_attrs = Util_toolkit::convert_to_attr($btn_attrs, $default_btn_attrs);
$menu_id = !empty($btn_attrs['data-menu']) ? str_replace('#', '', $btn_attrs['data-menu']) : '';
if (empty($btn_with_text)) {
    $btn_with_text = false;
}
?>
<div <?php 
echo array_to_attr($btn_group_attrs);
?>
>
	<?php 
echo btn($type, null, 'dropdown-toggle', $btn_with_text, $btn_size, $btn_type, $btn_attrs, null, 'button', null, null, $with_caret);
?>
	<ul class="dropdown-menu<?php 
if ($is_popover_align_right) {
    ?>
 pull-right<?php 
}
?>
" role="menu"<?php 
if ($menu_id) {
    ?>
 id="<?php 
开发者ID:uzura8,项目名称:flockbird,代码行数:31,代码来源:btn_dropdown.php

示例11: html_tag

 function html_tag($tag, $attr = array(), $content = false)
 {
     $self_close = array('link', 'meta');
     $has_content = (bool) ($content !== false && $content !== null);
     if (isset($attr['cddata'])) {
         $has_content = true;
         $content = $attr['cddata'];
         unset($attr['cddata']);
     }
     $html = '<' . $tag;
     $html .= !empty($attr) ? ' ' . (is_array($attr) ? array_to_attr($attr) : $attr) : '';
     $html .= ($has_content or !in_array($tag, $self_close)) ? '>' : ' />';
     $html .= ($has_content or !in_array($tag, $self_close)) ? $content . '</' . $tag . '>' : '';
     return $html;
 }
开发者ID:NaszvadiG,项目名称:cim-xa,代码行数:15,代码来源:Ember_js.php

示例12: action_open

 /**
  * Open an action wrapper.
  * 
  * @access public
  * @return void
  */
 public function action_open($attrs = array())
 {
     static::$helper->add_template($attrs);
     $class = array('form-actions');
     static::$helper->merge_classes($attrs, $class);
     return '<div ' . array_to_attr($attrs) . '>';
 }
开发者ID:ronan-gloo,项目名称:FuelPHP-Twitter-Bootstrap,代码行数:13,代码来源:instance.php

示例13: render

 /**
  * renders the breadcrumbs
  *
  * @param   array   array with tag attribute settings
  * @access	public
  * @return	void
  */
 public static function render(array $attributes = array())
 {
     if (empty(self::$breadcrumbs)) {
         return;
     }
     if (isset($attributes['class'])) {
         $attributes['class'] = 'breadcrumb ' . $attributes['class'];
     } else {
         $attributes['class'] = 'breadcrumb';
     }
     echo \View::forge('breadcrumbs.php', array('links' => self::$breadcrumbs, 'attributes' => array_to_attr($attributes)))->render();
 }
开发者ID:joel-depiltech,项目名称:fuel-bootstrap,代码行数:19,代码来源:breadcrumbs.php

示例14: html_tag

 function html_tag($tag, $attr = array(), $content = false)
 {
     // list of void elements (tags that can not have content)
     static $void_elements = array("area", "base", "br", "col", "hr", "img", "input", "link", "meta", "param", "command", "embed", "keygen", "source", "track", "wbr", "menuitem");
     // construct the HTML
     $html = '<' . $tag;
     $html .= !empty($attr) ? ' ' . (is_array($attr) ? array_to_attr($attr) : $attr) : '';
     // a void element?
     if (in_array(strtolower($tag), $void_elements)) {
         // these can not have content
         $html .= ' />';
     } else {
         // add the content and close the tag
         $html .= '>' . $content . '</' . $tag . '>';
     }
     return $html;
 }
开发者ID:socialskeptic,项目名称:sainsburys,代码行数:17,代码来源:base.php

示例15: label

 public static function label($text, $attr = array(), $error = '')
 {
     $error_icon = empty($error) ? \Config::get('petro.form.error_icon') : '';
     return static::template('label', array('{label_attr}', '{label}', '{error_icon}'), array(array_to_attr($attr), $text, $error_icon));
 }
开发者ID:ratiw,项目名称:petro,代码行数:5,代码来源:form.php


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