本文整理汇总了PHP中Horde_Mime_Magic::mimeToExt方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Mime_Magic::mimeToExt方法的具体用法?PHP Horde_Mime_Magic::mimeToExt怎么用?PHP Horde_Mime_Magic::mimeToExt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Mime_Magic
的用法示例。
在下文中一共展示了Horde_Mime_Magic::mimeToExt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _renderInline
/**
* Return the full rendered version of the Horde_Mime_Part object.
*
* URL parameters used by this function:
* - c: (integer) The VCARD component that contains an image.
* - p: (integer) The index of image inside the component to display.
*
* @return array See parent::render().
* @throws Horde_Exception
*/
protected function _renderInline()
{
$vars = $GLOBALS['injector']->getInstance('Horde_Variables');
if (!isset($vars->p)) {
$imp_contents = $this->getConfigParam('imp_contents');
$GLOBALS['injector']->getInstance('Horde_Core_Factory_Imple')->create('IMP_Ajax_Imple_VcardImport', array('mime_id' => $this->_mimepart->getMimeId(), 'muid' => strval($imp_contents->getIndicesOb())));
$this->_imageUrl = $this->getConfigParam('imp_contents')->urlView($this->_mimepart, 'download_render', array('params' => array('mode' => IMP_Contents::RENDER_INLINE)));
return parent::_renderInline();
}
/* Send the requested photo. */
$data = $this->_mimepart->getContents();
$ical = new Horde_Icalendar();
if (!$ical->parsevCalendar($data, 'VCALENDAR', $this->_mimepart->getCharset())) {
// TODO: Error reporting
return array();
}
$components = $ical->getComponents();
if (!isset($components[$vars->c])) {
// TODO: Error reporting
return array();
}
$name = $components[$vars->c]->getAttributeDefault('FN', false);
if ($name === false) {
$name = $components[$vars->c]->printableName();
}
if (empty($name)) {
$name = preg_replace('/\\..*?$/', '', $this->_mimepart->getName());
}
$photos = $components[$vars->c]->getAllAttributes('PHOTO');
if (!isset($photos[$vars->p])) {
// TODO: Error reporting
return array();
}
$type = 'image/' . Horde_String::lower($photos[$vars->p]['params']['TYPE']);
return array($this->_mimepart->getMimeId() => array('data' => base64_decode($photos[$vars->p]['value']), 'name' => $name . '.' . Horde_Mime_Magic::mimeToExt($type), 'type' => $type));
}
示例2: _listFolder
/**
* Returns an unsorted file list of the specified directory.
*
* @param string $path The path of the directory.
* @param string|array $filter Regular expression(s) to filter
* file/directory name on.
* @param boolean $dotfiles Show dotfiles?
* @param boolean $dironly Show only directories?
*
* @return array File list.
* @throws Horde_Vfs_Exception
*/
protected function _listFolder($path, $filter = null, $dotfiles = true, $dironly = false)
{
$list = array();
if ($path == '/') {
try {
$apps = $this->_registry->listApps(null, false, Horde_Perms::READ);
} catch (Horde_Exception $e) {
throw new Horde_Vfs_Exception($e->getMessage());
}
foreach ($apps as $app) {
if ($this->_registry->hasMethod('browse', $app)) {
$file = array('name' => $app, 'date' => time(), 'type' => '**dir', 'size' => -1);
$list[] = $file;
}
}
return $list;
}
if (substr($path, 0, 1) == '/') {
$path = substr($path, 1);
}
$pieces = explode('/', $path);
try {
$items = $this->_registry->callByPackage($pieces[0], 'browse', array('path' => $path, 'properties' => array('name', 'browseable', 'contenttype', 'contentlength', 'modified')));
} catch (Horde_Exception $e) {
throw new Horde_Vfs_Exception($e->getMessage());
}
if (!is_array(reset($items))) {
/* We return an object's content. */
throw new Horde_Vfs_Exception('Unknown error');
}
foreach ($items as $sub_path => $i) {
if ($dironly && !$i['browseable']) {
continue;
}
$name = basename($sub_path);
if ($this->_filterMatch($filter, $name)) {
continue;
}
$type = class_exists('Horde_Mime_Magic') ? Horde_Mime_Magic::mimeToExt(empty($i['contenttype']) ? 'application/octet-stream' : $i['contenttype']) : '**none';
$file = array('name' => $name, 'date' => empty($i['modified']) ? 0 : $i['modified'], 'type' => $i['browseable'] ? '**dir' : $type, 'size' => empty($i['contentlength']) ? 0 : $i['contentlength']);
$list[] = $file;
}
return $list;
}
示例3: downloadHeaders
/**
* Sends the correct HTTP headers to the browser to download this image.
*
* @param string $view The view to download.
*/
public function downloadHeaders($view = 'full')
{
global $browser, $conf;
$filename = $this->filename;
if ($view != 'full') {
if ($ext = Horde_Mime_Magic::mimeToExt('image/' . $conf['image']['type'])) {
$filename .= '.' . $ext;
}
}
$browser->downloadHeaders($filename);
}
示例4: _store
/**
* Stores an object in the Kolab message store.
*
* TODO
*
* @return string The object id, possibly updated.
* @throws Turba_Exception
*/
protected function _store($attributes, $object_id = null)
{
if (isset($attributes['__type']) && $attributes['__type'] == 'Group') {
$this->_convertMembers($attributes);
$data = $this->_getListData();
} else {
if (isset($attributes['photo']) && isset($attributes['phototype'])) {
$filename = 'photo.' . Horde_Mime_Magic::mimeToExt($attributes['phototype']);
$attributes['_attachments'][$filename] = array('type' => $attributes['phototype'], 'content' => Horde_Stream_Wrapper_String::getStream($attributes['photo']));
$attributes['picture'] = $filename;
unset($attributes['photo'], $attributes['phototype']);
}
// EAS sets the date fields to '' instead of null -> fix it up
$fix_date_fields = array('birthday', 'anniversary');
foreach ($fix_date_fields as $fix_date) {
if (empty($attributes[$fix_date])) {
unset($attributes[$fix_date]);
}
}
$data = $this->_getData();
}
if ($object_id === null) {
$object_id = $data->create($attributes);
} else {
$data->modify($attributes);
}
/* Invalidate cache. */
$this->_connected = false;
return Horde_Url::uriB64Encode($object_id);
}
示例5: processMail
//.........这里部分代码省略.........
}
} else {
$comment .= _("[ Could not render body of message. ]");
}
$info['comment'] = $comment . "\n";
// Try to determine the Horde user for creating the ticket.
if (empty($auth_user)) {
$tmp = new Horde_Mail_Rfc822_Address($from);
$auth_user = self::_findAuthUser($tmp->bare_address);
}
$author = $auth_user;
if (empty($auth_user) && !empty($info['default_auth'])) {
$auth_user = $info['default_auth'];
if (!empty($from)) {
$info['user_email'] = $from;
}
}
if (empty($auth_user) && !empty($conf['mail']['username'])) {
$auth_user = $conf['mail']['username'];
if (!empty($from)) {
$info['user_email'] = $from;
}
}
// Authenticate as the correct Horde user.
if (!empty($auth_user) && $auth_user != $GLOBALS['registry']->getAuth()) {
$GLOBALS['registry']->setAuth($auth_user, array());
}
// Attach message.
$attachments = array();
if (!empty($GLOBALS['conf']['mail']['attach_message'])) {
$tmp_name = Horde::getTempFile('whups');
$fp = @fopen($tmp_name, 'wb');
if (!$fp) {
throw new Whups_Exception(sprintf('Cannot open file %s for writing.', $tmp_name));
}
fwrite($fp, $text);
fclose($fp);
$attachments[] = array('name' => _("Original Message") . '.eml', 'tmp_name' => $tmp_name);
}
// Extract attachments.
$dl_list = array_slice(array_keys($message->contentTypeMap()), 1);
foreach ($dl_list as $key) {
$part = $message->getPart($key);
if ($key == $body_id && $part->getType() == 'text/plain' || $part->getType() == 'multipart/alternative' || $part->getType() == 'multipart/mixed') {
continue;
}
$tmp_name = Horde::getTempFile('whups');
$fp = @fopen($tmp_name, 'wb');
if (!$fp) {
throw new Whups_Exception(sprintf('Cannot open file %s for writing.', $tmp_name));
}
fwrite($fp, $part->getContents());
fclose($fp);
$part_name = $part->getName(true);
if (!$part_name) {
$ptype = $part->getPrimaryType();
switch ($ptype) {
case 'multipart':
case 'application':
$part_name = sprintf(_("%s part"), ucfirst($part->getSubType()));
break;
default:
$part_name = sprintf(_("%s part"), ucfirst($ptype));
break;
}
if ($ext = Horde_Mime_Magic::mimeToExt($part->getType())) {
$part_name .= '.' . $ext;
}
}
$attachments[] = array('name' => $part_name, 'tmp_name' => $tmp_name);
}
// See if we can match this message to an existing ticket.
if ($ticket = self::_findTicket($info)) {
$ticket->change('comment', $info['comment']);
$ticket->change('comment-email', $from);
if ($attachments) {
$ticket->change('attachments', $attachments);
}
$ticket->commit($author);
} elseif (!empty($info['ticket'])) {
// Didn't match an existing ticket though a ticket number had been
// specified.
throw new Whups_Exception(sprintf(_("Could not find ticket \"%s\"."), $info['ticket']));
} else {
if (!empty($info['guess-queue'])) {
// Try to guess the queue name for the new ticket from the
// message subject.
$queues = $GLOBALS['whups_driver']->getQueues();
foreach ($queues as $queueId => $queueName) {
if (preg_match('/\\b' . preg_quote($queueName, '/') . '\\b/i', $info['summary'])) {
$info['queue'] = $queueId;
break;
}
}
}
$info['attachments'] = $attachments;
// Create a new ticket.
$ticket = Whups_Ticket::newTicket($info, $author);
}
}
示例6: fromiCalendar
//.........这里部分代码省略.........
$vEvent->getAttribute('X-MOZ-LASTACK');
try {
// If X-MOZ-SNOOZE-TIME is set, this event is snoozed.
$snooze = $vEvent->getAttribute('X-MOZ-SNOOZE-TIME');
$this->_snooze = intval(($snooze - time()) / 60);
} catch (Horde_Icalendar_Exception $e) {
// If X-MOZ-SNOOZE-TIME is not set, this event is dismissed.
$this->_snooze = -1;
}
} catch (Horde_Icalendar_Exception $e) {
}
}
// Attached files, we require a UID so we can attach the file in VFS.
if ($this->uid) {
$attach = false;
$attach_params = array();
try {
$attach = $vEvent->getAttribute('ATTACH');
$attach_params = $vEvent->getAttribute('ATTACH', true);
if (!is_array($attach)) {
$attach = array($attach);
}
foreach ($attach as $key => $attribute) {
if (isset($attach_params[$key]['VALUE']) && Horde_String::lower($attach_params[$key]['VALUE']) == 'uri') {
// @todo
} elseif (Horde_String::upper($attach_params[$key]['ENCODING']) == 'BASE64') {
$mime_type = !empty($attach_params[$key]['FMTTYPE']) ? $attach_params[$key]['FMTTYPE'] : '';
// @todo We really should add stream support to VFS
$file_data = base64_decode($attribute);
$vfs = $this->vfsInit();
$dir = Kronolith::VFS_PATH . '/' . $this->getVfsUid();
// @todo - Is there a way to get a filename from a
// non-uri ATTACH attribute??
$filename = sprintf(_("File %d.%s"), $key, Horde_Mime_Magic::mimeToExt($mime_type));
try {
$vfs->writeData($dir, $filename, $file_data, true);
} catch (Horde_Vfs_Exception $e) {
Horde::log($e->getMessage(), 'ERR');
}
}
}
} catch (Horde_Icalendar_Exception $e) {
}
}
// Attendance.
// Importing attendance may result in confusion: editing an imported
// copy of an event can cause invitation updates to be sent from
// people other than the original organizer. So we don't import by
// default. However to allow updates by synchronization, this behavior
// can be overriden.
// X-ATTENDEE is there for historical reasons. @todo remove in
// Kronolith 5.
$attendee = $users = null;
if ($parseAttendees) {
try {
$attendee = $vEvent->getAttribute('ATTENDEE');
$params = $vEvent->getAttribute('ATTENDEE', true);
} catch (Horde_Icalendar_Exception $e) {
try {
$attendee = $vEvent->getAttribute('X-ATTENDEE');
$params = $vEvent->getAttribute('X-ATTENDEE', true);
} catch (Horde_Icalendar_Exception $e) {
}
}
if ($attendee && !is_array($attendee)) {
$attendee = array($attendee);