-
Notifications
You must be signed in to change notification settings - Fork 1
/
Common.php
52 lines (31 loc) · 1.04 KB
/
Common.php
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace Addon\Polls;
defined('is_running') or die('Not an entry point...');
class Common{
public static $lang;
static function GetTranslations(){
global $config, $addonPathCode;
$path = $addonPathCode.'/languages/';
self::$lang = \gpFiles::Get($path.$config['language'].'.php', 'lang') ?: \gpFiles::Get($path.'en.php', 'lang');
}
static function GetPolls(){
global $addonPathData;
return \gpFiles::Get($addonPathData.'/polls.php', 'polls');
}
static function GetPoll($id){
global $addonPathData;
return \gpFiles::Get($addonPathData.'/'.$id.'/poll.php', 'poll');
}
static function GetVotes($id){
global $addonPathData;
return \gpFiles::Get($addonPathData.'/'.$id.'/votes.php', 'votes');
}
static function ShowResults($poll_id){
$votes = self::GetVotes($poll_id);
$poll = self::GetPoll($poll_id);
$content = '<h4>'.$poll['poll_question'].'</h4>';
foreach ($poll['poll_answers'] as $answer)
$content .= '<p>'.$answer.' ('.(isset($votes[$answer]) ? $votes[$answer] : 0).')</p>';
return $content;
}
}