protected function set_up($args)
 {
     $db = new Database($this->wpdb);
     $this->table = $db->get_table($args['table']);
     // Check that a point column exists.
     $points = $this->table->get_columns('point');
     if (empty($points)) {
         // @TODO Show error.
         return;
     }
     $point_col = array_shift($points);
     $this->point_col_name = $point_col->get_name();
     // Apply filters.
     $filter_param = isset($args['filter']) ? $args['filter'] : array();
     $this->table->add_filters($filter_param);
     $this->table->add_filter($this->point_col_name, 'not empty', '');
 }
 /**
  * Get a set of results for Foreign Key lookups.
  * @param \WordPress\Tabulate\DB\Table $table    The table to search.
  * @param string                       $operator One of the permitted filter operators.
  * @param string                       $term     The search term.
  * @return string[]
  */
 protected function foreign_key_values_build($table, $operator, $term)
 {
     $table->reset_filters();
     $table->add_filter($table->get_title_column(), $operator, $term);
     $out = array();
     foreach ($table->get_records() as $record) {
         $out[$record->get_primary_key()] = array('value' => $record->get_primary_key(), 'label' => $record->get_title());
     }
     return $out;
 }
Example #3
0
 /**
  * Get a list of records that reference this record in one of their columns.
  *
  * @param string|\WordPress\Tabulate\DB\Table $foreign_table
  * @param string|\WordPress\Tabulate\DB\Column $foreign_column
  * @param boolean $with_pagination Whether to only return the top N records.
  * @return \WordPress\Tabulate\DB\Record[]
  */
 public function get_referencing_records($foreign_table, $foreign_column, $with_pagination = true)
 {
     $foreign_table->reset_filters();
     $foreign_table->add_filter($foreign_column, '=', $this->get_primary_key(), true);
     return $foreign_table->get_records($with_pagination);
 }