diff --git a/assets/style.css b/assets/style.css
new file mode 100755
index 0000000..e9dd24d
--- /dev/null
+++ b/assets/style.css
@@ -0,0 +1,11 @@
+table td+td {
+ border-left: 1px dashed green;
+}
+
+td {
+ font-family: monospace;
+}
+
+td.empty {
+ color: silver;
+}
diff --git a/index_main.php b/index_main.php
index 07e3fd4..aaaa9c6 100755
--- a/index_main.php
+++ b/index_main.php
@@ -2,6 +2,7 @@
BlackBerry/TCL Firmware List
+
getAllVariants();
+$unknowns = $db->getUnknownRefs();
+if (count($unknowns) > 0) {
+ $variants = array();
+ foreach ($unknowns as $uref) {
+ $variants[$uref] = '';
+ }
+ $allVars['Unknown'] = array(
+ 'Variants' => $variants,
+ );
+}
foreach ($allVars as $family => $models) {
foreach ($models as $model => $variants) {
echo '' . $family . ' ' . $model . '
' . PHP_EOL;
- echo '';
+ $allVersions = $db->getAllVersionsForModel($model);
+ echo '';
foreach ($variants as $ref => $name) {
- echo '' . $ref . ' | ' . '
' . PHP_EOL;
+ echo '' . $ref . ' | ';
+ $refVersions = $db->getAllVersionsForRef($ref);
+ foreach ($allVersions as $v) {
+ if (in_array($v, $refVersions, true)) {
+ echo '' . $v . ' | ';
+ } else {
+ echo '------ | ';
+ }
+ }
+ echo '
' . PHP_EOL;
}
- echo '
';
+ echo '
';
}
}
-print_r($db->getAllUpdates('PRD-63117-011', $db::BOTH));
-
-print_r($db->getLatestUpdate('PRD-63117-011', $db::BOTH));
-
-
-print_r($db->getUnknownPrds());
-
?>
diff --git a/lib/TclUpdates/SQLiteReader.php b/lib/TclUpdates/SQLiteReader.php
index 835766d..f341520 100644
--- a/lib/TclUpdates/SQLiteReader.php
+++ b/lib/TclUpdates/SQLiteReader.php
@@ -20,7 +20,7 @@ class SQLiteReader
$this->pdo->exec('PRAGMA foreign_keys=on;');
}
- public function getAllPrds()
+ public function getAllRefs()
{
$sql = 'SELECT DISTINCT curef FROM updates ORDER BY curef;';
$sqlresult = $this->pdo->query($sql);
@@ -31,7 +31,7 @@ class SQLiteReader
return $result;
}
- public function getAllKnownPrds()
+ public function getAllKnownRefs()
{
$sql = 'SELECT DISTINCT ref FROM devices ORDER BY ref;';
$sqlresult = $this->pdo->query($sql);
@@ -42,10 +42,10 @@ class SQLiteReader
return $result;
}
- public function getUnknownPrds()
+ public function getUnknownRefs()
{
- $knownPrds = $this->getAllKnownPrds();
- $allPrds = $this->getAllPrds();
+ $knownPrds = $this->getAllKnownRefs();
+ $allPrds = $this->getAllRefs();
$unknownPrds = array_diff($allPrds, $knownPrds);
return $unknownPrds;
}
@@ -99,4 +99,47 @@ class SQLiteReader
$result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
return $result;
}
+
+ public function getAllVersionsForRef($ref = null)
+ {
+ $sql = 'SELECT fv, tv FROM updates u LEFT JOIN files f ON u.file_sha1=f.sha1';
+ $params_arr = array();
+ if (!is_null($ref)) {
+ $sql .= ' WHERE curef=?';
+ $params_arr[] = $ref;
+ }
+ $stmt = $this->pdo->prepare($sql);
+ $ok = $stmt->execute($params_arr);
+ $result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
+ $version = array();
+ foreach ($result as $row) {
+ if (!is_null($row['fv'])) {
+ $version[] = $row['fv'];
+ }
+ $version[] = $row['tv'];
+ }
+ $version = array_unique($version);
+ sort($version);
+ return $version;
+ }
+
+ public function getAllVersionsForModel($model)
+ {
+ $sql = 'SELECT fv, tv FROM models m LEFT JOIN devices d ON m.modelId=d.modelId LEFT JOIN updates u ON d.ref=u.curef LEFT JOIN files f ON u.file_sha1=f.sha1 WHERE m.name=?';
+ $stmt = $this->pdo->prepare($sql);
+ $ok = $stmt->execute(array($model));
+ $result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
+ $version = array();
+ foreach ($result as $row) {
+ if (!is_null($row['fv'])) {
+ $version[] = $row['fv'];
+ }
+ if (!is_null($row['tv'])) {
+ $version[] = $row['tv'];
+ }
+ }
+ $version = array_unique($version);
+ sort($version);
+ return $version;
+ }
}