Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoit Tremblay <bentremblay@benoit-tremblays-macbook-pro.local>2009-11-05 16:36:52 (GMT)
committer Benoit Tremblay <bentremblay@benoit-tremblays-macbook-pro.local>2009-11-05 16:36:52 (GMT)
commit53ed056acb5bf13efba14173c0502f381c62856f (patch)
treea1a1028ca1aae84ac717cc93035472887e1c9b64
parenta84e16ff4c929790d356a69c00a4e84abc526684 (diff)
remove some duplication in views
-rw-r--r--site/app/controllers/tutorius_api_controller.php15
-rw-r--r--site/app/views/tutorius_api/publish.thtml88
-rw-r--r--site/app/views/tutorius_api/tutorial_display.thtml3
3 files changed, 7 insertions, 99 deletions
diff --git a/site/app/controllers/tutorius_api_controller.php b/site/app/controllers/tutorius_api_controller.php
index 40acccb..05755cc 100644
--- a/site/app/controllers/tutorius_api_controller.php
+++ b/site/app/controllers/tutorius_api_controller.php
@@ -36,7 +36,6 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
-//require_once('Archive/Zip.php');
vendor('sphinx/addonsSearch');
uses('sanitize');
@@ -66,22 +65,11 @@ class TutoriusApiController extends AppController
'Html', 'Link', 'Time', 'Localization'
);
- var $securityLevel = 'low';
-
const STATUS_OK = '200 OK';
const STATUS_CREATED = '201 Created';
- const STATUS_ACCEPTED = '202 Accepted';
- const STATUS_FOUND = '302 Found';
- const STATUS_SEE_OTHER = '303 See Other';
const STATUS_NOT_MODIFIED = '304 Not Modified';
- const STATUS_BAD_REQUEST = '400 Bad Request';
const STATUS_UNAUTHORIZED = '401 Unauthorized';
- const STATUS_FORBIDDEN = '403 Forbidden';
- const STATUS_NOT_FOUND = '404 Not Found';
const STATUS_METHOD_NOT_ALLOWED = '405 Method Not Allowed';
- const STATUS_CONFLICT = '409 Conflict';
- const STATUS_GONE = '410 Gone';
- const STATUS_UNSUPPORTED_MEDIA = '415 Unsupported Media Type';
const STATUS_ERROR = '500 Internal Server Error';
var $cache_lifetime = 0; // 0 seconds
@@ -250,8 +238,6 @@ class TutoriusApiController extends AppController
function tutorials_GET($context, $category='all', $page=1, $limit=10, $sort_by='') {
extract($context);
-
- $this->forceShadowDb();
$addontype = ADDON_TUTORIUS;
@@ -902,6 +888,7 @@ class TutoriusApiController extends AppController
}
$addon_id = $data['Addon']['id'];
+
// now get the newly created tutorial, associate it with
// categories and return it
$this->_getTutorials(array($addon_id));
diff --git a/site/app/views/tutorius_api/publish.thtml b/site/app/views/tutorius_api/publish.thtml
index e7d3f0d..6eb1e28 100644
--- a/site/app/views/tutorius_api/publish.thtml
+++ b/site/app/views/tutorius_api/publish.thtml
@@ -37,87 +37,7 @@
if (isset($error)) { ?>
<error><?php echo ($error); ?></error>
<?php
-} else { ?>
- <tutorial>
- <?php
- $amo = "http://tutorius.org";
- // Allow some additional content to be injected into the addon element by
- // the including template.
- if (isset($addon_pre)) echo $addon_pre;
- ?>
- <name><?php echo $tutorial['Translation']['name']['string']; ?></name>
- <type id='<?php echo $tutorial['Addon']['addontype_id']; ?>'><?php echo Addontype::getName($tutorial['Addon']['addontype_id']); ?></type>
- <guid><?php echo $tutorial['Addon']['guid']; ?></guid>
- <version><?php echo $tutorial['install_version']; ?></version>
- <status id='<?php echo $tutorial['Addon']['status']; ?>'><?php if ($tutorial['Addon']['status'] == STATUS_PUBLIC) {
- echo rtrim(___('Public', 'a_header_public'));
- } else {
- echo rtrim(___('Sandbox', 'a_header_sandbox'));
- }
- ?></status>
- <authors>
- <?php
- foreach ($tutorial['User'] as $author) {
- $authorName = (!empty($author['nickname'])) ? $author['nickname'] : $author['firstname'].' '.$author['lastname'];
- ?>
- <author><?php echo $authorName; ?></author>
- <?php
- }
- ?> </authors>
- <summary><?php echo $tutorial['Translation']['summary']['string']; ?></summary>
- <description><?php echo $tutorial['Translation']['description']['string']; ?></description>
- <icon><?php if (isset($tutorial['Icon'])) {
- echo $amo.$tutorial['Icon'];
- } else {
- $tutorialIconPath = ($tutorial['Addon']['addontype_id'] == ADDON_THEME ? $html->urlImage(DEFAULT_THEME_ICON) : $html->urlImage(DEFAULT_ADDON_ICON));
- echo $amo.$tutorialIconPath;
- } ?></icon>
- <compatible_applications>
- <?php
- foreach ($tutorial['Compatible_apps'] as $app) {
- $name = $app_names[$app['Application']['application_id']];
- ?>
- <application>
- <name><?php echo $name; ?></name>
- <application_id><?php echo $app['Application']['application_id']; ?></application_id>
- <min_version><?php echo $app['Min_Version']['version']; ?></min_version>
- <max_version><?php echo $app['Max_Version']['version']; ?></max_version>
- <?php
- if ($api_version > 1) { ?>
- <appID><?php echo $guids[$name]; ?></appID>
- <?php } ?>
- </application>
- <?php
- }
- ?> </compatible_applications>
- <eula><?php echo $tutorial['Translation']['eula']['string'];?></eula>
- <thumbnail><?php echo $amo.$tutorial['Thumbnail']; ?></thumbnail>
- <rating><?php
- $rating ='';
- if (isset($tutorial['Addon']['averagerating'])) {
- $rating = $tutorial['Addon']['averagerating'];
- if ($api_version < 1) {
- // we need to double the rating since the addons mgr expects it to
- // be out of 10 and we have halved everything in the db
- $rating *= 2;
- }
- // round rating to match stars in AMO
- $rating = ceil($rating);
- }
- echo $rating;
- ?></rating>
- <learnmore><?php echo $amo.'/addon/'.$tutorial['Addon']['id']; ?>?src=api</learnmore>
- <?php foreach($tutorial['fileinfo'] as $file) { ?>
- <install hash='<?php echo $file['File']['hash'];?>'>
- <?php
- echo $amo.'/downloads/file/'.$file['File']['id'].'/'
- .$file['File']['filename']; ?></install>
-
- <?php }
- // Allow some additional content to be injected into the addon element by
- // the including template.
- if (isset($tutorial_post)) echo $tutorial_post;
- ?>
- </tutorial>
-
-<?php } ?> \ No newline at end of file
+} else {
+ $addon = $tutorial;
+ include 'tutorial_display.thtml';
+} ?> \ No newline at end of file
diff --git a/site/app/views/tutorius_api/tutorial_display.thtml b/site/app/views/tutorius_api/tutorial_display.thtml
index 433b342..eeaf69a 100644
--- a/site/app/views/tutorius_api/tutorial_display.thtml
+++ b/site/app/views/tutorius_api/tutorial_display.thtml
@@ -48,7 +48,8 @@
if (isset($addon_pre)) echo $addon_pre;
?>
<name><?php echo $addon['Translation']['name']['string']; ?></name>
- <type id='<?php echo $addon['Addon']['addontype_id']; ?>'><?php echo Addontype::getName($addon['Addon']['addontype_id']); ?></type>
+ <id><?php echo $addon['Addon']['id'] ?></id>
+ <type id='<?php echo $addon['Addon']['addontype_id']; ?>'><?php echo Addontype::getName($addon['Addon']['addontype_id']); ?></type>
<guid><?php if (isset($addon['Addon']['guid'])) echo $addon['Addon']['guid']; ?></guid>
<version><?php echo $addon['install_version']['version']; ?></version>
<status id='<?php echo $addon['Addon']['status']; ?>'><?php if ($addon['Addon']['status'] == STATUS_PUBLIC) {