/** * @todo doc * @param $connInfo @todo doc * @param $fileInfo @todo doc * @return @todo doc */ protected function getSVNFile(&$connInfo, &$fileInfo) { $out = false; global $wgPieceOfCodeConfig; /* * Calculation full-path to the font-code file. */ $filepath = $wgPieceOfCodeConfig['uploaddirectory'] . DIRECTORY_SEPARATOR . $fileInfo['upload_path']; /* * If it's not available, it tries to download it. */ if (!is_readable($filepath)) { /* * Building SVN comand. */ $command = $wgPieceOfCodeConfig['svn-binary'] . " "; $command .= "cat "; $command .= "\"{$connInfo['url']}{$fileInfo['path']}\" "; $command .= "-r{$fileInfo['revision']} "; if (isset($connInfo['username'])) { $command .= "--username {$connInfo['username']} "; } if (isset($connInfo['password'])) { $command .= "--password {$connInfo['password']} "; } $command .= "> \"{$filepath}\""; /* * Attemting to download it running a SVN command. */ passthru($command, $error); if (!$error && is_readable($filepath)) { $this->_history->newSVNCode($fileInfo['code'], "Downloading file {$fileInfo['path']}:{$fileInfo['revision']} from SVN."); $out = true; } elseif ($error && is_readable($filepath)) { unlink($filepath); } elseif (is_readable($filepath)) { $this->_errors->setLastError(wfMsg('poc-errmsg-svn-no-file', $filepath)); } } else { $this->_errors->setLastError(wfMsg('poc-errmsg-svn-file-exist', $filepath)); } 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'))); } }
/** * @return Returns the singleton instance of this class * POCHistoryManager. */ public static function Instance() { if (!isset(self::$_Instance)) { $c = __CLASS__; self::$_Instance = new $c(); } return self::$_Instance; }