コード例 #1
0
ファイル: Attributes.class.php プロジェクト: Niggu/cloudrexx
 /**
  * Returns a string containing an Javascript array variable definition
  * with the first option ID for each Attribute
  *
  * The array has the form
  *  optionId[Attribute ID] = first option ID;
  * Additionally, the variable "index" is set to the highest option ID
  * encountered.  This is incremented for each new option added
  * on the page.
  * @static
  * @access    private
  * @return    string    $jsVars    Javascript variables list
  */
 static function getAttributeJSVars()
 {
     $jsVars = '';
     $highestIndex = 0;
     foreach (Attributes::getOptionArray() as $attribute_id => $arrOption) {
         $first = true;
         foreach (array_keys($arrOption) as $option_id) {
             if ($first) {
                 $jsVars .= "optionId[{$attribute_id}] = {$option_id};\n";
             }
             $first = false;
             if ($option_id > $highestIndex) {
                 $highestIndex = $option_id;
             }
         }
     }
     $jsVars .= "\nindex = " . $highestIndex . ";\n";
     return $jsVars;
 }