예제 #1
0
파일: Issue.php 프로젝트: burbuja/indefero
 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_FileUtil::getMimeType($attach->filename);
     if (!IDF_FileUtil::isText($info)) {
         return $this->getAttachment($request, $match);
     }
     // Now we want to look at the file but with links back to the
     // issue.
     $file = IDF_FileUtil::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);
 }
예제 #2
0
파일: Source.php 프로젝트: burbuja/indefero
 /**
  * Should only be called through self::tree
  */
 public function viewFile($request, $match, $extra)
 {
     $title = sprintf(__('%1$s %2$s Source Tree'), (string) $request->project, $this->getScmType($request));
     $scm = IDF_Scm::get($request->project);
     $branches = $extra['branches'];
     $tags = $extra['tags'];
     $commit = $extra['commit'];
     $request_file = $extra['request_file'];
     $request_file_info = $extra['request_file_info'];
     $bc = self::makeBreadCrumb($request->project, $commit, $request_file_info->fullpath);
     $page_title = $bc . ' - ' . $title;
     $cobject = $scm->getCommit($commit);
     $in_branches = $scm->inBranches($commit, $request_file);
     $in_tags = $scm->inTags($commit, '');
     // try to find the previous level if it exists.
     $prev = explode('/', $request_file);
     $l = array_pop($prev);
     $previous = substr($request_file, 0, -strlen($l . ' '));
     $scmConf = $request->conf->getVal('scm', 'git');
     $props = $scm->getProperties($commit, $request_file);
     $content = IDF_FileUtil::highLight($extra['mime'], $scm->getFile($request_file_info));
     return Pluf_Shortcuts_RenderToResponse('idf/source/' . $scmConf . '/file.html', array('page_title' => $page_title, 'title' => $title, 'breadcrumb' => $bc, 'file' => $content, 'commit' => $commit, 'cobject' => $cobject, 'fullpath' => $request_file, 'efullpath' => IDF_Scm::smartEncode($request_file), 'base' => $request_file_info->file, 'prev' => $previous, 'tree_in' => $in_branches, 'branches' => $branches, 'tags' => $tags, 'tags_in' => $in_tags, 'props' => $props), $request);
 }