blob: 428877552fdf0ace8d8b0838d450ff45e0c936cb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
<?php
class HelpbarTextElement extends WidgetElement
{
public function __construct($label, $id, $language = null)
{
$language = $language ?: $GLOBALS['user']->preferred_language;
try {
$query = "SELECT content
FROM help_content
WHERE content_id = :id AND language = :language
ORDER BY version DESC
LIMIT 1";
$statement = DBManager::get()->prepare($query);
$statement->bindValue(':id', $id);
$statement->bindValue(':language', $language);
$statement->execute();
$text = $statement->fetchColumn() ?: sprintf('Unknown help id "%s"', $id);
$content = sprintf('<strong>%s</strong><p>%s</p>',
htmlReady($label), formatReady($text));
} catch (Exception $e) {
if ($GLOBALS['user']->perms === 'root') {
$content = 'DB-Error: please migrate';
} else {
$content = '';
}
}
parent::__construct($content);
}
}
|