Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Public Attributes | Protected Attributes | List of all members
admin_category Class Reference

The object used to represent folders (a.k.a. More...

Inheritance diagram for admin_category:
parentable_part_of_admin_tree part_of_admin_tree admin_root

Public Member Functions

 __construct ($name, $visiblename, $hidden=false)
 Constructor for an empty admin category. More...
 
 __get ($property)
 Magically gets a property from this object. More...
 
 __isset ($property)
 Checks if an inaccessible property is set. More...
 
 __set ($property, $value)
 Magically sets a property against this object. More...
 
 add ($parentname, $something, $beforesibling=null)
 Adds a part_of_admin_tree to a child or grandchild (or great-grandchild, and so forth) of this object. More...
 
 check_access ()
 Checks if the user has access to anything in this category. More...
 
 get_children ()
 Returns the children associated with this category. More...
 
 is_hidden ()
 Is this category hidden in admin tree block? More...
 
 locate ($name)
 Finds a named part_of_admin_tree. More...
 
 locate ($name, $findpath=false)
 Returns a reference to the part_of_admin_tree object with internal name $name. More...
 
 prune ($name)
 Removes part_of_admin_tree object with internal name $name. More...
 
 search ($query)
 Search using query. More...
 
 set_sorting ($sort, $asc=true, $split=true)
 Sets sorting on this category. More...
 
 show_save ()
 Show we display Save button at the page bottom? More...
 

Public Attributes

bool $hidden
 Should this category be hidden in admin tree block?
 
string $name
 An internal name for this category. More...
 
mixed $path
 Either a string or an array or strings.
 
string $visiblename
 The displayed name for this category. More...
 
mixed $visiblepath
 Either a string or an array or strings.
 

Protected Attributes

array $category_cache
 fast lookup category cache, all categories of one tree point to one cache
 
part_of_admin_tree[] $children
 An array of part_of_admin_tree objects that are this object's children.
 
bool $sort = false
 If set to true children will be sorted when calling admin_category::get_children().
 
bool $sortasc = true
 If set to true children will be sorted in ascending order.
 
bool $sorted = false
 $sorted True if the children have been sorted and don't need resorting
 
bool $sortsplit = true
 If set to true sub categories and pages will be split and then sorted. More...
 

Detailed Description

The object used to represent folders (a.k.a.

categories) in the admin tree block.

Each admin_category object contains a number of part_of_admin_tree objects.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

admin_category::__construct (   $name,
  $visiblename,
  $hidden = false 
)

Constructor for an empty admin category.

Parameters
string$nameThe internal name for this category. Must be unique amongst ALL part_of_admin_tree objects
string$visiblenameThe displayed named for this category. Usually obtained through get_string()
bool$hiddenhide category in admin tree block, defaults to false

Member Function Documentation

◆ __get()

admin_category::__get (   $property)

Magically gets a property from this object.

Parameters
$property
Return values
part_of_admin_tree[]
Exceptions
coding_exception

◆ __isset()

admin_category::__isset (   $property)

Checks if an inaccessible property is set.

Parameters
string$property
Return values
bool
Exceptions
coding_exception

◆ __set()

admin_category::__set (   $property,
  $value 
)

Magically sets a property against this object.

Parameters
string$property
mixed$value
Exceptions
coding_exception

◆ add()

admin_category::add (   $parentname,
  $something,
  $beforesibling = null 
)

Adds a part_of_admin_tree to a child or grandchild (or great-grandchild, and so forth) of this object.

By default the new part of the tree is appended as the last child of the parent. You can specify a sibling node that the new part should be prepended to. If the given sibling is not found, the part is appended to the end (as it would be by default) and a developer debugging message is displayed.

Exceptions
coding_exceptionif the $beforesibling is empty string or is not string at all.
Parameters
string$destinationameThe internal name of the immediate parent that we want for $something.
mixed$somethingA part_of_admin_tree or setting instance to be added.
string$beforesiblingThe name of the parent's child the $something should be prepended to.
Return values
boolTrue if successfully added, false if $something can not be added.

Implements parentable_part_of_admin_tree.

◆ check_access()

admin_category::check_access ( )

Checks if the user has access to anything in this category.

Return values
boolTrue if the user has access to at least one child in this category, false otherwise.

Implements part_of_admin_tree.

◆ get_children()

admin_category::get_children ( )

Returns the children associated with this category.

Return values
part_of_admin_tree[]

◆ is_hidden()

admin_category::is_hidden ( )

Is this category hidden in admin tree block?

Return values
boolTrue if hidden

Implements part_of_admin_tree.

◆ locate() [1/2]

part_of_admin_tree::locate (   $name)
inherited

Finds a named part_of_admin_tree.

Used to find a part_of_admin_tree. If a class only inherits part_of_admin_tree and not parentable_part_of_admin_tree, then this function should only check if $this->name matches $name. If it does, it should return a reference to $this, otherwise, it should return a reference to NULL.

If a class inherits parentable_part_of_admin_tree, this method should be called recursively on all child objects (assuming, of course, the parent object's name doesn't match the search criterion).

Parameters
string$nameThe internal name of the part_of_admin_tree we're searching for.
Return values
mixedAn object reference or a NULL reference.

◆ locate() [2/2]

admin_category::locate (   $name,
  $findpath = false 
)

Returns a reference to the part_of_admin_tree object with internal name $name.

Parameters
string$nameThe internal name of the object we want.
bool$findpathinitialize path and visiblepath arrays
Return values
mixedA reference to the object with internal name $name if found, otherwise a reference to NULL. defaults to false

◆ prune()

admin_category::prune (   $name)

Removes part_of_admin_tree object with internal name $name.

Parameters
string$nameThe internal name of the object we want to remove.
Return values
boolsuccess

Implements part_of_admin_tree.

◆ search()

admin_category::search (   $query)

Search using query.

Parameters
stringquery
Return values
mixedarray-object structure of found settings and pages

Implements part_of_admin_tree.

◆ set_sorting()

admin_category::set_sorting (   $sort,
  $asc = true,
  $split = true 
)

Sets sorting on this category.

Please note this function doesn't actually do the sorting. It can be called anytime. Sorting occurs when the user calls get_children. Code using the children array directly won't see the sorted results.

Parameters
bool$sortIf set to true children will be sorted, if false they won't be.
bool$ascIf true sorting will be ascending, otherwise descending.
bool$splitIf true we sort pages and sub categories separately.

◆ show_save()

admin_category::show_save ( )

Show we display Save button at the page bottom?

Return values
bool

Implements part_of_admin_tree.

Member Data Documentation

◆ $name

string admin_category::$name

An internal name for this category.

Must be unique amongst ALL part_of_admin_tree objects

◆ $sortsplit

bool admin_category::$sortsplit = true
protected

If set to true sub categories and pages will be split and then sorted.

◆ $visiblename

string admin_category::$visiblename

The displayed name for this category.

Usually obtained through get_string()


The documentation for this class was generated from the following file: