本文整理汇总了PHP中Horde_Mime_Magic::extToMime方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Mime_Magic::extToMime方法的具体用法?PHP Horde_Mime_Magic::extToMime怎么用?PHP Horde_Mime_Magic::extToMime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Mime_Magic
的用法示例。
在下文中一共展示了Horde_Mime_Magic::extToMime方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: vfsDisplayUrl
/**
* Returns a link to display and download a file from the VFS backend
* associated with this object.
*
* @param string $file The file name.
*
* @return string The HTML code of the generated link.
*/
public function vfsDisplayUrl($file)
{
global $registry;
$mime_part = new Horde_Mime_Part();
$mime_part->setType(Horde_Mime_Magic::extToMime($file['type']));
$viewer = $GLOBALS['injector']->getInstance('Horde_Core_Factory_MimeViewer')->create($mime_part);
// We can always download files.
$url_params = array('actionID' => 'download_file', 'file' => $file['name'], 'type' => $file['type'], 'source' => $this->driver->getName(), 'key' => $this->getValue('__key'));
$dl = Horde::link($registry->downloadUrl($file['name'], $url_params), $file['name']) . Horde_Themes_Image::tag('download.png', array('alt' => _("Download"))) . '</a>';
// Let's see if we can view this one, too.
if ($viewer && !$viewer instanceof Horde_Mime_Viewer_Default) {
$url = Horde::url('view.php')->add($url_params)->add('actionID', 'view_file');
$link = Horde::link($url, $file['name'], null, '_blank') . $file['name'] . '</a>';
} else {
$link = $file['name'];
}
return $link . ' ' . $dl;
}
示例2: setMapiAttribute
public function setMapiAttribute($type, $name, $value)
{
switch ($name) {
case Horde_Compress_Tnef::MAPI_ATTACH_LONG_FILENAME:
$this->name = preg_replace('/.*[\\/](.*)$/', '\\1', $value);
break;
case Horde_Compress_Tnef::MAPI_ATTACH_MIME_TAG:
$type = str_replace("", '', preg_replace('/^(.*)\\/.*/', '\\1', $value));
$subtype = str_replace("", '', preg_replace('/.*\\/(.*)$/', '\\1', $value));
$this->type = $type;
$this->subtype = $subtype;
break;
case Horde_Compress_Tnef::MAPI_ATTACH_EXTENSION:
$value = Horde_Mime_Magic::extToMime($value);
$type = str_replace("", '', preg_replace('/^(.*)\\/.*/', '\\1', $value));
$subtype = str_replace("", '', preg_replace('/.*\\/(.*)$/', '\\1', $value));
$this->type = $type;
$this->subtype = $subtype;
}
}
示例3: catch
}
$gollem_vfs = $injector->getInstance('Gollem_Vfs');
$stream = null;
$data = '';
try {
if (is_callable(array($gollem_vfs, 'readStream'))) {
$stream = $gollem_vfs->readStream($vars->dir, $vars->file);
} else {
$data = $gollem_vfs->read($vars->dir, $vars->file);
}
} catch (Horde_Vfs_Exception $e) {
Horde::log($e, 'NOTICE');
throw $e;
}
$mime_part = new Horde_Mime_Part();
$mime_part->setType(Horde_Mime_Magic::extToMime($vars->type));
$mime_part->setContents(is_resource($stream) ? $stream : $data);
$mime_part->setName($vars->file);
// We don't know better.
$mime_part->setCharset('US-ASCII');
$ret = $injector->getInstance('Horde_Core_Factory_MimeViewer')->create($mime_part)->render('full');
reset($ret);
$key = key($ret);
try {
$size = $gollem_vfs->size($vars->dir, $vars->file);
} catch (Horde_Vfs_Exception $e) {
$size = null;
}
if (empty($ret)) {
$browser->downloadHeaders($vars->file, null, false, $size);
if (is_resource($stream)) {
示例4: attachmentUrl
/**
* Returns the links to view, download, and delete an attachment.
*
* @param integer $ticket A ticket ID.
* @param string $file An attachment name.
* @param integer $queue The ticket's queue ID.
*
* @return array List of URLs.
*/
public static function attachmentUrl($ticket, $file, $queue)
{
global $injector, $registry;
$links = array();
// Can we view the attachment online?
$mime_part = new Horde_Mime_Part();
$mime_part->setType(Horde_Mime_Magic::extToMime($file['type']));
$viewer = $injector->getInstance('Horde_Core_Factory_MimeViewer')->create($mime_part);
if ($viewer && !$viewer instanceof Horde_Mime_Viewer_Default) {
$links['view'] = Horde::url('view.php')->add(array('actionID' => 'view_file', 'type' => $file['type'], 'file' => $file['name'], 'ticket' => $ticket))->link(array('title' => $file['name'], 'target' => '_blank')) . $file['name'] . '</a>';
} else {
$links['view'] = $file['name'];
}
// We can always download attachments.
$url_params = array('actionID' => 'download_file', 'file' => $file['name'], 'ticket' => $ticket);
$links['download'] = $registry->downloadUrl($file['name'], $url_params)->link(array('title' => $file['name'])) . Horde::img('download.png', _("Download")) . '</a>';
// Admins can delete attachments.
if (self::hasPermission($queue, 'queue', Horde_Perms::DELETE)) {
$links['delete'] = Horde::url('ticket/delete_attachment.php')->add(array('file' => $file['name'], 'id' => $ticket, 'url' => Horde::selfUrl(true, false, true)))->link(array('title' => sprintf(_("Delete %s"), $file['name']), 'onclick' => 'return window.confirm(\'' . addslashes(sprintf(_("Permanently delete %s?"), $file['name'])) . '\');')) . Horde::img('delete.png', sprintf(_("Delete %s"), $file['name'])) . '</a>';
}
return $links;
}
示例5: explode
if (substr($val['link'], 0, 1) == '/') {
$parts = explode('/', $val['link']);
$name = array_pop($parts);
$dir = implode('/', $parts);
} else {
$name = $val['link'];
$dir = Gollem::$backend['dir'];
}
$url = $manager_url->copy()->add('dir', Gollem::subdirectory($dir, $name));
$item['link'] = $item['name'] . ' -> ' . $url->link() . $val['link'] . '</a>';
} else {
$item['link'] = $item['name'] . ' -> ' . $val['link'];
}
break;
default:
$mime_type = Horde_Mime_Magic::extToMime($val['type']);
// Edit link if possible.
if (strpos($mime_type, 'text/') === 0) {
$url = $edit_url->copy()->add(array('actionID' => 'edit_file', 'type' => $val['type'], 'file' => $val['name'], 'dir' => Gollem::$backend['dir'], 'driver' => Gollem::$backend['driver']));
$item['edit'] = Horde::link('#', '', '', '_blank', Horde::popupJs($url));
}
// We can always download files.
$item['dl'] = $registry->downloadUrl($val['name'], array('dir' => Gollem::$backend['dir'], 'backend' => $GLOBALS['session']->get('gollem', 'backend_key')))->link(array('title' => sprintf(_("Download %s"), $val['name'])));
// Try a view link.
$url = $view_url->copy()->add(array('type' => $val['type'], 'file' => $val['name'], 'dir' => Gollem::$backend['dir'], 'driver' => Gollem::$backend['driver']));
$item['link'] = Horde::link('#', '', '', '_blank', Horde::popupJs($url)) . $name . '</a>';
break;
}
$entry[] = $item;
}
/* Set up the variables needed for the header row. */
示例6: base64ImgData
public static function base64ImgData($in, $limit = null)
{
if (!($dataurl = $GLOBALS['browser']->hasFeature('dataurl'))) {
return $in;
}
if (!is_null($limit) && (is_bool($dataurl) || $limit < $dataurl)) {
$dataurl = $limit;
}
/* Only encode image files if they are below the dataurl limit. */
if (!$in instanceof Horde_Themes_Image) {
$in = self::fromUri($in);
}
if (!file_exists($in->fs)) {
return $in->uri;
}
/* Delete approx. 50 chars from the limit to account for the various
* data/base64 header text. Multiply by 0.75 to determine the
* base64 encoded size. */
return $dataurl === true || filesize($in->fs) <= $dataurl * 0.75 - 50 ? strval(Horde_Url_Data::create(Horde_Mime_Magic::extToMime(substr($in->uri, strrpos($in->uri, '.') + 1)), file_get_contents($in->fs))) : $in->uri;
}