From: Jonas Häggqvist Date: Wed, 18 Mar 2009 00:15:33 +0000 (+0100) Subject: Switch site->listthemes to expect a resolution rather than a target. Adjust other... X-Git-Url: https://repo.or.cz/w/rockboxthemes.git/commitdiff_plain/31535e3fb0d6a56fc8175fbb47d5d686002abebf Switch site->listthemes to expect a resolution rather than a target. Adjust other pages accordingly. Add a page for rbutil. --- diff --git a/private/templates/rbutil.tpl b/private/templates/rbutil.tpl new file mode 100644 index 0000000..d1ed5e5 --- /dev/null +++ b/private/templates/rbutil.tpl @@ -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} diff --git a/private/themesite.class.php b/private/themesite.class.php index 86b88b4..d2319f4 100644 --- a/private/themesite.class.php +++ b/private/themesite.class.php @@ -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; diff --git a/public/admin.php b/public/admin.php index 9f26acb..8904666 100644 --- a/public/admin.php +++ b/public/admin.php @@ -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); diff --git a/public/index.php b/public/index.php index 33ef49d..e7d68cd 100644 --- a/public/index.php +++ b/public/index.php @@ -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'; } diff --git a/public/rss.php b/public/rbutilqt.php similarity index 75% copy from public/rss.php copy to public/rbutilqt.php index e04feb1..e49f00e 100644 --- a/public/rss.php +++ b/public/rbutilqt.php @@ -21,8 +21,13 @@ ****************************************************************************/ 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'); ?> diff --git a/public/rss.php b/public/rss.php index e04feb1..c4817be 100644 --- a/public/rss.php +++ b/public/rss.php @@ -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)); ?>