skipv1_0_0HTML_Element

The Facebook Fanpage Import skip v1 0 HTML Element class.

Defined (1)

The class is defined in the following location(s).

/includes/skip/elements/html_element.php  
  1. class HTML_Element extends Element{ 
  2.  
  3. var $tag; 
  4. var $close_tag; 
  5. var $echo_tag; 
  6. var $content; 
  7.  
  8. var $params = array(); 
  9.  
  10. /** 
  11. * Skip constructor 
  12. * @package Skip 
  13. * @since 1.0 
  14. */ 
  15. public function __construct( $tag, $args = array() ) { 
  16.  
  17. $defaults = array( 
  18. 'id' => id(),  
  19. 'classes' => '',  
  20. 'params' => array(),  
  21. 'close_tag' => FALSE,  
  22. 'echo_tag' => TRUE 
  23. ); 
  24. $args = wp_parse_args( $args, $defaults ); 
  25. extract( $args , EXTR_SKIP ); 
  26.  
  27. parent::__construct( $args ); 
  28.  
  29. $this->tag = $tag; 
  30.  
  31. if( $close_tag === TRUE ) 
  32. $this->close_tag = TRUE; 
  33.  
  34. if( $echo_tag === TRUE ) 
  35. $this->echo_tag = TRUE; 
  36.  
  37. if( '' != $classes ) 
  38. $this->add_param( 'class', $classes ); 
  39.  
  40. if( '' != $id ) 
  41. $this->add_param( 'id', $id ); 
  42.  
  43. $this->add_params( $params ); 
  44.  
  45. /** 
  46. * Adding parameter to HTML Element 
  47. *  
  48. * @param string $name Name of the parameter 
  49. * @param string $value Value of the parameter 
  50. * @package Skip 
  51. * @since 1.0 
  52. * @return string The content of the element 
  53. */ 
  54. public function add_param( $name, $value ) { 
  55. $this->params[ $name ] = $value; 
  56.  
  57. /** 
  58. * Adding parameters in an array 
  59. *  
  60. * @param array $params an array of parameters with name as key and value 
  61. * @package Skip 
  62. * @since 1.0 
  63. * @return string The content of the element 
  64. */ 
  65. public function add_params( $params = array() ) { 
  66. if( 0 != count( $params ) ): 
  67. foreach( $params AS $name => $value ): 
  68. if( '' != $key && '' != $param ) 
  69. $this->add_param( $name, $value); 
  70. endforeach; 
  71. endif; 
  72.  
  73. /** 
  74. * Deleting parameter in an array 
  75. *  
  76. * @param string $name Name of the parameter to delete 
  77. * @package Skip 
  78. * @since 1.0 
  79. * @return string The content of the element 
  80. */ 
  81. public function del_param( $name ) { 
  82. unset( $this->params[ $name ] ); 
  83.  
  84. /** 
  85. * Render the content 
  86. * @package Skip 
  87. * @since 1.0 
  88. * @param string $content Content which will be added if close_tag is TRUE 
  89. * @return string The content of the element 
  90. */ 
  91. public function render() { 
  92. if( $this->close_tag ): 
  93.  
  94. if( count( $this->elements ) > 0 && '' == $this->content ) 
  95. foreach( $this->elements AS $element ) 
  96. $this->content.= display( $element ); 
  97.  
  98. if( $this->echo_tag ) 
  99. $html = '<' . $this->tag . $this->params() . '>' . $this->content . '</' . $this->tag . '>' . chr(13); 
  100. else 
  101. $html = $content; 
  102. else: 
  103. if( $this->echo_tag ) 
  104. $html = '<' . $this->tag . $this->params() . ' />' . chr(13); 
  105. else 
  106. $html = $this->content; 
  107. endif; 
  108.  
  109. $html_element = $this->before_element . $html . $this->after_element; 
  110. return $html_element; 
  111.  
  112. public function content( $content ) { 
  113. $this->content = $content; 
  114.  
  115. /** 
  116. * Returns the params 
  117. * @param array $params Parameters as array like $params[][ 'name' ] = VALUE 
  118. * @package Skip 
  119. * @since 1.0 
  120. * @return string The content of the element 
  121. */ 
  122. public function params( $params = FALSE ) { 
  123. $params_return = ''; 
  124.  
  125. if( FALSE === $params ) 
  126. $params = $this->params; 
  127.  
  128. if( count( $params ) > 0 ) 
  129. foreach( $params AS $param_name => $param ) 
  130. $params_return.= ' ' . $param_name . '="' . $param . '"'; 
  131.  
  132. return $params_return;