Breadcrumb.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace ThurData\Servers\KerioEmail\Core\UI\Helpers;
  3. /**
  4. * Breadcrumb
  5. *
  6. * @autor ThurData <info@thurdata.ch>
  7. */
  8. class Breadcrumb
  9. {
  10. use \ThurData\Servers\KerioEmail\Core\UI\Traits\Title;
  11. use \ThurData\Servers\KerioEmail\Core\Traits\Lang;
  12. use \ThurData\Servers\KerioEmail\Core\Traits\IsAdmin;
  13. protected $url = null;
  14. protected $order = 100;
  15. protected $disabled = false;
  16. public function __construct($url = null, $title = null, $order = null, $rawTitle = null)
  17. {
  18. $this->setUrl($url);
  19. $this->setTitle($title);
  20. $this->setOrder($order);
  21. $this->setRawTitle($rawTitle);
  22. }
  23. public function setOrder($order = null)
  24. {
  25. if (is_int($order) && $order >= 0)
  26. {
  27. $this->order = $order;
  28. }
  29. return $this;
  30. }
  31. public function getOrder()
  32. {
  33. return $this->order;
  34. }
  35. public function setUrl($url = null)
  36. {
  37. if (is_string($url) && $url !== '')
  38. {
  39. $this->url = $url;
  40. }
  41. return $this;
  42. }
  43. public function getUrl()
  44. {
  45. return $this->url;
  46. }
  47. public function getBreadcrumb()
  48. {
  49. return ['url' => $this->url, 'title' => $this->buildTitle()];
  50. }
  51. public function buildTitle()
  52. {
  53. if ($this->getRawTitle())
  54. {
  55. return $this->getRawTitle();
  56. }
  57. $this->loadLang();
  58. return $this->lang->absoluteTranslate('addon' . ($this->isAdmin() ? 'AA' : 'CA'),
  59. 'breadcrumbs', $this->title);
  60. }
  61. public function setDisabled()
  62. {
  63. $this->disabled = true;
  64. }
  65. public function isDisabled()
  66. {
  67. return $this->disabled;
  68. }
  69. }