Controller_Tags.class.php 1.6 KB

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