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


PHP HTML::attributes方法代码示例

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


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

示例1: render

    /**
     * Render alert.
     *
     * @return  string
     */
    public function render()
    {
        ob_start();
        // Section attributes
        $attributes = array('class' => 'alert alert-block ' . $this->class);
        ?>

<div <?php 
        echo HTML::attributes($attributes);
        ?>
>
	<?php 
        if ($this->header) {
            ?>
<h4 class="alert-heading"><?php 
            echo HTML::chars($this->header);
            ?>
</h4><?php 
        }
        ?>

	<?php 
        echo $this->content;
        ?>
</div>

<?php 
        return ob_get_clean();
    }
开发者ID:anqh,项目名称:core,代码行数:34,代码来源:alert.php

示例2: th

 /**
  * Render a sortable <th> tag based on current request
  *
  * @param string $column
  * @param string $name
  * @param string|array $attributes
  * @return string
  */
 public static function th($column, $name, $attributes = null)
 {
     static $_query;
     // Only get one per request
     if ($_query === null) {
         $_query = Request::current()->query();
         // Default
         $_query['sort'] = isset($_query['sort']) ? strtolower($_query['sort']) : 'id';
         $_query['order'] = isset($_query['order']) ? strtolower($_query['order']) : 'desc';
     }
     // Attributes
     if (!is_array($attributes)) {
         $attributes = array('class' => $attributes);
     }
     // Init
     $class = 'sorting';
     $order = 'asc';
     // This column is selected
     if ($column == $_query['sort']) {
         $class .= '_' . $_query['order'];
         $order = $_query['order'] == 'asc' ? 'desc' : 'asc';
     }
     // Add class to element
     $attributes['class'] = trim($class . ' ' . $attributes['class'], ' ');
     // Build URL query
     $url = URL::query(array('sort' => $column, 'order' => $order));
     // Return HTML
     return strtr('<th:attrs><a href=":url">:name</a></th>', array(':attrs' => HTML::attributes($attributes), ':url' => $url, ':name' => $name));
 }
开发者ID:NegoCore,项目名称:core,代码行数:37,代码来源:Table.php

示例3: error

 public static function error($message = '', $class = 'field_error', array $attributes = NULL)
 {
     if (empty($attributes['class'])) {
         $attributes['class'] = $class;
     }
     return '<span' . HTML::attributes($attributes) . '>' . $message . '</span>';
 }
开发者ID:kerkness,项目名称:kerkness,代码行数:7,代码来源:kerk.php

示例4: anchor

 /**
  * Create HTML link anchors. Note that the title is not escaped, to allow
  * HTML elements within links (images, etc).
  *
  * @param   string  URL or URI string
  * @param   string  link text
  * @param   array   HTML anchor attributes
  * @param   string  use a specific protocol
  * @return  string
  */
 public static function anchor($uri, $title = NULL, array $attributes = NULL, $protocol = NULL)
 {
     if ($title === NULL) {
         // Use the URI as the title
         $title = $uri;
     }
     // Translate the title
     $title = __($title);
     if ($uri === '') {
         // Only use the base URL
         $uri = URL::base(FALSE, $protocol);
     } else {
         if (strpos($uri, '://') !== FALSE) {
             if (HTML::$windowed_urls === TRUE and empty($attributes['target'])) {
                 // Make the link open in a new window
                 $attributes['target'] = '_blank';
             }
         } elseif ($uri[0] !== '#') {
             // Make the URI absolute for non-id anchors
             $uri = URL::site($uri, $protocol);
         }
     }
     // Add the sanitized link to the attributes
     $attributes['href'] = $uri;
     return '<a' . HTML::attributes($attributes) . '>' . $title . '</a>';
 }
开发者ID:joffuk,项目名称:modulargaming,代码行数:36,代码来源:html.php

示例5: open

 /**
  * Generates an opening HTML form tag.
  *
  *     // Form will submit back to the current page using POST
  *     echo Form::open();
  *
  *     // Form will submit to 'search' using GET
  *     echo Form::open('search', array('method' => 'get'));
  *
  *     // When "file" inputs are present, you must include the "enctype"
  *     echo Form::open(NULL, array('enctype' => 'multipart/form-data'));
  *
  * @param   mixed   form action, defaults to the current request URI, or [Request] class to use
  * @param   array   html attributes
  * @return  string
  * @uses    Request::instance
  * @uses    URL::site
  * @uses    HTML::attributes
  */
 public static function open($action = NULL, array $attributes = NULL)
 {
     if ($action instanceof Request) {
         // Use the current URI
         $action = $action->uri();
     }
     if (!$action) {
         // Allow empty form actions (submits back to the current url).
         $action = '';
     } elseif (strpos($action, '://') === FALSE) {
         // Make the URI absolute
         $action = URL::site($action);
     }
     // Add the form action to the attributes
     $attributes['action'] = $action;
     // Only accept the default character set
     $attributes['accept-charset'] = Kohana::$charset;
     if (!isset($attributes['method'])) {
         // Use POST method
         $attributes['method'] = 'post';
     }
     // Only render the CSRF field when the POST method is used
     $hidden_csrf_field = $attributes['method'] == 'post' ? self::hidden('form_auth_id', CSRF::token()) : '';
     return '<form' . HTML::attributes($attributes) . '>' . $hidden_csrf_field;
 }
