public function SiteTreeHints()
    {
        $classes = SiteTree::page_type_classes();
        $memberID = Security::getCurrentUser() ? Security::getCurrentUser()->ID : 0;
        $cache = $this->getHintsCache();
        $cacheKey = $this->generateHintsCacheKey($memberID);
        $json = $cache->get($cacheKey);

        if ($json) {
            return $json;
        }

        $canCreate = [];
        foreach ($classes as $class) {
            $canCreate[$class] = singleton($class)->canCreate();
        }

        $def['Root'] = [];
        $def['Root']['disallowedChildren'] = [];

        // Contains all possible classes to support UI controls listing them all,
        // such as the "add page here" context menu.
        $def['All'] = [];

        // Identify disallows and set globals
        foreach ($classes as $class) {
            $obj = singleton($class);
            if ($obj instanceof HiddenClass) {
                continue;
            }

            // Name item
            $def['All'][$class] = [
                'title' => $obj->i18n_singular_name()
            ];

            // Check if can be created at the root
            $needsPerm = $obj->config()->get('need_permission');
            if (!$obj->config()->get('can_be_root')
                || (!array_key_exists($class, $canCreate) || !$canCreate[$class])
                || ($needsPerm && !$this->can($needsPerm))
            ) {
                $def['Root']['disallowedChildren'][] = $class;
            }

            // Hint data specific to the class
            $def[$class] = [];

            $defaultChild = $obj->defaultChild();
            if ($defaultChild !== 'Page' && $defaultChild !== null) {
                $def[$class]['defaultChild'] = $defaultChild;
            }

            $defaultParent = $obj->defaultParent();
            if ($defaultParent !== 1 && $defaultParent !== null) {
                $def[$class]['defaultParent'] = $defaultParent;
            }
        }

        $this->extend('updateSiteTreeHints', $def);

        $json = json_encode($def);
        $cache->set($cacheKey, $json);

        return $json;
    }
public function SiteTreeHints()
    {
        $classes = SiteTree::page_type_classes();
        $memberID = Security::getCurrentUser() ? Security::getCurrentUser()->ID : 0;
        $cache = $this->getHintsCache();
        $cacheKey = $this->generateHintsCacheKey($memberID);
        $json = $cache->get($cacheKey);

        if ($json) {
            return $json;
        }

        $canCreate = [];
        foreach ($classes as $class) {
            $canCreate[$class] = singleton($class)->canCreate();
        }

        $def['Root'] = [];
        $def['Root']['disallowedChildren'] = [];

        // Contains all possible classes to support UI controls listing them all,
        // such as the "add page here" context menu.
        $def['All'] = [];

        // Identify disallows and set globals
        foreach ($classes as $class) {
            $obj = singleton($class);
            if ($obj instanceof HiddenClass) {
                continue;
            }

            // Name item
            $def['All'][$class] = [
                'title' => $obj->i18n_singular_name()
            ];

            // Check if can be created at the root
            $needsPerm = $obj->config()->get('need_permission');
            if (!$obj->config()->get('can_be_root')
                || (!array_key_exists($class, $canCreate) || !$canCreate[$class])
                || ($needsPerm && !$this->can($needsPerm))
            ) {
                $def['Root']['disallowedChildren'][] = $class;
            }

            // Hint data specific to the class
            $def[$class] = [];

            $defaultChild = $obj->defaultChild();
            if ($defaultChild !== 'Page' && $defaultChild !== null) {
                $def[$class]['defaultChild'] = $defaultChild;
            }

            $defaultParent = $obj->defaultParent();
            if ($defaultParent !== 1 && $defaultParent !== null) {
                $def[$class]['defaultParent'] = $defaultParent;
            }
        }

        $this->extend('updateSiteTreeHints', $def);

        $json = json_encode($def);
        $cache->set($cacheKey, $json);

        return $json;
    }
public function SiteTreeHints ( ) { $ classes = SiteTree :: page_type_classes ( ) ; $ memberID = Security :: getCurrentUser ( ) ? Security :: getCurrentUser ( ) -> ID : 0 ; $ cache = $ this -> getHintsCache ( ) ; $ cacheKey = $ this -> generateHintsCacheKey ( $ memberID ) ; $ json = $ cache -> get ( $ cacheKey ) ; if ( $ json ) { return $ json ; } $ canCreate = [ ] ; foreach ( $ classes as $ class ) { $ canCreate [ $ class ] = singleton ( $ class ) -> canCreate ( ) ; } $ def [ 'Root' ] = [ ] ; $ def [ 'Root' ] [ 'disallowedChildren' ] = [ ] ; // Contains all possible classes to support UI controls listing them all, // such as the "add page here" context menu. $ def [ 'All' ] = [ ] ; // Identify disallows and set globals foreach ( $ classes as $ class ) { $ obj = singleton ( $ class ) ; if ( $ obj instanceof HiddenClass ) { continue ; } // Name item $ def [ 'All' ] [ $ class ] = [ 'title' => $ obj -> i18n_singular_name ( ) ] ; // Check if can be created at the root $ needsPerm = $ obj -> config ( ) -> get ( 'need_permission' ) ; if ( ! $ obj -> config ( ) -> get ( 'can_be_root' ) || ( ! array_key_exists ( $ class , $ canCreate ) || ! $ canCreate [ $ class ] ) || ( $ needsPerm && ! $ this -> can ( $ needsPerm ) ) ) { $ def [ 'Root' ] [ 'disallowedChildren' ] [ ] = $ class ; } // Hint data specific to the class $ def [ $ class ] = [ ] ; $ defaultChild = $ obj -> defaultChild ( ) ; if ( $ defaultChild !== 'Page' && $ defaultChild !== null ) { $ def [ $ class ] [ 'defaultChild' ] = $ defaultChild ; } $ defaultParent = $ obj -> defaultParent ( ) ; if ( $ defaultParent !== 1 && $ defaultParent !== null ) { $ def [ $ class ] [ 'defaultParent' ] = $ defaultParent ; } } $ this -> extend ( 'updateSiteTreeHints' , $ def ) ; $ json = json_encode ( $ def ) ; $ cache -> set ( $ cacheKey , $ json ) ; return $ json ; }
Create serialized JSON string with site tree hints data to be injected into
'data-hints' attribute of root node of jsTree.

@return string Serialized JSON
Create serialized JSON string with site tree hints data to be injected into data - hints attribute of root node of jsTree .