setLabel($label); $this->setShowSeconds($showSeconds); $this->setShowFullDate($showFullDate); } /** * Set the Label * * @param Label $label Clock Label * @return \FML\Script\Features\Clock */ public function setLabel(Label $label) { $label->checkId(); $this->label = $label; return $this; } /** * Set whether the Seconds should be shown * * @param bool $showSeconds Whether the Seconds should be shown * @return \FML\Script\Features\Clock */ 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 \FML\Script\Features\Clock */ 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); $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; } }