Location: PHPKode > projects > PHPLayouts > PHPLayouts/libs/Helper.php
<?php

/**
 * Helpers
 * 
 * @author rodix53 <hide@address.com>
 * @version 0.9.1-beta
 * @package php-layouts
 * @license http://creativecommons.org/licenses/by-nc/2.0/fr/ Creative Commons BY-NC 2.0
 */
 
class Helper
{
    const   EOL                    =  "\r\n";
    
    /**
     * Display the specified doctype tag
     * @param string $dtd
     * @return string
     */
    public static function doctype($dtd)
    {
        switch (strtolower($dtd))
		{
			case "xhtmlstrict":
				$return  = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
                $return .= self::EOL;
				$return .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">';	
				break;
 
			case "xhtmltransitional":
				$return  = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
                $return .= self::EOL;
				$return .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">';
				break;
 
			case "htmlstrict":
				$return  = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">';
                $return .= self::EOL;
				$return .= '<html>';
				break;
 
			case "htmltransitional":
				$return  = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">';
                $return .= self::EOL;
				$return .= '<html>';
				break;
 
			default:
                $return  = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
                $return .= self::EOL;
				$return .= '<html>';
				break;
		}
		$return .= self::EOL;
		return $return;
    }
    
    /**
     * Display the specified charset tag
     * @param string $charset
     * @return string
     */
    public static function charset($charset)
    {
        switch (strtolower($charset))
		{
			case "iso-8859-1":
				$return = '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />';
				break;
 
			case "utf-8":
				$return = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
				break;
 
			default:
                $return = '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />';
				break;
		}
        
		$return .= self::EOL;
		return $return;	
    }
    
    /**
     * Display the specified title tag
     * @param string $title
     * @return string
     */
    public static function title($title)
	{
		$return  = '<title>' . $title . '</title>';
        $return .= self::EOL;
		return $return;
	}
    
    /**
     * Display the specified link tag
     * @param string $file
     * @param string $media (null as default)
     * @return string
     */
    public static function css($file, $media = null)
	{
        if (isset($media) && !empty($media))
        {
            $return = '<link rel="stylesheet" href="' . $file . '" type="text/css" media="' . $media . '" />';
        }
        else
        {
            $return = '<link rel="stylesheet" href="' . $file . '" type="text/css" />';
        }
		$return .= self::EOL;
		return $return;
	}
    
    /**
     * Display the specified script tag
     * @param string $file
     * @return string
     */
	public static function javascript($file)
	{
        $return  = '<script type="text/javascript" src="' . $file . '"></script>';
        $return .= self::EOL;
        return $return;
	}
    
    /**
     * Display the specified link-rss tag
     * @param string $file
     * @param string $title
     * @return string
     */
    public static function rss($file, $title)
    {
		$return  = '<link type="application/rss+xml" rel="alternate" href="' . $file . '" title="' . $title . '" />';
        $return .= self::EOL;
		return $return;
    }

}
Return current item: PHPLayouts