public function showTable($opts = false) { global $zdb_action; if (is_array($opts)) { extract($opts); } if (!$view) { $view = $_REQUEST['view']; } if ($this->_gridEdit == true) { $ajax = true; } if (isset($_REQUEST['row'])) { $row = $_REQUEST['row']; $date_range = $this->rowToDateRange($row, $view); $filters['dates'] = " from " . $date_range['date_starting'] . " to " . $date_range['date_ending']; } $limit_chapter = $this->limitChapterSql(); $sql = " SELECT {$this->_table}.* "; $sql .= $limit_chapter['select']; $sql .= " FROM {$this->_table} "; $sql .= $limit_chapter['join']; $sql .= $join; $sql .= " WHERE 1"; $sql .= $limit_chapter['where']; $sql .= $date_range['where']; $sql .= $this->_where; if ($where) { $sql .= $where; } if ($this->_dateField) { $sql .= " ORDER BY {$this->_dateField} DESC "; } $this->_tableSql = $sql; if ($sql_only) { return $sql; } $browse = new browse($sql, array("db" => $this->_db, "rows" => 100)); foreach ($_GET as $f => $v) { $browse->add_var("&{$f}={$v}"); } if (is_object($this->_dbo)) { $rows = $this->_dbo->fetchAll($browse->sql); } else { $rows = $zdb_action->fetchAll($browse->sql); } // Backwards compatibility for GreenpeaceUSA. JB 10/7/08 4:30 PM if (is_array($this->hidefields)) { $hidefields = $this->hidefields; } elseif (is_array($this->_hiddenFields)) { $hidefields = $this->_hiddenFields; } else { $hidefields = array(); } // Activate some graphing variables. $graphf = array(); $data = array(); $i = 0; if (!$this->_tableTitle) { $this->_tableTitle = camelcap($this->_table); } if (is_array($limit_chapter)) { $chapter_id = $limit_chapter[chapter_id]; $chapter_name = Chapter::get_name($chapter_id); $filters[chapter] = " in chapter {$chapter_name} "; } if ($num = count($rows)) { ?> <div>Showing <b><?php echo $num; ?> </b> <?php echo $this->_tableTitle; ?> s <?php if (is_array($limit_chapter)) { ?> for chapter <b><?php echo $chapter_name; ?> </b> <?php } ?> .</div> <?php echo $browse->show_nav_lite(); ?> <table class="list"><?php foreach ($rows as $row) { $i++; $i % 2 ? $row_class = "odd" : ($row_class = "even"); extract($row); if ($i == 1) { // do header row ?> <tr class="reverse"> <td>Action</td> <?php foreach ($row as $f => $v) { if (!in_array($f, $hidefields)) { ?> <td><?php echo camelcap($f); ?> </td> <?php } } ?> </tr> <?php } if ($ajax) { if (is_array($this->_idField)) { $ajax = false; } else { $this->loadRecord($row[$this->_idField]); } } ?> <tr class="<?php echo $row_class; ?> "> <td nowrap> <?php $this->adminActionCell($row); ?> </td> <?php foreach ($row as $f => $v) { if (!in_array($f, $hidefields)) { // Deal with fields that have relationships defined to other tables via phpmyadmin. if ($related = $this->tbl[$f][rel]) { $obj = DBOS::factory($this->tbl[$f][rel][foreign_table], $v); if (is_object($obj)) { $v = $obj->summary_link(); } } if ($f == $graphf[0]) { $data[$i - 1][label] = $v; } if ($f == $graphf[1]) { $data[$i - 1][point] = $v; } ?> <td> <?php if (!$ajax || $related || $this->tbl[$f][type] == "timestamp") { ?> <?php echo $v; ?> <?php } else { $ajaxable = $this->ajaxField($f, array("raw" => true, "gridedit" => true)); if ($ajaxable === false) { echo $v; } } ?> </td> <?php } ?> <?php } ?> </tr> <?php } ?> </table> <center><?php $browse->show_nav(); ?> </center> <?php if (count($data)) { $g = new ACGraph($data); $g->render(); } } else { ?> <p id="noRecordsFound"><?php if ($this->_noRecordsMessage) { echo $this->_noRecordsMessage; } else { ?> No records found in <?php echo $this->_tableTitle; ?> table <?php } ?> </p><?php } if (is_array($filters)) { ?> <br /> for filters:<br /><?php echo implode(",<br />", $filters); } ?> <div class="table_debug_info" style="display:none;"><?php da($sql); ?> </div><?php }