/** * @todo doc * @return @todo doc */ public function show() { $out = ""; if ($this->_fileInfo) { global $wgPieceOfCodeConfig; global $wgParser; $tag = ''; if (!PieceOfCode::CheckSyntaxHighlightExtension($tag)) { $out .= $this->_errors->getLastError(); } $upload_path = $wgPieceOfCodeConfig['uploaddirectory'] . DIRECTORY_SEPARATOR . $this->_fileInfo['upload_path']; $out .= "<div class=\"PieceOfCode_code\">\n"; if ($this->_showTitle) { $auxUrl = Title::makeTitle(NS_SPECIAL, 'PieceOfCode')->escapeFullURL("action=show&connection={$this->_connection}&path={$this->_filename}&revision={$this->_revision}"); $out .= "<span class=\"PieceOfCode_title\"><a href=\"{$auxUrl}\"><strong>{$this->_connection}></strong>{$this->_filename}:{$this->_revision}</a></span>"; } $auxCount = count($this->_lines); if ($auxCount) { foreach ($this->_lines as $l) { $auxCount--; $auxOut = "<{$tag} lang=\"{$this->_fileInfo['lang']}\" line=\"GESHI_NORMAL_LINE_NUMBERS\" start=\"{$l[0]}\"" . ($this->_highlightLines ? " highlight=\"{$this->_highlightLines}\"" : "") . ">"; $file = file($upload_path); for ($i = $l[0] - 1; $i < $l[1]; $i++) { if (isset($file[$i])) { $auxOut .= $file[$i]; } } $auxOut .= "</{$tag}>"; $out .= $wgParser->recursiveTagParse($auxOut); if ($this->_separator && $auxCount > 0) { $out .= html_entity_decode($this->_separator); } } } else { $st = stat($upload_path); if ($st['size'] > $wgPieceOfCodeConfig['maxsize']['showing']) { $out .= $this->_errors->setLastError(wfMsg('poc-errmsg-large-showall', $wgPieceOfCodeConfig['maxsize']['showing'])); $out .= "<pre>"; $out .= htmlentities(file_get_contents($upload_path)); $out .= "</pre>"; } else { $lang = $this->_fileInfo['lang']; if ($st['size'] > $wgPieceOfCodeConfig['maxsize']['highlighting']) { $out .= $this->_errors->setLastError(wfMsg('poc-errmsg-large-highlight', $wgPieceOfCodeConfig['maxsize']['highlighting'])); $lang = "text"; } $auxOut = "<{$tag} lang=\"{$lang}\" line=\"GESHI_NORMAL_LINE_NUMBERS\" start=\"1\">"; $auxOut .= file_get_contents($upload_path); $auxOut .= "</{$tag}>"; $out .= $wgParser->recursiveTagParse($auxOut); } } $out .= "</div>\n"; } return $out; }
/** * @todo doc * @param $fontcode Is the list of parameter gotten from URL. */ protected function statPagesByCode(array &$fontcode) { global $wgOut; global $wgPieceOfCodeConfig; if ($wgPieceOfCodeConfig['stats']) { $out = ""; $code = POCStoredCodes::Instance()->getByCode($fontcode['code']); if ($this->_errors->ok()) { $this->appendTOC($out); $out .= "== " . wfMsg('poc-sinfo-information') . " ==\n"; $out .= "*'''" . wfMsg('poc-sinfo-connection') . "''': {$code['connection']}\n"; $out .= "*'''" . wfMsg('poc-sinfo-path') . "''': {$code['path']}\n"; $out .= "*'''" . wfMsg('poc-sinfo-revision') . "''': {$code['revision']}\n"; $out .= "*'''" . wfMsg('poc-sinfo-lang') . "''': {$code['lang']}\n"; $auxUrl = Title::makeTitle(NS_USER, $code['user'])->getFullURL(); $out .= "*'''" . wfMsg('poc-sinfo-user') . "''': [[User:{$code['user']}|{$code['user']}]]\n"; $auxUrl = Title::makeTitle(NS_SPECIAL, 'PieceOfCode')->escapeFullURL("action=show&connection={$code['connection']}&path={$code['path']}&revision={$code['revision']}"); $out .= "*[{$auxUrl} " . wfMsg('poc-view-source') . "]\n"; $out .= "== " . wfMsg('poc-sinfo-usage') . " ==\n"; $out .= "{|class=\"wikitable sortable\"\n"; $out .= "|-\n"; $out .= "!" . wfMsg('poc-sinfo-page') . "\n"; $out .= "!" . wfMsg('poc-sinfo-stored-codes-count') . "\n"; $out .= "!" . wfMsg('poc-sinfo-stored-codes-user') . "\n"; foreach (POCStats::Instance()->getCodePages($fontcode['code']) as $c) { $out .= "|-\n"; $auxPage = Title::newFromID($c['page_id']); $title = $c['title']; /* * Checking if it isn't the default namesapace. */ if ($auxPage->getNamespace() != NS_MAIN) { $title = $auxPage->getNsText() . $title; } $out .= "|[[{$title}]]\n"; $out .= "|{$c['times']}\n"; $out .= "|[[User:{$c['last_user']}|{$c['last_user']}]]\n"; } $out .= "|}\n"; $out .= "== " . wfMsg('poc-sinfo-history') . " ==\n"; $out .= "{|class=\"wikitable\"\n"; $out .= "|-\n"; $out .= "!" . wfMsg('poc-sinfo-stored-codes-action') . "\n"; $out .= "!" . wfMsg('poc-sinfo-stored-codes-user') . "\n"; $out .= "!" . wfMsg('poc-sinfo-stored-codes-description') . "\n"; $out .= "!" . wfMsg('poc-sinfo-stored-codes-timestamp') . "\n"; foreach ($this->_history->getHistory($fontcode['code']) as $h) { $out .= "|-\n"; $out .= "|" . wfMsg('poc-sinfo-history-' . $h['action']) . "\n"; $out .= "|[[User:{$h['user']}|{$h['user']}]]\n"; $out .= "|{$h['description']}\n"; $out .= "|{$h['timestamp']}\n"; } $out .= "|}\n"; $out .= "== " . wfMsg('poc-sinfo-links') . " ==\n"; $out .= "*[[Special:PieceOfCode|Back]]\n"; } else { $out .= $this->_errors->getLastError(); } $wgOut->addWikiText($out); } else { $wgOut->addHTML($this->_errors->setLastError(wfMsg('poc-errmsg-stats-disabled'))); } }