aboutsummaryrefslogtreecommitdiff
path: root/r7r_repo
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2012-01-06 01:34:57 +0100
committerKevin Chabowski <kevin@kch42.de>2012-01-06 01:34:57 +0100
commitfca7d3ce3e20e6c89c798cb71a5260680e7fc1b4 (patch)
treec450384ec1732d6ef3a554a4f06969936294b277 /r7r_repo
parent026a434edc60a1e5ffaade16063dc670214def8a (diff)
downloadr7r-repo-fca7d3ce3e20e6c89c798cb71a5260680e7fc1b4.tar.gz
r7r-repo-fca7d3ce3e20e6c89c798cb71a5260680e7fc1b4.tar.bz2
r7r-repo-fca7d3ce3e20e6c89c798cb71a5260680e7fc1b4.zip
my_plugins implemented and rewritten main/index.
Diffstat (limited to 'r7r_repo')
-rw-r--r--r7r_repo/main.php38
-rw-r--r--r7r_repo/models.php4
-rw-r--r--r7r_repo/templates/src/package_list.html (renamed from r7r_repo/templates/src/home.html)9
3 files changed, 37 insertions, 14 deletions
diff --git a/r7r_repo/main.php b/r7r_repo/main.php
index 17bce03..6f69cbe 100644
--- a/r7r_repo/main.php
+++ b/r7r_repo/main.php
@@ -78,6 +78,22 @@ if(isset($_SESSION["r7r_repo_login_name"]))
}
}
+function package_list($pkgs, $heading)
+{
+ global $ste;
+
+ $ste->vars["list_heading"] = $heading;
+ $ste->vars["pkgs"] = array_map(function($pkg) { return array(
+ "name" => $pkg->get_name(),
+ "version" => $pkg->txtversion,
+ "author" => $pkg->author,
+ "description" => $pkg->description,
+ "last_update" => $pkg->lastupdate
+ ); }, $pkgs);
+
+ return $ste->exectemplate("package_list.html");
+}
+
/* url handlers */
$url_handlers = array(
"_prelude" => function(&$data, $url_now, &$url_next)
@@ -119,15 +135,8 @@ $url_handlers = array(
$ste->vars["menu"] = "home";
$latest = Package::latest();
- $ste->vars["latest_pkgs"] = array_map(function($pkg) { return array(
- "name" => $pkg->get_name(),
- "version" => $pkg->txtversion,
- "author" => $pkg->author,
- "description" => $pkg->description,
- "last_update" => $pkg->lastupdate
- ); }, $latest);
- echo $ste->exectemplate("home.html");
+ echo package_list($latest, "Latest Packages");
},
"login" => function(&$data, $url_now, &$url_next)
{
@@ -491,6 +500,19 @@ $url_handlers = array(
echo $ste->exectemplate("upload.html");
},
+ "my_packages" => function(&$data, $url_now, &$url_next)
+ {
+ global $ste, $user;
+
+ if($user === NULL)
+ throw new NotFoundError();
+
+ $ste->vars["menu"] = "my_packages";
+
+ $my_packages = $user->get_packages();
+
+ echo package_list($my_packages, "My Packages");
+ },
"setup" => function(&$data, $url_now, &$url_next)
{
global $settings, $ste;
diff --git a/r7r_repo/models.php b/r7r_repo/models.php
index cd1ae2b..7c56033 100644
--- a/r7r_repo/models.php
+++ b/r7r_repo/models.php
@@ -213,9 +213,9 @@ class User extends BySQLRowEnabled
public function get_packages()
{
$rv = array();
- $result = qdb("SELECT `id`, `name`, `user`, `lastversion`, `description`, `lastupdate`, `txtversion` FROM `PREFIX_packages` WHERE `user` = %d", $this->id);
+ $result = qdb("SELECT `id`, `name`, `user`, `author`, `lastversion`, `description`, `lastupdate`, `txtversion` FROM `PREFIX_packages` WHERE `user` = %d", $this->id);
while($sqlrow = mysql_fetch_assoc($result))
- $rv[] = Package::by_sqlrow($result);
+ $rv[] = Package::by_sqlrow($sqlrow);
return $rv;
}
diff --git a/r7r_repo/templates/src/home.html b/r7r_repo/templates/src/package_list.html
index 56a4a6a..e610860 100644
--- a/r7r_repo/templates/src/home.html
+++ b/r7r_repo/templates/src/package_list.html
@@ -3,7 +3,8 @@
<ste:default_error />
<ste:default_success />
- <h2>Latest Packages</h2>
+ <h2><ste:escape>$list_heading</ste:escape></h2>
+
<table class="listtab fullwidth">
<thead>
<tr>
@@ -16,10 +17,10 @@
</thead>
<tbody>
<ste:if>
- <ste:set var="pkgs_n"><ste:arraylen array="latest_pkgs" /></ste:set>
+ <ste:set var="pkgs_n"><ste:arraylen array="pkgs" /></ste:set>
~{$pkgs_n|gt|0}
<ste:then>
- <ste:foreach array="latest_pkgs" value="pkg">
+ <ste:foreach array="pkgs" value="pkg">
<tr>
<td><a href="$rel_path_to_root/p/<ste:escape>$pkg[name]</ste:escape>"><ste:escape>$pkg[name]</ste:escape></a></td>
<td><ste:escape>$pkg[version]</ste:escape></td>
@@ -31,7 +32,7 @@
</ste:then>
<ste:else>
<tr>
- <td style="text-align: center; font-style: italic;" colspan="5">No Packages available.</td>
+ <td style="text-align: center; font-style: italic;" colspan="5">No Packages found.</td>
</tr>
</ste:else>
</ste:if>