Controller_Graph.class.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * Controller for displaying graph selection
  4. *
  5. * @author Christopher Han <xiphux@gmail.com>
  6. * @copyright Copyright (c) 2012 Christopher Han
  7. * @package GitPHP
  8. * @subpackage Controller
  9. */
  10. class GitPHP_Controller_Graph extends GitPHP_ControllerBase
  11. {
  12. /**
  13. * Initialize controller
  14. */
  15. public function Initialize()
  16. {
  17. parent::Initialize();
  18. if (!$this->config->GetValue('graphs')) {
  19. throw new Exception('Graphing has been disabled');
  20. }
  21. if (empty($this->params['graphtype']))
  22. $this->params['graphtype'] = 'commitactivity';
  23. }
  24. /**
  25. * Gets the template for this controller
  26. *
  27. * @return string template filename
  28. */
  29. protected function GetTemplate()
  30. {
  31. return 'graph.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['graphtype']) ? $this->params['graphtype'] : '';
  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('graph');
  52. }
  53. return 'graph';
  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. if (!$head)
  63. $this->tpl->assign('enablesearch', false);
  64. if (!empty($this->params['graphtype']))
  65. $this->tpl->assign('graphtype', $this->params['graphtype']);
  66. }
  67. }