Switch site->listthemes to expect a resolution rather than a target. Adjust other...
authorJonas Häggqvist <rasher@rasher.dk>
Wed, 18 Mar 2009 00:15:33 +0000 (18 01:15 +0100)
committerJonas Häggqvist <rasher@rasher.dk>
Wed, 18 Mar 2009 00:15:33 +0000 (18 01:15 +0100)
private/templates/rbutil.tpl [new file with mode: 0644]
private/themesite.class.php
public/admin.php
public/index.php
public/rbutilqt.php [copied from public/rss.php with 75% similarity]
public/rss.php

diff --git a/private/templates/rbutil.tpl b/private/templates/rbutil.tpl
new file mode 100644 (file)
index 0000000..d1ed5e5
--- /dev/null
@@ -0,0 +1,17 @@
+[error]
+code={$errno}
+description={$errmsg}
+
+{section name=i loop=$themes}
+[{$themes[i].shortname}]
+name={$themes[i].name}
+size={$themes[i].size}
+descriptionfile=
+image={$themes[i].sshot_wps}
+image2={$themes[i].sshot_menu}
+archive={$themes[i].zipfile}
+author={$themes[i].author}
+version={$themes[i].timestamp}
+about={$themes[i].description}
+
+{/section}
index 86b88b4..d2319f4 100644 (file)
@@ -121,34 +121,40 @@ class themesite {
         return $result['count'] == 1 ? true : false;
     }
 
-    public function listthemes($target, $orderby = 'timestamp DESC', $approved = 'approved', $onlyverified = true) {
+    public function listthemes($mainlcd, $orderby = 'timestamp DESC', $approved = 'approved', $onlyverified = true) {
         $ret = array();
         switch($approved) {
             case 'any':
                 $approved_clause = "";
                 break;
             case 'hidden':
-                $approved_clause = " AND th.approved = 0 ";
+                $approved_clause = " AND approved = 0 ";
                 break;
             case 'approved':
             default:
-                $approved_clause = " AND th.approved = 1 ";
+                $approved_clause = " AND approved = 1 ";
                 break;
         }
         if ($onlyverified == true) {
-            $verified = " AND th.emailverification = 1 ";
+            $verified = " AND emailverification = 1 ";
         }
         else {
             $verified = "";
         }
-        $sql = sprintf("SELECT name, timestamp, th.mainlcd as mainlcd, approved, reason, description, th.RowID as id, th.shortname AS shortname, zipfile, sshot_wps, sshot_menu, emailverification = 1 as verified FROM themes th, targets ta WHERE 1 %s %s AND th.mainlcd=ta.mainlcd and ta.shortname='%s' AND (ta.remotelcd IS NULL OR ta.remotelcd=th.remotelcd) ORDER BY %s",
+        $sql = sprintf("SELECT name, timestamp, mainlcd, approved, reason, description, RowID as id, shortname, zipfile, sshot_wps, sshot_menu, emailverification = 1 as verified FROM themes WHERE 1 %s %s AND mainlcd='%s' ORDER BY %s",
             $verified,
             $approved_clause,
-            db::quote($target),
+            db::quote($mainlcd),
             $orderby
         );
         $themes = $this->db->query($sql);
         while ($theme = $themes->next()) {
+            $theme['size'] = filesize(sprintf("%s/%s/%s/%s",
+                $theme['approved'] == 1 ? $this->themedir_public : $this->themedir_private,
+                $theme['mainlcd'],
+                $theme['shortname'],
+                $theme['zipfile']
+            ));
             $ret[] = $theme;
         }
         return $ret;
index 9f26acb..8904666 100644 (file)
@@ -59,8 +59,8 @@ else {
         }
         $approved = isset($_REQUEST['approved']) ? $_REQUEST['approved'] : 'any';
         $template = 'adminlist.tpl';
-        $themes = $site->listthemes($_REQUEST['target'], 'timestamp DESC',$approved, $onlyverified = false);
         $lcd = $site->target2lcd($_REQUEST['target']);
+        $themes = $site->listthemes($lcd['mainlcd'], 'timestamp DESC',$approved, $onlyverified = false);
         $t->assign('mainlcd', $lcd['mainlcd']);
         $t->assign('themes', $themes);
         $t->assign('approved', $approved);
index 33ef49d..e7d68cd 100644 (file)
@@ -29,8 +29,8 @@ if (isset($_REQUEST['target']) && isset($_REQUEST['themename'])) {
 }
 /* Show all themes for a specific target */
 elseif (isset($_REQUEST['target'])) {
-    $values['themes'] = $site->listthemes($_REQUEST['target']);
     $lcd = $site->target2lcd($_REQUEST['target']);
+    $values['themes'] = $site->listthemes($lcd['mainlcd']);
     $t->assign('mainlcd', $lcd['mainlcd']);
     $template = 'themelist.tpl';
 }
similarity index 75%
copy from public/rss.php
copy to public/rbutilqt.php
index e04feb1..e49f00e 100644 (file)
  ****************************************************************************/
 
 require_once('preconfig.inc.php');
+header('Content-type: text/plain');
 
-header("Content-type: application/xhtml+xml");
-$res = $site->listthemes($_REQUEST['target']);
-$t->render('rss.tpl', array('themes' => $res));
+$mainlcd = substr($_REQUEST['res'], 0, strrpos($_REQUEST['res'], 'x'));
+$themes = $site->listthemes($mainlcd);
+$t->assign('themes', $themes);
+/* Not sure what kind of error message we would want to send? */
+$t->assign('errno', 0);
+$t->assign('errmsg', 'Rocking da boxes');
+$t->render('rbutil.tpl');
 ?>
index e04feb1..c4817be 100644 (file)
@@ -23,6 +23,7 @@
 require_once('preconfig.inc.php');
 
 header("Content-type: application/xhtml+xml");
-$res = $site->listthemes($_REQUEST['target']);
+$lcd = $site->target2lcd($_REQUEST['target']);
+$res = $site->listthemes($lcd['mainlcd']);
 $t->render('rss.tpl', array('themes' => $res));
 ?>