public function testArrayAssociative() { $this->assertEquals("[0 => \"a\", 1 => \"b\", 2 => \"c\"]", Builder::getArray(array("a", "b", "c"), true)); $this->assertEquals("[\"a\" => 1, \"b\" => 2, \"c\" => 3]", Builder::getArray(array("a" => 1, "b" => 2, "c" => 3), true)); $this->assertEquals("[0 => -1, 1 => -2, 2 => -3]", Builder::getArray(array(-1, -2, -3), true)); $this->assertEquals("[0 => 1.2, 1 => 3.4, 2 => 5.6]", Builder::getArray(array(1.2, 3.4, 5.6), true)); }
/** * Build the array text for the Elements * * @return string */ protected function getElementsArrayText() { $elements = array(); foreach ($this->elements as $element) { $elementId = $element->getItem()->getId(); $elements[$elementId] = $element->getControl()->getId(); } return Builder::getArray($elements, true); }
/** * Build the array text for the Page Buttons * * @return string */ protected function getPageButtonsArrayText() { if (empty($this->buttons)) { return Builder::getArray(array('' => 0), true); } $pageButtons = array(); foreach ($this->buttons as $pageButton) { $pageButtons[$pageButton->getControl()->getId()] = $pageButton->getPagingCount(); } return Builder::getArray($pageButtons, true); }
/** * Build the init script text * * @return string */ protected function buildInitScriptText() { $labelId = Builder::getId($this->label); $entryId = Builder::EMPTY_STRING; if ($this->entry) { $entryId = Builder::getId($this->entry); } $values = Builder::getArray($this->values); $default = Builder::escapeText($this->getDefault()); return "\ndeclare Label_Picker <=> (Page.GetFirstChild(\"{$labelId}\") as CMlLabel);\ndeclare Text[] " . self::VAR_PICKER_VALUES . " as Values for Label_Picker;\nValues = {$values};\ndeclare Text " . self::VAR_PICKER_DEFAULT_VALUE . " as Default for Label_Picker;\nDefault = {$default};\ndeclare Text " . self::VAR_PICKER_ENTRY_ID . " as EntryId for Label_Picker;\nEntryId = \"{$entryId}\";\n" . self::FUNCTION_UPDATE_PICKER_VALUE . "(Label_Picker);\n"; }