/** * @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 showFontCode(array &$fontcode) { $out = ""; global $wgOut; global $wgPieceOfCodeConfig; $this->_errors->clearError(); $fileInfo = $this->_storedCodes->getFile($fontcode['connection'], $fontcode['path'], $fontcode['revision']); $this->appendTOC($out); if ($fileInfo) { $tag = ''; if (!PieceOfCode::CheckSyntaxHighlightExtension($tag)) { $out .= "<br/>" . $this->_errors->getLastError(); } $filepath = $wgPieceOfCodeConfig['uploaddirectory'] . DIRECTORY_SEPARATOR . $fileInfo['upload_path']; $st = stat($filepath); $lang = $fileInfo['lang']; if ($st['size'] > $wgPieceOfCodeConfig['maxsize']['highlighting']) { $out .= "*" . $this->_errors->setLastError(wfMsg('poc-errmsg-large-highlight', $wgPieceOfCodeConfig['maxsize']['highlighting'])); $lang = "text"; } if ($st['size'] > $wgPieceOfCodeConfig['maxsize']['showing']) { $out .= "*" . $this->_errors->setLastError(wfMsg('poc-errmsg-large-show', $wgPieceOfCodeConfig['maxsize']['showing'])); $lang = "text"; } $out .= "<h2>{$fileInfo['connection']}: {$fileInfo['path']}:{$fontcode['revision']} </h2>"; $out .= "<div class=\"PieceOfCode_code\"><{$tag} lang=\"{$lang}\" line=\"GESHI_NORMAL_LINE_NUMBERS\" start=\"1\">"; $out .= file_get_contents($filepath, false, null, -1, $wgPieceOfCodeConfig['maxsize']['showing']); $out .= "</{$tag}></div>"; } else { if ($this->_errors->ok()) { $this->_errors->setLastError(wfMsg('poc-errmsg-no-fileinfo', $fontcode['connection'], $fontcode['path'], $fontcode['revision'])); } $out .= $this->_errors->getLastError(); } $out .= "<h2>" . wfMsg('poc-sinfo-links') . "</h2>\n"; $out .= "*[[Special:PieceOfCode|Back]]\n"; $wgOut->addWikiText($out); }