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);
|
||||
$storedCrit = $bl->getCriteria();
|
||||
|
||||
/* $modRoadMap stores the number of modifier rows each
|
||||
* criteria row has. We need to know this so we display the
|
||||
* the form elements properly
|
||||
|
||||
/* $modRoadMap stores the number of same criteria
|
||||
* Ex: 3 Album titles, and 2 Track titles
|
||||
* We need to know this so we display the form elements properly
|
||||
*/
|
||||
$modRowMap = array();
|
||||
|
||||
|
@ -138,117 +138,78 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
|||
$critCount = 1;
|
||||
}
|
||||
|
||||
$modRowMap[$i] = $critCount-1;
|
||||
$modRowMap[$i] = $critCount;
|
||||
|
||||
/* Loop through all criteria with the same field
|
||||
* Ex: all criteria for 'Album'
|
||||
*/
|
||||
for ($j = 0; $j < $critCount; $j++) {
|
||||
/****************** CRITERIA ***********/
|
||||
if ($j < 1) {
|
||||
$criteria = new Zend_Form_Element_Select("sp_criteria_field_".$i);
|
||||
$criteria->setAttrib('class', 'input_select sp_input_select')
|
||||
->setValue('Select criteria')
|
||||
->setDecorators(array('viewHelper'))
|
||||
->setMultiOptions($criteriaOptions);
|
||||
if ($i != 0 && !isset($criteriaKeys[$i])) {
|
||||
$criteria->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
|
||||
if (isset($criteriaKeys[$i])) {
|
||||
$criteriaType = $criteriaTypes[$storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]];
|
||||
$criteria->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]);
|
||||
}
|
||||
$this->addElement($criteria);
|
||||
|
||||
/****************** MODIFIER ***********/
|
||||
$criteriaModifers = new Zend_Form_Element_Select("sp_criteria_modifier_".$i);
|
||||
$criteriaModifers->setValue('Select modifier')
|
||||
->setAttrib('class', 'input_select sp_input_select')
|
||||
->setDecorators(array('viewHelper'));
|
||||
if ($i != 0 && !isset($criteriaKeys[$i])) {
|
||||
$criteriaModifers->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
if (isset($criteriaKeys[$i])) {
|
||||
if($criteriaType == "s"){
|
||||
$criteriaModifers->setMultiOptions($stringCriteriaOptions);
|
||||
}else{
|
||||
$criteriaModifers->setMultiOptions($numericCriteriaOptions);
|
||||
}
|
||||
$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 ($j > 0) {
|
||||
$invisible = ' sp-invisible';
|
||||
} else {
|
||||
$invisible = '';
|
||||
}
|
||||
|
||||
$criteria = new Zend_Form_Element_Select("sp_criteria_field_".$i."_".$j);
|
||||
$criteria->setAttrib('class', 'input_select sp_input_select'.$invisible)
|
||||
->setValue('Select criteria')
|
||||
->setDecorators(array('viewHelper'))
|
||||
->setMultiOptions($criteriaOptions);
|
||||
if ($i != 0 && !isset($criteriaKeys[$i])) {
|
||||
$criteria->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
|
||||
if (isset($criteriaKeys[$i])) {
|
||||
$criteriaType = $criteriaTypes[$storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]];
|
||||
$criteria->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]);
|
||||
}
|
||||
$this->addElement($criteria);
|
||||
|
||||
/****************** MODIFIER ***********/
|
||||
$criteriaModifers = new Zend_Form_Element_Select("sp_criteria_modifier_".$i."_".$j);
|
||||
$criteriaModifers->setValue('Select modifier')
|
||||
->setAttrib('class', 'input_select sp_input_select')
|
||||
->setDecorators(array('viewHelper'));
|
||||
if ($i != 0 && !isset($criteriaKeys[$i])) {
|
||||
$criteriaModifers->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
if (isset($criteriaKeys[$i])) {
|
||||
if($criteriaType == "s"){
|
||||
$criteriaModifers->setMultiOptions($stringCriteriaOptions);
|
||||
}else{
|
||||
$criteriaModifers->setMultiOptions($numericCriteriaOptions);
|
||||
}
|
||||
$criteriaModifers->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["modifier"]);
|
||||
$this->addElement($criteriaModifers);
|
||||
|
||||
$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);
|
||||
}else{
|
||||
$criteriaModifers->setMultiOptions(array('0' => 'Select modifier'));
|
||||
}
|
||||
|
||||
$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
|
||||
|
|
|
@ -935,6 +935,7 @@ EOT;
|
|||
public function saveSmartBlockCriteria($p_criteria)
|
||||
{
|
||||
$data = $this->organizeSmartPlyalistCriteria($p_criteria);
|
||||
|
||||
// things we need to check
|
||||
// 1. limit value shouldn't be empty and has upperbound of 24 hrs
|
||||
// 2. sp_criteria or sp_criteria_modifier shouldn't be 0
|
||||
|
@ -976,70 +977,11 @@ EOT;
|
|||
}
|
||||
|
||||
$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'])) {
|
||||
$modKeys = array_keys($data['modrow']);
|
||||
for ($i = 0; $i < count($modKeys); $i++) {
|
||||
foreach ($data['modrow'][$modKeys[$i]] as $key=>$d){
|
||||
if (isset($data['criteria'])) {
|
||||
$critKeys = array_keys($data['criteria']);
|
||||
for ($i = 0; $i < count($critKeys); $i++) {
|
||||
foreach ($data['criteria'][$critKeys[$i]] as $key=>$d){
|
||||
$error = array();
|
||||
// check for not selected select box
|
||||
if ($d['sp_criteria_field'] == "0" || $d['sp_criteria_modifier'] == "0"){
|
||||
|
@ -1092,9 +1034,9 @@ EOT;
|
|||
$error[] = "Value cannot be empty";
|
||||
}
|
||||
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
|
||||
}//if
|
||||
|
||||
|
@ -1140,25 +1082,12 @@ EOT;
|
|||
public function storeCriteriaIntoDb($p_criteriaData){
|
||||
// delete criteria under $p_blockId
|
||||
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
|
||||
if (isset($p_criteriaData['modrow'])) {
|
||||
$modKeys = array_keys($p_criteriaData['modrow']);
|
||||
for ($i = 0; $i < count($modKeys); $i++) {
|
||||
foreach( $p_criteriaData['modrow'][$modKeys[$i]] as $d){
|
||||
if (isset($p_criteriaData['criteria'])) {
|
||||
$critKeys = array_keys($p_criteriaData['criteria']);
|
||||
for ($i = 0; $i < count($critKeys); $i++) {
|
||||
foreach( $p_criteriaData['criteria'][$critKeys[$i]] as $d){
|
||||
$qry = new CcBlockcriteria();
|
||||
$qry->setDbCriteria($d['sp_criteria_field'])
|
||||
->setDbModifier($d['sp_criteria_modifier'])
|
||||
|
@ -1379,41 +1308,40 @@ EOT;
|
|||
|
||||
$index = strrpos($ele['name'], '_');
|
||||
|
||||
/* Get criteria row index.
|
||||
* We only need this if there is a modifier row
|
||||
/* Strip field name of modifier index
|
||||
* Ex: sp_criteria_field_0_0 -> sp_criteria_field_0
|
||||
*/
|
||||
$fieldName = substr($ele['name'], 0, $index);
|
||||
|
||||
// Get criteria row index.
|
||||
$tempName = $ele['name'];
|
||||
// Get the last digit in the field name
|
||||
preg_match('/^\D*(?=\d)/', $tempName, $r);
|
||||
if (isset($r[0])) {
|
||||
$critIndexPos = strlen($r[0]);
|
||||
$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
|
||||
* We will know if $fieldName's last character is an integer
|
||||
*/
|
||||
$modRow = $fieldName[strlen($fieldName)-1];
|
||||
if (!preg_match("/^[a-zA-Z]$/", $modRow)) {
|
||||
$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'];
|
||||
}
|
||||
if (in_array($fieldName, $fieldNames)) {
|
||||
$rowNum = intval(substr($ele['name'], $index+1));
|
||||
$output['criteria'][$critIndex][$lastChar][$fieldName] = trim($ele['value']);
|
||||
}else{
|
||||
$output['etc'][$ele['name']] = $ele['value'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $output;
|
||||
}
|
||||
// smart block functions end
|
||||
|
|
|
@ -24,36 +24,22 @@
|
|||
|
||||
<dd id='sp_criteria-element'>
|
||||
<?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';
|
||||
} ?>>
|
||||
<?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 ?>'>
|
||||
<span class='ui-icon ui-icon-plusthick'></span>
|
||||
</a>
|
||||
<?php echo $this->element->getElement("sp_criteria_modifier_".$i) ?>
|
||||
<?php echo $this->element->getElement("sp_criteria_value_".$i) ?>
|
||||
<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>
|
||||
<?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 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 } ?>
|
||||
|
|
|
@ -317,32 +317,22 @@ function reindexElements() {
|
|||
* a modifier row
|
||||
*/
|
||||
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++;
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
$(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) {
|
||||
$(div).remove();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue