Controller_Project.class.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /**
  3. * Controller for displaying a project summary
  4. *
  5. * @author Christopher Han <xiphux@gmail.com>
  6. * @copyright Copyright (c) 2010 Christopher Han
  7. * @package GitPHP
  8. * @subpackage Controller
  9. */
  10. class GitPHP_Controller_Project extends GitPHP_ControllerBase
  11. {
  12. /**
  13. * Gets the template for this controller
  14. *
  15. * @return string template filename
  16. */
  17. protected function GetTemplate()
  18. {
  19. return 'project.tpl';
  20. }
  21. /**
  22. * Gets the cache key for this controller
  23. *
  24. * @return string cache key
  25. */
  26. protected function GetCacheKey()
  27. {
  28. return '';
  29. }
  30. /**
  31. * Gets the name of this controller's action
  32. *
  33. * @param boolean $local true if caller wants the localized action name
  34. * @return string action name
  35. */
  36. public function GetName($local = false)
  37. {
  38. if ($local && $this->resource) {
  39. return $this->resource->translate('summary');
  40. }
  41. return 'summary';
  42. }
  43. /**
  44. * Loads data for this template
  45. */
  46. protected function LoadData()
  47. {
  48. $log = GitPHP_DebugLog::GetInstance();
  49. $log->TimerStart();
  50. $head = $this->GetProject()->GetHeadCommit();
  51. $this->tpl->assign('head', $head);
  52. if (!$head)
  53. $this->tpl->assign('enablesearch', false);
  54. $log->TimerStop('GetHeadCommit');
  55. //$compat = $this->GetProject()->GetCompat();
  56. $strategy = null;
  57. //if ($compat) {
  58. $strategy = new GitPHP_LogLoad_Git($this->exe);
  59. //} else {
  60. // $strategy = new GitPHP_LogLoad_Raw();
  61. //}
  62. $revlist = new GitPHP_Log($this->GetProject(), $this->GetProject()->GetHeadCommit(), $strategy, 17);
  63. if ($revlist->GetCount() > 16) {
  64. $this->tpl->assign('hasmorerevs', true);
  65. $revlist->SetLimit(16);
  66. }
  67. $this->tpl->assign('revlist', $revlist);
  68. $log->TimerStart();
  69. $taglist = $this->GetProject()->GetTagList()->GetOrderedTags('-creatordate', 17);
  70. $log->TimerStop('GetTagList');
  71. if ($taglist) {
  72. if (count($taglist) > 16) {
  73. $this->tpl->assign('hasmoretags', true);
  74. $taglist = array_slice($taglist, 0, 16);
  75. }
  76. $this->tpl->assign('taglist', $taglist);
  77. }
  78. $log->TimerStart();
  79. $headlist = $this->GetProject()->GetHeadList()->GetOrderedHeads('-committerdate', 17);
  80. $log->TimerStop('GetHeadList');
  81. if ($headlist) {
  82. if (count($headlist) > 17) {
  83. $this->tpl->assign('hasmoreheads', true);
  84. $headlist = array_slice($headlist, 0, 16);
  85. }
  86. $this->tpl->assign('headlist', $headlist);
  87. }
  88. }
  89. }