当前位置: 首页>>代码示例>>PHP>>正文


PHP Horde_Mime_Magic类代码示例

本文整理汇总了PHP中Horde_Mime_Magic的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Mime_Magic类的具体用法?PHP Horde_Mime_Magic怎么用?PHP Horde_Mime_Magic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Horde_Mime_Magic类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _getEmbeddedMimeParts

 /**
  * If this MIME part can contain embedded MIME part(s), and those part(s)
  * exist, return a representation of that data.
  *
  * @return mixed  A Horde_Mime_Part object representing the embedded data.
  *                Returns null if no embedded MIME part(s) exist.
  */
 protected function _getEmbeddedMimeParts()
 {
     /* Get the data from the attachment. */
     try {
         if (!($tnef = $this->getConfigParam('tnef'))) {
             $tnef = Horde_Compress::factory('Tnef');
             $this->setConfigParam('tnef', $tnef);
         }
         $tnefData = $tnef->decompress($this->_mimepart->getContents());
     } catch (Horde_Compress_Exception $e) {
         $tnefData = array();
     }
     if (!count($tnefData)) {
         return null;
     }
     $mixed = new Horde_Mime_Part();
     $mixed->setType('multipart/mixed');
     reset($tnefData);
     while (list(, $data) = each($tnefData)) {
         $temp_part = new Horde_Mime_Part();
         $temp_part->setName($data['name']);
         $temp_part->setDescription($data['name']);
         $temp_part->setContents($data['stream']);
         /* Short-circuit MIME-type guessing for winmail.dat parts;
          * we're showing enough entries for them already. */
         $type = $data['type'] . '/' . $data['subtype'];
         if (in_array($type, array('application/octet-stream', 'application/base64'))) {
             $type = Horde_Mime_Magic::filenameToMIME($data['name']);
         }
         $temp_part->setType($type);
         $mixed->addPart($temp_part);
     }
     return $mixed;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:41,代码来源:Tnef.php

示例2: testBug325

 public function testBug325()
 {
     if (!extension_loaded('fileinfo')) {
         $this->markTestSkipped('The fileinfo extension is not available.');
     }
     $this->assertEquals('text/plain', Horde_Mime_Magic::analyzeFile(__DIR__ . '/fixtures/flowed_msg.txt'));
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:7,代码来源:MagicTest.php

示例3: _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));
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:46,代码来源:Vcard.php

