Controller_Tag.class.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * Controller for displaying a tag
  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_Tag extends GitPHP_ControllerBase
  11. {
  12. /**
  13. * Initialize controller
  14. */
  15. public function Initialize()
  16. {
  17. parent::Initialize();
  18. if (!empty($this->params['output']) && ($this->params['output'] == 'jstip'))
  19. $this->DisableLogging();
  20. }
  21. /**
  22. * Gets the template for this controller
  23. *
  24. * @return string template filename
  25. */
  26. protected function GetTemplate()
  27. {
  28. if (isset($this->params['output']) && ($this->params['output'] == 'jstip')) {
  29. return 'tagtip.tpl';
  30. }
  31. return 'tag.tpl';
  32. }
  33. /**
  34. * Gets the cache key for this controller
  35. *
  36. * @return string cache key
  37. */
  38. protected function GetCacheKey()
  39. {
  40. return isset($this->params['tag']) ? sha1($this->params['tag']) : '';
  41. }
  42. /**
  43. * Gets the name of this controller's action
  44. *
  45. * @param boolean $local true if caller wants the localized action name
  46. * @return string action name
  47. */
  48. public function GetName($local = false)
  49. {
  50. if ($local && $this->resource) {
  51. return $this->resource->translate('tag');
  52. }
  53. return 'tag';
  54. }
  55. /**
  56. * Loads data for this template
  57. */
  58. protected function LoadData()
  59. {
  60. $head = $this->GetProject()->GetHeadCommit();
  61. $this->tpl->assign('head', $head);
  62. $tag = $this->GetProject()->GetTagList()->GetTag($this->params['tag']);
  63. $this->tpl->assign("tag", $tag);
  64. }
  65. }