UIX Documentation
  • Namespace
  • Class
  • Tree

Namespaces

  • None
  • uix
    • data
    • ui
      • control

Classes

  • uix\data\data
  • uix\ui
  • uix\ui\box
  • uix\ui\control
  • uix\ui\control\autocomplete
  • uix\ui\control\button
  • uix\ui\control\checkbox
  • uix\ui\control\color
  • uix\ui\control\editor
  • uix\ui\control\email
  • uix\ui\control\file
  • uix\ui\control\hidden
  • uix\ui\control\number
  • uix\ui\control\post_relation
  • uix\ui\control\radio
  • uix\ui\control\select
  • uix\ui\control\separator
  • uix\ui\control\slider
  • uix\ui\control\template
  • uix\ui\control\text
  • uix\ui\control\textarea
  • uix\ui\control\toggle
  • uix\ui\footer
  • uix\ui\grid
  • uix\ui\header
  • uix\ui\help
  • uix\ui\metabox
  • uix\ui\modal
  • uix\ui\notice
  • uix\ui\page
  • uix\ui\panel
  • uix\ui\post_type
  • uix\ui\repeat
  • uix\ui\section
  • uix\ui\uix

Interfaces

  • uix\data\load
  • uix\data\save

Functions

  • uix
  • uix_autoload_class
  1 <?php
  2 /**
  3  * UIX Grid
  4  *
  5  * @package   ui
  6  * @author    David Cramer
  7  * @license   GPL-2.0+
  8  * @link
  9  * @copyright 2016 David Cramer
 10  */
 11 namespace uix\ui;
 12 
 13 /**
 14  * A Grid system for layout control
 15  *
 16  * @since 1.0.0
 17  * @see \uix\uix
 18  */
 19 class grid extends section {
 20 
 21     /**
 22      * The type of object
 23      *
 24      * @since 1.0.0
 25      * @access public
 26      * @var      string
 27      */
 28     public $type = 'grid';
 29 
 30     /**
 31      * List of attributes to apply to the wrapper element
 32      *
 33      * @since 1.0.0
 34      * @access public
 35      * @var array
 36      */
 37     public $attributes = array( 'class' => 'uix-grid' );
 38 
 39 
 40     /**
 41      * Set the grid params
 42      *
 43      * @since 1.0.0
 44      * @access public
 45      * @return string|null HTML of rendered notice
 46      */
 47     public function setup(){
 48 
 49         if( !empty( $this->struct['row'] ) )
 50             $this->struct['grid'] = $this->struct['row'];
 51 
 52         if( !empty( $this->struct['column'] ) )
 53             $this->struct['grid'] = $this->struct['column'];
 54 
 55         parent::setup();
 56 
 57     }
 58 
 59     /**
 60      * Get Data from all controls of this section
 61      *
 62      * @since 1.0.0
 63      * @see \uix\load
 64      * @return array Array of sections data structured by the controls
 65      */
 66     public function get_data(){
 67         $data = array();
 68         if( !empty( $this->child ) ){
 69             foreach( $this->child as $child ) {
 70                 if( null !== $child->get_data() )
 71                     $data += $child->get_data();
 72             }
 73         }
 74 
 75         if( empty( $data ) )
 76             $data = null;
 77 
 78         return $data;
 79     }
 80 
 81     /**
 82      * Get Data from all controls of this section
 83      *
 84      * @since 1.0.0
 85      * @see \uix\load
 86      * @return array Array of sections data structured by the controls
 87      */
 88     public function is_row_column(){
 89         return !empty( $this->struct['row'] ) || !empty( $this->struct['column'] );
 90     }
 91 
 92     /**
 93      * Sets the wrappers attributes
 94      *
 95      * @since 1.0.0
 96      * @access public
 97      */
 98     public function set_attributes(){
 99 
100         if( !empty( $this->struct['column'] ) )
101             $this->attributes['class'] = 'row';
102 
103         if( !empty( $this->struct['size'] ) )
104             $this->attributes['class'] = $this->struct['size'];
105 
106         parent::set_attributes();
107     }
108 
109     /**
110      * Render the complete section
111      *
112      * @since 1.0.0
113      * @access public
114      * @return string|null HTML of rendered notice
115      */
116     public function render(){
117 
118         $output = '<div ' . $this->build_attributes() . '>';
119         $output .= $this->render_children();
120         $output .= '</div>';
121 
122         return $output;
123     }
124 
125     /**
126      * Define core header styles
127      *
128      * @since 1.0.0
129      * @access public
130      */
131     public function set_assets() {
132 
133         $this->assets['style']['grid'] =  $this->url . 'assets/css/grid' . UIX_ASSET_DEBUG . '.css';
134 
135         parent::set_assets();
136     }
137 
138 }
UIX Documentation API documentation generated by ApiGen