function execute($par)
 {
     global $wgOut, $wgUser;
     // Check permissions
     if (!$this->userCanExecute($wgUser)) {
         $this->displayRestrictionError();
         return;
     }
     $this->setHeaders();
     $this->setDefaults();
     $wgOut->addScript('<script type="text/javascript">' . "var wgClickTrackUserDefs = " . json_encode($this->user_defs) . '</script>');
     $wgOut->setPageTitle(wfMsg('ct-title'));
     $outputTable = "";
     // grab top N
     $events = $this->getTopEvents();
     // open table
     $outputTable .= Xml::openElement("table", array("class" => "sortable click-data", "id" => "clicktrack_data_table"));
     // create a row for every event
     $i = 0;
     $db_result;
     // build row headers
     $header_row = array();
     $header_row["event_header"] = wfMsg('ct-event-name');
     $header_row["expert_header"] = wfMsg('ct-expert-header');
     $header_row["intermediate_header"] = wfMsg('ct-intermediate-header');
     $header_row["basic_header"] = wfMsg('ct-beginner-header');
     $header_row["total_header"] = wfMsg('ct-total-header');
     $outputTable .= Xml::buildTableRow(array("class" => "table_headers"), $header_row);
     // foreach event, build a row
     while (($db_result = $events->fetchRow()) != null) {
         ++$i;
         $outputTable .= $this->buildRow($db_result, $i, $this->user_defs);
     }
     // close table
     $outputTable .= Xml::closeElement("table");
     $wgOut->addHTML($outputTable);
     $wgOut->addHTML($this->buildDateRange());
     // build chart
     $wgOut->addHTML($this->buildChart("advanced.hide", 10, "20090815", "20090902", 1));
     // $wgOut->addHTML($this->buildControlBox());
     $wgOut->addHTML($this->buildChartDialog());
     $wgOut->addHTML($this->buildUserDefBlankDialog());
 }
示例#2
0
文件: Xml.php 项目: whysasse/kmwiki
 /**
  * Build a table of data
  * @param array $rows An array of arrays of strings, each to be a row in a table
  * @param array $attribs An array of attributes to apply to the table tag [optional]
  * @param array $headers An array of strings to use as table headers [optional]
  * @return string
  */
 public static function buildTable($rows, $attribs = array(), $headers = null)
 {
     $s = Xml::openElement('table', $attribs);
     if (is_array($headers)) {
         $s .= Xml::openElement('thead', $attribs);
         foreach ($headers as $id => $header) {
             $attribs = array();
             if (is_string($id)) {
                 $attribs['id'] = $id;
             }
             $s .= Xml::element('th', $attribs, $header);
         }
         $s .= Xml::closeElement('thead');
     }
     foreach ($rows as $id => $row) {
         $attribs = array();
         if (is_string($id)) {
             $attribs['id'] = $id;
         }
         $s .= Xml::buildTableRow($attribs, $row);
     }
     $s .= Xml::closeElement('table');
     return $s;
 }