@@ -617,6 +617,30 @@ public function showingCMSTree()
617
617
&& in_array ($ controller ->getAction (), ["treeview " , "listview " , "getsubtree " ]);
618
618
}
619
619
620
+ /**
621
+ * Return the CSS classes to apply to this node in the CMS tree.
622
+ */
623
+ public function CMSTreeClasses (): string
624
+ {
625
+ $ owner = $ this ->getOwner ();
626
+ $ classes = sprintf ('class-%s ' , Convert::raw2htmlid (get_class ($ owner )));
627
+
628
+ if (!$ owner ->canAddChildren ()) {
629
+ $ classes .= " nochildren " ;
630
+ }
631
+
632
+ if (!$ owner ->canEdit () && !$ owner ->canAddChildren ()) {
633
+ if (!$ owner ->canView ()) {
634
+ $ classes .= " disabled " ;
635
+ } else {
636
+ $ classes .= " edit-disabled " ;
637
+ }
638
+ }
639
+
640
+ $ owner ->invokeWithExtensions ('updateCMSTreeClasses ' , $ classes );
641
+ return $ classes ;
642
+ }
643
+
620
644
/**
621
645
* Find the first class in the inheritance chain that has Hierarchy extension applied
622
646
*
@@ -777,6 +801,17 @@ public function getBreadcrumbs($separator = ' » ')
777
801
return implode ($ separator ?? '' , $ crumbs );
778
802
}
779
803
804
+ /**
805
+ * Get the title that will be used in TreeDropdownField and other tree structures.
806
+ */
807
+ public function getTreeTitle (): string
808
+ {
809
+ $ owner = $ this ->getOwner ();
810
+ $ title = $ owner ->MenuTitle ?: $ owner ->Title ;
811
+ $ owner ->extend ('updateTreeTitle ' , $ title );
812
+ return $ title ?? '' ; // @TODO see if we need to escape this (it was escaped in Group and is in File too)
813
+ }
814
+
780
815
/**
781
816
* Get the name of the dedicated sort field, if there is one.
782
817
*/
0 commit comments