-
Notifications
You must be signed in to change notification settings - Fork 4
/
zoo.php
124 lines (99 loc) · 4.07 KB
/
zoo.php
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
/**
* @package com_zoo
* @author YOOtheme http://www.yootheme.com
* @copyright Copyright (C) YOOtheme GmbH
* @license http://www.gnu.org/licenses/gpl.html GNU/GPL
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
// load config
require_once(dirname(__FILE__).'/config.php');
// get zoo instance
$zoo = App::getInstance('zoo');
// set zoo icon
$zoo->set('icon', 'zoo.png');
// add css, js
$zoo->document->addScript('libraries:jquery/jquery-ui.custom.min.js');
$zoo->document->addStylesheet('libraries:jquery/jquery-ui.custom.css');
$zoo->document->addScript('libraries:jquery/plugins/timepicker/timepicker.js');
$zoo->document->addStylesheet('libraries:jquery/plugins/timepicker/timepicker.css');
$zoo->document->addScript('assets:js/accordionmenu.js');
$zoo->document->addScript('assets:js/placeholder.js');
$zoo->document->addScript('assets:js/default.js');
$zoo->document->addStylesheet('assets:css/ui.css');
// add behavior modal
$zoo->html->_('behavior.modal', 'a.modal');
// init vars
$controller = $zoo->request->getWord('controller');
$task = $zoo->request->getWord('task');
$group = $zoo->request->getString('group');
// does the zoo require to be updated?
if ($zoo->update->required() && $controller != 'update') {
$zoo->system->application->redirect($zoo->link(array('controller' => 'update'), false));
}
// zoo_hack_start
if (0) {
// check for ZOO extension dependencies
$zoo->dependency->check();
// cache writable ?
if (!($cache_path = $zoo->path->path('cache:')) || !is_writable($cache_path)) {
$zoo->error->raiseNotice(0, sprintf("Zoo cache folder is not writable! Please check directory permissions (%s)", $cache_path));
}
// media folders writable ?
foreach (array_merge(array(''), $zoo->path->dirs('media:zoo', true)) as $dir) {
if (!is_writable($zoo->path->path('media:zoo/' . $dir))) {
$zoo->error->raiseNotice(0, sprintf("Zoo media folder is not writable! Please check directory permissions (%s)", $zoo->path->path('media:zoo/' . $dir)));
}
}
}
// zoo_hack_end
// change application
if ($id = $zoo->request->getInt('changeapp')) {
$zoo->system->application->setUserState('com_zooapplication', $id);
}
// load application
$application = $zoo->zoo->getApplication();
// set default controller
if (!$controller) {
$controller = $application ? 'item' : 'new';
$zoo->request->setVar('controller', $controller);
}
// build menu
$menu = $zoo->menu->get('nav');
// add "app" menu items
if ($instances = $zoo->table->application->all(array('order' => 'name'))) {
foreach ($instances as $instance) {
$instance->addMenuItems($menu);
}
}
// add "new" and "manager" menu item
if ($zoo->user->isAdmin()) {
$new = $zoo->object->create('AppMenuItem', array('new', '<span class="icon"> </span>', $zoo->link(array('controller' => 'new')), array('class' => 'new')));
$manager = $zoo->object->create('AppMenuItem', array('manager', '<span class="icon"> </span>', $zoo->link(array('controller' => 'manager')), array('class' => 'config')));
$menu->addChild($new);
$menu->addChild($manager);
}
if ($controller == 'new' && $task == 'add' && $group) {
// add info item
$new->addChild($zoo->object->create('AppMenuItem', array('new', $zoo->object->create('Application')->setGroup($group)->getMetaData('name'))));
}
if ($controller == 'manager' && $group) {
// add info item
$link = $zoo->link(array('controller' => 'manager', 'task' => 'types', 'group' => $group));
$info = $zoo->object->create('AppMenuItem', array('manager-types', $zoo->object->create('Application')->setGroup($group)->getMetaData('name'), $link));
$info->addChild($zoo->object->create('AppMenuItem', array('manager-types', 'Types', $link)));
$info->addChild($zoo->object->create('AppMenuItem', array('manager-info', 'Info', $zoo->link(array('controller' => 'manager', 'task' => 'info', 'group' => $group)))));
$manager->addChild($info);
}
try {
if ($application) {
// dispatch current application
$application->dispatch();
} else {
// dispatch app
$zoo->dispatch();
}
} catch (AppException $e) {
$zoo->error->raiseError(500, $e);
}