1
|
|
|
<?php |
2
|
|
|
class Install_Helper_CMS |
3
|
|
|
{ |
4
|
|
|
private $kernel; |
5
|
|
|
private $db; |
6
|
|
|
|
7
|
|
|
public function __construct($kernel, $db) |
8
|
|
|
{ |
9
|
|
|
$this->kernel = $kernel; |
10
|
|
|
$this->db = $db; |
11
|
|
|
} |
12
|
|
|
|
13
|
|
|
public function createSite() |
14
|
|
|
{ |
15
|
|
|
require_once 'Intraface/modules/cms/Site.php'; |
16
|
|
|
$site = new CMS_Site($this->kernel); |
17
|
|
|
$site_id = $site->save(array('name' => 'Test', 'url' => 'http://localhost/')); |
|
|
|
|
18
|
|
|
|
19
|
|
|
|
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
public function createSiteWithTemplate() { |
23
|
|
|
require_once 'Intraface/modules/cms/Site.php'; |
24
|
|
|
$site = new CMS_Site($this->kernel); |
25
|
|
|
$site_id = $site->save(array('name' => 'Test', 'url' => 'http://localhost/')); |
|
|
|
|
26
|
|
|
|
27
|
|
|
require_once 'Intraface/modules/cms/Template.php'; |
28
|
|
|
$template = new CMS_Template($site); |
29
|
|
|
$template_id = $template->save(array('name' => 'Test', 'identifier' => 'test', 'for_page_type' => array(1, 2, 4))); |
|
|
|
|
30
|
|
|
|
31
|
|
|
require_once 'Intraface/modules/cms/TemplateSection.php'; |
32
|
|
|
require_once 'Intraface/modules/cms/templatesection/Mixed.php'; |
33
|
|
|
$section = new Intraface_modules_cms_templatesection_Mixed($template); |
34
|
|
|
$section_id = $section->save(array('name' => 'Test', 'identifier' => 'test', 'allowed_element' => array(1, 2, 3, 4, 5, 6, 7, 8, 9))); |
|
|
|
|
35
|
|
|
|
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function createPageWithMixedSection() { |
39
|
|
|
|
40
|
|
|
require_once 'Intraface/modules/cms/Site.php'; |
41
|
|
|
$site = new CMS_Site($this->kernel); |
42
|
|
|
$site_id = $site->save(array('name' => 'Test', 'url' => 'http://localhost/')); |
43
|
|
|
if (!$site_id) { |
44
|
|
|
throw new Exception('Error: '.implode(', ', $site->error->getMessage())); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
require_once 'Intraface/modules/cms/Template.php'; |
48
|
|
|
$template = new CMS_Template($site); |
49
|
|
|
$template_id = $template->save(array('name' => 'Test', 'identifier' => 'test', 'for_page_type' => array(1, 2, 4))); |
50
|
|
|
|
51
|
|
|
require_once 'Intraface/modules/cms/TemplateSection.php'; |
52
|
|
|
$section = new Intraface_modules_cms_templatesection_Mixed($template); |
53
|
|
|
$section_id = $section->save(array('name' => 'Content', 'identifier' => 'content', 'allowed_element' => array(1, 2, 3, 4, 5, 6, 7, 8, 9))); |
|
|
|
|
54
|
|
|
|
55
|
|
|
require_once 'Intraface/modules/cms/Page.php'; |
56
|
|
|
$page = new CMS_Page($site); |
57
|
|
|
$template_id = $page->save(array('title' => 'Test', 'allow_comment' => 0, 'hidden' => 0, 'page_type' => 'page', 'template_id' => $template_id, 'identifier' => 'test')); |
|
|
|
|
58
|
|
|
|
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
?> |
|
|
|
|
62
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.