public static function render()
{
$output = null;
/* html elements */
$titleElement = new Html\Element();
$titleElement->init('h3', ['class' => self::$_configArray['className']['title']]);
$linkElement = new Html\Element();
$linkElement->init('a');
$listElement = new Html\Element();
$listElement->init('ul', ['class' => self::$_configArray['className']['list']]);
/* query articles */
$articles = Db::forTablePrefix('articles')->where('status', 1)->whereLanguageIs(Registry::get('language'))->orderByDesc('date')->findMany();
/* process articles */
if (!$articles) {
$error = Language::get('article_no') . Language::get('point');
} else {
$accessValidator = new Validator\Access();
$accessDeny = 0;
$lastDate = 0;
foreach ($articles as $value) {
if ($accessValidator->validate($value->access, Registry::get('myGroups')) === Validator\ValidatorInterface::PASSED) {
$month = date('n', strtotime($value->date));
$year = date('Y', strtotime($value->date));
$currentDate = $month + $year;
/* collect output */
if ($lastDate != $currentDate) {
$output .= $titleElement->text(Language::get($month - 1, '_month') . ' ' . $year);
}
$lastDate = $currentDate;
/* collect item output */
$outputItem = '<li>';
$outputItem .= $linkElement->attr(['href' => Registry::get('parameterRoute') . build_route('articles', $value->id), 'title' => $value->description ? $value->description : $value->title])->text($value->title);
$outputItem .= '</li>';
/* collect list output */
$output .= $listElement->html($outputItem);
} else {
$accessDeny++;
}
}
/* handle access */
if (count($articles) === $accessDeny) {
$error = Language::get('access_no') . Language::get('point');
}
}
/* handle error */
if ($error) {
$output = $listElement->html('<li>' . $error . '</li>');
}
return $output;
}