pretty() 공개 정적인 메소드

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.
리턴 mixed The Horde_Mime_Viewer object which can be rendered or false on failure.
예제 #1
0
파일: Html.php 프로젝트: jubinpatel/horde
 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');
 }
예제 #2
0
파일: co.php 프로젝트: horde/horde
    Chora::fatal(sprintf(_("Revision Not Found: %s is not a valid revision"), $r), '400 Bad Request');
}
/* Retrieve the actual checkout. */
try {
    $checkOut = $VC->checkout($file->getPath(), $r);
} catch (Horde_Vcs_Exception $e) {
    Chora::fatal($e);
}
/* Get the MIME type of the file, or at least our best guess at it. */
$mime_type = Horde_Mime_Magic::filenameToMIME($fullname);
if ($mime_type == 'application/octet-stream') {
    $mime_type = 'text/plain';
}
if (!$plain) {
    /* Pretty-print the checked out copy */
    $pretty = Chora::pretty($mime_type, $checkOut);
    if (strpos($mime_type, 'text/plain') !== false) {
        $data = $pretty->render('inline');
        $data = reset($data);
        $rendered = '<div class="fixed">' . $GLOBALS['injector']->getInstance('Horde_Core_Factory_TextFilter')->filter($data['data'], 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO)) . '</div>';
    } elseif (strpos($mime_type, 'image/') !== false) {
        $rendered = Horde::img(Horde::selfUrl(true)->add('p', 1), '', '', '');
    } elseif ($pretty->canRender('inline')) {
        $data = $pretty->render('inline');
        $data = reset($data);
        $rendered = $data['data'];
    } else {
        $rendered = Horde::link(Horde::selfUrl(true)->add('p', 1)) . Horde::img('download.png') . ' ' . sprintf(_("Download revision %s"), $r) . '</a>';
    }
    /* Get this revision's attributes in printable form. */
    $log = $file->getLog($r);