/
zoo.php
111 lines (87 loc) · 3.46 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
<?php
/**
* @package ZOO Component
* @file zoo.php
* @version 2.3.0 December 2010
* @author YOOtheme http://www.yootheme.com
* @copyright Copyright (C) 2007 - 2011 YOOtheme GmbH
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
// load config
require_once(dirname(__FILE__).'/config.php');
// add css, js
JHTML::script('jquery-ui-1.8.6.custom.min.js', ZOO_ADMIN_URI.'libraries/jquery/');
JHTML::stylesheet('jquery-ui-1.8.6.custom.css', ZOO_ADMIN_URI.'libraries/jquery/');
JHTML::script('accordionmenu.js', ZOO_ADMIN_URI.'assets/js/');
JHTML::script('placeholder.js', ZOO_ADMIN_URI.'assets/js/');
JHTML::script('jquery.pnotify.js', ZOO_ADMIN_URI.'libraries/jquery/plugins/notifier/');
JHTML::stylesheet('jquery.pnotify.default.css', ZOO_ADMIN_URI.'libraries/jquery/plugins/notifier/');
JHTML::script('default.js', ZOO_ADMIN_URI.'assets/js/');
JHTML::stylesheet('ui.css', ZOO_ADMIN_URI.'assets/css/');
JHTMLBehavior::modal();
// init vars
$controller = YRequest::getWord('controller');
$task = YRequest::getWord('task');
$group = YRequest::getString('group');
// change application
if ($id = YRequest::getInt('changeapp')) {
JFactory::getApplication()->setUserState('com_zooapplication', $id);
}
// load application
$application = Zoo::getApplication();
// set default controller
if (!$controller) {
$controller = $application ? 'item' : 'new';
YRequest::setVar('controller', $controller);
}
// set toolbar button include path
$toolbar = JToolBar::getInstance('toolbar');
$toolbar->addButtonPath(ZOO_ADMIN_PATH.'/joomla/button');
// build menu
$menu = YMenu::getInstance('nav');
// add "app" menu items
foreach (YTable::getInstance('application')->all(array('order' => 'name')) as $app) {
$app->addMenuItems($menu);
}
// add "new" and "manager" menu item
$new = new YMenuItem('new', '<span class="icon"> </span>', 'index.php?option=com_zoo&controller=new', array('class' => 'new'));
$manager = new YMenuItem('manager', '<span class="icon"> </span>', 'index.php?option=com_zoo&controller=manager', array('class' => 'config'));
$menu->addChild($new);
$menu->addChild($manager);
if ($controller == 'new' && $task == 'add' && $group) {
// get application meta
$app = new Application();
$app->setGroup($group);
$meta = $app->getMetaData();
// add info item
$new->addChild(new YMenuItem('new', $meta['name']));
}
if ($controller == 'manager' && $group) {
// get application meta
$app = new Application();
$app->setGroup($group);
$meta = $app->getMetaData();
// add info item
$info = new YMenuItem('manager-types', $meta['name'], 'index.php?option=com_zoo&controller=manager&task=types&group='.$group);
$info->addChild(new YMenuItem('manager-types', 'Types', 'index.php?option=com_zoo&controller=manager&task=types&group='.$group));
$info->addChild(new YMenuItem('manager-info', 'Info', 'index.php?option=com_zoo&controller=manager&task=info&group='.$group));
$manager->addChild($info);
}
try {
if ($application) {
// dispatch current application
$application->dispatch();
} else {
// load controller
require_once(ZOO_ADMIN_PATH."/controllers/$controller.php");
// perform the request task
$class = $controller.'Controller';
$controller = new $class();
$controller->execute($task);
$controller->redirect();
}
} catch (YException $e) {
JError::raiseError(500, $e);
}