예제 #1
0
 /**
  * Create a Columnator Object.
  * @param array $props This is the properties that the Columnator will use to display.
  * <pre>
  * $props = array ( 'attribs'          => 'array ( 'style' => 'display:none ), // Optional,
  *                                        // Attributes that will be stamped on the div that is generated
  *                                        // if not supplied will be empty array.
  *                                        // Need to supply if the primary key is not simple column name
  *                  'suffix'           => 'V', // Optional, suffix for the action variable for Columnator
  *                                        // useful when there is a numbner on the screen
  *                                        // if not supplied one will be generated based on the number of
  *                                        // Columnator that are generated
  *                  'request_vars'     => 'CEMID', // Optional, regexpression or individual name of any request
  *                                        //  vars that are to be copied to the response vars (chained vars)
  *                  'init_column'      => 'fldDate', // Optional, Initial Coloumn to be sorted
  *                  'init_order'       => 'DESC', // Optional, initial direction
  *                );
  * </pre>
  */
 public function __construct($props = [])
 {
     parent::__construct();
     $this->attribs = isset($props['attribs']) ? $props['attribs'] : [];
     $suffix = isset($props['suffix']) ? $props['suffix'] : Invocation::next();
     $this->navVar = self::navVar($suffix);
     $initPattern = isset($props['request_vars']) ? $props['request_vars'] : '';
     $this->respVars = new Response($initPattern);
     $initialVars = self::$columnation;
     $initialVars[self::SORT_COL] = isset($props['init_column']) ? $props['init_column'] : '';
     $initialVars[self::SORT_ORDER] = isset($props['init_order']) ? $props['init_order'] : '';
     // ensyre that they have been set
     $requestColumnVars = Request::get($this->navVar, []);
     foreach ($initialVars as $key => $val) {
         $this->set($key, isset($requestColumnVars[$key]) ? $requestColumnVars[$key] : $val);
     }
     // Get the current settings
     $this->sortColumn = $this->formVars[self::SORT_COL];
     $this->sortOrder = $this->formVars[self::SORT_ORDER];
     if (!isset($this->sortOrder) || $this->sortOrder == false || !in_array($this->sortOrder, ['ASC', 'DESC'])) {
         $this->sortOrder = 'ASC';
     }
     $this->styles[self::COL_LINK_CLASS] = 'jb-collink';
     $this->styles[self::COL_BUTTON_CLASS] = 'jb-colbutton';
 }
예제 #2
0
 /**
  * Create a Pagination Object.
  * @param array $props This is the properties that the Paginator will use to display.
  * <pre>
  * $props = array ( 'attribs'          => 'array ( 'style' => 'display:none ), // Optional,
  *                                        // Attributes that will be stamped on the div that is generated
  *                                        // if not supplied will be empty array.
  *                                        // Need to supply if the primary key is not simple column name
  *                  'suffix'           => 'V', // Optional, suffix for the action variable for paginator
  *                                        // useful when there is a numbner on the screen
  *                                        // if not supplied one will be generated based on the number of
  *                                        // paginators that are generated
  *                  'request_vars'     => 'CEMID', // Optional, regexpression or individual name of any request
  *                                        //  vars that are to be copied to the response vars (chained vars)
  *                  'display_pagesize' => true, // Optional defaults to true. If false the page sizes will not
  *                                        // be displayed
  *                  'rows'             => 100,  // Optional. Number of rows that the Paginator has to deal with
  *                                        // Based on this number and the number of rows per page, the number of
  *                                        // pages are calculated
  *                  'def_num_rows'     => 15,  // Optional. Number of rows default on this pagination
  *                );
  * </pre>
  */
 public function __construct($props = [])
 {
     parent::__construct();
     $this->attribs = isset($props['attribs']) ? $props['attribs'] : [];
     $suffix = isset($props['suffix']) ? $props['suffix'] : Invocation::next();
     $this->navVar = self::navVar($suffix);
     $initPattern = isset($props['request_vars']) ? $props['request_vars'] : '';
     $this->respVars = new Response($initPattern);
     $this->dispPageSize = isset($props['display_pagesize']) ? $props['display_pagesize'] : true;
     $defPagination = array_merge(self::$pagination);
     if (isset($props['def_num_rows'])) {
         $defPagination[self::ROWS_PER_PAGE] = $props['def_num_rows'];
     }
     if (!in_array($defPagination[self::ROWS_PER_PAGE], self::$itemsPerPageList)) {
         self::$itemsPerPageList[] = $defPagination[self::ROWS_PER_PAGE];
         sort(self::$itemsPerPageList);
     }
     // ensure that they have been set
     $requestPageVars = Request::get($this->navVar, []);
     foreach ($defPagination as $key => $val) {
         $this->set($key, isset($requestPageVars[$key]) ? $requestPageVars[$key] : $val);
     }
     if (isset($props['rows'])) {
         $this->setRows((int) $props['rows']);
     }
     $this->styles[self::PAGE_LINK_CLASS] = 'jb-pagelink';
     $this->styles[self::PAGE_BUTTON_CLASS] = 'jb-pagebuton';
     if ($this->getStart() > 0 && $this->getRows() < $this->getPageSize()) {
         $this->setStart(0);
     }
 }