/** * Generate an HTML table for external libraries that are installed * * @return string */ protected function getExternalLibraries() { global $IP; $path = "{$IP}/vendor/composer/installed.json"; if (!file_exists($path)) { return ''; } $installed = new ComposerInstalled($path); $out = Html::element('h2', ['id' => 'mw-version-libraries'], $this->msg('version-libraries')->text()); $out .= Html::openElement('table', ['class' => 'wikitable plainlinks', 'id' => 'sv-libraries']); $out .= Html::openElement('tr') . Html::element('th', [], $this->msg('version-libraries-library')->text()) . Html::element('th', [], $this->msg('version-libraries-version')->text()) . Html::element('th', [], $this->msg('version-libraries-license')->text()) . Html::element('th', [], $this->msg('version-libraries-description')->text()) . Html::element('th', [], $this->msg('version-libraries-authors')->text()) . Html::closeElement('tr'); foreach ($installed->getInstalledDependencies() as $name => $info) { if (strpos($info['type'], 'mediawiki-') === 0) { // Skip any extensions or skins since they'll be listed // in their proper section continue; } $authors = array_map(function ($arr) { // If a homepage is set, link to it if (isset($arr['homepage'])) { return "[{$arr['homepage']} {$arr['name']}]"; } return $arr['name']; }, $info['authors']); $authors = $this->listAuthors($authors, false, "{$IP}/vendor/{$name}"); // We can safely assume that the libraries' names and descriptions // are written in English and aren't going to be translated, // so set appropriate lang and dir attributes $out .= Html::openElement('tr') . Html::rawElement('td', [], Linker::makeExternalLink("https://packagist.org/packages/{$name}", $name, true, '', ['class' => 'mw-version-library-name'])) . Html::element('td', ['dir' => 'auto'], $info['version']) . Html::element('td', ['dir' => 'auto'], $this->listToText($info['licenses'])) . Html::element('td', ['lang' => 'en', 'dir' => 'ltr'], $info['description']) . Html::rawElement('td', [], $authors) . Html::closeElement('tr'); } $out .= Html::closeElement('table'); return $out; }
protected function appendInstalledLibraries($property) { global $IP; $path = "{$IP}/vendor/composer/installed.json"; if (!file_exists($path)) { return true; } $data = array(); $installed = new ComposerInstalled($path); foreach ($installed->getInstalledDependencies() as $name => $info) { if (strpos($info['type'], 'mediawiki-') === 0) { // Skip any extensions or skins since they'll be listed // in their proper section continue; } $data[] = array('name' => $name, 'version' => $info['version']); } ApiResult::setIndexedTagName($data, 'library'); return $this->getResult()->addValue('query', $property, $data); }