Horde_Themes::sound PHP Method

sound() public static method

Return the path to a sound, using the default sound if the sound does not exist in the current theme.
public static sound ( string $name = null, mixed $options = [] ) : Horde_Themes_Sound
$name string The sound name. If null, will return the sound directory.
$options mixed Additional options. If a string, is taken to be the 'app' parameter. If an array, the following options are available: - app: (string) Use this application instead of the current app. - nohorde: (boolean) If true, do not fallback to horde for sound. - noview: (boolean) If true, do not load images from view-specific directories. (Since 2.4.0) - theme: (string) Use this theme instead of the Horde default.
return Horde_Themes_Sound An object which contains the URI and filesystem location of the sound.
    public static function sound($name = null, $options = array())
    {
        if (is_string($options)) {
            $options = array('app' => $options);
        }
        return new Horde_Themes_Sound($name, $options);
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Returns an alarm hash of this event suitable for Horde_Alarm.
  *
  * @param Horde_Date $time  Time of alarm.
  * @param string $user      The user to return alarms for.
  * @param Prefs $prefs      A Prefs instance.
  *
  * @return array  Alarm hash or null.
  */
 public function toAlarm($time, $user = null, $prefs = null)
 {
     if (!$this->alarm || $this->status == Kronolith::STATUS_CANCELLED) {
         return;
     }
     if ($this->recurs()) {
         $eventDate = $this->recurrence->nextRecurrence($time);
         if (!$eventDate || $eventDate && $this->recurrence->hasException($eventDate->year, $eventDate->month, $eventDate->mday)) {
             return;
         }
         $start = clone $eventDate;
         $diff = Date_Calc::dateDiff($this->start->mday, $this->start->month, $this->start->year, $this->end->mday, $this->end->month, $this->end->year);
         if ($diff == -1) {
             $diff = 0;
         }
         $end = new Horde_Date(array('year' => $start->year, 'month' => $start->month, 'mday' => $start->mday + $diff, 'hour' => $this->end->hour, 'min' => $this->end->min, 'sec' => $this->end->sec));
     } else {
         $start = clone $this->start;
         $end = clone $this->end;
     }
     $serverName = $_SERVER['SERVER_NAME'];
     $serverConf = $GLOBALS['conf']['server']['name'];
     if (!empty($GLOBALS['conf']['reminder']['server_name'])) {
         $_SERVER['SERVER_NAME'] = $GLOBALS['conf']['server']['name'] = $GLOBALS['conf']['reminder']['server_name'];
     }
     if (empty($user)) {
         $user = $GLOBALS['registry']->getAuth();
     }
     if (empty($prefs)) {
         $prefs = $GLOBALS['prefs'];
     }
     $methods = !empty($this->methods) ? $this->methods : @unserialize($prefs->getValue('event_alarms'));
     if (isset($methods['notify'])) {
         $methods['notify']['show'] = array('__app' => $GLOBALS['registry']->getApp(), 'event' => $this->id, 'calendar' => $this->calendar);
         $methods['notify']['ajax'] = 'event:' . $this->calendarType . '|' . $this->calendar . ':' . $this->id . ':' . $start->dateString();
         if (!empty($methods['notify']['sound'])) {
             if ($methods['notify']['sound'] == 'on') {
                 // Handle boolean sound preferences.
                 $methods['notify']['sound'] = (string) Horde_Themes::sound('theetone.wav');
             } else {
                 // Else we know we have a sound name that can be
                 // served from Horde.
                 $methods['notify']['sound'] = (string) Horde_Themes::sound($methods['notify']['sound']);
             }
         }
         if ($this->isAllDay()) {
             if ($start->compareDate($end) == 0) {
                 $methods['notify']['subtitle'] = sprintf(_("On %s"), '<strong>' . $start->strftime($prefs->getValue('date_format')) . '</strong>');
             } else {
                 $methods['notify']['subtitle'] = sprintf(_("From %s to %s"), '<strong>' . $start->strftime($prefs->getValue('date_format')) . '</strong>', '<strong>' . $end->strftime($prefs->getValue('date_format')) . '</strong>');
             }
         } else {
             $methods['notify']['subtitle'] = sprintf(_("From %s at %s to %s at %s"), '<strong>' . $start->strftime($prefs->getValue('date_format')), $start->format($prefs->getValue('twentyFour') ? 'H:i' : 'h:ia') . '</strong>', '<strong>' . $end->strftime($prefs->getValue('date_format')), $this->end->format($prefs->getValue('twentyFour') ? 'H:i' : 'h:ia') . '</strong>');
         }
     }
     if (isset($methods['mail'])) {
         $image = Kronolith::getImagePart('big_alarm.png');
         $view = new Horde_View(array('templatePath' => KRONOLITH_TEMPLATES . '/alarm', 'encoding' => 'UTF-8'));
         new Horde_View_Helper_Text($view);
         $view->event = $this;
         $view->imageId = $image->getContentId();
         $view->user = $user;
         $view->dateFormat = $prefs->getValue('date_format');
         $view->timeFormat = $prefs->getValue('twentyFour') ? 'H:i' : 'h:ia';
         $view->start = $start;
         if (!$prefs->isLocked('event_reminder')) {
             $view->prefsUrl = Horde::url($GLOBALS['registry']->getServiceLink('prefs', 'kronolith'), true)->remove(session_name());
         }
         if ($this->attendees) {
             $view->attendees = Kronolith::getAttendeeEmailList($this->attendees)->addresses;
         }
         $methods['mail']['mimepart'] = Kronolith::buildMimeMessage($view, 'mail', $image);
     }
     if (isset($methods['desktop'])) {
         if ($this->isAllDay()) {
             if ($this->start->compareDate($this->end) == 0) {
                 $methods['desktop']['subtitle'] = sprintf(_("On %s"), $start->strftime($prefs->getValue('date_format')));
             } else {
                 $methods['desktop']['subtitle'] = sprintf(_("From %s to %s"), $start->strftime($prefs->getValue('date_format')), $end->strftime($prefs->getValue('date_format')));
             }
         } else {
             $methods['desktop']['subtitle'] = sprintf(_("From %s at %s to %s at %s"), $start->strftime($prefs->getValue('date_format')), $start->format($prefs->getValue('twentyFour') ? 'H:i' : 'h:ia'), $end->strftime($prefs->getValue('date_format')), $this->end->format($prefs->getValue('twentyFour') ? 'H:i' : 'h:ia'));
         }
         $methods['desktop']['url'] = strval($this->getViewUrl(array(), true, false));
     }
     $alarmStart = clone $start;
     $alarmStart->min -= $this->alarm;
     $alarm = array('id' => $this->uid, 'user' => $user, 'start' => $alarmStart, 'end' => $end, 'methods' => array_keys($methods), 'params' => $methods, 'title' => $this->getTitle($user), 'text' => $this->description, 'instanceid' => $this->recurs() ? $eventDate->dateString() : null);
     $_SERVER['SERVER_NAME'] = $serverName;
     $GLOBALS['conf']['server']['name'] = $serverConf;
     return $alarm;
 }
All Usage Examples Of Horde_Themes::sound