Esempio n. 1
0
 /**
  * @see ScriptFeature::prepare()
  */
 public function prepare(Script $script)
 {
     $script->appendGenericScriptLabel($this->labelName, $this->getScriptText());
     return $this;
 }
Esempio n. 2
0
 /**
  * @see ScriptFeature::prepare()
  */
 public function prepare(Script $script)
 {
     $script->appendGenericScriptLabel(ScriptLabel::KEYPRESS, $this->getScriptText());
     return $this;
 }
Esempio n. 3
0
 /**
  * @see ScriptFeature::prepare()
  */
 public function prepare(Script $script)
 {
     $script->setScriptInclude(ScriptInclude::TEXTLIB);
     $controlScript = new ControlScript($this->entry, $this->getScriptText(), ScriptLabel::ENTRYSUBMIT);
     $controlScript->prepare($script);
     return $this;
 }
Esempio n. 4
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;
 }
 /**
  * @see ScriptFeature::prepare()
  */
 public function prepare(Script $script)
 {
     $isolated = !ScriptLabel::isEventLabel($this->labelName);
     $script->appendGenericScriptLabel($this->labelName, $this->buildScriptText(), $isolated);
     return $this;
 }
Esempio n. 6
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;
 }
Esempio n. 7
0
 /**
  * @see ScriptFeature::prepare()
  */
 public function prepare(Script $script)
 {
     $script->setScriptInclude(ScriptInclude::TEXTLIB)->appendGenericScriptLabel(ScriptLabel::TICK, $this->getScriptText(), true);
     return $this;
 }
 /**
  * @see ScriptFeature::prepare()
  */
 public function prepare(Script $script)
 {
     if ($this->getQuad()) {
         $script->setScriptInclude(ScriptInclude::TEXTLIB);
         $script->addScriptFunction(self::FUNCTION_UPDATE_QUAD_DESIGN, $this->buildUpdateQuadDesignFunction());
         $script->appendGenericScriptLabel(ScriptLabel::ONINIT, $this->buildInitScriptText(), true);
         $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $this->buildClickScriptText());
     }
     return $this;
 }
Esempio n. 9
0
 /**
  * @see ScriptFeature::prepare()
  */
 public function prepare(Script $script)
 {
     $updateFunctionName = self::FUNCTION_UPDATE_MENU;
     $elementsArrayText = $this->getElementsArrayText();
     // OnInit
     if ($this->startElement) {
         $startControlId = Builder::escapeText($this->startElement->getControl()->getId());
         $initScriptText = "\n{$updateFunctionName}({$elementsArrayText}, {$startControlId});";
         $script->appendGenericScriptLabel(ScriptLabel::ONINIT, $initScriptText, true);
     }
     // MouseClick
     $scriptText = "\ndeclare MenuElements = {$elementsArrayText};\nif (MenuElements.existskey(Event.Control.ControlId)) {\n\tdeclare ShownControlId = MenuElements[Event.Control.ControlId];\n\t{$updateFunctionName}(MenuElements, ShownControlId);\n}";
     $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $scriptText, true);
     // Update menu function
     $updateFunctionText = "\nVoid {$updateFunctionName}(Text[Text] _Elements, Text _ShownControlId) {\n\tforeach (ItemId => ControlId in _Elements) {\n\t\tdeclare Control <=> (Page.GetFirstChild(ControlId));\n\t\tControl.Visible = (ControlId == _ShownControlId);\n\t}\n}";
     $script->addScriptFunction($updateFunctionName, $updateFunctionText);
     return $this;
 }
Esempio n. 10
0
 public function testRenderWithScript()
 {
     $maniaLink = new ManiaLink();
     $script = new Script();
     $script->addCustomScriptLabel("some-label", "some-code");
     $maniaLink->setScript($script);
     $domDocument = $maniaLink->render();
     $this->assertNotEquals("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n<manialink version=\"1\"/>\n", $domDocument->saveXML());
 }
Esempio n. 11
0
 /**
  * Render the ManiaLink
  *
  * @param bool         $echo        (optional) If the XML text should be echoed and the Content-Type header should be set
  * @param \DOMDocument $domDocument (optional) DOMDocument for which the ManiaLink should be rendered
  * @return \DOMDocument
  */
 public function render($echo = false, $domDocument = null)
 {
     $isChild = (bool) $domDocument;
     if (!$isChild) {
         $domDocument = new \DOMDocument("1.0", "utf-8");
         $domDocument->xmlStandalone = true;
     }
     $maniaLink = $domDocument->createElement("manialink");
     if (!$isChild) {
         $domDocument->appendChild($maniaLink);
     }
     $maniaLink->setAttribute("version", "1");
     if ($this->maniaLinkId) {
         $maniaLink->setAttribute("id", $this->maniaLinkId);
     }
     if ($this->name) {
         $maniaLink->setAttribute("name", $this->name);
     }
     if ($this->background) {
         $maniaLink->setAttribute("background", $this->background);
     }
     if (!$this->navigable3d) {
         $maniaLink->setAttribute("navigable3d", "0");
     }
     if ($this->timeout) {
         $timeoutXml = $domDocument->createElement("timeout", $this->timeout);
         $maniaLink->appendChild($timeoutXml);
     }
     if ($this->dico) {
         $dicoXml = $this->dico->render($domDocument);
         $maniaLink->appendChild($dicoXml);
     }
     $scriptFeatures = array();
     foreach ($this->children as $child) {
         $childXml = $child->render($domDocument);
         $maniaLink->appendChild($childXml);
         if ($child instanceof ScriptFeatureable) {
             $scriptFeatures = array_merge($scriptFeatures, $child->getScriptFeatures());
         }
     }
     if ($this->stylesheet) {
         $stylesheetXml = $this->stylesheet->render($domDocument);
         $maniaLink->appendChild($stylesheetXml);
     }
     if ($scriptFeatures) {
         $this->createScript()->loadFeatures($scriptFeatures);
     }
     if ($this->script) {
         if ($this->script->needsRendering()) {
             $scriptXml = $this->script->render($domDocument);
             $maniaLink->appendChild($scriptXml);
         }
         $this->script->resetGenericScriptLabels();
     }
     if ($isChild) {
         return $maniaLink;
     }
     if ($echo) {
         header("Content-Type: application/xml; charset=utf-8;");
         echo $domDocument->saveXML();
     }
     return $domDocument;
 }
 /**
  * @see ScriptFeature::prepare()
  */
 public function prepare(Script $script)
 {
     if ($this->label) {
         $script->setScriptInclude(ScriptInclude::TEXTLIB);
         $script->addScriptFunction(self::FUNCTION_UPDATE_PICKER_VALUE, $this->buildUpdatePickerValueFunction());
         $script->appendGenericScriptLabel(ScriptLabel::ONINIT, $this->buildInitScriptText(), true);
         $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $this->buildClickScriptText());
     }
     return $this;
 }