skipv1_0_0Select

The Facebook Fanpage Import skip v1 0 Select class.

Defined (1)

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

/includes/skip/elements/forms/select.php  
  1. class Select extends Form_Element{ 
  2. /** 
  3. * Constructor 
  4. * @since 1.0 
  5. * @param string $name Name of Color field. 
  6. * @param array/string $args List of Arguments. 
  7. */ 
  8. function __construct( $name, $label = FALSE, $args = array() ) { 
  9. $defaults = array( 
  10. 'size' => '',  
  11. 'multiselect' => FALSE,  
  12. ); 
  13.  
  14. $args = wp_parse_args( $args, $defaults ); 
  15.  
  16. $args[ 'label' ] = $label; 
  17. $args[ 'close_tag' ] = TRUE; 
  18.  
  19. parent::__construct( 'select', $name, $args ); 
  20.  
  21. if( '' != $args[ 'size' ] ) 
  22. $this->add_param( 'size', $args[ 'size' ] ); 
  23.  
  24. if( $args[ 'multiselect' ] ) 
  25. $this->add_param( 'multiple', 'multiple' ); 
  26.  
  27. /** 
  28. * Adding element 
  29. *  
  30. * Adds an option to the select field. 
  31. *  
  32. * <code> 
  33. * $element = array( 
  34. * 'label' => 'Option 1',  
  35. * 'value' => 1 
  36. * ); 
  37. * </code> 
  38. * Example for an element which can be added.  
  39. *  
  40. * @since 1.0 
  41. * @param array/string $element The element 
  42. */ 
  43. public function add_element( $element = array() ) { 
  44. $defaults = array( 
  45. 'id' => id(),  
  46. 'value' => '',  
  47. 'label' => $element['value'],  
  48. 'disabled' => FALSE,  
  49. 'params' => array() 
  50. ); 
  51.  
  52. $element = wp_parse_args( $element, $defaults ); 
  53.  
  54. if( !$element['disabled'] ) 
  55. unset( $element['disabled'] ); 
  56.  
  57. parent::add_element( $element ); 
  58.  
  59. /** 
  60. * Rendering Select field 
  61. * @package Skip 
  62. * @since 1.0 
  63. * @return string $html Returns The HTML Code. 
  64. */  
  65. public function render() { 
  66. $this->content = ''; 
  67.  
  68. foreach( $this->elements AS $element ): 
  69. $params = $element['params']; 
  70. unset( $element['params'] ); 
  71.  
  72. $label = $element['label']; 
  73. unset( $element['label'] ); 
  74.  
  75. $params = array_merge( $element, $params ); 
  76.  
  77. if( $params[ 'value' ] == $this->value ) 
  78. $params[ 'selected' ] = 'selected'; 
  79.  
  80. $this->content.= '<option' . $this->params( $params ) . '>' . $label . '</option>'; 
  81. endforeach; 
  82.  
  83. return parent::render(); 
  84. }