示例4: displayContents

 /**
  * @throws Wicked_Exception
  */
 public function displayContents($isBlock)
 {
     $view = $GLOBALS['injector']->createInstance('Horde_View');
     $view->addHelper('Wicked_View_Helper_Navigation');
     $view->name = $this->pageName();
     $view->text = $this->getProcessor()->transform($this->getText());
     if ($isBlock) {
         return $view->render('display/standard');
     }
     $view->showTools = true;
     if ($this->allows(Wicked::MODE_EDIT) && !$this->isLocked(Wicked::lockUser())) {
         $view->edit = Horde::widget(array('url' => Wicked::url('EditPage')->add('referrer', $this->pageName()), 'title' => _("_Edit"), 'class' => 'wicked-edit'));
     }
     if ($this->isLocked()) {
         if ($this->allows(Wicked::MODE_UNLOCKING)) {
             $view->unlock = Horde::widget(array('url' => $this->pageUrl(null, 'unlock')->remove('version'), 'title' => _("Un_lock"), 'class' => 'wicked-unlock'));
         }
     } else {
         if ($this->allows(Wicked::MODE_LOCKING)) {
             $view->lock = Horde::widget(array('url' => $this->pageUrl(null, 'lock')->remove('version'), 'title' => _("_Lock"), 'class' => 'wicked-lock'));
         }
     }
     if ($this->allows(Wicked::MODE_REMOVE)) {
         $params = array('referrer' => $this->pageName());
         if ($this->isOld()) {
             $params['version'] = $this->version();
         }
         $view->remove = Horde::widget(array('url' => Wicked::url('DeletePage')->add($params), 'title' => _("_Delete"), 'class' => 'wicked-delete'));
     }
     if ($this->allows(Wicked::MODE_REMOVE) && !$this->isLocked(Wicked::lockUser())) {
         $view->rename = Horde::widget(array('url' => Wicked::url('MergeOrRename')->add('referrer', $this->pageName()), 'title' => _("_Merge/Rename")));
     }
     $view->backLinks = Horde::widget(array('url' => Wicked::url('BackLinks')->add('referrer', $this->pageName()), 'title' => _("_Backlinks")));
     $view->likePages = Horde::widget(array('url' => Wicked::url('LikePages')->add('referrer', $this->pageName()), 'title' => _("S_imilar Pages")));
     $view->attachedFiles = Horde::widget(array('url' => Wicked::url('AttachedFiles')->add('referrer', $this->pageName()), 'title' => _("Attachments")));
     if ($this->allows(Wicked::MODE_HISTORY)) {
         $view->changes = Horde::widget(array('url' => $this->pageUrl('history.php')->remove('version'), 'title' => _("Hi_story")));
     }
     if ($GLOBALS['registry']->isAdmin()) {
         $permsurl = Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/admin/perms/edit.php')->add(array('category' => 'wicked:pages:' . $this->pageId(), 'autocreate' => 1, 'autocreate_copy' => 'wicked', 'autocreate_guest' => Horde_Perms::SHOW | Horde_Perms::READ, 'autocreate_default' => Horde_Perms::SHOW | Horde_Perms::READ | Horde_Perms::EDIT | Horde_Perms::DELETE));
         $view->perms = Horde::widget(array('url' => $permsurl, 'target' => '_blank', 'title' => _("Permissio_ns")));
     }
     if ($histories = $GLOBALS['session']->get('wicked', 'history')) {
         $view->history = Horde::widget(array('url' => '#', 'onclick' => 'document.location = document.display.history[document.display.history.selectedIndex].value;', 'title' => _("Ba_ck to")));
         $view->histories = array();
         foreach ($histories as $history) {
             if (!strlen($history)) {
                 continue;
             }
             $view->histories[(string) Wicked::url($history)] = $history;
         }
     }
     $pageId = $GLOBALS['wicked']->getPageId($this->pageName());
     $attachments = $GLOBALS['wicked']->getAttachedFiles($pageId);
     if (count($attachments)) {
         $view->attachments = array();
         foreach ($attachments as $attachment) {
             $url = $GLOBALS['registry']->downloadUrl($attachment['attachment_name'], array('page' => $this->pageName(), 'file' => $attachment['attachment_name'], 'version' => $attachment['attachment_version']));
             $icon = $GLOBALS['injector']->getInstance('Horde_Core_Factory_MimeViewer')->getIcon(Horde_Mime_Magic::filenameToMime($attachment['attachment_name']));
             $view->attachments[] = Horde::link($url) . '<img src="' . $icon . '" width="16" height="16" alt="" />&nbsp;' . htmlspecialchars($attachment['attachment_name']) . '</a>';
         }
     }
     $view->downloadPlain = Wicked::url($this->pageName())->add(array('actionID' => 'export', 'format' => 'plain'))->link() . _("Plain Text") . '</a>';
     $view->downloadHtml = Wicked::url($this->pageName())->add(array('actionID' => 'export', 'format' => 'html'))->link() . _("HTML") . '</a>';
     $view->downloadLatex = Wicked::url($this->pageName())->add(array('actionID' => 'export', 'format' => 'tex'))->link() . _("Latex") . '</a>';
     $view->downloadRest = Wicked::url($this->pageName())->add(array('actionID' => 'export', 'format' => 'rst'))->link() . _("reStructuredText") . '</a>';
     return $view->render('display/standard');
 }
开发者ID:horde,项目名称:horde,代码行数:71,代码来源:StandardPage.php

