예제 #1
0
 public function index()
 {
     $template = new \WordPress\Tabulate\Template('home.html');
     $db = new \WordPress\Tabulate\DB\Database($this->wpdb);
     $template->tables = $db->get_tables();
     $template->views = $db->get_views();
     return $template->render();
 }
예제 #2
0
 public function __construct($wpdb)
 {
     parent::__construct($wpdb);
     $db = new \WordPress\Tabulate\DB\Database($this->wpdb);
     $this->selected_tables = array();
     foreach ($db->get_tables() as $table) {
         $this->tables[] = $table;
         // If any tables are requested, only show them
         if (isset($_GET['tables']) && count($_GET['tables']) > 0) {
             if (isset($_GET['tables'][$table->get_name()])) {
                 $this->selected_tables[$table->get_name()] = $table;
             }
         } else {
             // Otherwise, default to all linked tables
             $referenced = count($table->get_referencing_tables()) > 0;
             $referencing = count($table->get_referenced_tables()) > 0;
             if ($referenced || $referencing) {
                 $this->selected_tables[$table->get_name()] = $table;
             }
         }
     }
 }
예제 #3
0
 public function index()
 {
     $template = new \WordPress\Tabulate\Template('home.html');
     $template->title = 'Tabulate';
     $db = new \WordPress\Tabulate\DB\Database($this->wpdb);
     // Tables.
     $transient_name = TABULATE_SLUG . 'home_table_list';
     $table_info = get_transient($transient_name);
     if (!$table_info) {
         $table_info = array();
         foreach ($db->get_tables() as $table) {
             $table_info[] = array('title' => $table->get_title(), 'count' => $table->count_records(), 'url' => $table->get_url());
         }
         set_transient($transient_name, $table_info, MINUTE_IN_SECONDS * 5);
     }
     $template->tables = $table_info;
     // Views.
     $template->views = $db->get_views();
     // Reports.
     $reports_table = $db->get_table(\WordPress\Tabulate\DB\Reports::reports_table_name());
     $template->reports = $reports_table ? $reports_table->get_records(false) : array();
     return $template->render();
 }