Example #1
0
 /**
  * Extract column data from a row while trying
  * to keep everything in the same order as the
  * columns.  Generally, don't need to call this
  * method unless you are micro managing an export.
  *
  * @param mixed $row Can be an object, array or html_table_row (if this, then ensure proper cell ordering!)
  * @return array
  */
 public function extract_data($row)
 {
     if (is_object($row)) {
         $row = (array) $row;
     }
     $data = array();
     $columns = $this->get_columns(true);
     // Try our best with html_table_row
     if ($row instanceof html_table_row) {
         foreach ($row->cells as $cell) {
             if ($cell instanceof html_table_cell) {
                 $data[] = $cell->text;
             } else {
                 $data[] = $cell;
             }
         }
     } else {
         foreach ($columns as $key => $column) {
             if ($this->export instanceof mr_file_export and $this->export->is_exporting() and !$column->get_config()->export) {
                 unset($columns[$key]);
                 continue;
             }
             $cell = $column->get_cell($row);
             if ($cell instanceof html_table_cell) {
                 $data[] = $cell->text;
             } else {
                 $data[] = $cell;
             }
         }
     }
     // Make sure we return even number of columns
     if (count($data) < count($columns)) {
         $data = array_pad($data, count($columns), '');
     }
     return $data;
 }
Example #2
0
 /**
  * Determine if the report is currently exporting
  *
  * This method must be called after _init() because the
  * export is setup during _init().
  *
  * @return boolean
  */
 public function is_exporting()
 {
     if ($this->export instanceof mr_file_export and $this->export->is_exporting()) {
         return true;
     }
     return false;
 }
Example #3
0
 /**
  * Set the export instance
  *
  * This will set the limitfrom and limitnum
  * appropriately for exporting
  *
  * @param mr_file_export $export The export plugin
  * @return mr_html_paging
  */
 public function set_export($export)
 {
     if ($export->is_exporting()) {
         // Start from the beginning
         $this->page = 0;
         // Grab as many rows as the exporter can handle
         $this->perpage = $export->instance()->max_rows();
     }
     return $this;
 }