art-web r520 - in branches/art-hub: controllers models views
- From: thos svn gnome org
- To: svn-commits-list gnome org
- Subject: art-web r520 - in branches/art-hub: controllers models views
- Date: Sun, 15 Jun 2008 21:54:00 +0000 (UTC)
Author: thos
Date: Sun Jun 15 21:54:00 2008
New Revision: 520
URL: http://svn.gnome.org/viewvc/art-web?rev=520&view=rev
Log:
* Add model, view and controller for backgrounds
Added:
branches/art-hub/controllers/
branches/art-hub/controllers/backgrounds.php
branches/art-hub/models/
branches/art-hub/models/backgrounds.php
branches/art-hub/views/
branches/art-hub/views/backgrounds.php
Added: branches/art-hub/controllers/backgrounds.php
==============================================================================
--- (empty file)
+++ branches/art-hub/controllers/backgrounds.php Sun Jun 15 21:54:00 2008
@@ -0,0 +1,28 @@
+<?php
+/* load model */
+require ("models/backgrounds.php");
+
+$bg = new Backgrounds();
+
+preg_match ('/^\/backgrounds\/(abstract|gnome|nature|other)\/?$/', $_SERVER['PHP_SELF'], $params);
+$category = $params[1];
+
+$page = $_GET['page'];
+if (!is_numeric ($page))
+ $page = 1;
+
+$limit = $_GET['limit'];
+if (!is_numeric ($limit))
+ $limit = 10;
+
+$start = ($page - 1) * $limit;
+
+if ($category)
+ $view_data = $bg->get_backgrounds ($category, $start, $limit, "name");
+else
+ $view_data = null;
+
+/* load view */
+require ("views/backgrounds.php");
+
+?>
Added: branches/art-hub/models/backgrounds.php
==============================================================================
--- (empty file)
+++ branches/art-hub/models/backgrounds.php Sun Jun 15 21:54:00 2008
@@ -0,0 +1,26 @@
+<?php
+require ("mysql.inc.php");
+
+class Backgrounds
+{
+ function get_backgrounds ($category, $start, $length, $order)
+ {
+ $sql = "SELECT * FROM background,user
+ WHERE status='active' AND category = '$category'
+ AND background.userID = user.userID
+ ORDER BY $order LIMIT $start,$length ";
+
+ $bg_select_result = mysql_query ($sql);
+ if (!$bg_select_result)
+ printf ("Database error: %s", mysql_error());
+ $table = Array ();
+ while ($row = mysql_fetch_assoc ($bg_select_result))
+ {
+ $table[] = $row;
+ }
+
+ return $table;
+ }
+}
+
+?>
Added: branches/art-hub/views/backgrounds.php
==============================================================================
--- (empty file)
+++ branches/art-hub/views/backgrounds.php Sun Jun 15 21:54:00 2008
@@ -0,0 +1,58 @@
+<?php
+
+require ("lib/pagination.php");
+require ("lib/template.php");
+
+$t = new Template ("backgrounds");
+
+$t->print_header();
+
+if (!$view_data)
+{
+ print ('
+
+ <a href="/">GNOME Art</a> > Backgrounds
+ <br><br>
+ Choose a category:
+ <ul>
+ <li><a href="/backgrounds/gnome">GNOME</a></li>
+ <li><a href="/backgrounds/nature">Nature</a></li>
+ <li><a href="/backgrounds/abstract">Abstract</a></li>
+ <li><a href="/backgrounds/other">Other</a></li>
+ </ul>');
+ $t->print_footer ();
+ exit;
+}
+
+$p = new Paginator (400, 10, $_GET['page'] * 10);
+
+if ($category == "gnome")
+ $d_category = "GNOME";
+else
+ $d_category = ucwords ($category);
+
+?>
+<a href="/">GNOME Art</a> > <a href="/backgrounds">Backgrounds</a>
+> <?php echo $d_category ?>
+<br/><br/>
+<center><?php $p->print_pagination (); ?></center>
+<br/>
+<table>
+
+<?php
+ foreach ($view_data as $row)
+ {
+ print ("<tr><td colspan='3'><b>{$row['name']}</b></td></tr>");
+ print ("<tr><td colspan='3'><a href=\"mailto:{$row['email']}\">{$row['realname']}</a></td></tr>");
+ print ("<tr><td rowspan='2'><img width=96' src='/images/thumbnails/backgrounds/{$row['backgroundID']}.jpg'/></td>");
+ print ("<td colspan='2'>{$row['description']}</td></tr>");
+ print ("<tr><td>{$row['release_date']}</td><td width='75%'>{$row['license']}</td></tr>");
+ print ("<tr><td colspan='3'> </td></tr>");
+ }
+?>
+
+</table>
+<br/>
+<center><?php $p->print_pagination (); ?></center>
+
+<?php $t->print_footer() ?>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]