Guest User

Untitled

a guest
May 26th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. public function getHtmlTree($root = true, $model, $color = null,$backColor,$age=2018)
  2. {
  3.  
  4. $html='';
  5. if ($root) {
  6. $html .= Html::beginTag('ul',['style'=>'width: 100px; height:20px;']);
  7. }
  8.  
  9. $html .= Html::beginTag('li', ['id' => 'node-'.$this->id]);
  10.  
  11. $childCount = $this->children(1)->count();
  12.  
  13. $nodeName = $this->name;
  14.  
  15. if ($this->date_of_birth) {
  16. $nodeName .= ' '.Html::tag('span', $this->date_of_birth, ['class' => 'label label-info']);
  17. }
  18.  
  19. if ($this->date_of_death) {
  20. $nodeName .= ' '.Html::tag('span', $this->date_of_death, ['class' => 'label label-default']);
  21. }
  22.  
  23. if ($childCount > 0 ) {
  24. $nodeName .= ' '.Html::tag('span', $childCount, ['class' => 'label label-success']);
  25. }
  26.  
  27. $nodeName = Html::img($this->getImage()->getUrl('x50')).' '.$nodeName;
  28.  
  29. $class = '';
  30.  
  31. if ($model->isChildOf($this) || $this->isChildOf($model)) {
  32. $class = 'node-is-primary';
  33. }
  34.  
  35. if ($this->id == $model->id) {
  36. $class = 'node-is-self';
  37. }
  38.  
  39. if ($this->color) {
  40. $color = $this->color;
  41. }
  42. $birth=$this->date_of_birth;
  43. $birth=explode('-',$birth);
  44. $px=$birth[0]*2/40;
  45. $px=round($px);
  46.  
  47.  
  48. $html .= Html::a($nodeName, '#person-'.$this->id, [
  49. 'data-toggle' => 'collapse',
  50. 'data-target' => '#person-'.$this->id,
  51. 'aria-expanded' => false,
  52. 'class' => $class,
  53. 'style' => $color ? 'background: '.$color.'; margin-top: 20px;' : '',
  54. ]);
  55. // $classLine=['class'=>'tree li::before tree li::after'];
  56. // $html.=Html::('li',$classLine,['style' => 'height: 100px;']);
  57. // Html::addCssClass($classLine, 'tree-height');
  58. // $html.=Html::($nodeName,$classLine,
  59. // [
  60. // 'style' => 'height: 100px;'
  61. // ]);
  62.  
  63. // start dair
  64.  
  65.  
  66. // end dair
  67.  
  68. $html .= Html::tag('span', '', [
  69. 'class' => 'glyphicon glyphicon-eye-open',
  70. 'style' => 'cursor: pointer; cursor: hand;',
  71. 'onclick' => "window.open('".Url::to(['/person/view', 'id' => $this->id])."', '_blank');",
  72. ]);
  73.  
  74. $childs = $this->children(1)->orderBy(['date_of_birth' => SORT_ASC])->all();
  75.  
  76. if ($childs) {
  77. $html .= Html::beginTag('ul', [
  78. 'id' => 'person-'.$this->id,
  79. 'class' => $model->isChildOf($this) ? 'collapse in' : 'collapse out',
  80. 'style'=>'background-color:'.$this->getColor($backColor).'; width: 100%; height: 50px;',
  81. 'title'=>$age
  82. ]);
  83.  
  84. foreach ($childs as $child) {
  85. $backColor=++$backColor;
  86. if($backColor>3) $backColor=0;
  87. $age=$age+25;
  88. $html .= $child->getHtmlTree($root = false, $model, $color,$backColor,$age);
  89. }
  90.  
  91. $html .= Html::endTag('ul');
  92. }
  93.  
  94. $html .= Htm
  95.  
  96. l::endTag('li');
  97.  
  98. if ($root) {
  99. $html .= Html::endTag('ul');
  100. }
  101.  
  102. return $html;
  103. }
Add Comment
Please, Sign In to add comment