Commit 06d17296 authored by remy's avatar remy
Browse files

fix: R/Bioconductor was not working anymore

parent fd129d2b
Pipeline #317 failed with stage
in 1 minute and 3 seconds
...@@ -51,6 +51,8 @@ if(isset($_GET['limit'])) { ...@@ -51,6 +51,8 @@ if(isset($_GET['limit'])) {
} }
$result = array(); $result = array();
$version_num = "";
$version_name = "";
if(strpos($distrib, ':') !== false) { if(strpos($distrib, ':') !== false) {
$os = explode (":", $distrib); $os = explode (":", $distrib);
...@@ -146,4 +148,4 @@ foreach ($result as $t) { ...@@ -146,4 +148,4 @@ foreach ($result as $t) {
echo '</tr> echo '</tr>
</tbody> </tbody>
</table> </table>
'; ';
\ No newline at end of file
...@@ -41,8 +41,10 @@ function getDocument($url) { ...@@ -41,8 +41,10 @@ function getDocument($url) {
$context = stream_context_create($opts); $context = stream_context_create($opts);
$content = file_get_contents($url, false, $context); $content = file_get_contents($url, false, $context);
$doc = new DOMDocument(); $doc = new \DOMDocument('1.0', 'UTF-8');
$internalErrors = libxml_use_internal_errors(true);
$doc->loadHtml($content); $doc->loadHtml($content);
libxml_use_internal_errors($internalErrors);
return $doc; return $doc;
} }
...@@ -406,7 +408,7 @@ function findRPackage($os_name, $version_num, $version_name, $keyword, $limit, $ ...@@ -406,7 +408,7 @@ function findRPackage($os_name, $version_num, $version_name, $keyword, $limit, $
$url_packages = "https://www.bioconductor.org/packages/release/bioc/"; $url_packages = "https://www.bioconductor.org/packages/release/bioc/";
$doc = getDocument($url_packages); $doc = getDocument($url_packages);
$trs = $doc->getElementsByTagName('tr'); $trs = $doc->getElementsByTagName('tr');
$size = $trs->length - 1; $size = $trs->length - 1;
...@@ -414,21 +416,15 @@ function findRPackage($os_name, $version_num, $version_name, $keyword, $limit, $ ...@@ -414,21 +416,15 @@ function findRPackage($os_name, $version_num, $version_name, $keyword, $limit, $
$index = 0; $index = 0;
for ($i = 1; $i <= $size; $i++) { for ($i = 1; $i <= $size; $i++) {
$name = $trs[$i]->childNodes[1]->nodeValue; $name = $trs[$i]->getElementsByTagName('td')[0]->nodeValue;
if(strpos($name, $keyword) !== false) { if(strpos($name, $keyword) !== false) {
$description = $trs[$i]->getElementsByTagName('td')[2]->nodeValue;
$description = $trs[$i]->childNodes[5]->nodeValue;
$version = ""; $version = "";
$link = "https://www.bioconductor.org/packages/release/bioc/html/".$name.".html"; $link = "https://www.bioconductor.org/packages/release/bioc/html/".$name.".html";
$other = $trs[$i]->getElementsByTagName('td')[1]->nodeValue;
$other = $trs[$i]->childNodes[3]->nodeValue;
$package = new Package($name, $version, $description, $link, $other); $package = new Package($name, $version, $description, $link, $other);
$results[] = $package; $results[] = $package;
$index++; $index++;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment