Issues (1358)

modules/Content/events.php (1 issue)

1
<?php
2
/**
3
 * @package  Content
4
 * @category modules
5
 * @author   Nazar Mokrynskyi <[email protected]>
6
 * @license  0BSD
7
 */
8
namespace cs\modules\Content;
9
use
10
	cs\Config,
11
	cs\Event,
12
	cs\Page;
13
14
Event::instance()
15
	->on(
16
		'System/Page/render/after',
17
		function () {
18
			$module_data = Config::instance()->module('Content');
19
			if ($module_data->simple_insert && $module_data->enabled()) {
0 ignored issues
show
Bug Best Practice introduced by
The property simple_insert does not exist on cs\Config\Module_Properties. Since you implemented __get, consider adding a @property annotation.
Loading history...
20
				$Page          = Page::instance();
21
				$Page->Content = preg_replace_callback(
22
					'/{(Content|Content_title):(.+)}/Uims',
23
					function ($match) {
24
						$content = Content::instance()->get($match[2]);
25
						return $content[$match[1] == 'Content' ? 'content' : 'title'];
26
					},
27
					$Page->Content
28
				);
29
			}
30
		}
31
	)
32
	->on(
33
		'admin/System/modules/uninstall/before',
34
		function ($data) {
35
			if ($data['name'] != 'Content') {
36
				return;
37
			}
38
			time_limit_pause();
39
			$Content = Content::instance();
40
			foreach ($Content->get_all() ?: [] as $item) {
41
				$Content->del($item);
42
			}
43
			time_limit_pause(false);
44
		}
45
	);
46