示例5: _addAttachment

 /**
  * Adds an attachment to the outgoing compose message.
  *
  * @param string $atc_file  Temporary file containing attachment contents.
  * @param integer $bytes    Size of data, in bytes.
  * @param string $filename  Filename of data.
  * @param string $type      MIME type of data.
  *
  * @return IMP_Compose_Attachment  Attachment object.
  * @throws IMP_Compose_Exception
  */
 protected function _addAttachment($atc_file, $bytes, $filename, $type)
 {
     global $conf, $injector;
     $atc = new Horde_Mime_Part();
     $atc->setBytes($bytes);
     /* Try to determine the MIME type from 1) the extension and
      * then 2) analysis of the file (if available). */
     if (strlen($filename)) {
         $atc->setName($filename);
         if ($type == 'application/octet-stream') {
             $type = Horde_Mime_Magic::filenameToMIME($filename, false);
         }
     }
     $atc->setType($type);
     if ($atc->getType() == 'application/octet-stream' || $atc->getPrimaryType() == 'text') {
         $analyze = Horde_Mime_Magic::analyzeFile($atc_file, empty($conf['mime']['magic_db']) ? null : $conf['mime']['magic_db'], array('nostrip' => true));
         $atc->setCharset('UTF-8');
         if ($analyze) {
             $ctype = new Horde_Mime_Headers_ContentParam('Content-Type', $analyze);
             $atc->setType($ctype->value);
             if (isset($ctype->params['charset'])) {
                 $atc->setCharset($ctype->params['charset']);
             }
         }
     } else {
         $atc->setHeaderCharset('UTF-8');
     }
     $atc_ob = new IMP_Compose_Attachment($this, $atc, $atc_file);
     /* Check for attachment size limitations. */
     $size_limit = null;
     if ($atc_ob->linked) {
         if (!empty($conf['compose']['link_attach_size_limit'])) {
             $linked = true;
             $size_limit = 'link_attach_size_limit';
         }
     } elseif (!empty($conf['compose']['attach_size_limit'])) {
         $linked = false;
         $size_limit = 'attach_size_limit';
     }
     if (!is_null($size_limit)) {
         $total_size = $conf['compose'][$size_limit] - $bytes;
         foreach ($this as $val) {
             if ($val->linked == $linked) {
                 $total_size -= $val->getPart()->getBytes();
             }
         }
         if ($total_size < 0) {
             throw new IMP_Compose_Exception(strlen($filename) ? sprintf(_("Attached file \"%s\" exceeds the attachment size limits. File NOT attached."), $filename) : _("Attached file exceeds the attachment size limits. File NOT attached."));
         }
     }
     try {
         $injector->getInstance('Horde_Core_Hooks')->callHook('compose_attachment', 'imp', array($atc_ob));
     } catch (Horde_Exception_HookNotSet $e) {
     }
     $this->_atc[$atc_ob->id] = $atc_ob;
     $this->changed = 'changed';
     return $atc_ob;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:69,代码来源:Compose.php

示例6: array

        $currDir = $injector->getInstance('Horde_Core_Factory_TextFilter')->filter($currentDir, 'space2html', array('encode' => true, 'encode_all' => true));
        require CHORA_TEMPLATES . '/directory/dir.inc';
    }
    echo '</tbody>';
}
/* Display all of the files in this directory */
$readmes = array();
if ($fileList) {
    echo '<tbody>';
    foreach ($fileList as $currFile) {
        if ($conf['hide_restricted'] && Chora::isRestricted($currFile->getFileName())) {
            continue;
        }
        $lg = $currFile->getLastLog();
        $realname = $currFile->getFileName();
        $mimeType = Horde_Mime_Magic::filenameToMIME($realname);
        $currFile->mimeType = $mimeType;
        if (Horde_String::lower(Horde_String::substr($realname, 0, 6)) == 'readme') {
            $readmes[] = $currFile;
        }
        $icon = $injector->getInstance('Horde_Core_Factory_MimeViewer')->getIcon($mimeType);
        $author = Chora::showAuthorName($lg->getAuthor());
        $filerev = $lg->getRevision();
        $date = $lg->getDate();
        $log = $lg->getMessage();
        $attic = $currFile->isDeleted();
        $fileName = $where . ($attic ? '/' . 'Attic' : '') . '/' . $realname;
        $name = $injector->getInstance('Horde_Core_Factory_TextFilter')->filter($realname, 'space2html', array('encode' => true, 'encode_all' => true));
        $url = Chora::url('browsefile', $fileName, $branchArgs);
        $readableDate = Chora::readableTime($date);
        if ($log) {
开发者ID:horde,项目名称:horde,代码行数:31,代码来源:browsedir.php

示例7: copy

            }
        } else {
            $file_name = $tmpdir . '/mod_' . $file;
            if (!file_exists($file_name)) {
                copy($tmpdir . '/' . $file, $file_name);
            }
        }
        if (!file_exists($file_name)) {
            Horde::log(sprintf('Image not found [%s]', $file_name), 'ERR');
            exit;
        }
        $file_data = file_get_contents($file_name);
        break;
}
/* Load the image object. */
$type = Horde_Mime_Magic::analyzeData($file_data);
$image = $injector->getInstance('Horde_Core_Factory_Image')->create(array('data' => $file_data, 'type' => $type));
/* Check if no editing action required and send the image to browser. */
if (empty($action)) {
    $image->display();
    exit;
}
/* Image editing required. */
switch ($action) {
    case 'rotate':
        $image->rotate($vars->v);
        break;
    case 'flip':
        $image->flip();
        break;
    case 'mirror':
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:31,代码来源:view.php

示例8: _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;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:56,代码来源:Horde.php

示例9: dirExpand

 function dirExpand($dir)
 {
     global $files, $mime_drivers, $mime_drivers_map;
     $result = Horde::loadConfiguration('mime_drivers.php', array('mime_drivers', 'mime_drivers_map'), 'horde');
     extract($result);
     $result = Horde::loadConfiguration('mime_drivers.php', array('mime_drivers', 'mime_drivers_map'), 'luxor');
     if (isset($result['mime_drivers'])) {
         $mime_drivers = array_replace_recursive($mime_drivers, $result['mime_drivers']);
     }
     if (isset($result['mime_drivers_map'])) {
         $mime_drivers_map = array_replace_recursive($mime_drivers_map, $result['mime_drivers_map']);
     }
     $nodes = $files->getDir($dir);
     if (is_a($nodes, 'PEAR_Error')) {
         return $nodes;
     }
     $index = $files->getIndex($dir);
     if (is_a($index, 'PEAR_Error')) {
         return $index;
     }
     if ($dir != '/') {
         array_unshift($nodes, '../');
     }
     $list = array();
     foreach ($nodes as $node) {
         $link = Luxor::url($dir . $node);
         $modtime = $files->getFiletime($dir . $node);
         $modtime = $modtime ? gmdate('Y-m-d H:i:s', $modtime) : '-';
         $description = empty($index[$node]) ? '&nbsp;' : $index[$node];
         if (substr($node, -1) == '/') {
             $filesize = '-';
             $bytes = '';
             if ($node == '../') {
                 $icon = Horde::img('parent.png', _("Up to parent"));
                 $node = _("Parent Directory");
             } else {
                 $icon = Horde::img('folder.png', $node);
             }
         } else {
             if (preg_match('/^.*\\.[oa]$|^core$|^00-INDEX$/', $node)) {
                 continue;
             }
             $icon = Horde::img($GLOBALS['injector']->getInstance('Horde_Core_Factory_MimeViewer')->getIcon(Horde_Mime_Magic::filenameToMime($node)), '', '', '');
             $filesize = $files->getFilesize($dir . $node);
             if ($filesize < 1 << 10) {
                 $bytes = _("bytes");
             } else {
                 $bytes = _("kbytes");
                 $filesize = $filesize >> 10;
             }
         }
         $list[] = array('icon' => $icon, 'name' => $node, 'link' => $link, 'filesize' => $filesize, 'bytes' => $bytes, 'modtime' => $modtime, 'description' => $description);
     }
     return $list;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:55,代码来源:Luxor.php

示例10: implode

    echo implode("\n", $VC->diff($fl, $vars->r1, $vars->r2, array('num' => $num, 'type' => $type))) . "\n";
    exit;
}
/* Human-Readable diff. */
$abbrev_r1 = $VC->abbrev($vars->r1);
$abbrev_r2 = $VC->abbrev($vars->r2);
$title = sprintf(_("Diff for %s between version %s and %s"), $injector->getInstance('Horde_Core_Factory_TextFilter')->filter($where, 'space2html', array('encode' => true, 'encode_all' => true)), $abbrev_r1, $abbrev_r2);
/* Format log entries. */
$log_messages = array();
foreach ($VC->getRevisionRange($fl, $vars->r1, $vars->r2) as $val) {
    $clog = $fl->getLog($val);
    if (!is_null($clog)) {
        $log_messages[] = $clog;
    }
}
$page_output->addScriptFile('stripe.js', 'horde');
Chora::header($title);
require CHORA_TEMPLATES . '/diff/header.inc';
$mime_type = Horde_Mime_Magic::filenameToMIME($fullname);
if (substr($mime_type, 0, 6) == 'image/') {
    /* Check for images. */
    $url1 = Chora::url('co', $where, array('r' => $vars->r1, 'p' => 1));
    $url2 = Chora::url('co', $where, array('r' => $vars->r2, 'p' => 1));
    echo "<tr><td><img src=\"{$url1}\" alt=\"" . htmlspecialchars($vars->r1) . '" /></td>' . "<td><img src=\"{$url2}\" alt=\"" . htmlspecialchars($vars->r2) . '" /></td></tr>';
} else {
    $view = $injector->createInstance('Horde_View');
    $view->addHelper('Chora_Diff_Helper');
    echo $view->diff($fl, $vars->r1, $vars->r2);
    echo $view->diffCaption();
}
$page_output->footer();
开发者ID:raz0rsdge,项目名称:horde,代码行数:31,代码来源:diff.php

示例11: 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;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:31,代码来源:Whups.php

示例12: 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)) {
开发者ID:raz0rsdge,项目名称:horde,代码行数:31,代码来源:view.php

示例13: 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. */
开发者ID:horde,项目名称:horde,代码行数:31,代码来源:manager.php

示例14: fromASContact

 /**
  * Convert an ActiveSync contact message into a hash suitable for
  * importing via self::add().
  *
  * @param Horde_ActiveSync_Message_Contact $message  The contact message
  *                                                   object.
  *
  * @return array  A contact hash.
  */
 public function fromASContact(Horde_ActiveSync_Message_Contact $message)
 {
     $hash = array();
     foreach (self::$_asMap as $turbaField => $asField) {
         if (!$message->isGhosted($asField)) {
             try {
                 $hash[$turbaField] = $message->{$asField};
             } catch (InvalidArgumentException $e) {
             }
         }
     }
     /* Requires special handling */
     try {
         if ($message->getProtocolVersion() >= Horde_ActiveSync::VERSION_TWELVE) {
             if (!empty($message->airsyncbasebody)) {
                 $hash['notes'] = $message->airsyncbasebody->data;
             }
         } else {
             $hash['notes'] = $message->body;
         }
     } catch (InvalidArgumentException $e) {
     }
     // picture ($message->picture *should* already be base64 encdoed)
     if (!$message->isGhosted('picture')) {
         $hash['photo'] = base64_decode($message->picture);
         if (!empty($hash['photo'])) {
             $hash['phototype'] = Horde_Mime_Magic::analyzeData($hash['photo']);
         } else {
             $hash['phototype'] = null;
         }
     }
     /* Email addresses */
     $hash['emails'] = array();
     if (!$message->isGhosted('email1address')) {
         $e = Horde_Icalendar_Vcard::getBareEmail($message->email1address);
         $hash['emails'][] = $hash['email'] = $e ? $e : '';
     }
     if (!$message->isGhosted('email2address')) {
         $e = Horde_Icalendar_Vcard::getBareEmail($message->email2address);
         $hash['emails'][] = $hash['homeEmail'] = $e ? $e : '';
     }
     if (!$message->isGhosted('email3address')) {
         $e = Horde_Icalendar_Vcard::getBareEmail($message->email3address);
         $hash['emails'][] = $hash['workEmail'] = $e ? $e : '';
     }
     $hash['emails'] = implode(',', $hash['emails']);
     /* Categories */
     if (is_array($message->categories) && count($message->categories)) {
         $hash['__tags'] = $message->categories;
     }
     /* Children */
     if (is_array($message->children) && count($message->children)) {
         // We use a comma as incoming delimiter as it's the most
         // common even though it might be used withing a name string.
         $hash['children'] = implode(', ', $message->children);
     } elseif (!$message->isGhosted('children')) {
         $hash['children'] = '';
     }
     /* Birthday and Anniversary */
     if (!empty($message->birthday)) {
         $bday = clone $message->birthday;
         $bday->setTimezone(date_default_timezone_get());
         $hash['birthday'] = $bday->format('Y-m-d');
     } elseif (!$message->isGhosted('birthday')) {
         $hash['birthday'] = '';
     }
     if (!empty($message->anniversary)) {
         $anniversary = clone $message->anniversary;
         $anniversary->setTimezone(date_default_timezone_get());
         $hash['anniversary'] = $anniversary->format('Y-m-d');
     } elseif (!$message->isGhosted('anniversary')) {
         $hash['anniversary'] = '';
     }
     /* Countries */
     include 'Horde/Nls/Countries.php';
     if (!empty($message->homecountry)) {
         if (!empty($this->map['homeCountryFree'])) {
             $hash['homeCountryFree'] = $message->homecountry;
         } else {
             $country = array_search($message->homecountry, $countries);
             if ($country === false) {
                 $country = $message->homecountry;
             }
             $hash['homeCountry'] = $country;
         }
     } elseif (!$message->isGhosted('homecountry')) {
         $hash['homeCountry'] = '';
     }
     if (!empty($message->businesscountry)) {
         if (!empty($this->map['workCountryFree'])) {
             $hash['workCountryFree'] = $message->businesscountry;
//.........这里部分代码省略.........
开发者ID:kossamums,项目名称:horde,代码行数:101,代码来源:Driver.php

示例15: printfile_raw

function printfile_raw($pathname)
{
    global $mime_drivers, $mime_drivers_map;
    $result = Horde::loadConfiguration('mime_drivers.php', array('mime_drivers', 'mime_drivers_map'), 'horde');
    extract($result);
    $result = Horde::loadConfiguration('mime_drivers.php', array('mime_drivers', 'mime_drivers_map'), 'luxor');
    if (isset($result['mime_drivers'])) {
        $mime_drivers = array_replace_recursive($mime_drivers, $result['mime_drivers']);
    }
    if (isset($result['mime_drivers_map'])) {
        $mime_drivers_map = array_replace_recursive($mime_drivers_map, $result['mime_drivers_map']);
    }
    $filename = $GLOBALS['files']->toReal($pathname);
    $data = file_get_contents($filename);
    $mime_part = new Horde_Mime_Part(Horde_Mime_Magic::filenameToMime($pathname), $data);
    $mime_part->setName($pathname);
    $viewer = $GLOBALS['injector']->getInstance('Horde_Core_Factory_MimeViewer')->create($mime_part);
    if ($viewer->getType() == 'text/plain') {
        return '<pre class="fixed">' . htmlspecialchars($viewer->render()) . '</pre>';
    } else {
        return $viewer->render();
    }
}
开发者ID:raz0rsdge,项目名称:horde,代码行数:23,代码来源:source.php


注:本文中的Horde_Mime_Magic类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。