YiiDebugToolbarPanel.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /**
  3. * YiiDebugToolbarPanel class file.
  4. *
  5. * @author Sergey Malyshev <malyshev.php@gmail.com>
  6. */
  7. /**
  8. * YiiDebugToolbarPanel represents an ...
  9. *
  10. * Description of YiiDebugToolbarPanel
  11. *
  12. * @author Sergey Malyshev <malyshev.php@gmail.com>
  13. * @author Igor Golovanov <igor.golovanov@gmail.com>
  14. * @version $Id$
  15. * @package YiiDebugToolbar
  16. * @since 1.1.7
  17. */
  18. abstract class YiiDebugToolbarPanel extends CWidget
  19. implements YiiDebugToolbarPanelInterface
  20. {
  21. public $i = 'n';
  22. const VIEWS_PATH = '/views/panels';
  23. private $_enabled = true;
  24. private $_id;
  25. private static $_counter = 0;
  26. /**
  27. * Returns the ID of the panel or generates a new one if requested.
  28. * It uses 'dt' as prefix to avoid clashes with autogenerated IDs from Yii widgets
  29. * @param boolean $autoGenerate whether to generate an ID if it is not set previously
  30. * @return string id of the panel.
  31. */
  32. public function getId($autoGenerate=true)
  33. {
  34. if($this->_id!==null)
  35. return $this->_id;
  36. elseif($autoGenerate)
  37. return $this->_id='ydtb-panel-'.self::$_counter++;
  38. }
  39. /**
  40. * @param boolean $value set is panel enabled
  41. */
  42. public function setEnabled($value)
  43. {
  44. $this->_enabled = CPropertyValue::ensureBoolean($value);
  45. }
  46. /**
  47. * @return boolean $value is panel enabled
  48. */
  49. public function getEnabled()
  50. {
  51. return $this->_enabled;
  52. }
  53. /**
  54. * Displays a variable.
  55. * This method achieves the similar functionality as var_dump and print_r
  56. * but is more robust when handling complex objects such as Yii controllers.
  57. * @param mixed $var variable to be dumped
  58. */
  59. public function dump($var)
  60. {
  61. YiiDebug::dump($var);
  62. }
  63. /**
  64. * {@inheritdoc}
  65. */
  66. public function getSubTitle()
  67. {
  68. return null;
  69. }
  70. /**
  71. * {@inheritdoc}
  72. */
  73. public function getMenuSubTitle()
  74. {
  75. return null;
  76. }
  77. /**
  78. * Returns the directory containing the view files for this widget.
  79. * @param boolean $checkTheme not implemented. Only for inheriting CWidget interface.
  80. * @return string the directory containing the view files for this widget.
  81. */
  82. public function getViewPath($checkTheme = false)
  83. {
  84. return dirname(__FILE__) . self::VIEWS_PATH;
  85. }
  86. }