/**
* Add base javascript variables to the page.
*/
protected function _addBaseVars()
{
global $conf, $injector, $prefs, $registry;
$auth_name = $registry->getAuth();
$has_tasks = Kronolith::hasApiPermission('tasks');
$identity = $injector->getInstance('Horde_Core_Factory_Identity')->create();
$app_urls = $js_vars = array();
if (isset($conf['menu']['apps']) && is_array($conf['menu']['apps'])) {
foreach ($conf['menu']['apps'] as $app) {
$app_urls[$app] = strval(Horde::url($registry->getInitialPage($app), true));
}
}
/* Variables used in core javascript files. */
$js_vars['conf'] = array_filter(array('URI_CALENDAR_EXPORT' => str_replace(array('%23', '%2523', '%7B', '%257B', '%7D', '%257D'), array('#', '#', '{', '{', '}', '}'), strval($registry->downloadUrl('#{calendar}.ics', array('actionID' => 'export', 'all_events' => 1, 'exportID' => Horde_Data::EXPORT_ICALENDAR, 'exportCal' => 'internal_#{calendar}'))->setRaw(true))), 'URI_RESOURCE_EXPORT' => str_replace(array('%23', '%2523', '%7B', '%257B', '%7D', '%257D'), array('#', '#', '{', '{', '}', '}'), strval($registry->downloadUrl('#{calendar}.ics', array('actionID' => 'export', 'all_events' => 1, 'exportID' => Horde_Data::EXPORT_ICALENDAR, 'exportCal' => 'resource_#{calendar}'))->setRaw(true))), 'URI_EVENT_EXPORT' => str_replace(array('%23', '%7B', '%7D'), array('#', '{', '}'), Horde::url('event.php', true)->add(array('view' => 'ExportEvent', 'eventID' => '#{id}', 'calendar' => '#{calendar}', 'type' => '#{type}'))), 'images' => array('alarm' => strval(Horde_Themes::img('alarm-fff.png')), 'attendees' => strval(Horde_Themes::img('attendees-fff.png')), 'exception' => strval(Horde_Themes::img('exception-fff.png')), 'new_event' => strval(Horde_Themes::img('new.png')), 'new_task' => strval(Horde_Themes::img('new_task.png')), 'recur' => strval(Horde_Themes::img('recur-fff.png'))), 'new_event' => $injector->getInstance('Kronolith_View_Sidebar')->newLink . $injector->getInstance('Kronolith_View_Sidebar')->newText . '</a>', 'new_task' => $injector->getInstance('Kronolith_View_SidebarTasks')->newLink . $injector->getInstance('Kronolith_View_SidebarTasks')->newText . '</a>', 'user' => $registry->convertUsername($auth_name, false), 'name' => $identity->getName(), 'email' => strval($identity->getDefaultFromAddress()), 'prefs_url' => strval($registry->getServiceLink('prefs', 'kronolith')->setRaw(true)), 'app_urls' => $app_urls, 'name' => $registry->get('name'), 'has_tasks' => intval($has_tasks), 'has_resources' => intval(!empty($conf['resource']['driver'])), 'login_view' => $prefs->getValue('defaultview') == 'workweek' ? 'week' : $prefs->getValue('defaultview'), 'default_calendar' => 'internal|' . Kronolith::getDefaultCalendar(Horde_Perms::EDIT), 'max_events' => intval($prefs->getValue('max_events')), 'date_format' => Horde_Core_Script_Package_Datejs::translateFormat(Horde_Nls::getLangInfo(D_FMT)), 'time_format' => $prefs->getValue('twentyFour') ? 'HH:mm' : 'hh:mm tt', 'import_file' => Horde_Data::IMPORT_FILE, 'import_url' => Horde_Data::IMPORT_URL, 'show_time' => Kronolith::viewShowTime(), 'default_alarm' => intval($prefs->getValue('default_alarm')), 'status' => array('cancelled' => Kronolith::STATUS_CANCELLED, 'confirmed' => Kronolith::STATUS_CONFIRMED, 'free' => Kronolith::STATUS_FREE, 'tentative' => Kronolith::STATUS_TENTATIVE), 'recur' => array(Horde_Date_Recurrence::RECUR_NONE => 'None', Horde_Date_Recurrence::RECUR_DAILY => 'Daily', Horde_Date_Recurrence::RECUR_WEEKLY => 'Weekly', Horde_Date_Recurrence::RECUR_MONTHLY_DATE => 'Monthly', Horde_Date_Recurrence::RECUR_MONTHLY_WEEKDAY => 'Monthly', Horde_Date_Recurrence::RECUR_YEARLY_DATE => 'Yearly', Horde_Date_Recurrence::RECUR_YEARLY_DAY => 'Yearly', Horde_Date_Recurrence::RECUR_YEARLY_WEEKDAY => 'Yearly'), 'perms' => array('all' => Horde_Perms::ALL, 'show' => Horde_Perms::SHOW, 'read' => Horde_Perms::READ, 'edit' => Horde_Perms::EDIT, 'delete' => Horde_Perms::DELETE, 'delegate' => Kronolith::PERMS_DELEGATE), 'tasks' => $has_tasks ? $registry->tasks->ajaxDefaults() : null));
/* Make sure this value is not optimized out by array_filter(). */
$js_vars['conf']['week_start'] = intval($prefs->getValue('week_start_monday'));
/* Gettext strings. */
$js_vars['text'] = array('alarm' => _("Alarm:"), 'alerts' => _("Notifications"), 'allday' => _("All day"), 'delete_calendar' => _("Are you sure you want to delete this calendar and all the events in it?"), 'delete_tasklist' => _("Are you sure you want to delete this task list and all the tasks in it?"), 'external_category' => _("Other events"), 'fix_form_values' => _("Please enter correct values in the form first."), 'geocode_error' => _("Unable to locate requested address"), 'hidelog' => _("Hide Notifications"), 'import_warning' => _("Importing calendar data. This may take a while..."), 'more' => _("more..."), 'no_assignee' => _("None"), 'no_calendar_title' => _("The calendar title must not be empty."), 'no_parent' => _("No parent task"), 'no_tasklist_title' => _("The task list title must not be empty."), 'no_url' => _("You must specify a URL."), 'prefs' => _("Preferences"), 'searching' => sprintf(_("Events matching \"%s\""), '#{term}'), 'shared' => _("Shared"), 'tasks' => _("Tasks"), 'unknown_resource' => _("Unknown resource."), 'wrong_auth' => _("The authentication information you specified wasn't accepted."), 'wrong_date_format' => sprintf(_("You used an unknown date format \"%s\". Please try something like \"%s\"."), '#{wrong}', '#{right}'), 'wrong_time_format' => sprintf(_("You used an unknown time format \"%s\". Please try something like \"%s\"."), '#{wrong}', '#{right}'));
for ($i = 1; $i <= 12; ++$i) {
$js_vars['text']['month'][$i - 1] = Horde_Nls::getLangInfo(constant('MON_' . $i));
}
for ($i = 1; $i <= 7; ++$i) {
$js_vars['text']['weekday'][$i] = Horde_Nls::getLangInfo(constant('DAY_' . $i));
}
foreach (array_diff(array_keys($js_vars['conf']['recur']), array(Horde_Date_Recurrence::RECUR_NONE)) as $recurType) {
$js_vars['text']['recur'][$recurType] = Kronolith::recurToString($recurType);
}
$js_vars['text']['recur']['exception'] = _("Exception");
// Maps
$js_vars['conf']['maps'] = $conf['maps'];
return $js_vars;
}
开发者ID:jubinpatel,项目名称:horde,代码行数:35,代码来源:Ajax.php
示例3: browse
/**
* Browse through Whups' object tree.
*
* @param string $path The level of the tree to browse.
*
* @return array The contents of $path
*/
public function browse($path = '')
{
global $whups_driver, $registry;
if (substr($path, 0, 5) == 'whups') {
$path = substr($path, 5);
}
$path = trim($path, '/');
if (empty($path)) {
$results = array('whups/queue' => array('name' => _("Queues"), 'icon' => Horde_Themes::img('whups.png'), 'browseable' => count(Whups::permissionsFilter($whups_driver->getQueues(), 'queue', Horde_Perms::READ))));
} else {
$path = explode('/', $path);
$results = array();
switch ($path[0]) {
case 'queue':
$queues = Whups::permissionsFilter($whups_driver->getQueues(), 'queue', Horde_Perms::SHOW);
if (count($path) == 1) {
foreach ($queues as $queue => $name) {
$results['whups/queue/' . $queue] = array('name' => sprintf(_("Tickets from %s"), $name), 'browseable' => true);
}
} else {
if (!Whups::hasPermission($queues[$path[1]], 'queue', Horde_Perms::READ)) {
throw new Horde_Exception_PermissionDenied();
}
$tickets = $whups_driver->getTicketsByProperties(array('queue' => $path[1]));
foreach ($tickets as $ticket) {
$results['whups/queue/' . $path[1] . '/' . $ticket['id']] = array('name' => $ticket['summary'], 'browseable' => false);
}
}
break;
}
}
return $results;
}
开发者ID:raz0rsdge,项目名称:horde,代码行数:40,代码来源:Api.php
示例4: tag
/**
* Constructs a correctly-pathed tag to an image.
*
* @param mixed $src The image file (either a string or a
* Horde_Themes_Image object).
* @param array $opts Additional options:
* - alt: (string) Text describing the image.
* - attr: (mixed) Any additional attributes for the image tag. Can be a
* pre-built string or an array of key/value pairs that will be
* assembled and html-encoded.
* - fullsrc: (boolean) TODO
* - imgopts: (array) TODO
*
* @return string The full image tag.
*/
public static function tag($src, array $opts = array())
{
global $browser, $conf;
$opts = array_merge(array('alt' => '', 'attr' => array(), 'fullsrc' => false, 'imgopts' => array()), $opts);
/* If browser does not support images, simply return the ALT text. */
if (!$browser->hasFeature('images')) {
return htmlspecialchars($opts['alt']);
}
$xml = new SimpleXMLElement('<root><img ' . (is_array($opts['attr']) ? '' : $opts['attr']) . '/></root>');
$img = $xml->img;
if (is_array($opts['attr'])) {
foreach ($opts['attr'] as $key => $val) {
$img->addAttribute($key, $val);
}
}
if (strlen($opts['alt'])) {
$img->addAttribute('alt', $opts['alt']);
}
/* If no directory has been specified, get it from the registry. */
if (!$src instanceof Horde_Themes_Image && substr($src, 0, 1) != '/') {
$src = Horde_Themes::img($src, $opts['imgopts']);
}
if (empty($conf['nobase64_img'])) {
$src = self::base64ImgData($src);
}
if ($opts['fullsrc'] && substr($src, 0, 10) != 'data:image') {
$src = Horde::url($src, true, array('append_session' => -1));
}
$img->addAttribute('src', $src);
return $img->asXML();
}
/**
* Outputs the html for a DateGallery tile.
*
* @param Ansel_Gallery_Decorator_Date $dgallery The Ansel_Gallery_Date we are
* displaying.
* @param Ansel_Style $style A style object.
* @param boolean $mini Force the use of a mini thumbail?
* @param array $params An array containing additional parameters.
* Currently, gallery_view_url and image_view_url
* are used to override the respective urls.
* %g and %i are replaced with image id and
* gallery id, respectively.
*
* @return string The HTML for the tile.
*/
public function getTile(Ansel_Gallery_Decorator_Date $dgallery, Ansel_Style $style = null, $mini = false, array $params = array())
{
$view = $GLOBALS['injector']->createInstance('Horde_View');
$view->addTemplatePath(ANSEL_TEMPLATES . '/tile');
// User's preferred date format
$date_format = $GLOBALS['prefs']->getValue('date_format');
$date_array = $dgallery->getDate();
if (empty($date_array['month'])) {
$date_array['month'] = 1;
}
if (empty($date_array['day'])) {
$date_array['day'] = 1;
}
$full_date = new Horde_Date($date_array);
// Need the unaltered date part array
$date_array = $dgallery->getDate();
// Figure out the needed link for the next drill down level. We *must*
// have at least a year since we are in a date tile.
if (empty($date_array['month'])) {
// unit == year
$view->caption = $full_date->strftime('%Y');
$next_date = array('year' => (int) $view->caption);
} elseif (empty($date_array['day'])) {
// unit == month
$view->caption = $full_date->strftime('%B %Y');
$next_date = array('year' => date('Y', $full_date->timestamp()), 'month' => date('n', $full_date->timestamp()));
} else {
// unit == day
$view->caption = $full_date->strftime($date_format);
$next_date = array('year' => date('Y', $full_date->timestamp()), 'month' => date('n', $full_date->timestamp()), 'day' => date('j', $full_date->timestamp()));
}
// Check permissions on the gallery and get appropriate tile image
if ($dgallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
if (is_null($style)) {
$style = $dgallery->getStyle();
}
$thumbstyle = $mini ? 'mini' : 'thumb';
$view->gallery_image = Ansel::getImageUrl($dgallery->getKeyImage(), $thumbstyle, true, $style);
} else {
$view->gallery_image = Horde_Themes::img('thumb-error.png');
}
/* Check for being called via the api and generate correct view links */
if (!isset($params['gallery_view_url'])) {
if (empty($params['style'])) {
$gstyle = $dgallery->getStyle();
} else {
$gstyle = $params['style'];
}
$params = array('gallery' => $dgallery->id, 'view' => 'Gallery', 'slug' => $dgallery->get('slug'));
$view->view_link = Ansel::getUrlFor('view', array_merge($params, $next_date));
} else {
$view->view_link = new Horde_Url(str_replace(array('%g', '%s'), array($dgallery->id, $dgallery->get('slug')), urldecode($params['gallery_view_url'])));
$view->view_link->add($next_date);
}
$view->gallery_count = $dgallery->countImages(true);
return $view->render('dategallery');
}
请发表评论