Ejemplo n.º 1
0
 public function testBoolean()
 {
     $this->assertEquals("True", Builder::getBoolean(true));
     $this->assertEquals("False", Builder::getBoolean(false));
 }
Ejemplo n.º 2
0
 /**
  * @see ScriptFeature::prepare()
  */
 public function prepare(Script $script)
 {
     $hoverControlId = Builder::escapeText($this->hoverControl->getId());
     $tooltipControlId = Builder::escapeText($this->tooltipControl->getId());
     // MouseOver
     $visibility = Builder::getBoolean(!$this->invert);
     $scriptText = "\nif (Event.Control.ControlId == {$hoverControlId}) {\n\tdeclare TooltipControl = Page.GetFirstChild({$tooltipControlId});\n\tTooltipControl.Visible = {$visibility};";
     if (is_string($this->text) && $this->tooltipControl instanceof Label) {
         $tooltipText = Builder::escapeText($this->text);
         $scriptText .= "\n\tdeclare TooltipLabel = (TooltipControl as CMlLabel);\n\tTooltipLabel.Value = {$tooltipText};";
     }
     $scriptText .= "\n}";
     $script->appendGenericScriptLabel(ScriptLabel::MOUSEOVER, $scriptText);
     // MouseOut
     $visibility = Builder::getBoolean($this->invert);
     $scriptText = "\nif (Event.Control.ControlId == {$hoverControlId}) {\n\tdeclare TooltipControl = Page.GetFirstChild({$tooltipControlId});";
     if ($this->stayOnClick) {
         $scriptText .= "\n\tdeclare FML_Clicked for Event.Control = False;\n\tif (!FML_Clicked) ";
     }
     $scriptText .= "\n\tTooltipControl.Visible = {$visibility};\n}";
     $script->appendGenericScriptLabel(ScriptLabel::MOUSEOUT, $scriptText);
     // MouseClick
     if ($this->stayOnClick) {
         $scriptText = "\nif (Event.Control.ControlId == {$hoverControlId}) {\n\tdeclare FML_Clicked for Event.Control = False;\n\tFML_Clicked = !FML_Clicked;\n}";
         $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $scriptText);
     }
     return $this;
 }
