1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Modules\Contents;
13
14 use ICanBoogie\I18n;
15
16 17 18 19 20
21 class CacheManager implements \Icybee\Modules\Cache\CacheManagerInterface
22 {
23 public $title = "Contents body";
24 public $description = "The rendered body of contents is cached.";
25 public $group = 'contents';
26 public $state = false;
27 public $config_preview;
28
29 public function __construct()
30 {
31 global $core;
32
33 $this->state = !empty($core->registry['contents.cache_rendered_body']);
34 }
35
36 public function enable()
37 {
38 global $core;
39
40 return $core->registry['contents.cache_rendered_body'] = true;
41 }
42
43 public function disable()
44 {
45 global $core;
46
47 return $core->registry['contents.cache_rendered_body'] = false;
48 }
49
50 public function stat()
51 {
52 global $core;
53
54 $model = $core->models['contents/rendered'];
55
56 list($count, $size) = $model->select('COUNT(nid) count, SUM(LENGTH(body)) size')->one(\PDO::FETCH_NUM);
57
58 return [ (int) $count, I18n\t(':count records<br /><span class="small">:size</span>', [ ':count' => (int) $count, 'size' => \ICanBoogie\I18n\format_size($size) ]) ];
59 }
60
61 function clear()
62 {
63 global $core;
64
65 return $core->models['contents/rendered']->truncate();
66 }
67 }