YiiDebugToolbarPanelViews.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /**
  3. * YiiDebugToolbarPanelViews class file.
  4. *
  5. * @author Sergey Malyshev <malyshev.php@gmail.com>
  6. */
  7. Yii::import('yii-debug-toolbar.YiiDebugViewRenderer');
  8. /**
  9. * YiiDebugToolbarPanelViews represents an ...
  10. *
  11. * Description of YiiDebugToolbarPanelViews
  12. *
  13. * @author Sergey Malyshev <malyshev.php@gmail.com>
  14. * @version $Id$
  15. * @package
  16. * @since 1.1.7
  17. */
  18. class YiiDebugToolbarPanelViews extends YiiDebugToolbarPanel
  19. {
  20. public $i = 'l';
  21. private $_viewsCount = 0;
  22. private $_viewRenderer;
  23. public function getViewsCount()
  24. {
  25. return count($this->_viewRenderer->debugStackTrace);
  26. }
  27. public function init()
  28. {
  29. parent::init();
  30. $this->_viewRenderer = Yii::app()->getComponent('viewRenderer');
  31. }
  32. public function run()
  33. {
  34. $data = array();
  35. $viewRenderer = $this->_viewRenderer;
  36. if ($viewRenderer instanceof YiiDebugViewRenderer) {
  37. $data = $this->_viewRenderer->debugStackTrace;
  38. }
  39. $this->render('views', array('data'=>$data));
  40. }
  41. public function getInheritance(ReflectionClass $class)
  42. {
  43. $data = array();
  44. while($class = $class->getParentClass())
  45. {
  46. $data[] = $class->name;
  47. if('CBaseController' === $class->name)
  48. break;
  49. }
  50. return implode('&nbsp;&raquo;&nbsp;', $data);
  51. }
  52. public function getFilePath($file)
  53. {
  54. return trim(str_replace(Yii::getPathOfAlias('webroot'), '', $file), '\\/');
  55. }
  56. public function getFileAlias($file)
  57. {
  58. return str_replace(DIRECTORY_SEPARATOR, '.',
  59. dirname(trim(str_replace(Yii::getPathOfAlias('webroot'), '', $file), '\\/')) . '/'
  60. . basename(trim(str_replace(Yii::getPathOfAlias('webroot'), '', $file), '\\/'), '.php'));
  61. }
  62. public function getWidgetsData()
  63. {
  64. }
  65. /**
  66. * {@inheritdoc}
  67. */
  68. public function getMenuTitle()
  69. {
  70. return YiiDebug::t('Views Rendering');
  71. }
  72. /**
  73. * {@inheritdoc}
  74. */
  75. public function getMenuSubTitle()
  76. {
  77. return $this->viewsCount;
  78. }
  79. /**
  80. * {@inheritdoc}
  81. */
  82. public function getTitle()
  83. {
  84. return YiiDebug::t('Views Rendering');
  85. }
  86. /**
  87. * {@inheritdoc}
  88. */
  89. public function getSubTitle()
  90. {
  91. return false;
  92. }
  93. }