1 | <?php |
||
14 | class wordgraph extends block |
||
15 | { |
||
16 | /** @var \phpbb\auth\auth */ |
||
17 | protected $auth; |
||
18 | |||
19 | /** @var \phpbb\content_visibility */ |
||
20 | protected $content_visibility; |
||
21 | |||
22 | /** @var \phpbb\db\driver\driver_interface */ |
||
23 | protected $db; |
||
24 | |||
25 | /** @var string */ |
||
26 | protected $phpbb_root_path; |
||
27 | |||
28 | /** @var string */ |
||
29 | protected $php_ext; |
||
30 | |||
31 | /** @var int */ |
||
32 | protected $cache_time; |
||
33 | |||
34 | /** |
||
35 | * Constructor |
||
36 | * |
||
37 | * @param \phpbb\auth\auth $auth Auth object |
||
38 | * @param \phpbb\content_visibility $content_visibility Content visibility |
||
39 | * @param \phpbb\db\driver\driver_interface $db Database connection |
||
40 | * @param string $phpbb_root_path phpBB root path |
||
41 | * @param string $php_ext phpEx |
||
42 | */ |
||
43 | 3 | public function __construct(\phpbb\auth\auth $auth, \phpbb\content_visibility $content_visibility, \phpbb\db\driver\driver_interface $db, $phpbb_root_path, $php_ext, $cache_time = 10800) |
|
44 | { |
||
45 | 3 | $this->auth = $auth; |
|
46 | 3 | $this->content_visibility = $content_visibility; |
|
47 | 3 | $this->db = $db; |
|
48 | 3 | $this->phpbb_root_path = $phpbb_root_path; |
|
49 | 3 | $this->php_ext = $php_ext; |
|
50 | 3 | $this->cache_time = $cache_time; |
|
51 | 3 | } |
|
52 | |||
53 | /** |
||
54 | * {@inheritdoc} |
||
55 | */ |
||
56 | 1 | public function get_config(array $settings) |
|
57 | { |
||
58 | return array( |
||
59 | 1 | 'legend1' => 'SETTINGS', |
|
60 | 1 | 'show_word_count' => array('lang' => 'SHOW_WORD_COUNT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false, 'default' => 0), |
|
61 | 1 | 'max_num_words' => array('lang' => 'MAX_WORDS', 'validate' => 'int:0:255', 'type' => 'number:0:255', 'maxlength' => 2, 'explain' => false, 'default' => 15), |
|
62 | 1 | 'max_word_size' => array('lang' => 'WORD_MAX_SIZE', 'validate' => 'int:0:55', 'type' => 'number:0:55', 'maxlength' => 2, 'explain' => false, 'default' => 25, 'append' => 'PIXEL'), |
|
63 | 1 | 'min_word_size' => array('lang' => 'WORD_MIN_SIZE', 'validate' => 'int:0:20', 'type' => 'number:0:20', 'maxlength' => 2, 'explain' => false, 'default' => 9, 'append' => 'PIXEL'), |
|
64 | 1 | 'exclude_words' => array('lang' => 'EXCLUDE_WORDS', 'validate' => 'string', 'type' => 'textarea:5:50', 'maxlength' => 255, 'explain' => true, 'default' => ''), |
|
65 | 1 | ); |
|
66 | } |
||
67 | |||
68 | /** |
||
69 | * {@inheritdoc} |
||
70 | */ |
||
71 | 2 | public function display(array $bdata, $edit_mode = false) |
|
72 | { |
||
73 | 2 | $settings = $bdata['settings']; |
|
74 | $block = array( |
||
75 | 2 | 'title' => 'WORDGRAPH', |
|
76 | 2 | 'content' => '', |
|
77 | 2 | ); |
|
78 | |||
79 | 2 | $words_array = $this->get_words($settings); |
|
80 | 2 | if (sizeof($words_array)) |
|
81 | 2 | { |
|
82 | 2 | $this->show_graph($words_array, $settings); |
|
83 | |||
84 | 2 | $block['content'] = $this->ptemplate->render_view('blitze/sitemaker', 'blocks/wordgraph.html', 'wordgraph_block'); |
|
85 | 2 | } |
|
86 | |||
87 | 2 | return $block; |
|
88 | } |
||
89 | |||
90 | /** |
||
91 | * @param array $words_array |
||
92 | * @param array $settings |
||
93 | */ |
||
94 | 2 | private function show_graph(array $words_array, array $settings) |
|
117 | |||
118 | /** |
||
119 | * @param array $words_array |
||
120 | * @param array $settings |
||
121 | * @return array |
||
122 | */ |
||
123 | 2 | private function get_graph_params(array $words_array, array $settings) |
|
148 | |||
149 | /** |
||
150 | * @param array $settings |
||
151 | * @return array |
||
152 | */ |
||
153 | 2 | private function get_words(array $settings) |
|
169 | |||
170 | /** |
||
171 | * @param string $exclude_words |
||
172 | * @return array |
||
173 | */ |
||
174 | 2 | private function get_words_sql($exclude_words) |
|
197 | |||
198 | /** |
||
199 | * @param string $exclude_words Comma separated string of words |
||
200 | * @return string |
||
201 | */ |
||
202 | 2 | private function exclude_words_sql($exclude_words) |
|
213 | |||
214 | /** |
||
215 | * @param string $word |
||
216 | * @param int $count |
||
217 | * @param bool $show_count |
||
218 | * @return string |
||
219 | */ |
||
220 | 2 | private function show_word($word, $count, $show_count) |
|
224 | } |
||
225 |