1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13:
14: if (!defined('TREAN_BASE')) {
15: define('TREAN_BASE', dirname(__FILE__) . '/..');
16: }
17:
18: if (!defined('HORDE_BASE')) {
19: 20:
21: if (file_exists(TREAN_BASE . '/config/horde.local.php')) {
22: include TREAN_BASE . '/config/horde.local.php';
23: } else {
24: define('HORDE_BASE', TREAN_BASE . '/..');
25: }
26: }
27:
28: 29:
30: require_once HORDE_BASE . '/lib/core.php';
31:
32: class Trean_Application extends Horde_Registry_Application
33: {
34: 35:
36: public $version = 'H4 (1.0-git)';
37:
38: 39: 40: 41: 42: 43: 44:
45: protected function _init()
46: {
47:
48: $GLOBALS['registry']->setTimeZone();
49:
50:
51: $GLOBALS['trean_db'] = Trean::getDb();
52: if ($GLOBALS['trean_db'] instanceof PEAR_Error) {
53: throw new Horde_Exception($GLOBALS['trean_db']);
54: }
55: $GLOBALS['trean_shares'] = new Trean_Bookmarks();
56:
57: Trean::initialize();
58:
59: $GLOBALS['injector']->getInstance('Horde_Themes_Css')->addThemeStylesheet('grids-min.css');
60: $rss = Horde::url('rss.php', true, -1);
61: if (Horde_Util::getFormData('f')) {
62: $rss->add('f', Horde_Util::getFormData('f'));
63: }
64: $GLOBALS['linkTags'] = array('<link rel="alternate" type="application/rss+xml" title="' . htmlspecialchars(_("Bookmarks Feed")) . '" href="' . $rss . '" />');
65: }
66:
67: 68:
69: public function perms()
70: {
71: return array(
72: 'max_bookmarks' => array(
73: 'title' => _("Maximum Number of Bookmarks"),
74: 'type' => 'int'
75: ),
76: 'max_folders' => array(
77: 'title' => _("Maximum Number of Folders"),
78: 'type' => 'int'
79: )
80: );
81: }
82:
83: 84:
85: public function ($menu)
86: {
87: $menu->add(Horde::url('browse.php'), _("_Browse"), 'trean.png', null, null, null, basename($_SERVER['PHP_SELF']) == 'index.php' ? 'current' : null);
88: $menu->add(Horde::url('search.php'), _("_Search"), 'search.png');
89: $menu->add(Horde::url('reports.php'), _("_Reports"), 'reports.png');
90:
91:
92: if ($GLOBALS['conf']['menu']['import_export']) {
93: $menu->add(Horde::url('data.php'), _("_Import/Export"), 'data.png');
94: }
95: }
96:
97:
98:
99: 100:
101: public function (Horde_Tree_Base $tree, $parent = null,
102: array $params = array())
103: {
104: $tree->addNode(
105: $parent . '__new',
106: $parent,
107: _("Add"),
108: 1,
109: false,
110: array(
111: 'icon' => Horde_Themes::img('add.png'),
112: 'url' => Horde::url('add.php')
113: )
114: );
115:
116: $tree->addNode(
117: $parent . '__search',
118: $parent,
119: _("Search"),
120: 1,
121: false,
122: array(
123: 'icon' => Horde_Themes::img('search.png'),
124: 'url' => Horde::url('search.php')
125: )
126: );
127:
128: $folders = Trean::listFolders();
129: if (!($folders instanceof PEAR_Error)) {
130: $browse = Horde::url('browse.php');
131:
132: foreach ($folders as $folder) {
133: $parent_id = $folder->getParent();
134: $tree->addNode(
135: $parent . $folder->getId(),
136: $parent . $parent_id,
137: $folder->get('name'),
138: substr_count($folder->getName(), ':') + 1,
139: false,
140: array(
141: 'icon' => Horde_Themes::img('tree/folder.png'),
142: 'url' => $browse->copy()->add('f', $folder->getId())
143: )
144: );
145: }
146: }
147: }
148:
149: }
150: