/** * print a numeric data cell * * @param string $data * @param int $span * @param bool $number */ private function cell($data = '', $span = 1, $number = true) { if ($number) { if (!$data) { $data = 0; } $align = 'right'; } else { $align = null; } $this->R->tablecell_open($span, $align); $this->R->cdata($data); $this->R->tablecell_close(); }
/** * Renders activity report to the page * @param string $mode Name of the format mode * @param Doku_Renderer $renderer ref to the Doku_Renderer * @param array $params Parameter object returned by handle() */ function renderActivityByNamespaceReport($mode, Doku_Renderer $renderer, $params) { global $CHUNKPROGRESS_STATUS_TAGS; $renderer->table_open(); $renderer->tablerow_open(); $renderer->tablecell_open(); $renderer->strong_open(); $renderer->unformatted("Namespace"); $renderer->strong_close(); $renderer->tablecell_close(); foreach ($CHUNKPROGRESS_STATUS_TAGS as $status) { $renderer->tablecell_open(); $renderer->strong_open(); $renderer->unformatted($status); $renderer->strong_close(); $renderer->tablecell_close(); } $renderer->tablerow_close(); $count_by_sub_namespace_then_status = $params["count_by_sub_namespace_then_status"]; foreach ($count_by_sub_namespace_then_status as $sub_namespace => $statuses) { $renderer->tablerow_open(); $renderer->tablecell_open(); $renderer->unformatted($sub_namespace); $renderer->tablecell_close(); foreach ($CHUNKPROGRESS_STATUS_TAGS as $status) { $renderer->tablecell_open(); if (array_key_exists($status, $statuses)) { $renderer->unformatted($statuses[$status]); } $renderer->tablecell_close(); } $renderer->tablerow_close(); } $renderer->table_close(); }
/** * Create output */ function render($mode, Doku_Renderer &$renderer, $opt) { if ($mode == 'metadata') { return false; } // load file data if ($opt['file']) { if (preg_match('/^https?:\\/\\//i', $opt['file'])) { require_once DOKU_INC . 'inc/HTTPClient.php'; $http = new DokuHTTPClient(); $opt['content'] = $http->get($opt['file']); if ($opt['content'] === false) { $renderer->cdata('Failed to fetch remote CSV data'); return true; } } else { $renderer->info['cache'] = false; if (auth_quickaclcheck(getNS($opt['file']) . ':*') < AUTH_READ) { $renderer->cdata('Access denied to CSV data'); return true; } else { $file = mediaFN($opt['file']); $opt['content'] = io_readFile($file); } } // if not valid UTF-8 is given we assume ISO-8859-1 if (!utf8_check($opt['content'])) { $opt['content'] = utf8_encode($opt['content']); } } // check if there is content $content =& $opt['content']; $content = trim($content); if ($content === '') { $renderer->cdata('No csv data found'); return true; } // Export the csv file $targetfile = ''; $export = $opt['export']; if ($export != '') { $targetfile = htmlspecialchars(trim($export)); if (auth_quickaclcheck(getNS($targetfile . ':*')) < AUTH_EDIT) { $renderer->cdata('Access denied: Could not create download link.'); $targetfile = ''; return true; } else { $file = mediaFN($targetfile); if (file_put_contents($file, $content, LOCK_EX) > 0) { $linkname = $opt['linkname']; if ($linkname == '') { $linkname = 'Download CSV file'; } } else { $targetfile = ''; $renderer->cdata('Failed to write ' . $file . ': Could not create download link.'); return true; } } } // get the first row - it will define the structure $row = $this->csv_explode_row($content, $opt['delim'], $opt['enclosure'], $opt['escape']); $maxcol = count($row); $line = 0; // create the table and start rendering $renderer->table_open($maxcol); while ($row !== false) { // make sure we have enough columns $row = array_pad($row, $maxcol, ''); // render $renderer->tablerow_open(); for ($i = 0; $i < $maxcol;) { $span = 1; // lookahead to find spanning cells if ($opt['span_empty_cols']) { for ($j = $i + 1; $j < $maxcol; $j++) { if ($row[$j] === '') { $span++; } else { break; } } } // open cell if ($line < $opt['hdr_rows'] || $i < $opt['hdr_cols']) { $renderer->tableheader_open($span); } else { $renderer->tablecell_open($span); } // print cell content, call linebreak() for newlines $lines = explode("\n", $row[$i]); $cnt = count($lines); for ($k = 0; $k < $cnt; $k++) { $renderer->cdata($lines[$k]); if ($k < $cnt - 1) { $renderer->linebreak(); } } // close cell if ($line < $opt['hdr_rows'] || $i < $opt['hdr_cols']) { $renderer->tableheader_close(); } else { $renderer->tablecell_close(); } $i += $span; } $renderer->tablerow_close(); // get next row $row = $this->csv_explode_row($content, $opt['delim'], $opt['enclosure'], $opt['escape']); $line++; } $renderer->table_close(); if ($targetfile != '') { $renderer->internalmedia($targetfile, $linkname); } return true; }
/** * @param string $mode Name of the format mode * @param Doku_Renderer $renderer ref to the Doku_Renderer * @param array $params Parameter object returned by handle() */ function renderActivityByUserReport($mode, Doku_Renderer $renderer, $params) { global $CHUNKPROGRESS_STATUS_TAGS; $renderer->table_open(); $renderer->tablerow_open(); $renderer->tablecell_open(); $renderer->strong_open(); $renderer->unformatted("User"); $renderer->strong_close(); $renderer->tablecell_close(); foreach ($CHUNKPROGRESS_STATUS_TAGS as $status) { $renderer->tablecell_open(); $renderer->strong_open(); $renderer->unformatted($status); $renderer->strong_close(); $renderer->tablecell_close(); } $renderer->tablerow_close(); $user_status_count = $params["user_status_count"]; foreach ($user_status_count as $user => $statuses) { $renderer->tablerow_open(); $renderer->tablecell_open(); $renderer->unformatted($user); $renderer->tablecell_close(); foreach ($CHUNKPROGRESS_STATUS_TAGS as $status) { $renderer->tablecell_open(); if (array_key_exists($status, $statuses)) { $renderer->unformatted($statuses[$status]); } $renderer->tablecell_close(); } $renderer->tablerow_close(); } $renderer->table_close(); }
/** * After value in listitem * * @param Doku_Renderer $R */ protected function after_val(Doku_Renderer $R) { switch ($R->getFormat()) { case 'xhtml': $R->doc .= '</td>'; break; case 'odt': $R->p_close(); $R->tablecell_close(); break; } }
/** * Create an empty table * * @param array $data instruction by handler() * @param array $clist keys of the columns * @param Doku_Renderer $R */ function nullList($data, $clist, $R) { $R->doc .= $this->preList($clist, $data); $R->tablerow_open(); $R->tablecell_open(count($clist), 'center'); $R->cdata($this->getLang('none')); $R->tablecell_close(); $R->tablerow_close(); $R->doc .= '</table></div>'; }