1 | <?php |
||
13 | class Text { |
||
14 | use Singleton; |
||
15 | /** |
||
16 | * Gets text on current language |
||
17 | * |
||
18 | * @param int $database |
||
19 | * @param int|null $id Getting may be done with group and label or with id |
||
20 | * @param bool $store_in_cache If `true` - text will be stored in cache |
||
21 | * |
||
22 | * @return false|string |
||
23 | */ |
||
24 | 12 | public function get ($database, $id = null, $store_in_cache = false) { |
|
41 | /** |
||
42 | * @param int $database |
||
43 | * @param string $clang |
||
44 | * @param int $id |
||
45 | * |
||
46 | * @return false|string |
||
47 | */ |
||
48 | 12 | protected function get_text_by_id ($database, $clang, $id) { |
|
49 | 12 | $cdb = DB::instance()->db($database); |
|
50 | 12 | $text = $cdb->qfs( |
|
51 | "SELECT `d`.`text` |
||
52 | FROM `[prefix]texts` AS `t` |
||
53 | LEFT JOIN `[prefix]texts_data` AS `d` |
||
54 | ON `t`.`id` = `d`.`id` |
||
55 | WHERE |
||
56 | 12 | `t`.`id` = $id AND |
|
57 | `d`.`lang` = '%s' |
||
58 | LIMIT 1", |
||
59 | $clang |
||
60 | ); |
||
61 | 12 | if (!$text) { |
|
62 | 12 | $text = $cdb->qfs( |
|
63 | "SELECT `d`.`text` |
||
64 | FROM `[prefix]texts` AS `t` |
||
65 | LEFT JOIN `[prefix]texts_data` AS `d` |
||
66 | ON `t`.`id` = `d`.`id` |
||
67 | 12 | WHERE `t`.`id` = $id |
|
68 | LIMIT 1" |
||
69 | ); |
||
70 | } |
||
71 | 12 | return $text; |
|
72 | } |
||
73 | /** |
||
74 | * Sets text on current language |
||
75 | * |
||
76 | * @param int $database |
||
77 | * @param string $group |
||
78 | * @param string $label |
||
79 | * @param string $text |
||
80 | * |
||
81 | * @return false|string If multilingual support enabled or was enabled and then disabled but translations remains - returns {¶<i>id</i>}, otherwise returns |
||
82 | * original text |
||
83 | */ |
||
84 | 10 | public function set ($database, $group, $label, $text) { |
|
133 | /** |
||
134 | * @param int $id |
||
135 | * @param string $text |
||
136 | * @param DB\_Abstract $cdb |
||
137 | * @param string $clang |
||
138 | * |
||
139 | * @return mixed |
||
140 | */ |
||
141 | 8 | protected function set_text ($id, $text, $cdb, $clang) { |
|
191 | /** |
||
192 | * Deletes text on all languages |
||
193 | * |
||
194 | * @param int $database |
||
195 | * @param string $group |
||
196 | * @param string $label |
||
197 | * |
||
198 | * @return bool |
||
199 | */ |
||
200 | 2 | public function del ($database, $group, $label) { |
|
229 | /** |
||
230 | * Process text, and replace {¶([0-9]+)} on real text, is used before showing multilingual information |
||
231 | * |
||
232 | * @param int $database |
||
233 | * @param string|string[] $data |
||
234 | * @param bool $store_in_cache If <b>true</b> - text will be stored in cache |
||
235 | * |
||
236 | * @return string|string[] |
||
237 | */ |
||
238 | 18 | public function process ($database, $data, $store_in_cache = false) { |
|
253 | } |
||
254 |