setLabel($label); } $this->setShowSeconds($showSeconds) ->setShowFullDate($showFullDate); } /** * Get the Label * * @api * @return Label */ public function getLabel() { return $this->label; } /** * Set the Label * * @api * @param Label $label Clock Label * @return static */ public function setLabel(Label $label) { $label->checkId(); $this->label = $label; return $this; } /** * Get if seconds should be shown * * @api * @return bool */ public function getShowSeconds() { return $this->showSeconds; } /** * Set if seconds should be shown * * @api * @param bool $showSeconds If seconds should be shown * @return static */ public function setShowSeconds($showSeconds) { $this->showSeconds = (bool)$showSeconds; return $this; } /** * Get if the full date should be shown * * @api * @return bool */ public function getShowFullDate() { return $this->showFullDate; } /** * Set if the full date should be shown * * @api * @param bool $showFullDate If the full date should be shown * @return static */ public function setShowFullDate($showFullDate) { $this->showFullDate = (bool)$showFullDate; return $this; } /** * @see ScriptFeature::prepare() */ public function prepare(Script $script) { $script->setScriptInclude(ScriptInclude::TEXTLIB) ->appendGenericScriptLabel(ScriptLabel::TICK, $this->getScriptText(), true); return $this; } /** * Get the script text * * @return string */ protected function getScriptText() { $controlId = Builder::escapeText($this->label->getId()); $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; } }