diff --git a/class-HTML.php b/class-HTML.php
index 10818c2..d7fd777 100644
--- a/class-HTML.php
+++ b/class-HTML.php
@@ -1,125 +1,161 @@
.
+# along with this program. If not, see .
-/*
- * Static classes useful to create some HTML tags.
+/**
+ * Static class useful to create some HTML tags
+ *
* Use: esc_attr()
*/
-
class HTML {
- private $tabs;
-
/**
- * If it contains a list of tag, it return all the tags with a space before.
+ * If it contains a list of tag, it return all the tags with a space before
*
* @param string $tags The tag list
*/
- public static function spaced($tags) {
- return ( empty($tags) ) ? '' : " $tags";
+ public static function spaced( $tags ) {
+ return empty( $tags ) ? '' : " $tags";
}
/**
- * Closed tag.
+ * Generate a closed tag
+ *
+ * @param string $name Tag name
+ * @param string $intag Tag attributes
+ * @param string $attributes Tag attributes
*/
- public static function tag($name, $intag = '', $properties = '') {
- return "<$name$properties>$intag$name>";
+ public static function tag( $name, $intag = '', $attributes = '' ) {
+ return "<$name$attributes>$intag$name>";
}
/**
- * Self closed tag.
+ * Generate a self closed tag
*/
- public static function tagc($name, $properties = null) {
- return "<$name$properties />";
+ public static function tagc( $name, $attributes = null ) {
+ return "<$name$attributes />";
}
- public static function a($href, $text = null, $title = null, $class= null, $intag = null) {
- return self::tag('a', $text, self::property('href', $href) . self::property('title', $title) . self::property('class', $class) . self::spaced($intag) );
+ /**
+ * Generate an tag
+ *
+ * @param string $href The href="" attribute
+ * @param string $text Displayed text
+ * @param string $title The title="" attribute
+ * @param string $class The class="" attribute
+ * @param string $intag Something else into the tag
+ * @return string
+ */
+ public static function a( $href, $text = null, $title = null, $class= null, $intag = null ) {
+ $s = self::property( 'href', $href );
+ $s .= self::property( 'title', $title );
+ $s .= self::property( 'class', $class );
+ $s .= self::spaced( $intag );
+ return self::tag( 'a', $text, $s );
}
- public static function img($src, $alt = null, $title = null, $class = null, $intag = null) {
- return self::tagc('img', self::property('src', $src) . self::property('title', $title) . self::property('alt', $alt) . self::property('class', $class) . self::spaced($intag) );
+ /**
+ * Generate an
tag
+ *
+ * @param string $src The src="" attribute
+ * @param string $alt The alt="" attribute
+ * @param string $title The title="" attribute
+ * @param string $class The class="" attribute
+ * @param string $intag Something else into the tag
+ * @return string
+ */
+ public static function img( $src, $alt = null, $title = null, $class = null, $intag = null ) {
+ $s = self::property( 'src', $src );
+ $s .= self::property( 'alt', $alt );
+ $s .= self::property( 'title', $title );
+ $s .= self::property( 'class', $class );
+ $s .= self::spaced( $intag );
+ return self::tagc( 'img', $s );
}
/**
- * Return the property of a tag, only if the value isn't NULL.
+ * Return the property of a tag, only if the value isn't NULL
*
- * @param string $name Property's name
- * @param string $value Property's value
- * @return string $name="$value" (or NULL if $value = '')
+ * @param string $name Property's name
+ * @param string $value Property's value
+ * @return string
*/
- public static function property($name, $value) {
- return (empty($value)) ? '' : ' ' . $name . '="' . esc_attr( $value ) . '"';
+ public static function property( $name, $value ) {
+ $s = '';
+ if( !empty( $value ) ) {
+ $value = esc_attr( $value );
+ $s = " $name=\"$value\"";
+ }
+ return $s;
}
}
class Table extends HTML {
public static function start($intag = '') {
return '
';
}
public static function tr($intag = '') {
return '';
}
public static function tr_stop() {
return '
';
}
public static function th($content, $intag = '') {
return '' . $content . ' | ';
}
public static function th_stop($content, $intag = '') {
return '' . $content . ' | ';
}
}
class Form extends HTML {
public static function start($action = '', $method = '', $intag = '') {
if($method != '' && $method != 'get' && $method != 'post') {
throw new Exception("Param method must be get or post.");
}
return '';
}
public static function input($type, $name, $value = '', $intag = '') {
return '';
}
public static function select($type, $name, $value = '', $intag = '') {
$tag = '';
}
public static function label($for, $text, $intag = '') {
return '';
}
}