Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
James 2011-11-10 15:35:52 -05:00
commit 56a6da51a9
16 changed files with 278 additions and 68 deletions

View file

@ -81,7 +81,7 @@ class Application_Form_AddUser extends Zend_Form
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('class', 'ui-button ui-state-default right-floated');
$submit->setIgnore(true);
$submit->setLabel('Submit');
$submit->setLabel('Save');
$this->addElement($submit);
}

View file

@ -16,7 +16,7 @@ class Application_Form_AdvancedSearch extends Zend_Form
// Add the submit button
$this->addElement('button', 'search_submit', array(
'ignore' => true,
'label' => 'Submit',
'label' => 'Save',
'order' => '-1'
));
$this->getElement('search_submit')->removeDecorator('DtDdWrapper');

View file

@ -134,7 +134,7 @@ class Application_Form_EditAudioMD extends Zend_Form
$this->addElement('submit', 'submit', array(
'ignore' => true,
'class' => 'ui-button ui-state-default',
'label' => 'Submit',
'label' => 'Save',
'decorators' => array(
'ViewHelper'
)

View file

@ -24,7 +24,7 @@ class Application_Form_PlaylistMetadata extends Zend_Form{
// Add the comment element
$this->addElement('button', 'new_playlist_submit', array(
'label' => 'Submit',
'label' => 'Save',
'ignore' => true
));
}

View file

@ -1,5 +1,7 @@
<?php
require_once 'customfilters/ImageSize.php';
class Application_Form_RegisterAirtime extends Zend_Form
{
@ -102,12 +104,8 @@ class Application_Form_RegisterAirtime extends Zend_Form
->setRequired(false)
->setDecorators(array('File'))
->addValidator('Count', false, 1)
->addValidator('Extension', false, 'jpg,png,gif')
->addValidator('ImageSize', false, array(
'minwidth' => 200,
'minheight' => 200,
'maxwidth' => 600,
'maxheight' => 600));
->addValidator('Extension', false, 'jpg,jpeg,png,gif')
->addFilter('ImageSize');
$this->addElement($upload);
//enable support feedback

View file

@ -1,5 +1,7 @@
<?php
require_once 'customfilters/ImageSize.php';
class Application_Form_SupportSettings extends Zend_Form
{
@ -99,12 +101,8 @@ class Application_Form_SupportSettings extends Zend_Form
->setRequired(false)
->setDecorators(array('File'))
->addValidator('Count', false, 1)
->addValidator('Extension', false, 'jpg,png,gif')
->addValidator('ImageSize', false, array(
'minwidth' => 200,
'minheight' => 200,
'maxwidth' => 600,
'maxheight' => 600));
->addValidator('Extension', false, 'jpg,jpeg,png,gif')
->addFilter('ImageSize');
$upload->setAttrib('accept', 'image/jpeg,image/gif,image/png,image/jpg');
$this->addElement($upload);
@ -153,7 +151,7 @@ class Application_Form_SupportSettings extends Zend_Form
$submit = new Zend_Form_Element_Submit("submit");
$submit->class = 'ui-button ui-state-default right-floated';
$submit->setIgnore(true)
->setLabel("Submit")
->setLabel("Save")
->setDecorators(array('ViewHelper'));
$this->addElement($submit);
}

View file

@ -0,0 +1,42 @@
<?php
class Zend_Filter_ImageSize implements Zend_Filter_Interface {
public function filter($value) {
if(!file_exists($value)) {
throw new Zend_Filter_Exception('Image does not exist: ' . $value);
}
$image = imageCreateFromString(file_get_contents($value));
if(false === $image) {
throw new Zend_Filter_Exception('Can\'t load image: ' . $value);
}
// find ratio to scale down to
// TODO: pass 600 as parameter in the future
$origWidth = imagesx($image);
$origHeight = imagesy($image);
$ratio = max($origWidth, $origHeight) / 600;
if($ratio < 1) {
return;
}
// create a scaled down image
$newWidth = round($origWidth / $ratio);
$newHeight = round($origHeight / $ratio);
$resized = imagecreatetruecolor($newWidth, $newHeight);
imagecopyresampled($resized, $image, 0, 0, 0, 0, $newWidth, $newHeight, $origWidth, $origHeight);
// determine type and store to disk
$explodeResult = explode(".", $value);
$type = $explodeResult[count($explodeResult) - 1];
$writeFunc = 'image' . $type;
if($type == 'jpeg' || $type == 'jpg') {
imagejpeg($resized, $value, 100);
} else {
$writeFunc($resized, $value);
}
}
}
?>

View file

@ -144,7 +144,7 @@
<?php }?>
<?php echo $this->element->getElement('Logo') ?>
<p class="info-text">Min. size: 200x200 Max. size: 600x600</p>
<p class="info-text">Note: Anything larger than 600x600 will be resized.</p>
<?php if($this->element->getElement('Logo')->hasErrors()) : ?>
<ul class='errors'>
<?php foreach($this->element->getElement('Logo')->getMessages() as $error): ?>

View file

@ -138,7 +138,7 @@
<?php }?>
<?php echo $this->element->getElement('Logo') ?>
<div class="info-text"><p>Min. size: 200x200 Max. size: 600x600</p></div>
<div class="info-text"><p>Note: Anything larger than 600x600 will be resized.</p></div>
<?php if($this->element->getElement('Logo')->hasErrors()) : ?>
<ul class='errors'>
<?php foreach($this->element->getElement('Logo')->getMessages() as $error): ?>