1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17:
18:
19: if (!defined('ANSEL_BASE')) {
20: define('ANSEL_BASE', dirname(__FILE__) . '/..');
21: }
22:
23: if (!defined('HORDE_BASE')) {
24: if (file_exists(ANSEL_BASE . '/config/horde.local.php')) {
25: include ANSEL_BASE . '/config/horde.local.php';
26: } else {
27: define('HORDE_BASE', ANSEL_BASE . '/..');
28: }
29: }
30: require_once HORDE_BASE . '/lib/core.php';
31:
32: class Ansel_Application extends Horde_Registry_Application
33: {
34: 35:
36: public $version = 'H4 (2.0.3-git)';
37:
38: 39: 40: 41: 42:
43: protected function _init()
44: {
45: if (!$GLOBALS['conf']['image']['driver']) {
46: throw new Horde_Exception('You must configure a Horde_Image driver to use Ansel');
47: }
48:
49:
50:
51:
52: $GLOBALS['injector']
53: ->getInstance('Horde_Autoloader')
54: ->addClassPathMapper(
55: new Horde_Autoloader_ClassPathMapper_Prefix(
56: '/^Content_/',
57: $GLOBALS['registry']->get('fileroot', 'content') . '/lib/'));
58: if (!class_exists('Content_Tagger')) {
59: throw new Horde_Exception('The Content_Tagger class could not be found. Make sure the registry entry for the Content system is present.');
60: }
61:
62: $factories = array(
63: 'Ansel_Styles' => 'Ansel_Factory_Styles',
64: 'Ansel_Faces' => 'Ansel_Factory_Faces',
65: 'Ansel_Storage' => 'Ansel_Factory_Storage',
66: );
67: foreach ($factories as $interface => $v) {
68: $GLOBALS['injector']->bindFactory($interface, $v, 'create');
69: }
70:
71:
72:
73: $GLOBALS['ansel_db'] = $GLOBALS['injector']->getInstance('Horde_Db_Adapter');
74:
75:
76: $GLOBALS['injector']->bindImplementation('Ansel_Config', 'Ansel_Config');
77: }
78:
79: 80:
81: public function perms()
82: {
83: return array(
84: 'admin' => array(
85: 'title' => _("Administrators")
86: )
87: );
88: }
89:
90: 91:
92: public function ($menu)
93: {
94: global $conf, $registry;
95:
96:
97: $menu->add(Horde::url('browse.php'), _("_Browse"),
98: 'browse.png', null, null, null,
99: (($GLOBALS['prefs']->getValue('defaultview') == 'browse' &&
100: basename($_SERVER['PHP_SELF']) == 'index.php') ||
101: (basename($_SERVER['PHP_SELF']) == 'browse.php'))
102: ? 'current'
103: : '__noselection');
104:
105: $menu->add(Ansel::getUrlFor('view', array('view' => 'List')), _("_Galleries"),
106: 'galleries.png', null, null, null,
107: (($GLOBALS['prefs']->getValue('defaultview') == 'galleries' &&
108: basename($_SERVER['PHP_SELF']) == 'index.php') ||
109: ((basename($_SERVER['PHP_SELF']) == 'group.php') &&
110: Horde_Util::getFormData('owner') !== $GLOBALS['registry']->getAuth())
111: ? 'current'
112: : '__noselection'));
113:
114: if ($GLOBALS['registry']->getAuth()) {
115: $url = Ansel::getUrlFor('view', array('owner' => $GLOBALS['registry']->getAuth(),
116: 'groupby' => 'owner',
117: 'view' => 'List'));
118: $menu->add($url, _("_My Galleries"), 'mygalleries.png', null, null,
119: null,
120: (Horde_Util::getFormData('owner', false) == $GLOBALS['registry']->getAuth())
121: ? 'current' :
122: '__noselection');
123: }
124:
125:
126: if ($GLOBALS['registry']->isAdmin() ||
127: (!$GLOBALS['injector']->getInstance('Horde_Perms')->exists('ansel') && $GLOBALS['registry']->getAuth()) ||
128: $GLOBALS['injector']->getInstance('Horde_Perms')->hasPermission('ansel', $GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
129: $menu->add(Horde::url('gallery.php')->add('actionID', 'add'),
130: _("_New Gallery"), 'add.png', null, null, null,
131: (basename($_SERVER['PHP_SELF']) == 'gallery.php' &&
132: Horde_Util::getFormData('actionID') == 'add')
133: ? 'current'
134: : '__noselection');
135: }
136:
137: if ($conf['faces']['driver'] && $registry->isAuthenticated()) {
138: $menu->add(Horde::url('faces/search/all.php'), _("_Faces"), 'user.png');
139: }
140:
141:
142: if ($conf['menu']['print'] &&
143: ($pl = Horde_Util::nonInputVar('print_link'))) {
144: $menu->add($pl, _("_Print"), 'print.png',
145: null, '_blank',
146: Horde::popupJs($pl, array('urlencode' => true)) . 'return false;');
147: }
148: }
149:
150: 151:
152: public function prefsGroup($ui)
153: {
154: global $conf;
155:
156: foreach ($ui->getChangeablePrefs() as $val) {
157: switch ($val) {
158: case 'exif_tags':
159: $fields = Horde_Image_Exif::getFields(array($conf['exif']['driver'], !empty($conf['exif']['params']) ? $conf['exif']['params'] : array()), true);
160: $ui->override['exif_tags'] = $fields;
161: $ui->override['exif_title'] = array_merge(array(
162: 'none' => _("None")
163: ), $fields);
164: break;
165: }
166: }
167: }
168:
169: 170:
171: public function prefsSpecial($ui, $item)
172: {
173: switch ($item) {
174: case 'default_gallerystyle_select':
175: return _("Default style for galleries") .
176: Ansel::getStyleSelect('default_gallerystyle_select', $GLOBALS['prefs']->getValue('default_gallerystyle')) .
177: '<br />';
178: }
179:
180: return '';
181: }
182:
183: 184:
185: public function prefsSpecialUpdate($ui, $item)
186: {
187: switch ($item) {
188: case 'default_gallerystyle_select':
189: if (isset($ui->vars->default_gallerystyle_select)) {
190: $GLOBALS['prefs']->setValue('default_gallerystyle', $ui->vars->default_gallerystyle_select);
191: return true;
192: }
193: break;
194: }
195:
196: return false;
197: }
198:
199: 200: 201: 202:
203: public function mobileInitCallback()
204: {
205: require ANSEL_TEMPLATES . '/mobile/javascript_defs.php';
206: Horde::addScriptFile('mobile.js');
207: Horde::addInlineScript(
208: '$(window.document).bind("mobileinit", function() {
209: $.mobile.page.prototype.options.backBtnText = "' . _("Back") .'";
210: $.mobile.loadingMessage = "' . _("loading") . '";
211: // TODO: Figure out how to force load the gallerylist page..
212: // this does not work
213: //$("#imageview").live("pagebeforeshow", function() {
214: // if (!AnselMobile.currentImage) {
215: // $.mobile.changePage("gallerylist", "slide", false, true);
216: // }
217: //});
218: });'
219: );
220: }
221:
222: }
223: