Esempio n. 1
0
 public function testLabel()
 {
     $clock = new Clock();
     $label = new Label();
     $this->assertNull($clock->getLabel());
     $this->assertNull($label->getId());
     $this->assertSame($clock, $clock->setLabel($label));
     $this->assertSame($label, $clock->getLabel());
     $this->assertNotNull($label->getId());
 }
Esempio n. 2
0
 /**
  * Get the script text
  *
  * @return string
  */
 protected function getScriptText()
 {
     $controlId = Builder::escapeText($this->label->getId());
     $scriptText = "\ndeclare ClockLabel <=> (Page.GetFirstChild({$controlId}) as CMlLabel);\ndeclare TimeText = CurrentLocalDateText;";
     if (!$this->showSeconds) {
         $scriptText .= "\nTimeText = TextLib::SubText(TimeText, 0, 16);";
     }
     if (!$this->showFullDate) {
         $scriptText .= "\nTimeText = TextLib::SubText(TimeText, 11, 9);";
     }
     $scriptText .= "\nClockLabel.Value = TimeText;";
     return $scriptText;
 }
 public function testControl()
 {
     $actionTrigger = new ActionTrigger();
     $control = new Label();
     $this->assertNull($actionTrigger->getControl());
     $this->assertNull($control->getId());
     $this->assertNull($control->getScriptEvents());
     $this->assertSame($actionTrigger, $actionTrigger->setControl($control));
     $this->assertEquals($control, $actionTrigger->getControl());
     $this->assertNotNull($control->getId());
     $this->assertTrue($control->getScriptEvents());
     $this->assertSame($actionTrigger, $actionTrigger->setControl(null));
     $this->assertNull($actionTrigger->getControl());
 }
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;
 }