Пример #1
0
 function callbackEmbeddedDoc($m)
 {
     $scm = IDF_Scm::get($this->request->project);
     $view_source = new IDF_Views_Source();
     $match = array('dummy', $this->request->project->shortname);
     $match[] = isset($m[2]) ? $m[2] : $scm->getMainBranch();
     $match[] = $m[1];
     $res = $view_source->getFile($this->request, $match);
     if ($res->status_code != 200) {
         return $m[0];
     }
     $info = pathinfo($m[1]);
     $fileinfo = array($res->headers['Content-Type'], $m[1], isset($info['extension']) ? $info['extension'] : 'bin');
     if (!IDF_Views_Source::isText($fileinfo)) {
         return $m[0];
     }
     return $res->content;
 }
Пример #2
0
 public function viewAttachment($request, $match)
 {
     $prj = $request->project;
     $attach = Pluf_Shortcuts_GetObjectOr404('IDF_IssueFile', $match[2]);
     $prj->inOr404($attach->get_comment()->get_issue());
     // If one cannot see the attachement, redirect to the
     // getAttachment view.
     $info = IDF_Views_Source::getMimeType($attach->filename);
     if (!IDF_Views_Source::isText($info)) {
         return $this->getAttachment($request, $match);
     }
     // Now we want to look at the file but with links back to the
     // issue.
     $file = IDF_Views_Source::highLight($info, file_get_contents(Pluf::f('upload_issue_path') . '/' . $attach->attachment));
     $title = sprintf(__('View %s'), $attach->filename);
     return Pluf_Shortcuts_RenderToResponse('idf/issues/attachment.html', array('attachment' => $attach, 'page_title' => $title, 'comment' => $attach->get_comment(), 'issue' => $attach->get_comment()->get_issue(), 'file' => $file), $request);
 }