From fca7d3ce3e20e6c89c798cb71a5260680e7fc1b4 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Fri, 6 Jan 2012 01:34:57 +0100 Subject: my_plugins implemented and rewritten main/index. --- r7r_repo/main.php | 38 ++++++++++++++++++++++------- r7r_repo/models.php | 4 ++-- r7r_repo/templates/src/home.html | 40 ------------------------------- r7r_repo/templates/src/package_list.html | 41 ++++++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 50 deletions(-) delete mode 100644 r7r_repo/templates/src/home.html create mode 100644 r7r_repo/templates/src/package_list.html (limited to 'r7r_repo') 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/home.html deleted file mode 100644 index 56a4a6a..0000000 --- a/r7r_repo/templates/src/home.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - -

Latest Packages

- - - - - - - - - - - - - - ~{$pkgs_n|gt|0} - - - - - - - - - - - - - - - - - - -
Package NameVersionDescriptionAuthorLast update
$pkg[name]$pkg[version]$pkg[description]$pkg[author]%d. %h. %Y, %H:%M:%S
No Packages available.
-
diff --git a/r7r_repo/templates/src/package_list.html b/r7r_repo/templates/src/package_list.html new file mode 100644 index 0000000..e610860 --- /dev/null +++ b/r7r_repo/templates/src/package_list.html @@ -0,0 +1,41 @@ + + + + + +

$list_heading

+ + + + + + + + + + + + + + + ~{$pkgs_n|gt|0} + + + + + + + + + + + + + + + + + + +
Package NameVersionDescriptionAuthorLast update
$pkg[name]$pkg[version]$pkg[description]$pkg[author]%d. %h. %Y, %H:%M:%S
No Packages found.
+
-- cgit v1.2.3-70-g09d2