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

This commit is contained in:
Martin Konecny 2012-08-28 12:30:45 -04:00
commit 219fba9bee
7 changed files with 86 additions and 44 deletions

View file

@ -64,7 +64,7 @@ class PlaylistController extends Zend_Controller_Action
unset($this->view->obj);
}
private function createFullResponse($obj = null, $isJson = false)
private function createFullResponse($obj = null, $isJson = false, $formIsValid = false)
{
$isBlock = false;
$viewPath = 'playlist/playlist.phtml';
@ -80,11 +80,12 @@ class PlaylistController extends Zend_Controller_Action
if ($isBlock) {
$form = new Application_Form_SmartBlockCriteria();
$form->removeDecorator('DtDdWrapper');
$form->startForm($obj->getId());
$form->startForm($obj->getId(), $formIsValid);
$this->view->form = $form;
$this->view->obj = $obj;
$this->view->id = $obj->getId();
if ($isJson) {
return $this->view->render($viewPath);
} else {
@ -460,7 +461,7 @@ class PlaylistController extends Zend_Controller_Action
$bl = new Application_Model_Block($params['obj_id']);
if ($form->isValid($params)) {
$bl->saveSmartBlockCriteria($params['data']);
$result['html'] = $this->createFullResponse($bl, true);
$result['html'] = $this->createFullResponse($bl, true, true);
$result['result'] = 0;
} else {
$this->view->obj = $bl;
@ -486,7 +487,7 @@ class PlaylistController extends Zend_Controller_Action
if ($form->isValid($params)) {
$result = $bl->generateSmartBlock($params['data']);
try {
die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($bl, true))));
die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($bl, true, true))));
} catch (PlaylistNotFoundException $e) {
$this->playlistNotFound('block');
} catch (Exception $e) {

View file

@ -88,7 +88,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
}
public function startForm($p_blockId)
public function startForm($p_blockId, $p_isValid = false)
{
// load type
$out = CcBlockQuery::create()->findPk($p_blockId);
@ -236,7 +236,13 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
//getting block content candidate count that meets criteria
$bl = new Application_Model_Block($p_blockId);
$files = $bl->getListofFilesMeetCriteria();
if ($p_isValid) {
$files = $bl->getListofFilesMeetCriteria();
$showPoolCount = true;
} else {
$files = null;
$showPoolCount = false;
}
$generate = new Zend_Form_Element_Button('generate_button');
$generate->setAttrib('class', 'ui-button ui-state-default sp-button');
@ -256,7 +262,8 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/smart-block-criteria.phtml', "openOption"=> $openSmartBlockOption,
'criteriasLength' => count($this->criteriaOptions), 'poolCount' => $files['count'], 'modRowMap' => $modRowMap))
'criteriasLength' => count($this->criteriaOptions), 'poolCount' => $files['count'], 'modRowMap' => $modRowMap,
'showPoolCount' => $showPoolCount))
));
}

View file

@ -1187,6 +1187,16 @@ EOT;
if (isset($criteria['extra'])) {
$spCriteriaExtra = $criteria['extra']*1000;
}
/*
* If user is searching for an exact match of length we need to
* search as if it starts with the specified length because the
* user only sees the rounded version (i.e. 4:02.7 is 4:02.761625
* in the database)
*/
} else if ($spCriteria == 'length' && $spCriteriaModifier == "is") {
$spCriteriaModifier = "starts with";
$spCriteria = $spCriteria.'::text';
$spCriteriaValue = $criteria['value'];
} else {
/* Propel does not escape special characters properly when using LIKE/ILIKE
* We have to add extra slashes in these cases
@ -1214,6 +1224,7 @@ EOT;
}
$spCriteriaModifier = self::$modifier2CriteriaMap[$spCriteriaModifier];
try {
if ($i > 0) {
$qry->addOr($spCriteria, $spCriteriaValue, $spCriteriaModifier);

View file

@ -66,32 +66,35 @@
<?php endif; ?>
<br />
</dd>
<div class='sp_text_font sp_text_font_bold'>
<span id='sp_pool_count' class='sp_text_font sp_text_font_bold'>
<?php
if ($this->poolCount > 1) {
echo $this->poolCount;
?>
files meet the criteria
</span>
<span class='checked-icon sp-checked-icon' id='sp_pool_count_icon'></span>
<?php
} else if ($this->poolCount == 1) {
echo $this->poolCount;
?>
file meets the criteria
</span>
<span class='checked-icon sp-checked-icon' id='sp_pool_count_icon'></span>
<?php
} else {
?>
0 files meet the criteria
</span>
<span class='sp-warning-icon' id='sp_pool_count_icon'></span>
<?php
}
?>
</div>
<?php if ($this->showPoolCount) { ?>
<div class='sp_text_font sp_text_font_bold'>
<span id='sp_pool_count' class='sp_text_font sp_text_font_bold'>
<?php
if ($this->poolCount > 1) {
echo $this->poolCount;
?>
files meet the criteria
</span>
<span class='checked-icon sp-checked-icon' id='sp_pool_count_icon'></span>
<?php
} else if ($this->poolCount == 1) {
echo $this->poolCount;
?>
file meets the criteria
</span>
<span class='checked-icon sp-checked-icon' id='sp_pool_count_icon'></span>
<?php
} else {
?>
0 files meet the criteria
</span>
<span class='sp-warning-icon' id='sp_pool_count_icon'></span>
<?php
}
?>
</div>
<?php } ?>
</dl>