Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
dc31525d4c
|
@ -112,10 +112,10 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
||||||
|
|
||||||
$bl = new Application_Model_Block($p_blockId);
|
$bl = new Application_Model_Block($p_blockId);
|
||||||
$storedCrit = $bl->getCriteria();
|
$storedCrit = $bl->getCriteria();
|
||||||
|
|
||||||
/* $modRoadMap stores the number of modifier rows each
|
/* $modRoadMap stores the number of same criteria
|
||||||
* criteria row has. We need to know this so we display the
|
* Ex: 3 Album titles, and 2 Track titles
|
||||||
* the form elements properly
|
* We need to know this so we display the form elements properly
|
||||||
*/
|
*/
|
||||||
$modRowMap = array();
|
$modRowMap = array();
|
||||||
|
|
||||||
|
@ -138,117 +138,78 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
||||||
$critCount = 1;
|
$critCount = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$modRowMap[$i] = $critCount-1;
|
$modRowMap[$i] = $critCount;
|
||||||
|
|
||||||
/* Loop through all criteria with the same field
|
/* Loop through all criteria with the same field
|
||||||
* Ex: all criteria for 'Album'
|
* Ex: all criteria for 'Album'
|
||||||
*/
|
*/
|
||||||
for ($j = 0; $j < $critCount; $j++) {
|
for ($j = 0; $j < $critCount; $j++) {
|
||||||
/****************** CRITERIA ***********/
|
/****************** CRITERIA ***********/
|
||||||
if ($j < 1) {
|
if ($j > 0) {
|
||||||
$criteria = new Zend_Form_Element_Select("sp_criteria_field_".$i);
|
$invisible = ' sp-invisible';
|
||||||
$criteria->setAttrib('class', 'input_select sp_input_select')
|
} else {
|
||||||
->setValue('Select criteria')
|
$invisible = '';
|
||||||
->setDecorators(array('viewHelper'))
|
}
|
||||||
->setMultiOptions($criteriaOptions);
|
|
||||||
if ($i != 0 && !isset($criteriaKeys[$i])) {
|
$criteria = new Zend_Form_Element_Select("sp_criteria_field_".$i."_".$j);
|
||||||
$criteria->setAttrib('disabled', 'disabled');
|
$criteria->setAttrib('class', 'input_select sp_input_select'.$invisible)
|
||||||
}
|
->setValue('Select criteria')
|
||||||
|
->setDecorators(array('viewHelper'))
|
||||||
if (isset($criteriaKeys[$i])) {
|
->setMultiOptions($criteriaOptions);
|
||||||
$criteriaType = $criteriaTypes[$storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]];
|
if ($i != 0 && !isset($criteriaKeys[$i])) {
|
||||||
$criteria->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]);
|
$criteria->setAttrib('disabled', 'disabled');
|
||||||
}
|
}
|
||||||
$this->addElement($criteria);
|
|
||||||
|
if (isset($criteriaKeys[$i])) {
|
||||||
/****************** MODIFIER ***********/
|
$criteriaType = $criteriaTypes[$storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]];
|
||||||
$criteriaModifers = new Zend_Form_Element_Select("sp_criteria_modifier_".$i);
|
$criteria->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]);
|
||||||
$criteriaModifers->setValue('Select modifier')
|
}
|
||||||
->setAttrib('class', 'input_select sp_input_select')
|
$this->addElement($criteria);
|
||||||
->setDecorators(array('viewHelper'));
|
|
||||||
if ($i != 0 && !isset($criteriaKeys[$i])) {
|
/****************** MODIFIER ***********/
|
||||||
$criteriaModifers->setAttrib('disabled', 'disabled');
|
$criteriaModifers = new Zend_Form_Element_Select("sp_criteria_modifier_".$i."_".$j);
|
||||||
}
|
$criteriaModifers->setValue('Select modifier')
|
||||||
if (isset($criteriaKeys[$i])) {
|
->setAttrib('class', 'input_select sp_input_select')
|
||||||
if($criteriaType == "s"){
|
->setDecorators(array('viewHelper'));
|
||||||
$criteriaModifers->setMultiOptions($stringCriteriaOptions);
|
if ($i != 0 && !isset($criteriaKeys[$i])) {
|
||||||
}else{
|
$criteriaModifers->setAttrib('disabled', 'disabled');
|
||||||
$criteriaModifers->setMultiOptions($numericCriteriaOptions);
|
}
|
||||||
}
|
if (isset($criteriaKeys[$i])) {
|
||||||
$criteriaModifers->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["modifier"]);
|
|
||||||
}else{
|
|
||||||
$criteriaModifers->setMultiOptions(array('0' => 'Select modifier'));
|
|
||||||
}
|
|
||||||
$this->addElement($criteriaModifers);
|
|
||||||
|
|
||||||
/****************** VALUE ***********/
|
|
||||||
$criteriaValue = new Zend_Form_Element_Text("sp_criteria_value_".$i);
|
|
||||||
$criteriaValue->setAttrib('class', 'input_text sp_input_text')
|
|
||||||
->setDecorators(array('viewHelper'));
|
|
||||||
if ($i != 0 && !isset($criteriaKeys[$i])){
|
|
||||||
$criteriaValue->setAttrib('disabled', 'disabled');
|
|
||||||
}
|
|
||||||
if (isset($criteriaKeys[$i])) {
|
|
||||||
$criteriaValue->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["value"]);
|
|
||||||
}
|
|
||||||
$this->addElement($criteriaValue);
|
|
||||||
|
|
||||||
/****************** EXTRA ***********/
|
|
||||||
$criteriaExtra = new Zend_Form_Element_Text("sp_criteria_extra_".$i);
|
|
||||||
$criteriaExtra->setAttrib('class', 'input_text sp_extra_input_text')
|
|
||||||
->setDecorators(array('viewHelper'));
|
|
||||||
if (isset($criteriaKeys[$i]) && isset($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"])) {
|
|
||||||
$criteriaExtra->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"]);
|
|
||||||
$criteriaValue->setAttrib('class', 'input_text sp_extra_input_text');
|
|
||||||
}else{
|
|
||||||
$criteriaExtra->setAttrib('disabled', 'disabled');
|
|
||||||
}
|
|
||||||
$this->addElement($criteriaExtra);
|
|
||||||
|
|
||||||
/* This is where the additional modifier rows get defined
|
|
||||||
* The additional row count starts at 0 and gets appended
|
|
||||||
* to the parent field name
|
|
||||||
*/
|
|
||||||
} else if (count($storedCrit["crit"][$criteriaKeys[$i]]) > 1) {
|
|
||||||
$n = $j - 1;
|
|
||||||
$criteria = new Zend_Form_Element_Select("sp_criteria_field_".$i."_".$n);
|
|
||||||
$criteria->setAttrib('class', 'input_select sp_input_select sp-invisible')
|
|
||||||
->setValue('Select criteria')
|
|
||||||
->setDecorators(array('viewHelper'))
|
|
||||||
->setMultiOptions($criteriaOptions)
|
|
||||||
->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]);
|
|
||||||
$this->addElement($criteria);
|
|
||||||
|
|
||||||
$criteriaModifers = new Zend_Form_Element_Select("sp_criteria_modifier_".$i."_".$n);
|
|
||||||
$criteriaModifers->setValue('Select modifier')
|
|
||||||
->setAttrib('class', 'input_select sp_input_select')
|
|
||||||
->setDecorators(array('viewHelper'));
|
|
||||||
if($criteriaType == "s"){
|
if($criteriaType == "s"){
|
||||||
$criteriaModifers->setMultiOptions($stringCriteriaOptions);
|
$criteriaModifers->setMultiOptions($stringCriteriaOptions);
|
||||||
}else{
|
}else{
|
||||||
$criteriaModifers->setMultiOptions($numericCriteriaOptions);
|
$criteriaModifers->setMultiOptions($numericCriteriaOptions);
|
||||||
}
|
}
|
||||||
$criteriaModifers->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["modifier"]);
|
$criteriaModifers->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["modifier"]);
|
||||||
$this->addElement($criteriaModifers);
|
}else{
|
||||||
|
$criteriaModifers->setMultiOptions(array('0' => 'Select modifier'));
|
||||||
$criteriaValue = new Zend_Form_Element_Text("sp_criteria_value_".$i."_".$n);
|
|
||||||
$criteriaValue->setAttrib('class', 'input_text sp_input_text')
|
|
||||||
->setDecorators(array('viewHelper'))
|
|
||||||
->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["value"]);
|
|
||||||
$this->addElement($criteriaValue);
|
|
||||||
|
|
||||||
$criteriaExtra = new Zend_Form_Element_Text("sp_criteria_extra_".$i."_".$n);
|
|
||||||
$criteriaExtra->setAttrib('class', 'input_text sp_extra_input_text')
|
|
||||||
->setDecorators(array('viewHelper'));
|
|
||||||
if (isset($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"])) {
|
|
||||||
$criteriaExtra->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"]);
|
|
||||||
$criteriaValue->setAttrib('class', 'input_text sp_extra_input_text');
|
|
||||||
}else{
|
|
||||||
$criteriaExtra->setAttrib('disabled', 'disabled');
|
|
||||||
}
|
|
||||||
$this->addElement($criteriaExtra);
|
|
||||||
}
|
}
|
||||||
|
$this->addElement($criteriaModifers);
|
||||||
|
|
||||||
|
/****************** VALUE ***********/
|
||||||
|
$criteriaValue = new Zend_Form_Element_Text("sp_criteria_value_".$i."_".$j);
|
||||||
|
$criteriaValue->setAttrib('class', 'input_text sp_input_text')
|
||||||
|
->setDecorators(array('viewHelper'));
|
||||||
|
if ($i != 0 && !isset($criteriaKeys[$i])){
|
||||||
|
$criteriaValue->setAttrib('disabled', 'disabled');
|
||||||
|
}
|
||||||
|
if (isset($criteriaKeys[$i])) {
|
||||||
|
$criteriaValue->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["value"]);
|
||||||
|
}
|
||||||
|
$this->addElement($criteriaValue);
|
||||||
|
|
||||||
|
/****************** EXTRA ***********/
|
||||||
|
$criteriaExtra = new Zend_Form_Element_Text("sp_criteria_extra_".$i."_".$j);
|
||||||
|
$criteriaExtra->setAttrib('class', 'input_text sp_extra_input_text')
|
||||||
|
->setDecorators(array('viewHelper'));
|
||||||
|
if (isset($criteriaKeys[$i]) && isset($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"])) {
|
||||||
|
$criteriaExtra->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"]);
|
||||||
|
$criteriaValue->setAttrib('class', 'input_text sp_extra_input_text');
|
||||||
|
}else{
|
||||||
|
$criteriaExtra->setAttrib('disabled', 'disabled');
|
||||||
|
}
|
||||||
|
$this->addElement($criteriaExtra);
|
||||||
|
|
||||||
}//for
|
}//for
|
||||||
|
|
||||||
}//for
|
}//for
|
||||||
|
|
|
@ -935,6 +935,7 @@ EOT;
|
||||||
public function saveSmartBlockCriteria($p_criteria)
|
public function saveSmartBlockCriteria($p_criteria)
|
||||||
{
|
{
|
||||||
$data = $this->organizeSmartPlyalistCriteria($p_criteria);
|
$data = $this->organizeSmartPlyalistCriteria($p_criteria);
|
||||||
|
|
||||||
// things we need to check
|
// things we need to check
|
||||||
// 1. limit value shouldn't be empty and has upperbound of 24 hrs
|
// 1. limit value shouldn't be empty and has upperbound of 24 hrs
|
||||||
// 2. sp_criteria or sp_criteria_modifier shouldn't be 0
|
// 2. sp_criteria or sp_criteria_modifier shouldn't be 0
|
||||||
|
@ -976,70 +977,11 @@ EOT;
|
||||||
}
|
}
|
||||||
|
|
||||||
$criteriaFieldsUsed = array();
|
$criteriaFieldsUsed = array();
|
||||||
foreach ($data['criteria'] as $key=>$d){
|
|
||||||
$error = array();
|
|
||||||
// check for not selected select box
|
|
||||||
if ($d['sp_criteria_field'] == "0" || $d['sp_criteria_modifier'] == "0"){
|
|
||||||
$error[] = "You must select Criteria and Modifier";
|
|
||||||
} else if (in_array($d['sp_criteria_field'], $criteriaFieldsUsed)) {
|
|
||||||
$error[] = "Criteria fields can only be used once";
|
|
||||||
} else {
|
|
||||||
array_push($criteriaFieldsUsed, $d['sp_criteria_field']);
|
|
||||||
$column = CcFilesPeer::getTableMap()->getColumnByPhpName(self::$criteria2PeerMap[$d['sp_criteria_field']]);
|
|
||||||
// validation on type of column
|
|
||||||
if ($d['sp_criteria_field'] == 'length') {
|
|
||||||
if (!preg_match("/^(\d{2}):(\d{2}):(\d{2})$/", $d['sp_criteria_value'])) {
|
|
||||||
$error[] = "'Length' should be in '00:00:00' format";
|
|
||||||
}
|
|
||||||
} else if ($column->getType() == PropelColumnTypes::TIMESTAMP) {
|
|
||||||
if (!preg_match("/(\d{4})-(\d{2})-(\d{2})/", $d['sp_criteria_value'])) {
|
|
||||||
$error[] = "The value should be in timestamp format(eg. 0000-00-00 or 00-00-00 00:00:00";
|
|
||||||
} else {
|
|
||||||
$result = Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_value']);
|
|
||||||
if (!$result["success"]) {
|
|
||||||
// check for if it is in valid range( 1753-01-01 ~ 12/31/9999 )
|
|
||||||
$error[] = $result["errMsg"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($d['sp_criteria_extra'])) {
|
|
||||||
if (!preg_match("/(\d{4})-(\d{2})-(\d{2})/", $d['sp_criteria_extra'])) {
|
|
||||||
$error[] = "The value should be in timestamp format(eg. 0000-00-00 or 00-00-00 00:00:00";
|
|
||||||
} else {
|
|
||||||
$result = Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_extra']);
|
|
||||||
if (!$result["success"]) {
|
|
||||||
// check for if it is in valid range( 1753-01-01 ~ 12/31/9999 )
|
|
||||||
$error[] = $result["errMsg"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if ($column->getType() == PropelColumnTypes::INTEGER) {
|
|
||||||
if (!is_numeric($d['sp_criteria_value'])) {
|
|
||||||
$error[] = "The value has to be numeric";
|
|
||||||
}
|
|
||||||
// length check
|
|
||||||
if (intval($d['sp_criteria_value']) >= pow(2,31)) {
|
|
||||||
$error[] = "The value should be less then 2147483648";
|
|
||||||
}
|
|
||||||
} else if ($column->getType() == PropelColumnTypes::VARCHAR) {
|
|
||||||
if (strlen($d['sp_criteria_value']) > $column->getSize()) {
|
|
||||||
$error[] = "The value should be less ".$column->getSize()." characters";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($d['sp_criteria_value'] == "") {
|
|
||||||
$error[] = "Value cannot be empty";
|
|
||||||
}
|
|
||||||
if(count($error) > 0){
|
|
||||||
$errors[] = array("element"=>"sp_criteria_field_".$key, "msg"=>$error);
|
|
||||||
}
|
|
||||||
}// foreach
|
|
||||||
|
|
||||||
if (isset($data['modrow'])) {
|
if (isset($data['criteria'])) {
|
||||||
$modKeys = array_keys($data['modrow']);
|
$critKeys = array_keys($data['criteria']);
|
||||||
for ($i = 0; $i < count($modKeys); $i++) {
|
for ($i = 0; $i < count($critKeys); $i++) {
|
||||||
foreach ($data['modrow'][$modKeys[$i]] as $key=>$d){
|
foreach ($data['criteria'][$critKeys[$i]] as $key=>$d){
|
||||||
$error = array();
|
$error = array();
|
||||||
// check for not selected select box
|
// check for not selected select box
|
||||||
if ($d['sp_criteria_field'] == "0" || $d['sp_criteria_modifier'] == "0"){
|
if ($d['sp_criteria_field'] == "0" || $d['sp_criteria_modifier'] == "0"){
|
||||||
|
@ -1092,9 +1034,9 @@ EOT;
|
||||||
$error[] = "Value cannot be empty";
|
$error[] = "Value cannot be empty";
|
||||||
}
|
}
|
||||||
if(count($error) > 0){
|
if(count($error) > 0){
|
||||||
$errors[] = array("element"=>"sp_criteria_field_".$modKeys[$i]."_".$key, "msg"=>$error);
|
$errors[] = array("element"=>"sp_criteria_field_".$critKeys[$i]."_".$key, "msg"=>$error);
|
||||||
}
|
}
|
||||||
}//end mod foreach
|
}//end foreach
|
||||||
}//for loop
|
}//for loop
|
||||||
}//if
|
}//if
|
||||||
|
|
||||||
|
@ -1140,25 +1082,12 @@ EOT;
|
||||||
public function storeCriteriaIntoDb($p_criteriaData){
|
public function storeCriteriaIntoDb($p_criteriaData){
|
||||||
// delete criteria under $p_blockId
|
// delete criteria under $p_blockId
|
||||||
CcBlockcriteriaQuery::create()->findByDbBlockId($this->id)->delete();
|
CcBlockcriteriaQuery::create()->findByDbBlockId($this->id)->delete();
|
||||||
|
|
||||||
foreach( $p_criteriaData['criteria'] as $d){
|
|
||||||
$qry = new CcBlockcriteria();
|
|
||||||
$qry->setDbCriteria($d['sp_criteria_field'])
|
|
||||||
->setDbModifier($d['sp_criteria_modifier'])
|
|
||||||
->setDbValue($d['sp_criteria_value'])
|
|
||||||
->setDbBlockId($this->id);
|
|
||||||
|
|
||||||
if (isset($d['sp_criteria_extra'])) {
|
|
||||||
$qry->setDbExtra($d['sp_criteria_extra']);
|
|
||||||
}
|
|
||||||
$qry->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
//insert modifier rows
|
//insert modifier rows
|
||||||
if (isset($p_criteriaData['modrow'])) {
|
if (isset($p_criteriaData['criteria'])) {
|
||||||
$modKeys = array_keys($p_criteriaData['modrow']);
|
$critKeys = array_keys($p_criteriaData['criteria']);
|
||||||
for ($i = 0; $i < count($modKeys); $i++) {
|
for ($i = 0; $i < count($critKeys); $i++) {
|
||||||
foreach( $p_criteriaData['modrow'][$modKeys[$i]] as $d){
|
foreach( $p_criteriaData['criteria'][$critKeys[$i]] as $d){
|
||||||
$qry = new CcBlockcriteria();
|
$qry = new CcBlockcriteria();
|
||||||
$qry->setDbCriteria($d['sp_criteria_field'])
|
$qry->setDbCriteria($d['sp_criteria_field'])
|
||||||
->setDbModifier($d['sp_criteria_modifier'])
|
->setDbModifier($d['sp_criteria_modifier'])
|
||||||
|
@ -1379,41 +1308,40 @@ EOT;
|
||||||
|
|
||||||
$index = strrpos($ele['name'], '_');
|
$index = strrpos($ele['name'], '_');
|
||||||
|
|
||||||
/* Get criteria row index.
|
/* Strip field name of modifier index
|
||||||
* We only need this if there is a modifier row
|
* Ex: sp_criteria_field_0_0 -> sp_criteria_field_0
|
||||||
*/
|
*/
|
||||||
|
$fieldName = substr($ele['name'], 0, $index);
|
||||||
|
|
||||||
|
// Get criteria row index.
|
||||||
$tempName = $ele['name'];
|
$tempName = $ele['name'];
|
||||||
|
// Get the last digit in the field name
|
||||||
preg_match('/^\D*(?=\d)/', $tempName, $r);
|
preg_match('/^\D*(?=\d)/', $tempName, $r);
|
||||||
if (isset($r[0])) {
|
if (isset($r[0])) {
|
||||||
$critIndexPos = strlen($r[0]);
|
$critIndexPos = strlen($r[0]);
|
||||||
$critIndex = $tempName[$critIndexPos];
|
$critIndex = $tempName[$critIndexPos];
|
||||||
}
|
}
|
||||||
|
$lastChar = substr($ele['name'], -1);
|
||||||
|
|
||||||
$fieldName = substr($ele['name'], 0, $index);
|
// If lastChar is an integer we should strip it off
|
||||||
|
if (!preg_match("/^[a-zA-Z]$/", $lastChar)) {
|
||||||
|
/* Strip field name of criteria index
|
||||||
|
* Ex: sp_criteria_field_0 -> sp_criteria_field
|
||||||
|
* We do this to check if the field name is a criteria
|
||||||
|
* or the block type
|
||||||
|
*/
|
||||||
|
$n = strrpos($fieldName, '_');
|
||||||
|
$fieldName = substr($fieldName, 0, $n);
|
||||||
|
}
|
||||||
|
|
||||||
/* Determine if this is a modifier row
|
if (in_array($fieldName, $fieldNames)) {
|
||||||
* We will know if $fieldName's last character is an integer
|
$rowNum = intval(substr($ele['name'], $index+1));
|
||||||
*/
|
$output['criteria'][$critIndex][$lastChar][$fieldName] = trim($ele['value']);
|
||||||
$modRow = $fieldName[strlen($fieldName)-1];
|
}else{
|
||||||
if (!preg_match("/^[a-zA-Z]$/", $modRow)) {
|
$output['etc'][$ele['name']] = $ele['value'];
|
||||||
$modIndex = strrpos($fieldName, '_');
|
|
||||||
$fieldName = substr($fieldName, 0, $modIndex);
|
|
||||||
if (in_array($fieldName, $fieldNames)) {
|
|
||||||
$rowNum = intval($tempName[strlen($tempName)-1]);
|
|
||||||
$output['modrow'][$critIndex][$rowNum][$fieldName] = trim($ele['value']);
|
|
||||||
}else{
|
|
||||||
$output['etc'][$ele['name']] = $ele['value'];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (in_array($fieldName, $fieldNames)) {
|
|
||||||
$rowNum = intval(substr($ele['name'], $index+1));
|
|
||||||
$output['criteria'][$rowNum][$fieldName] = trim($ele['value']);
|
|
||||||
}else{
|
|
||||||
$output['etc'][$ele['name']] = $ele['value'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
// smart block functions end
|
// smart block functions end
|
||||||
|
|
|
@ -24,36 +24,22 @@
|
||||||
|
|
||||||
<dd id='sp_criteria-element'>
|
<dd id='sp_criteria-element'>
|
||||||
<?php for ($i = 0; $i < $this->criteriasLength; $i++) {?>
|
<?php for ($i = 0; $i < $this->criteriasLength; $i++) {?>
|
||||||
<div <?php if (($i > 0) && ($this->element->getElement("sp_criteria_field_".$i)->getAttrib('disabled') == 'disabled')) {
|
<?php for ($j = 0; $j < $this->modRowMap[$i]; $j++) {?>
|
||||||
|
<div <?php if (($i > 0) && ($this->element->getElement("sp_criteria_field_".$i."_".$j)->getAttrib('disabled') == 'disabled')) {
|
||||||
echo 'style=display:none';
|
echo 'style=display:none';
|
||||||
} ?>>
|
} ?>>
|
||||||
<?php echo $this->element->getElement("sp_criteria_field_".$i) ?>
|
<?php echo $this->element->getElement("sp_criteria_field_".$i."_".$j) ?>
|
||||||
<a class='ui-button sp-ui-button-icon-only sp_no_margins' id='modifier_add_<?php echo $i ?>'>
|
<a class='ui-button sp-ui-button-icon-only sp_no_margins' id='modifier_add_<?php echo $i ?>'>
|
||||||
<span class='ui-icon ui-icon-plusthick'></span>
|
<span class='ui-icon ui-icon-plusthick'></span>
|
||||||
</a>
|
</a>
|
||||||
<?php echo $this->element->getElement("sp_criteria_modifier_".$i) ?>
|
<?php echo $this->element->getElement("sp_criteria_modifier_".$i."_".$j) ?>
|
||||||
<?php echo $this->element->getElement("sp_criteria_value_".$i) ?>
|
<?php echo $this->element->getElement("sp_criteria_value_".$i."_".$j) ?>
|
||||||
<span class='sp_text_font' id="extra_criteria" <?php echo $this->element->getElement("sp_criteria_extra_".$i)->getAttrib("disabled") == "disabled"?'style="display:none;"':""?>> to <?php echo $this->element->getElement('sp_criteria_extra_'.$i) ?></span>
|
<span class='sp_text_font' id="extra_criteria" <?php echo $this->element->getElement("sp_criteria_extra_".$i."_".$j)->getAttrib("disabled") == "disabled"?'style="display:none;"':""?>> to <?php echo $this->element->getElement('sp_criteria_extra_'.$i."_".$j) ?></span>
|
||||||
<a class='ui-button sp-ui-button-icon-only' id='criteria_remove_<?php echo $i ?>'>
|
<a class='ui-button sp-ui-button-icon-only' id='criteria_remove_<?php echo $i ?>'>
|
||||||
<span class='ui-icon ui-icon-closethick'></span>
|
<span class='ui-icon ui-icon-closethick'></span>
|
||||||
</a>
|
</a>
|
||||||
<br />
|
<br />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php for ($j = 0; $j < $this->modRowMap[$i]; $j++) {?>
|
|
||||||
<div>
|
|
||||||
<?php echo $this->element->getElement("sp_criteria_field_".$i."_".$j) ?>
|
|
||||||
<a class='ui-button sp-ui-button-icon-only sp_no_margins' id='modifier_add_<?php echo $i ?>'>
|
|
||||||
<span class='ui-icon ui-icon-plusthick'></span>
|
|
||||||
</a>
|
|
||||||
<?php echo $this->element->getElement("sp_criteria_modifier_".$i."_".$j) ?>
|
|
||||||
<?php echo $this->element->getElement("sp_criteria_value_".$i."_".$j) ?>
|
|
||||||
<span class='sp_text_font' id="extra_criteria" <?php echo $this->element->getElement("sp_criteria_extra_".$i."_".$j)->getAttrib("disabled") == "disabled"?'style="display:none;"':""?>> to <?php echo $this->element->getElement('sp_criteria_extra_'.$i."_".$j) ?></span>
|
|
||||||
<a class='ui-button sp-ui-button-icon-only' id='criteria_remove_<?php echo $i ?>'>
|
|
||||||
<span class='ui-icon ui-icon-closethick'></span>
|
|
||||||
</a>
|
|
||||||
<br />
|
|
||||||
</div>
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
|
@ -317,32 +317,22 @@ function reindexElements() {
|
||||||
* a modifier row
|
* a modifier row
|
||||||
*/
|
*/
|
||||||
if ($(div).find('select[name^="sp_criteria_field"]').hasClass('sp-invisible')) {
|
if ($(div).find('select[name^="sp_criteria_field"]').hasClass('sp-invisible')) {
|
||||||
|
|
||||||
$(div).find('select[name^="sp_criteria_field"]').attr('name', 'sp_criteria_field_'+index+'_'+modIndex);
|
|
||||||
$(div).find('select[name^="sp_criteria_field"]').attr('id', 'sp_criteria_field_'+index+'_'+modIndex);
|
|
||||||
$(div).find('select[name^="sp_criteria_modifier"]').attr('name', 'sp_criteria_modifier_'+index+'_'+modIndex);
|
|
||||||
$(div).find('select[name^="sp_criteria_modifier"]').attr('id', 'sp_criteria_modifier_'+index+'_'+modIndex);
|
|
||||||
$(div).find('input[name^="sp_criteria_value"]').attr('name', 'sp_criteria_value_'+index+'_'+modIndex);
|
|
||||||
$(div).find('input[name^="sp_criteria_value"]').attr('id', 'sp_criteria_value_'+index+'_'+modIndex);
|
|
||||||
$(div).find('input[name^="sp_criteria_extra"]').attr('name', 'sp_criteria_extra_'+index+'_'+modIndex);
|
|
||||||
$(div).find('input[name^="sp_criteria_extra"]').attr('id', 'sp_criteria_extra_'+index+'_'+modIndex);
|
|
||||||
$(div).find('a[name^="modifier_add"]').attr('id', 'modifier_add_'+index);
|
|
||||||
$(div).find('a[id^="criteria_remove"]').attr('id', 'criteria_remove_'+index+'_'+modIndex);
|
|
||||||
modIndex++;
|
modIndex++;
|
||||||
} else {
|
} else {
|
||||||
index++;
|
index++;
|
||||||
$(div).find('select[name^="sp_criteria_field"]').attr('name', 'sp_criteria_field_'+index);
|
|
||||||
$(div).find('select[name^="sp_criteria_field"]').attr('id', 'sp_criteria_field_'+index);
|
|
||||||
$(div).find('select[name^="sp_criteria_modifier"]').attr('name', 'sp_criteria_modifier_'+index);
|
|
||||||
$(div).find('select[name^="sp_criteria_modifier"]').attr('id', 'sp_criteria_modifier_'+index);
|
|
||||||
$(div).find('input[name^="sp_criteria_value"]').attr('name', 'sp_criteria_value_'+index);
|
|
||||||
$(div).find('input[name^="sp_criteria_value"]').attr('id', 'sp_criteria_value_'+index);
|
|
||||||
$(div).find('input[name^="sp_criteria_extra"]').attr('name', 'sp_criteria_extra_'+index);
|
|
||||||
$(div).find('input[name^="sp_criteria_extra"]').attr('id', 'sp_criteria_extra_'+index);
|
|
||||||
$(div).find('a[name^="modifier_add"]').attr('id', 'modifier_add_'+index);
|
|
||||||
$(div).find('a[id^="criteria_remove"]').attr('id', 'criteria_remove_'+index);
|
|
||||||
modIndex = 0;
|
modIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$(div).find('select[name^="sp_criteria_field"]').attr('name', 'sp_criteria_field_'+index+'_'+modIndex);
|
||||||
|
$(div).find('select[name^="sp_criteria_field"]').attr('id', 'sp_criteria_field_'+index+'_'+modIndex);
|
||||||
|
$(div).find('select[name^="sp_criteria_modifier"]').attr('name', 'sp_criteria_modifier_'+index+'_'+modIndex);
|
||||||
|
$(div).find('select[name^="sp_criteria_modifier"]').attr('id', 'sp_criteria_modifier_'+index+'_'+modIndex);
|
||||||
|
$(div).find('input[name^="sp_criteria_value"]').attr('name', 'sp_criteria_value_'+index+'_'+modIndex);
|
||||||
|
$(div).find('input[name^="sp_criteria_value"]').attr('id', 'sp_criteria_value_'+index+'_'+modIndex);
|
||||||
|
$(div).find('input[name^="sp_criteria_extra"]').attr('name', 'sp_criteria_extra_'+index+'_'+modIndex);
|
||||||
|
$(div).find('input[name^="sp_criteria_extra"]').attr('id', 'sp_criteria_extra_'+index+'_'+modIndex);
|
||||||
|
$(div).find('a[name^="modifier_add"]').attr('id', 'modifier_add_'+index);
|
||||||
|
$(div).find('a[id^="criteria_remove"]').attr('id', 'criteria_remove_'+index+'_'+modIndex);
|
||||||
} else if (i > 0) {
|
} else if (i > 0) {
|
||||||
$(div).remove();
|
$(div).remove();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue