art-web r526 - in branches/art-hub: . controllers models views
- From: thos svn gnome org
- To: svn-commits-list gnome org
- Subject: art-web r526 - in branches/art-hub: . controllers models views
- Date: Mon, 16 Jun 2008 13:26:39 +0000 (UTC)
Author: thos
Date: Mon Jun 16 13:26:38 2008
New Revision: 526
URL: http://svn.gnome.org/viewvc/art-web?rev=526&view=rev
Log:
* Add MVC for themes
Added:
branches/art-hub/controllers/themes.php
branches/art-hub/models/themes.php
branches/art-hub/views/themes.php
Modified:
branches/art-hub/themes
Added: branches/art-hub/controllers/themes.php
==============================================================================
--- (empty file)
+++ branches/art-hub/controllers/themes.php Mon Jun 16 13:26:38 2008
@@ -0,0 +1,31 @@
+<?php
+/* load model */
+require ("models/themes.php");
+
+$themes = new Themes();
+
+preg_match ('/^\/themes\/(gtk2|metacity|icon|gdm_greeter|splash_screens|gtk_engines)\/?$/',
+ $_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 = $themes->get_themes ($category, $start, $limit, "name");
+else
+ $view_data = null;
+
+$total_themes = $themes->get_total ($category);
+
+/* load view */
+require ("views/themes.php");
+
+?>
Added: branches/art-hub/models/themes.php
==============================================================================
--- (empty file)
+++ branches/art-hub/models/themes.php Mon Jun 16 13:26:38 2008
@@ -0,0 +1,40 @@
+<?php
+require ("mysql.inc.php");
+
+class Themes
+{
+ function get_themes ($category, $start, $length, $order)
+ {
+ $sql = "SELECT * FROM theme,user
+ WHERE status='active' AND category = '$category'
+ AND theme.userID = user.userID
+ ORDER BY $order LIMIT $start,$length ";
+
+ $r = mysql_query ($sql);
+ if (!$r)
+ printf ("Database error: %s", mysql_error());
+ $table = Array ();
+ while ($row = mysql_fetch_assoc ($r))
+ {
+ $table[] = $row;
+ }
+
+ return $table;
+ }
+
+ function get_total ($category)
+ {
+ $sql = "SELECT COUNT(name) FROM theme
+ WHERE category = '$category'";
+ $r = mysql_query ($sql);
+ if (!$r)
+ printf ("Database error: %s", mysql_error());
+
+
+ $total = mysql_fetch_row ($r);
+
+ return $total[0];
+ }
+}
+
+?>
Modified: branches/art-hub/themes
==============================================================================
--- branches/art-hub/themes (original)
+++ branches/art-hub/themes Mon Jun 16 13:26:38 2008
@@ -1,5 +1,5 @@
<?php
-require ("art.html");
+require ("controllers/themes.php");
?>
Added: branches/art-hub/views/themes.php
==============================================================================
--- (empty file)
+++ branches/art-hub/views/themes.php Mon Jun 16 13:26:38 2008
@@ -0,0 +1,69 @@
+<?php
+
+require ("lib/pagination.php");
+require ("lib/template.php");
+
+$t = new Template ("themes");
+
+$t->print_header();
+
+if (!$view_data)
+{
+ print ('
+
+ <a href="/">GNOME Art</a> > Themes
+ <br><br>
+ Choose a category:
+ <ul>
+ <li><a href="/themes/gtk2">Controls</a></li>
+ <li><a href="/themes/metacity">Window Borders</a></li>
+ <li><a href="/themes/icon">Icons</a></li>
+ <li><a href="/themes/splash_screens">Splash Screens</a></li>
+ <li><a href="/themes/gdm_greeter">Login Window</a></li>
+ </ul>');
+ $t->print_footer ();
+ exit;
+}
+
+/* get the current page and ensure a default value is set */
+$cur_page = $_GET['page'];
+if (!is_numeric ($cur_page))
+ $cur_page = 1;
+
+$p = new Paginator ($total_themes, 10, $cur_page * 10);
+
+$display_cat = array (
+ "gtk2" => "Controls",
+ "icon" => "Icons",
+ "metacity" => "Window Borders",
+ "gdm_greeter" => "Login Screen",
+ "splash_screens" => "Splash Screens"
+);
+
+ $d_category = $display_cat [$category];
+
+?>
+<a href="/">GNOME Art</a> > <a href="/themes">Themes</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/themes/{$row['themeID']}.png'/></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]