-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBootstrap.php
More file actions
66 lines (59 loc) · 2.15 KB
/
Bootstrap.php
File metadata and controls
66 lines (59 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
class Highlight_Bootstrap extends Centurion_Application_Module_Bootstrap
{
public function _initHelpers()
{
Zend_Controller_Action_HelperBroker::addHelper(
new Highlight_Controller_Action_Helper_AddButtonOnGrid()
);
}
/**
* reads the config file for named containers
* if some don't already exist in base, create them
* the config authorizes numeric or string keys for the named highlights config container
*/
public function _initContainers()
{
// creating all named highlights if they weren't already there
$namedHighlights = self::listNamedHighlightsInConfig();
if(is_array($namedHighlights) && count($namedHighlights)) {
$containerModel = Centurion_Db::getSingleton('highlight/container');
$allNamed = $containerModel->select(true)->filter(array(
'proxy_pk__isnull' => true,
'proxy_content_type_id__isnull' => true
));
$allNamed = $allNamed->fetchAll();
$existing = array();
foreach ($allNamed as $container) {
$existing[$container->name] = true;
}
foreach ($namedHighlights as $name) {
if(!isset($existing[$name])) {
$containerModel->createWithName($name);
$existing[$name] = true;
}
}
}
}
/**
* reads all the named highlights from config and returned them in alphabetical order
* @return [string]
*/
static public function listNamedHighlightsInConfig()
{
$namedHighlights = Centurion_Config_Manager::get('highlight.named_highlights', array());
$res = array();
foreach ($namedHighlights as $key => $name) {
// if the value is an array, then the name is the key
if(is_array($name)) {
$res[] = $key;
}
// else the name is the value
else {
$res[] = $name;
}
}
sort($res);
return $res;
}
}