From 80addca7a13e2f8e2597a49b59e73af4380cecf3 Mon Sep 17 00:00:00 2001 From: "fligtar%gmail.com" Date: Sun, 27 Aug 2006 23:43:02 +0000 Subject: [PATCH] Updated addons MCV stuff git-svn-id: svn://10.0.0.236/trunk@208586 18797224-902f-48f8-a5cc-f745e15eee43 --- .../app/controllers/addons_controller.php | 36 ++++++++++++++----- .../remora/app/views/addons/add_step2.thtml | 6 +++- .../app/views/addons/author_lookup.thtml | 8 +++++ 3 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 mozilla/webtools/remora/app/views/addons/author_lookup.thtml diff --git a/mozilla/webtools/remora/app/controllers/addons_controller.php b/mozilla/webtools/remora/app/controllers/addons_controller.php index f6f1913150f..daad1aaeddc 100644 --- a/mozilla/webtools/remora/app/controllers/addons_controller.php +++ b/mozilla/webtools/remora/app/controllers/addons_controller.php @@ -4,8 +4,9 @@ require_once('Archive/Zip.php'); class AddonsController extends AppController { var $name = 'Addons'; - var $uses = array('Addon', 'Platform', 'Application', 'Appversion', 'Tag'); + var $uses = array('Addon', 'Platform', 'Application', 'Appversion', 'Tag', 'User'); var $components = array('Amo', 'Rdf', 'Versioncompare'); + var $helpers = array('Html', 'Javascript', 'Ajax'); var $scaffold; /** * @@ -210,19 +211,20 @@ class AddonsController extends AppController } + $info['name'] = (!empty($existing['Addon']['name'])) ? $existing['Addon']['name'] : $manifestData['name']['en-US']; + $info['description'] = (!empty($existing['Addon']['description'])) ? $existing['Addon']['description'] : $manifestData['description']['en-US']; + $info['homepage'] = (!empty($existing['Addon']['homepage'])) ? $existing['Addon']['homepage'] : $manifestData['homepageURL']; + $info['addontype_id'] = (!empty($existing['Addon']['addontype_id'])) ? $existing['Addon']['addontype_id'] : $this->data['Addon']['addontype_id']; + $info['version'] = $manifestData['version']; + $info['summary'] = $existing['Addon']['summary']; + //Get tags based on addontype - $tagsQry = $this->Tag->findAll(array('addontype_id' => $this->data['Addon']['addontype_id']), + $tagsQry = $this->Tag->findAll(array('addontype_id' => $info['addontype_id']), null, null, null, null, -1); foreach ($tagsQry as $k => $v) { $tags[$v['Tag']['id']] = $v['Tag']['name']; } - $info['name'] = (!empty($existing['Addon']['name'])) ? $existing['Addon']['name'] : $manifestData['name']['en-US']; - $info['description'] = (!empty($existing['Addon']['description'])) ? $existing['Addon']['description'] : $manifestData['description']['en-US']; - $info['homepage'] = (!empty($existing['Addon']['homepage'])) ? $existing['Addon']['homepage'] : $manifestData['homepageURL']; - $info['version'] = $manifestData['version']; - $info['summary'] = $existing['Addon']['summary']; - if (count($existing['Tag']) > 0) { foreach ($existing['Tag'] as $tag) { $info['selectedTags'][$tag['id']] = $tag['name']; @@ -287,6 +289,24 @@ class AddonsController extends AppController } + /** + * AJAX action for looking up an author by email + * @param string $email + */ + function authorLookup($email) { + if ($authors = $this->User->findAllByEmail($email)) { + $author = $authors[0]['User']['firstname'].' '.$authors[0]['User']['lastname']; + $author .= ' ['.$authors[0]['User']['email'].']'; + } + else { + $author = false; + } + + $this->set('author', $author); + $this->set('email', $email); + $this->render('author_lookup', 'ajax'); + } + } ?> diff --git a/mozilla/webtools/remora/app/views/addons/add_step2.thtml b/mozilla/webtools/remora/app/views/addons/add_step2.thtml index 91f6e4c84df..0367d15c9b6 100644 --- a/mozilla/webtools/remora/app/views/addons/add_step2.thtml +++ b/mozilla/webtools/remora/app/views/addons/add_step2.thtml @@ -17,8 +17,12 @@ echo ''._('File').''; echo ''.sprintf(_('%s (%d KB)'), $fileName, $fileSize).''; echo ''; echo ''; +echo ''._('Authors').''; +echo ''.''; +echo ''; +echo ''; echo ''._('Author E-mail').''; -echo ''.$html->input('Addon/Author', array('size' => 40)).$html->link(_('Add Author'), '').$html->tagErrorMsg('Addon/Author', _('Please enter at least one author.')).''; +echo ''.$html->input('Addon/Author', array('size' => 40, 'id' => 'test_input')).$ajax->link(_('Add Author'), 'javascript: void(0);', array('url' => "/addons/authorLookup/'+document.getElementById('test_input').value+'", 'update' => 'test_output')).''; echo ''; echo ''; echo ''._('Categories').''; diff --git a/mozilla/webtools/remora/app/views/addons/author_lookup.thtml b/mozilla/webtools/remora/app/views/addons/author_lookup.thtml new file mode 100644 index 00000000000..65de81bf567 --- /dev/null +++ b/mozilla/webtools/remora/app/views/addons/author_lookup.thtml @@ -0,0 +1,8 @@ +No author found ['.$email.']
'; + } + else { + echo $author.'
'; + } +?>