Chora::pretty PHP Méthode

pretty() public static méthode

Pretty-print the checked out copy, using Horde_Mime_Viewer.
public static pretty ( string $mime_type, resource $fp ) : mixed
$mime_type string File extension of the checked out file.
$fp resource File pointer to the head of the checked out copy.
Résultat mixed The Horde_Mime_Viewer object which can be rendered or false on failure.
    public static function pretty($mime_type, $fp)
    {
        $lns = '';
        while ($ln = fread($fp, 8192)) {
            $lns .= $ln;
        }
        $mime = new Horde_Mime_Part();
        $mime->setType($mime_type);
        $mime->setContents($lns);
        return $GLOBALS['injector']->getInstance('Horde_Core_Factory_MimeViewer')->create($mime);
    }

Usage Example

Exemple #1
0
 public function render()
 {
     // need the checkout
     $checkOut = $GLOBALS['VC']->checkout($this->_file->getPath(), $this->_revision);
     // Pretty-print the checked out copy */
     if ($this->_file->mimeType == 'application/octet-stream') {
         $this->_view->mimeType = 'text/plain';
     } else {
         $this->_view->mimeType = $this->_file->mimeType;
     }
     $this->_view->title = $this->_file->getFileName();
     $this->_view->pretty = Chora::pretty($this->_view->mimeType, $checkOut);
     if ($this->_view->mimeType == 'text/html') {
         $this->_view->pretty->setConfigParam('inline', true);
     }
     return $this->_view->render('app/views/file/html.html.php');
 }
All Usage Examples Of Chora::pretty