Overview

Packages

  • None
  • Trean

Classes

  • Trean_Api
  • Trean_Application
  • Trean_Block_Bookmarks
  • Trean_Block_Highestrated
  • Trean_Block_Mostclicked
  • Trean_View_BookmarkList
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Trean application API
  4:  *
  5:  * Copyright 2002-2012 Horde LLC (http://www.horde.org/)
  6:  *
  7:  * See the enclosed file LICENSE for license information (BSD). If you
  8:  * did not receive this file, see http://www.horde.org/licenses/bsdl.php.
  9:  *
 10:  * @author Mike Cochrane <mike@graftonhall.co.nz>
 11:  */
 12: 
 13: /* Determine the base directories. */
 14: if (!defined('TREAN_BASE')) {
 15:     define('TREAN_BASE', dirname(__FILE__) . '/..');
 16: }
 17: 
 18: if (!defined('HORDE_BASE')) {
 19:     /* If Horde does not live directly under the app directory, the HORDE_BASE
 20:      * constant should be defined in config/horde.local.php. */
 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: /* Load the Horde Framework core (needed to autoload
 29:  * Horde_Registry_Application::). */
 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:      * Global variables defined:
 40:      * - $trean_db:     TODO
 41:      * - $trean_shares: TODO
 42:      * - $linkTags:     <link> tags for common-header.inc.
 43:      * - $bodyClass:    <body> CSS class for common-header.inc.
 44:      */
 45:     protected function _init()
 46:     {
 47:         // Set the timezone variable.
 48:         $GLOBALS['registry']->setTimeZone();
 49: 
 50:         // Create db and share instances.
 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($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:         /* Import/Export. */
 92:         if ($GLOBALS['conf']['menu']['import_export']) {
 93:             $menu->add(Horde::url('data.php'), _("_Import/Export"), 'data.png');
 94:         }
 95:     }
 96: 
 97:     /* Sidebar method. */
 98: 
 99:     /**
100:      */
101:     public function sidebarCreate(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: 
API documentation generated by ApiGen