setLabel($label); } $this->setShowSeconds($showSeconds); $this->setShowFullDate($showFullDate); } /** * Set the Label * * @param Label $label Clock Label * @return static */ public function setLabel(Label $label) { $this->label = $label->checkId(); return $this; } /** * Set whether seconds should be shown * * @param bool $showSeconds Whether seconds should be shown * @return static */ public function setShowSeconds($showSeconds) { $this->showSeconds = (bool)$showSeconds; return $this; } /** * Set whether the full date should be shown * * @param bool $showFullDate Whether the full date should be shown * @return static */ public function setShowFullDate($showFullDate) { $this->showFullDate = (bool)$showFullDate; return $this; } /** * @see \FML\Script\Features\ScriptFeature::prepare() */ public function prepare(Script $script) { $script->setScriptInclude(ScriptInclude::TEXTLIB); $script->appendGenericScriptLabel(ScriptLabel::TICK, $this->getScriptText(), true); return $this; } /** * Get the script text * * @return string */ protected function getScriptText() { $controlId = $this->label->getId(true, true); $scriptText = " declare ClockLabel <=> (Page.GetFirstChild({$controlId}) as CMlLabel); declare TimeText = CurrentLocalDateText;"; if (!$this->showSeconds) { $scriptText .= " TimeText = TextLib::SubText(TimeText, 0, 16);"; } if (!$this->showFullDate) { $scriptText .= " TimeText = TextLib::SubText(TimeText, 11, 9);"; } $scriptText .= " ClockLabel.Value = TimeText;"; return $scriptText; } }