开发者ID:rukku,项目名称:SwiftRiver,代码行数:44,代码来源:form.php

示例6: test_attributes

	/**
	 * Tests HTML::attributes()
	 *
	 * @test
	 * @dataProvider provider_attributes
	 * @param array  $attributes  Attributes to use
	 * @param string $expected    Expected output
	 */
	public function test_attributes($attributes, $expected)
	{
		$this->assertSame(
			$expected,
			HTML::attributes($attributes)
		);
	}
开发者ID:nevermlnd,项目名称:cv,代码行数:15,代码来源:HTMLTest.php

示例7: counter

 public static function counter($num = 0)
 {
     if ($num == 0) {
         return '';
     }
     return '<span' . HTML::attributes(array('class' => 'counter')) . '>' . (int) $num . '</span>';
 }
开发者ID:helpse,项目名称:kohana-twitter-bootstrap-ui,代码行数:7,代码来源:UI.php

示例8: render

    /**
     * Render alert.
     *
     * @return  string
     */
    public function render()
    {
        ob_start();
        // Section attributes
        $attributes = array('class' => 'alert alert-block ' . $this->class);
        if ($this->header === true) {
            $this->header = self::generate_header();
        }
        ?>

<div <?php 
        echo HTML::attributes($attributes);
        ?>
>
	<?php 
        if ($this->header) {
            ?>
<strong><?php 
            echo HTML::chars($this->header);
            ?>
</strong><?php 
        }
        ?>

	<?php 
        echo $this->content;
        ?>
</div>

<?php 
        return ob_get_clean();
    }
开发者ID:anqh,项目名称:anqh,代码行数:37,代码来源:alert.php

示例9: __toString

 public function __toString()
 {
     $regular_browser = " <!--[if !IE]>< --><link " . HTML::attributes($this->attributes) . " /><!-- ><![endif]-->";
     $this->attributes['rel'] = 'shortcut icon';
     $ie = "<!--[if IE]><link " . HTML::attributes($this->attributes) . " /><![endif]-->";
     return $regular_browser . "\n" . $ie;
 }
开发者ID:roomcays,项目名称:kohana-html-header,代码行数:7,代码来源:favicon.php

示例10: favicon

 public static function favicon($file, array $attributes = array('rel' => 'icon', 'type' => 'image/x-icon'), $protocol = NULL, $index = FALSE)
 {
     if (strpos($file, '://') === FALSE) {
         $file = URL::base($protocol, $index) . $file;
     }
     $attributes['href'] = $file;
     return '<link' . HTML::attributes($attributes) . ' />';
 }
开发者ID:qlsove,项目名称:faq,代码行数:8,代码来源:Site.php

示例11: style

 protected static function style($file, $media = 'all')
 {
     if (!Asset::valid_url($file)) {
         // Add base url
         $file = URL::site($file);
     }
     return '<link' . HTML::attributes(array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => $file, 'media' => $media)) . '>';
 }
开发者ID:alle,项目名称:assets-merger,代码行数:8,代码来源:Asset.php

示例12: hidden

 /**
  *
  * @param string $title
  * @param array $types
  * @return string
  */
 public static function hidden($title, array $types = ['xs', 'sm'])
 {
     $attributes = ['class' => ''];
     foreach ($types as $type) {
         $attributes['class'] .= ' hidden-' . e($type);
     }
     return '<span' . \HTML::attributes($attributes) . '>' . $title . '</span>';
 }
开发者ID:BlueCatTAT,项目名称:kodicms-laravel,代码行数:14,代码来源:UI.php

示例13: image

 public static function image($file, array $attributes = NULL, $index = FALSE)
 {
     if (strpos($file, '://') === FALSE) {
         $file = URL::site($file);
     }
     $attributes['src'] = $file;
     return '<img' . HTML::attributes($attributes) . '>';
 }
开发者ID:andygoo,项目名称:kohana,代码行数:8,代码来源:HTML.php

示例14: link_to_route

 /**
  * Generate a HTML link to a named route.
  *
  * @param  string  $name
  * @param  string  $title
  * @param  array   $parameters
  * @param  array   $attributes
  * @return string
  */
 function link_to_route($name, $title = null, $parameters = array(), $attributes = array())
 {
     if (Route::getRoutes()->hasNamedRoute($name)) {
         return app('html')->linkRoute($name, $title, $parameters, $attributes);
     } else {
         return '<a href="javascript:void(0)"' . HTML::attributes($attributes) . '>' . $name . '</a>';
     }
 }
开发者ID:hxy79948345,项目名称:laravel-4.1-simple-blog,代码行数:17,代码来源:functions.php

示例15: link_icon

 public static function link_icon($action, $icon, $title = null, $parameters = array(), $attributes = array())
 {
     $url = URL::to_action($action, $parameters);
     if (is_null($title)) {
         $title = $url;
     }
     $icon_tag = '<i class="icon-' . $icon . '"></i>';
     return '<a href="' . $url . '"' . HTML::attributes($attributes) . ' title="' . $title . '">' . $icon_tag . '</a>';
 }
开发者ID:SerdarSanri,项目名称:gotin,代码行数:9,代码来源:gotinhelper.php


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