Moodle APIs
3.8
Moodle 3.8.6 (Build: 20201109)
|
Public Member Functions | |
add_block ($blockname, $region, $weight, $showinsubcontexts, $pagetypepattern=NULL, $subpagepattern=NULL) | |
Add a block to the current page, or related pages. More... | |
add_block_at_end_of_default_region ($blockname) | |
add_blocks ($blocks, $pagetypepattern=NULL, $subpagepattern=NULL, $showinsubcontexts=false, $weight=0) | |
Convenience method, calls add_block repeatedly for all the blocks in $blocks. More... | |
add_custom_regions_for_pagetype ($pagetype) | |
Finds custom block regions associated with a page type and registers them with this block manager. More... | |
add_fake_block ($bc, $region) | |
Add something that looks like a block, but which isn't an actual block_instance, to this page. More... | |
add_region ($region, $custom=true) | |
Setter methods =============================================================. More... | |
add_regions ($regions, $custom=true) | |
Add an array of regions. More... | |
create_all_block_instances () | |
Create all the block instances for all the blocks that were loaded by load_blocks. More... | |
edit_controls ($block) | |
Process actions from the URL ===============================================. More... | |
ensure_content_created ($region, $output) | |
Ensure that there is some content within the given region. More... | |
find_instance ($instanceid) | |
Find a given block by its instance id. More... | |
get_addable_blocks () | |
The list of block types that may be added to this page. More... | |
get_blocks_for_region ($region) | |
Get an array of all blocks within a given region. More... | |
get_content_for_all_regions ($output) | |
Returns an array of block content objects for all the existings regions. More... | |
get_content_for_region ($region, $output) | |
Returns an array of block content objects that exist in a region. More... | |
get_default_region () | |
Get the region name of the region blocks are added to by default. More... | |
get_installed_blocks () | |
Get an array of all of the installed blocks. More... | |
get_regions () | |
Getter methods =============================================================. More... | |
get_required_by_theme_block_types () | |
is_block_present ($blockname) | |
Given a block name, find out of any of them are currently present in the page. More... | |
is_known_block_type ($blockname, $includeinvisible=false) | |
Find out if a block type is known by the system. More... | |
is_known_region ($region) | |
Find out if a region exists on a page. More... | |
load_blocks ($includeinvisible=null) | |
Load blocks using the system context, rather than the user's context. More... | |
process_url_actions () | |
Process any block actions that were specified in the URL. More... | |
process_url_add () | |
Handle adding a block. More... | |
process_url_delete () | |
Handle deleting a block. More... | |
process_url_edit () | |
Handle showing/processing the submission from the block editing form. More... | |
process_url_move () | |
Handle showing/processing the submission from the block editing form. More... | |
process_url_show_hide () | |
Handle showing or hiding a block. More... | |
region_completely_docked ($region, $output) | |
Checks to see whether all of the blocks within the given region are docked. More... | |
region_has_content ($region, $output) | |
Determine whether a region contains anything. More... | |
region_uses_dock ($regions, $output) | |
Checks to see whether any of the blocks within the given regions are docked. More... | |
reposition_block ($blockinstanceid, $newregion, $newweight) | |
Move a block to a new position on this page. More... | |
set_default_region ($defaultregion) | |
Set the default region for new blocks on the page. More... | |
show_only_fake_blocks ($setting=true) | |
Turns the display of normal blocks either on or off. More... | |
Static Public Member Functions | |
static | get_undeletable_block_types () |
Get the list of "protected" blocks via admin block manager ui. More... | |
static | protect_block ($blockidorname) |
Make this block type undeletable and unaddable. More... | |
static | unprotect_block ($blockidorname) |
Make this block type deletable and addable. More... | |
Public Attributes | |
const | MAX_WEIGHT = 10 |
The UI normally only shows block weights between -MAX_WEIGHT and MAX_WEIGHT, although other weights are valid. | |
Protected Member Functions | |
add_block_required_by_theme ($blockname) | |
Add a block that is required by the current theme but has not been created yet. More... | |
check_is_loaded () | |
Check whether the page blocks have been loaded yet. More... | |
check_known_block_type ($blockname, $includeinvisible=false) | |
Check if a block type is known and usable. More... | |
check_not_yet_loaded () | |
Inner workings =============================================================. More... | |
check_region_is_known ($region) | |
Check if a region is known by its name. More... | |
create_block_contents ($instances, $output, $region) | |
Return an array of content objects from a set of block instances. More... | |
create_block_instances ($birecords) | |
Create a set of new block instance from a record array. More... | |
ensure_instances_exist ($region) | |
Ensure block instances exist for a given region. More... | |
get_move_target_url ($region, $weight) | |
Helper method used by get_content_for_region. More... | |
prepare_per_region_arrays () | |
Returns an array of region names as keys and nested arrays for values. More... | |
user_can_delete_block ($block) | |
Protected Attributes | |
array | $addableblocks = null |
blocks that this user can add to this page. More... | |
array | $allblocks = null |
will be $DB->get_records('blocks') | |
array | $birecordsbyregion = null |
Will be an array region-name => array(db rows loaded in load_blocks);. | |
array | $blockinstances = array() |
array region-name => array(block objects); populated as necessary by the ensure_instances_exist method. | |
string | $defaultregion = null |
the region where new blocks are added. | |
array | $extracontent = array() |
array region-name => array(block_contents objects) extra block-like things to be displayed in each region, before the real blocks. | |
$fakeblocksonly = false | |
Show only fake blocks. | |
integer null | $movingblock = null |
Used by the block move id, to track whether a block is currently being moved. More... | |
moodle_page | $page |
Field declarations =========================================================. More... | |
array | $regions = array() |
region name => 1. | |
array | $visibleblockcontent = array() |
array region-name => array(block_contents objects) what actually needs to be displayed in each region. | |
|
inherited |
Add a block to the current page, or related pages.
The block is added to context $this->page->contextid. If $pagetypepattern $subpagepattern
string | $blockname | The type of block to add. |
string | $region | the block region on this page to add the block to. |
integer | $weight | determines the order where this block appears in the region. |
boolean | $showinsubcontexts | whether this block appears in subcontexts, or just the current context. |
string | null | $pagetypepattern | which page types this block should appear on. Defaults to just the current page type. |
string | null | $subpagepattern | which subpage this block should appear on. NULL = any (the default), otherwise only the specified subpage. |
|
protectedinherited |
Add a block that is required by the current theme but has not been created yet.
This is a special type of block that only shows in themes that require it (by listing it in undeletable_block_types).
string | $blockname | the name of the block type. |
|
inherited |
Convenience method, calls add_block repeatedly for all the blocks in $blocks.
Optionally, a starting weight can be used to decide the starting point that blocks are added in the region, the weight is passed to add_block and incremented by the position of the block in the $blocks array
array | $blocks | array with array keys the region names, and values an array of block names. |
string | $pagetypepattern | optional. Passed to } * string $subpagepattern optional. Passed to add_block() |
boolean | $showinsubcontexts | optional. Passed to add_block() |
integer | $weight | optional. Determines the starting point that the blocks are added in the region. |
|
inherited |
Finds custom block regions associated with a page type and registers them with this block manager.
string | $pagetype |
|
inherited |
Add something that looks like a block, but which isn't an actual block_instance, to this page.
block_contents | $bc | the content of the block-like thing. |
string | $region | a block region that exists on this page. |
|
inherited |
Setter methods =============================================================.
Add a region to a page
string | $region | add a named region where blocks may appear on the current page. This is an internal name, like 'side-pre', not a string to display in the UI. |
bool | $custom | True if this is a custom block region, being added by the page rather than the theme layout. |
|
inherited |
Add an array of regions.
array | $regions | this utility method calls add_region for each array element. |
|
protectedinherited |
Check whether the page blocks have been loaded yet.
Nearly identical to the above function check_not_yet_loaded() except different message
void | Throws coding exception if already loaded |
|
protectedinherited |
Check if a block type is known and usable.
string | $blockname | The block type name to search for |
bool | $includeinvisible | Include disabled block types in the initial pass |
void | Coding Exception thrown if unknown or not enabled |
|
protectedinherited |
Inner workings =============================================================.
Check whether the page blocks have been loaded yet
void | Throws coding exception if already loaded |
|
protectedinherited |
Check if a region is known by its name.
string | $region |
void | Coding Exception thrown if the region is not known |
|
inherited |
Create all the block instances for all the blocks that were loaded by load_blocks.
This is used, for example, to ensure that all blocks get a chance to initialise themselves via the block_base::specialize() method, before any output is done.
It is also used to create any blocks that are "requiredbytheme" by the current theme. These blocks that are auto-created have requiredbytheme set on the block instance so they are only visible on themes that require them.
|
protectedinherited |
Return an array of content objects from a set of block instances.
array | $instances | An array of block instances |
renderer_base | The renderer to use. | |
string | $region | the region name. |
array | An array of block_content (and possibly block_move_target) objects. |
|
protectedinherited |
Create a set of new block instance from a record array.
array | $birecords | An array of block instance records |
array | An array of instantiated block_instance objects |
|
inherited |
Process actions from the URL ===============================================.
Get the appropriate list of editing icons for a block. This is used to set } in block_base::get_contents_for_output().
$output | The core_renderer to use when generating the output. (Need to get icon paths.) |
an | array in the format for block_contents::$controls |
|
inherited |
Ensure that there is some content within the given region.
string | $region | The name of the region to check |
|
protectedinherited |
Ensure block instances exist for a given region.
string | $region | Check for bi's with the instance with this name |
|
inherited |
|
inherited |
The list of block types that may be added to this page.
array | block name => record from block table. |
|
inherited |
Get an array of all blocks within a given region.
string | $region | a block region that exists on this page. |
array | of block instances. |
|
inherited |
Returns an array of block content objects for all the existings regions.
renderer_base | $output | the rendered to use |
array | of block block_contents objects for all the blocks in all regions. |
|
inherited |
Returns an array of block content objects that exist in a region.
string | $region | a block region that exists on this page. |
array | of block block_contents objects for all the blocks in a region. |
|
inherited |
Get the region name of the region blocks are added to by default.
string | the internal names of the region where new blocks are added by default, and where any blocks from an unrecognised region are shown. (Imagine that blocks were added with one theme selected, then you switched to a theme with different block positions.) |
|
inherited |
Get an array of all of the installed blocks.
array | contents of the block table. |
|
protectedinherited |
Helper method used by get_content_for_region.
string | $region | region name |
float | $weight | weight. May be fractional, since you may want to move a block between ones with weight 2 and 3, say ($weight would be 2.5). |
string | URL for moving block $this->movingblock to this position. |
|
inherited |
Getter methods =============================================================.
Get an array of all region names on this page where a block may appear
array | the internal names of the regions on this page where block may appear. |
|
inherited |
array | names of block types that must exist on every page with this theme. |
|
staticinherited |
Get the list of "protected" blocks via admin block manager ui.
array | names of block types that cannot be added or deleted. E.g. array('navigation','settings'). |
|
inherited |
Given a block name, find out of any of them are currently present in the page.
string | $blockname | - the basic name of a block (eg "navigation") |
boolean | - is there one of these blocks in the current page? |
|
inherited |
Find out if a block type is known by the system.
string | $blockname | the name of the type of block. |
boolean | $includeinvisible | if false (default) only check 'visible' blocks, that is, blocks enabled by the admin. |
boolean | true if this block in installed. |
|
inherited |
Find out if a region exists on a page.
string | $region | a region name |
boolean | true if this region exists on this page. |
my_syspage_block_manager::load_blocks | ( | $includeinvisible = null | ) |
Load blocks using the system context, rather than the user's context.
This is needed because the My Moodle pages set the page context to the user's context for access control, etc. But the blocks for the system pages are stored in the system context.
Reimplemented from block_manager.
|
protectedinherited |
Returns an array of region names as keys and nested arrays for values.
array | an array where the array keys are the region names, and the array values are empty arrays. |
|
inherited |
Process any block actions that were specified in the URL.
boolean | true if anything was done. False if not. |
|
inherited |
Handle adding a block.
boolean | true if anything was done. False if not. |
|
inherited |
Handle deleting a block.
boolean | true if anything was done. False if not. |
|
inherited |
Handle showing/processing the submission from the block editing form.
boolean | true if the form was submitted and the new config saved. Does not return if the editing form was displayed. False otherwise. |
|
inherited |
Handle showing/processing the submission from the block editing form.
boolean | true if the form was submitted and the new config saved. Does not return if the editing form was displayed. False otherwise. |
|
inherited |
Handle showing or hiding a block.
boolean | true if anything was done. False if not. |
|
staticinherited |
Make this block type undeletable and unaddable.
mixed | $blockidorname | string or int |
|
inherited |
Checks to see whether all of the blocks within the given region are docked.
string | $region |
bool | True if all of the blocks within that region are docked |
Return false as from MDL-64506
|
inherited |
Determine whether a region contains anything.
(Either any real blocks, or the add new block UI.)
(You may wonder why the $output parameter is required. Unfortunately, because of the way that blocks work, the only reliable way to find out if a block will be visible is to get the content for output, and to get the content, you need a renderer. Fortunately, this is not a performance problem, because we cache the output that is generated, and in almost every case where we call region_has_content, we are about to output the blocks anyway, so we are not doing wasted effort.)
string | $region | a block region that exists on this page. |
core_renderer | $output | a core_renderer. normally the global $OUTPUT. |
boolean | Whether there is anything in this region. |
|
inherited |
Checks to see whether any of the blocks within the given regions are docked.
array | string | $regions | array of regions (or single region) |
bool | True if any of the blocks within that region are docked |
Return false as from MDL-64506
|
inherited |
Move a block to a new position on this page.
If this block cannot appear on any other pages, then we change defaultposition/weight in the block_instances table. Otherwise we just set the position on this page.
$blockinstanceid | the block instance id. |
$newregion | the new region name. |
$newweight | the new weight. |
|
inherited |
Set the default region for new blocks on the page.
string | $defaultregion | the internal names of the region where new blocks should be added by default, and where any blocks from an unrecognised region are shown. |
|
inherited |
Turns the display of normal blocks either on or off.
bool | $setting |
|
staticinherited |
Make this block type deletable and addable.
mixed | $blockidorname | string or int |
|
protectedinherited |
block_base | $block | a block that appears on this page. |
boolean | boolean whether the currently logged in user is allowed to delete this block. |
|
protectedinherited |
blocks that this user can add to this page.
Will be a subset of $allblocks, but with array keys block->name. Access this via the get_addable_blocks() method to ensure it is lazy-loaded.
|
protectedinherited |
Used by the block move id, to track whether a block is currently being moved.
When you click on the move icon of a block, first the page needs to reload with extra UI for choosing a new position for a particular block. In that situation this field holds the id of the block being moved.
|
protectedinherited |
Field declarations =========================================================.
the moodle_page we are managing blocks for.