Updated addons MCV stuff

This commit is contained in:
fligtar%gmail.com 2006-08-27 23:43:02 +00:00
parent add040f3cf
commit 5355b2998c
3 changed files with 41 additions and 9 deletions

View File

@ -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');
}
}
?>

View File

@ -17,8 +17,12 @@ echo '<td>'._('File').'</td>';
echo '<td>'.sprintf(_('%s (%d KB)'), $fileName, $fileSize).'</td>';
echo '</tr>';
echo '<tr>';
echo '<td>'._('Authors').'</td>';
echo '<td id="test_output">'.'</td>';
echo '</tr>';
echo '<tr>';
echo '<td>'._('Author E-mail').'</td>';
echo '<td>'.$html->input('Addon/Author', array('size' => 40)).$html->link(_('Add Author'), '').$html->tagErrorMsg('Addon/Author', _('Please enter at least one author.')).'</td>';
echo '<td>'.$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')).'</td>';
echo '</tr>';
echo '<tr>';
echo '<td>'._('Categories').'</td>';

View File

@ -0,0 +1,8 @@
<?php
if ($author === false) {
echo '<strong>No author found ['.$email.']</strong><br />';
}
else {
echo $author.'<br />';
}
?>