/** * Execute the extra */ public function execute() { parent::execute(); $contentBlock = $this->get('content_blocks.repository.content_block')->findOneByIdAndLocale((int) $this->data['id'], Locale::frontendLanguage()); // if the content block is not found or if it is hidden, just return an array with empty text // @deprecated fix this for version 5, we just shouldn't assign this instead of this hack, but we need it for BC if (!$contentBlock instanceof ContentBlock || $contentBlock->isHidden()) { $contentBlock = ['text' => '']; } $this->tpl->assign('widgetContentBlocks', $contentBlock); // That's all folks! }
/** * Formats a timestamp as a string that indicates the time ago * syntax: {{ $string|timeago }}. * * @param string $string A UNIX-timestamp that will be formatted as a time-ago-string. * * @return string */ public static function timeAgo($string = null) { $string = (int) $string; // invalid timestamp if ($string == 0) { return ''; } // return return '<abbr title="' . \SpoonDate::getDate(FrontendModel::get('fork.settings')->get('Core', 'date_format_long') . ', ' . FrontendModel::get('fork.settings')->get('Core', 'time_format'), $string, Locale::frontendLanguage()) . '">' . \SpoonDate::getTimeAgo($string, Locale::frontendLanguage()) . '</abbr>'; }