Ejemplo n.º 3
0
 /**
  * @see ScriptFeature::prepare()
  */
 public function prepare(Script $script)
 {
     if (empty($this->pages)) {
         return $this;
     }
     $script->setScriptInclude(ScriptInclude::TEXTLIB);
     $currentPageVariable = self::VAR_CURRENT_PAGE;
     $updatePageFunction = self::FUNCTION_UPDATE_CURRENT_PAGE;
     $minPageNumber = 1;
     $startPageNumber = is_int($this->startPageNumber) ? $this->startPageNumber : $minPageNumber;
     $maxPage = $this->getMaxPage();
     $maxPageNumber = $this->customMaxPageNumber;
     if (!is_int($maxPageNumber)) {
         $maxPageNumber = $maxPage->getPageNumber();
     }
     $pagingId = $maxPage->getControl()->getId(true, true);
     $pagingId = Builder::escapeText($maxPage->getControl()->getId());
     $pageLabelId = Builder::EMPTY_STRING;
     if ($this->label) {
         $pageLabelId = Builder::escapeText($this->label->getId());
     }
     $pagesArrayText = $this->getPagesArrayText();
     $pageButtonsArrayText = $this->getPageButtonsArrayText();
     $previousChunkAction = Builder::escapeText($this->previousChunkAction);
     $nextChunkAction = Builder::escapeText($this->nextChunkAction);
     $chunkActionAppendsPageNumber = Builder::getBoolean($this->chunkActionAppendsPageNumber);
     // Init
     $initScriptText = "\ndeclare {$currentPageVariable} for This = Integer[Text];\n{$currentPageVariable}[{$pagingId}] = {$startPageNumber};\n{$updatePageFunction}({$pagingId}, {$pageLabelId}, 0, {$minPageNumber}, {$maxPageNumber}, {$pagesArrayText}, {$previousChunkAction}, {$nextChunkAction}, {$chunkActionAppendsPageNumber});";
     $script->appendGenericScriptLabel(ScriptLabel::ONINIT, $initScriptText, true);
     // MouseClick
     $clickScriptText = "\ndeclare PageButtons = {$pageButtonsArrayText};\nif (PageButtons.existskey(Event.Control.ControlId)) {\n\tdeclare BrowseAction = PageButtons[Event.Control.ControlId];\n\t{$updatePageFunction}({$pagingId}, {$pageLabelId}, BrowseAction, {$minPageNumber}, {$maxPageNumber}, {$pagesArrayText}, {$previousChunkAction}, {$nextChunkAction}, {$chunkActionAppendsPageNumber});\n}";
     $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $clickScriptText, true);
     // Update function
     $functionText = "\nVoid {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAction, Integer _MinPageNumber, Integer _MaxPageNumber, Text[Integer] _Pages, Text _PreviousChunkAction, Text _NextChunkAction, Boolean _ChunkActionAppendPageNumber) {\n\tdeclare {$currentPageVariable} for This = Integer[Text];\n\tif (!{$currentPageVariable}.existskey(_PagingId)) return;\n\tdeclare CurrentPage = {$currentPageVariable}[_PagingId] + _BrowseAction;\n\tif (CurrentPage < _MinPageNumber) {\n\t\tCurrentPage = _MinPageNumber;\n\t} else if (CurrentPage > _MaxPageNumber) {\n\t\tCurrentPage = _MaxPageNumber;\n\t}\n\t{$currentPageVariable}[_PagingId] = CurrentPage;\n\tdeclare PageFound = False;\n\tforeach (PageNumber => PageId in _Pages) {\n\t\tdeclare PageControl <=> Page.GetFirstChild(PageId);\n\t\tPageControl.Visible = (CurrentPage == PageNumber);\n\t\tif (PageControl.Visible) {\n\t\t\tPageFound = True;\n\t\t}\n\t}\n\tif (!PageFound && _BrowseAction != 0) {\n\t\tdeclare Text ChunkAction;\n\t\tif (_BrowseAction < 0) {\n\t\t\tChunkAction = _PreviousChunkAction;\n\t\t} else {\n\t\t\tChunkAction = _NextChunkAction;\n\t\t}\n\t\tif (_ChunkActionAppendPageNumber) {\n\t\t\tChunkAction ^= CurrentPage;\n\t\t}\n\t\tTriggerPageAction(ChunkAction);\n\t}\n\tif (_PageLabelId == " . Builder::EMPTY_STRING . ") return;\n\tdeclare PageLabel <=> (Page.GetFirstChild(_PageLabelId) as CMlLabel);\n\tif (PageLabel == Null) return;\n\tPageLabel.Value = CurrentPage^\"/\"^_MaxPageNumber;\n}";
     $script->addScriptFunction($updatePageFunction, $functionText);
     return $this;
 }
Ejemplo n.º 4
0
 /**
  * Build the init script text
  *
  * @return string
  */
 protected function buildInitScriptText()
 {
     $quadId = Builder::getId($this->getQuad());
     $entryId = Builder::EMPTY_STRING;
     if ($this->entry) {
         $entryId = Builder::getId($this->getEntry());
     }
     $default = Builder::getBoolean($this->default);
     $enabledDesignString = $this->enabledDesign->getDesignString();
     $disabledDesignString = $this->disabledDesign->getDesignString();
     return "\ndeclare Quad_CheckBox <=> (Page.GetFirstChild(\"{$quadId}\") as CMlQuad);\ndeclare Text[Boolean] " . self::VAR_CHECKBOX_DESIGNS . " as Designs for Quad_CheckBox;\nDesigns[True] = \"{$enabledDesignString}\";\nDesigns[False] = \"{$disabledDesignString}\";\ndeclare Boolean " . self::VAR_CHECKBOX_ENABLED . " as Enabled for Quad_CheckBox;\nEnabled = !{$default};\ndeclare Text " . self::VAR_CHECKBOX_ENTRY_ID . " as EntryId for Quad_CheckBox;\nEntryId = \"{$entryId}\";\n" . self::FUNCTION_UPDATE_QUAD_DESIGN . "(Quad_CheckBox);\n";
 }