html::attributes PHP Method

attributes() public static method

public static attributes ( $attributes )
    public static function attributes($attributes)
    {
        if (empty($attributes)) {
            return '';
        }
        if (is_string($attributes)) {
            return ' ' . $attributes;
        }
        foreach ($attributes as $key => $val) {
            $pairs[] = $key . '="' . $val . '"';
        }
        return ' ' . implode(' ', $pairs);
    }

Usage Example

Example #1
0
 public static function header($page = array())
 {
     $page['js'] = array_merge(array('jquery' => url::common() . '/js/jquery.js', 'plugins' => url::common() . '/js/jquery.plugins.js', 'zotop' => url::common() . '/js/zotop.js'), (array) $page['js']);
     $page['css'] = array_merge(array('zotop' => url::theme() . '/css/zotop.css', 'global' => url::theme() . '/css/global.css'), (array) $page['css']);
     $page = self::settings($page);
     $html[] = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
     $html[] = '<html xmlns="http://www.w3.org/1999/xhtml">';
     $html[] = '<head>';
     $html[] = '	<title>' . $page['title'] . ' Powered by ' . zotop::config("zotop.title") . '</title>';
     $html[] = self::meta($page['meta']);
     $html[] = self::stylesheet($page['css']);
     $html[] = self::script($page['js']);
     $html[] = '	' . html::link(url::theme() . '/image/fav.ico', array('rel' => 'shortcut icon', 'type' => 'image/x-icon'));
     $html[] = '	' . html::link(url::theme() . '/image/fav.ico', array('rel' => 'icon', 'type' => 'image/x-icon'));
     $html[] = '	' . html::link(url::theme() . '/image/fav.ico', array('rel' => 'bookmark', 'type' => 'image/x-icon'));
     $html[] = '	<script type="text/javascript">';
     $html[] = '		zotop.url.base = "' . url::base() . '";';
     $html[] = '		zotop.url.common = "' . url::common() . '";';
     $html[] = '		zotop.page.id = "' . page::id() . '";';
     $html[] = '		zotop.user.id =0;';
     $html[] = '		zotop.user.username = "";';
     $html[] = '	</script>';
     $html[] = '</head>';
     $html[] = '<body' . html::attributes($page['body']) . '>';
     $html[] = '<div id="wrapper">';
     $html[] = '';
     $str = implode("\n", $html);
     echo $str;
 }
All Usage Examples Of html::attributes