Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@sugarlabs.org>2008-12-20 02:08:10 (GMT)
committer YOUR NAME <USER@develer.com>2009-02-11 19:12:29 (GMT)
commit5bc094365ca8e2ac47f0ef8962eca7eaeb3d5429 (patch)
treef6da8602ffecdd218763546ca450acb457daf907
parent99117c7e0c84e43df584808faee69c7b9275571f (diff)
Extract bundle information from the activity.info file
-rw-r--r--site/app/controllers/developers_controller.php36
1 files changed, 32 insertions, 4 deletions
diff --git a/site/app/controllers/developers_controller.php b/site/app/controllers/developers_controller.php
index a06b881..eea3bd8 100644
--- a/site/app/controllers/developers_controller.php
+++ b/site/app/controllers/developers_controller.php
@@ -500,10 +500,38 @@ class DevelopersController extends AppController
$this->Amo->clean($addon);
}
elseif ($addon['Addon']['addontype_id'] == ADDON_ACTIVITY) {
- // TODO: Get better information from the activity.info file
- $addon['Addon']['name'] = $addon['File']['details']['path'];
- $addon['Addon']['summary'] = $addon['File']['details']['path'];
- $addon['Version']['version'] = date('Ymd');
+ // Extract activity.info from .xo
+ $zip = new Archive_Zip($addon['File']['details']['path']);
+ $files = $zip->listContent();
+ $first_file = $files[0]['stored_filename'];
+
+ $parts = split("/", $first_file, 2);
+ $activity_dir_name = $parts[0];
+ $ext = substr($activity_dir_name, strlen($activity_dir_name) - strlen(".activity"));
+ if ($ext != ".activity") {
+ return $this->Error->getJSONforError(_('devcp_error_malformed_bundle'));
+ }
+
+ $tmpdir = getenv("TMPDIR");
+ if (empty($tmpdir)) $tmpdir = "/tmp";
+
+ $activity_info_path = $activity_dir_name."/activity/activity.info";
+ $activity_info = $zip->extract(array('add_path' => $tmpdir, 'by_name' => array($activity_info_path)));
+ if (empty($activity_info)) {
+ return $this->Error->getJSONforError(_('devcp_error_activity_info_not_found'));
+ }
+ $activity_info = $activity_info[0];
+
+ $ini_file = parse_ini_file($activity_info['filename']);
+ unlink($activity_info['filename']);
+
+ if (!is_array($ini_file)) {
+ return $this->Error->getJSONforError(_('devcp_error_activity_info_not_found'));
+ }
+
+ $addon['Addon']['name'] = $ini_file['name'];
+ $addon['Addon']['summary'] = $ini_file['name'];
+ $addon['Version']['version'] = $ini_file['activity_version'];
}