1) { $sRowHeader = ""; } $sRowHeader .= ""; $sRowHeader .= $listHeaderDesigns[$nBaseAttributeIdx + $nYAttributeCount + $nAttributeIdx - 1][$nChoiceIdx]; $sRowHeader .= ""; // // Do recursion on next attribute // drawRows($nAttributeIdx + 1, $listCellChoiceIndices, $sRowHeader); } } else // we reached the last attribute, it's time to output row header and render row data cells { // // Draw table row header // if ( $nXAttributeCount == 0 ) { $sRowHeader .= " "; } echo ""; echo $sRowHeader; // // Draw table data cells // $nColumnIdx = 1; drawRowCells($nColumnIdx, $listCellChoiceIndices); echo ""; } } /*************************************************************** * * drawRowCells - Recursive function for drawing row data cells * * @param int $nColumnIdx index of the current column * @param int $listCellChoiceIndices list of choice indices * @author Zoltan Magyar * ***************************************************************/ function drawRowCells($nColumnIdx, &$listCellChoiceIndices) { global $nYAttributeCount; global $nXAttributeCount; global $nBaseAttributeIdx; global $listAttributeWidgets; global $listChoiceIds; global $listHeaderDesigns; global $listPermutations; global $sATC; global $sProdRef; global $sInvalidPermutation; global $sOOS; global $IsProductInStock; // // Build up a choice-permutation in listCellChoices and after that draw the cell // $nIsProductInStock = 0; if ($nColumnIdx <= $nYAttributeCount) { $nAttributeChoiceCount = count($listHeaderDesigns[$nBaseAttributeIdx + $nColumnIdx - 1]) - 1; for ($i = 1; $i <= $nAttributeChoiceCount; $i++) { $listCellChoiceIndices[$nColumnIdx] = $i; drawRowCells($nColumnIdx + 1, $listCellChoiceIndices); } } else // we know which choices are displayed by this cell, thus draw the cell { // // Check for validity of the given permutation, iterate on permutation list // $nValid = 0; $nPermutationSize = count( $listPermutations ); $nPermutationFound = 0; for( $nPermIdx = 1; $nPermIdx <= $nPermutationSize; $nPermIdx++ ) { $nIsProductInStock = $IsProductInStock [ $nPermIdx ]; // // Iterate on actual choices for the button and try to // find out whether these are present in actual permutation // $nPermChoiceSize = count( $listPermutations[ $nPermIdx ][ 0 ] ); $nChoicesFound = 1; for ($i = 1; $i <= $nXAttributeCount + $nYAttributeCount; $i++) { // // Get next button choice // $nChoiceID = $listChoiceIds[ $nBaseAttributeIdx + $i -1 ][ $listCellChoiceIndices[ $i ] ][ 1 ]; // // Check permutation's choices against it // $nChoiceFound = 0; for( $nPermChoiceIdx = 1; $nPermChoiceIdx <= $nPermChoiceSize; $nPermChoiceIdx++ ) { if ( $listPermutations[ $nPermIdx ][ 0 ][ $nPermChoiceIdx - 1 ] == $nChoiceID ) { $nChoiceFound = 1; break; } } // // If a button choice not found, we don't need this permutation // if ( $nChoiceFound == 0 ) { $nChoicesFound = 0; break; } } // // If all the choices found, check the validity of the actual permutation // if ( $nChoicesFound == 1 ) { $nPermutationFound = 1; $nValid = $listPermutations[ $nPermIdx ][ 1 ]; break; } } // // If invalid permutation was found, skip this button // (if there's no permutation for this button, it should be displayed // by default) // if ( ( $nValid == 0 ) && ( $nPermutationFound == 1 ) ) { echo ""; echo <<"; } elseif ( $nIsProductInStock <= 0 ) { echo ""; echo <<"; } else { // // Draw table data cell // echo ""; echo <<"; //+ // Put together a unique ID for this cell that we can refer to // It has a form _choiceidx1_choiceidx2_... // $nUniqueCellId = ''; for ($ChoiceIdx = 1; $ChoiceIdx <= count($listCellChoiceIndices); $ChoiceIdx++) { $nUniqueCellId .= '_' . $listCellChoiceIndices[$ChoiceIdx]; } // // Insert a local JavaScript into the cell that will adjust hidden fields to reflect the selected cell // echo ""; } } } ?>