getPackages.php 3.66 KB
Newer Older
jlopez's avatar
jlopez committed
1
2
3
4
5
6
7
8
9
10
<?php
/**
 * Created by PhpStorm.
 * User: jimmy
 * Date: 01/02/19
 * Time: 16:26
 */


require_once "./dao/DBquery.php";
jlopez's avatar
jlopez committed
11
require_once "./package.php";
jlopez's avatar
jlopez committed
12
13
14
15

$db = new DBquery();

$distrib = "";
jlopez's avatar
jlopez committed
16
$save_distrib = "";
jlopez's avatar
jlopez committed
17
18
19

if(isset($_GET['distrib'])) {
    $distrib = $_GET['distrib'];
jlopez's avatar
jlopez committed
20
    $save_distrib = $_GET['distrib'];
jlopez's avatar
jlopez committed
21
22
23
24
25
26
27
28
29
30
31
32
}

$filter = "";

if(isset($_GET['filter'])) {
    $filter = $_GET['filter'];
}

if(isset($_GET['filter'])) {
    $filter = $_GET['filter'];
}

jlopez's avatar
jlopez committed
33
34
$patternName = true;
$patternDescription = true;
jlopez's avatar
jlopez committed
35

jlopez's avatar
jlopez committed
36
/*
jlopez's avatar
jlopez committed
37
38
39
40
41
42
43
44
45
46
if(isset($_GET['patternName'])) {
    if($_GET['patternName'] == "true") {
        $patternName = true;
    }
}

if(isset($_GET['patternDescription'])) {
    if($_GET['patternDescription'] == "true") {
        $patternDescription = true;
    }
jlopez's avatar
jlopez committed
47
}*/
jlopez's avatar
jlopez committed
48

jlopez's avatar
jlopez committed
49
if(isset($_GET['limit'])) {
jlopez's avatar
jlopez committed
50
    $limit = $_GET['limit'];
jlopez's avatar
jlopez committed
51
}
jlopez's avatar
jlopez committed
52
53

$result = array();
jlopez's avatar
jlopez committed
54

jlopez's avatar
jlopez committed
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
if(strpos($distrib, ':') !== false) {
    $os = explode (":", $distrib);
    $os_name = $os[0];
    $version_num = $os[1];
    $version_name = $db->getVName($os_name, $version_num);
    $result = findDistributionPackage($os_name, $version_num, $version_name, $filter, $limit, false);
} else {

    if($distrib == "Conda") {
        $result = findCondaPackage($distrib, $version_num, $version_name, $filter, $limit, false);
    }
    else if($distrib == "Rubygems") {
        $result = findRubyPackage($distrib, $version_num, $version_name, $filter, $limit, false);
    } 
    else if($distrib == "NPM") {
       $result = findNPMPackage($distrib, $version_num, $version_name, $filter, $limit, false);
    }
    else if($distrib == "CPAN") {
        $result = findCPANPackage($distrib, $version_num, $version_name, $filter, $limit, false);
    }
jlopez's avatar
jlopez committed
75
    else if($distrib == "CRAN" || $distrib == "Bioconductor") {
jlopez's avatar
jlopez committed
76
77
        $result = findRPackage($distrib, $version_num, $version_name, $filter, $limit, false);
    }
jlopez's avatar
jlopez committed
78
79
80
    else if($distrib == "Python") {
        $result = findPythonPackage($distrib, $version_num, $version_name, $filter, $limit, false);
    }
jlopez's avatar
jlopez committed
81
82
83
84
    else {
        $result = $db->getPackages($distrib, $filter, $patternName, $patternDescription, $limit);
    }
}
jlopez's avatar
jlopez committed
85
86
87
88
89
90
91
92
93

echo '
<div class="container">
  <div class="row justify-content-center">
    <h4>Packages found : '.count($result).'</h4>
  </div>
</div>


jlopez's avatar
jlopez committed
94
<table class="table table-striped table-bordered">
jlopez's avatar
jlopez committed
95
    <thead>
jlopez's avatar
jlopez committed
96
97
98
99
100
101
102
103
            <tr>
                <th>Choose</th>
                <th>Name</th>
                <th>Version</th>
                <th>Description</th>
                <th>Documentation</th>
                <th>Other</th>                             
            </tr>
jlopez's avatar
jlopez committed
104
105
    </thead>
    <tbody>
jlopez's avatar
jlopez committed
106
        
jlopez's avatar
jlopez committed
107
108
';

jlopez's avatar
jlopez committed
109
110
111
112
if(strpos($distrib, ':') !== false) {
    $distrib = "Distribution";
}

jlopez's avatar
jlopez committed
113
114
115
116
foreach ($result as $t) {

    echo '<tr>
        <td>
jlopez's avatar
jlopez committed
117
118
119
120
            <label class="custom-control custom-checkbox">
                <input type="checkbox" onclick="generatePackageSelected(this)" data-pname="'.$t->name.'" data-pversion="'.$t->version.'"  data-psection="'.$distrib.'" id="checkbox$'.$distrib.'$'.$t->name.'$'.$t->version.'" class="custom-control-input" name="type">                                         
                <span class="custom-control-indicator"></span>
            </label>
jlopez's avatar
jlopez committed
121
        </td>';
jlopez's avatar
jlopez committed
122
123
124
125
126
127
128
129
130
131
132
133
    echo '<td>'.$t->name.'</td>';
    echo '<td>'.$t->version.'</td>';
    echo '<td>'.$t->description.'</td>';

    if($t->doc) {
        if($t->doc != "") {
            echo '<td><a href="'.$t->doc.'">documentation</a></td>';
        } else {
            echo '<td></td>';
        }
    } else {
        echo '<td></td>';
jlopez's avatar
jlopez committed
134
135
    }

jlopez's avatar
jlopez committed
136
137
138
139
140
141
142
    if($distrib == "Distribution") {
        echo '<td>'.$save_distrib.'</td>';
    } else {
        echo '<td>'.$t->other.'</td>';
    }
    
   
jlopez's avatar
jlopez committed
143
144
145
    echo '</tr>';
}

jlopez's avatar
jlopez committed
146
echo '</tr>
jlopez's avatar
jlopez committed
147
148
149
    </tbody>
</table>
';