Moodle  2.2.1
http://www.collinsharper.com
block_base Class Reference
Inheritance diagram for block_base:

Public Member Functions

 __construct ()
 Class Functions.
 before_delete ()
 name ()
 get_content ()
 get_title ()
 get_content_type ()
 is_empty ()
 refresh_content ()
 get_content_for_output ($output)
 _self_test ()
 has_config ()
 config_save ($data)
 applicable_formats ()
 hide_header ()
 html_attributes ()
 _load_instance ($instance, $page)
 get_required_javascript ()
 specialization ()
 instance_allow_config ()
 instance_allow_multiple ()
 instance_config_print ()
 instance_config_save ($data, $nolongerused=false)
 instance_config_commit ($nolongerused=false)
 instance_create ()
 instance_delete ()
 user_can_edit ()
 user_can_addto ($page)
 get_extra_capabilities ()
 preferred_width ()
 _print_block ()
 _print_shadow ()
 _title_html ()
 _add_edit_controls ()
 config_print ()
 instance_can_be_docked ()
 instance_can_be_hidden ()

Static Public Member Functions

static comment_template ($options)
static comment_permissions ($options)
static comment_url ($options)
static comment_display ($comments, $options)
static comment_add (&$comments, $options)

Data Fields

 $str
 $title = NULL
 $content_type = BLOCK_TYPE_TEXT
 $content = NULL
 $edit_controls = NULL
 $instance = NULL
 $page = NULL
 $context = NULL
 $config = NULL
 $cron = NULL

Protected Member Functions

 formatted_contents ($output)

Detailed Description

Definition at line 48 of file moodleblock.class.php.


Constructor & Destructor Documentation

Class Functions.

Fake constructor to keep PHP5 happy

Definition at line 117 of file moodleblock.class.php.


Member Function Documentation

Deprecated:
since Moodle 2.0.

Definition at line 611 of file moodleblock.class.php.

_load_instance ( instance,
page 
)

Set up a particular instance of this class given data from the block_insances table and the current page. (See block_manager::load_blocks().)

Parameters:
stdClass$instancedata from block_insances, block_positions, etc.
moodle_page$thepage this block is on.

Definition at line 415 of file moodleblock.class.php.

Here is the call graph for this function:

Deprecated:
since Moodle 2.0.

Definition at line 590 of file moodleblock.class.php.

Deprecated:
since Moodle 2.0.

Definition at line 597 of file moodleblock.class.php.

Tests if this block has been implemented correctly. Also, $errors isn't used right now

Returns:
boolean

Definition at line 296 of file moodleblock.class.php.

Here is the call graph for this function:

Deprecated:
since Moodle 2.0.

Definition at line 604 of file moodleblock.class.php.

Which page types this block may appear on.

The information returned here is processed by the blocks_name_allowed_in_format() function. Look there if you need to know exactly how this works.

Default case: everything except mod and tag.

Returns:
array page-type prefix => true/false.

Reimplemented in block_myprofile, block_course_overview, block_settings, block_navigation, block_activity_modules, block_admin_bookmarks, block_quiz_results, block_section_links, block_blog_menu, block_blog_tags, block_participants, block_comments, block_search_forums, block_blog_recent, block_private_files, block_rss_client, block_recent_activity, block_html, block_tags, block_feedback, block_mnet_hosts, block_tag_flickr, block_tag_youtube, block_mentees, block_login, block_site_main_menu, and block_social_activities.

Definition at line 364 of file moodleblock.class.php.

Here is the caller graph for this function:

Function that can be overridden to do extra cleanup before the database tables are deleted. (Called once per block, not per instance!)

Reimplemented in block_myprofile, and block_section_links.

Definition at line 125 of file moodleblock.class.php.

static comment_add ( &$  comments,
options 
) [static]

Definition at line 662 of file moodleblock.class.php.

static comment_display ( comments,
options 
) [static]

Definition at line 659 of file moodleblock.class.php.

static comment_permissions ( options) [static]

Definition at line 653 of file moodleblock.class.php.

static comment_template ( options) [static]

callback functions for comments api

Definition at line 643 of file moodleblock.class.php.

static comment_url ( options) [static]

Definition at line 656 of file moodleblock.class.php.

Deprecated:
since Moodle 2.0.

Definition at line 618 of file moodleblock.class.php.

config_save ( data)

Default behavior: save all variables as $CFG properties You don't need to override this if you 're satisfied with the above

Parameters:
array$data
Returns:
boolean

Definition at line 346 of file moodleblock.class.php.

Here is the call graph for this function:

formatted_contents ( output) [protected]

Convert the contents of the block to HTML.

This is used by block base classes like block_list to convert the structured $this->content->list and $this->content->icons arrays to HTML. So, in most blocks, you probaby want to override the get_contents() method, which generates that structured representation of the contents.

Parameters:
$outputThe core_renderer to use when generating the output.
Returns:
string the HTML that should appearn in the body of the block.
Since:
Moodle 2.0.

Reimplemented in block_tree, and block_list.

Definition at line 279 of file moodleblock.class.php.

Here is the call graph for this function:

Here is the caller graph for this function:

get_content_for_output ( output)

Return a block_contents object representing the full contents of this block.

This internally calls ->get_content(), and then adds the editing controls etc.

You probably should not override this method, but instead override html_attributes(), formatted_contents() or get_content(), hide_header(), (get_edit_controls), etc.

Returns:
block_contents a representation of the block, for rendering.
Since:
Moodle 2.0.

Definition at line 223 of file moodleblock.class.php.

Here is the call graph for this function:

Returns the class $content_type var value.

Intentionally doesn't check if content_type is set. This is already done in _self_test()

Returns:
string $this->content_type

Definition at line 178 of file moodleblock.class.php.

Here is the caller graph for this function:

Definition at line 574 of file moodleblock.class.php.

Reimplemented in block_navigation, and block_settings.

Definition at line 425 of file moodleblock.class.php.

Here is the call graph for this function:

Here is the caller graph for this function:

get_title ( )

Returns the class $title var value.

Intentionally doesn't check if a title is set. This is already done in _self_test()

Returns:
string $this->title

Definition at line 165 of file moodleblock.class.php.

Here is the caller graph for this function:

Subclasses should override this and return true if the subclass block has a config_global.html file.

Returns:
boolean

Reimplemented in block_myprofile, block_section_links, block_course_overview, block_rss_client, block_blog_menu, block_blog_tags, block_tags, block_online_users, block_course_list, and block_mnet_hosts.

Definition at line 335 of file moodleblock.class.php.

Default return is false - header will be shown

Returns:
boolean

Reimplemented in block_glossary_random, and block_course_summary.

Definition at line 374 of file moodleblock.class.php.

Here is the caller graph for this function:

Return any HTML attributes that you want added to the outer

that of the block when it is output.
Because of the way certain JS events are wired it is a good idea to ensure that the default values here still get set. I found the easiest way to do this and still set anything you want is to override it within your block in the following way
function html_attributes() { $attributes = parent::html_attributes(); $attributes['class'] .= ' mynewclass'; return $attributes; }
Returns:
array attribute name => value.

Reimplemented in block_list, and block_navigation.

Definition at line 397 of file moodleblock.class.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Is each block of this type going to have instance-specific configuration? Normally, this setting is controlled by instance_allow_multiple(): if multiple instances are allowed, then each will surely need its own configuration. However, in some cases it may be necessary to provide instance configuration to blocks that do not want to allow multiple instances. In that case, make this function return true. I stress again that this makes a difference ONLY if instance_allow_multiple() returns false.

Returns:
boolean

Reimplemented in block_myprofile, block_section_links, block_rss_client, block_settings, block_navigation, block_blog_menu, block_blog_tags, block_blog_recent, and block_tags.

Definition at line 450 of file moodleblock.class.php.

Here is the caller graph for this function:

Are you going to allow multiple instances of each block? If yes, then it is assumed that the block WILL USE per-instance configuration

Returns:
boolean

Reimplemented in block_quiz_results, block_myprofile, block_rss_client, block_glossary_random, block_navigation, block_settings, block_admin_bookmarks, block_comments, block_html, block_private_files, block_blog_menu, block_blog_tags, block_tag_youtube, block_tag_flickr, block_mentees, and block_tags.

Definition at line 459 of file moodleblock.class.php.

Here is the caller graph for this function:

Can be overridden by the block to prevent the block from being dockable.

Returns:
bool

Reimplemented in block_html, block_navigation, and block_settings.

Definition at line 627 of file moodleblock.class.php.

Here is the caller graph for this function:

If overridden and set to true by the block it will not be hidable when editing is turned on.

Returns:
bool

Reimplemented in block_navigation, and block_settings.

Definition at line 638 of file moodleblock.class.php.

instance_config_commit ( nolongerused = false)

Replace the instance's configuration data with those currently in $this->config;

Definition at line 503 of file moodleblock.class.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Default behavior: print the config_instance.html file You don't need to override this if you're satisfied with the above

Deprecated:
since Moodle 2.0.
Returns:
boolean whether anything was done. Blocks should use edit_form.php.

Reimplemented in block_myprofile.

Definition at line 472 of file moodleblock.class.php.

Here is the call graph for this function:

instance_config_save ( data,
nolongerused = false 
)

Serialize and store config data

Reimplemented in block_html.

Definition at line 494 of file moodleblock.class.php.

Here is the caller graph for this function:

Do any additional initialization you may need at the time a new block instance is created

Returns:
boolean

Definition at line 512 of file moodleblock.class.php.

Delete everything related to this instance if you have been using persistent storage other than the configdata field.

Returns:
boolean

Reimplemented in block_html.

Definition at line 520 of file moodleblock.class.php.

is_empty ( )

Returns true or false, depending on whether this block has any content to display and whether the user has permission to view the block

Returns:
boolean

Reimplemented in block_list.

Definition at line 189 of file moodleblock.class.php.

Here is the call graph for this function:

Here is the caller graph for this function:

name ( )

Returns the block name, as present in the class name, the database, the block directory, etc etc.

Returns:
string

Definition at line 134 of file moodleblock.class.php.

Here is the caller graph for this function:

Default case: the block wants to be 180 pixels wide

Deprecated:
since Moodle 2.0.
Returns:
int

Reimplemented in block_course_summary, block_rss_client, block_tag_youtube, block_tag_flickr, and block_calendar_month.

Definition at line 585 of file moodleblock.class.php.

Here is the caller graph for this function:

First sets the current value of $this->content to NULL then calls the block's get_content() function to set its value back.

Returns:
stdObject

Definition at line 205 of file moodleblock.class.php.

Here is the call graph for this function:

This function is called on your subclass right after an instance is loaded Use this function to act on instance data just after it's loaded and before anything else is done For instance: if your block will have different title's depending on location (site, course, blog, etc)

Reimplemented in block_myprofile, block_blog_tags, block_rss_client, block_comments, block_html, block_private_files, block_tags, block_tag_flickr, block_tag_youtube, block_mentees, block_glossary_random, and block_course_summary.

Definition at line 437 of file moodleblock.class.php.

Here is the caller graph for this function:

user_can_addto ( page)

Allows the block class to have a say in the user's ability to create new instances of this block. The framework has first say in whether this will be allowed (e.g., no adding allowed unless in edit mode) but if the framework does allow it, the block can still decide to refuse. This function has access to the complete page object, the creation related to which is being determined.

Parameters:
moodle_page$page
Returns:
boolean

Reimplemented in block_community.

Definition at line 557 of file moodleblock.class.php.

Here is the call graph for this function:

Allows the block class to have a say in the user's ability to edit (i.e., configure) blocks of this type. The framework has first say in whether this will be allowed (e.g., no editing allowed unless in edit mode) but if the framework does allow it, the block can still decide to refuse.

Returns:
boolean

Reimplemented in block_community.

Definition at line 530 of file moodleblock.class.php.

Here is the call graph for this function:


Field Documentation

stdObject $config = NULL

An object containing the instance configuration information for the current instance of this block.

Definition at line 102 of file moodleblock.class.php.

stdObject $content = NULL

An object to contain the information to be displayed in the block.

Definition at line 72 of file moodleblock.class.php.

int $content_type = BLOCK_TYPE_TEXT

The type of content that this block creates. Currently support options - BLOCK_TYPE_LIST, BLOCK_TYPE_TEXT

Reimplemented in block_tree, and block_list.

Definition at line 66 of file moodleblock.class.php.

$context = NULL

Definition at line 96 of file moodleblock.class.php.

int $cron = NULL

How often the cronjob should run, 0 if not at all.

Definition at line 109 of file moodleblock.class.php.

string $edit_controls = NULL

A string generated by _add_edit_controls() to display block manipulation links when the user is in editing mode.

Definition at line 78 of file moodleblock.class.php.

block $instance = NULL

The initialized instance of this block object.

Definition at line 84 of file moodleblock.class.php.

$page = NULL

Definition at line 90 of file moodleblock.class.php.

string $str

Internal var for storing/caching translated strings

Definition at line 54 of file moodleblock.class.php.

string $title = NULL

The title of the block to be displayed in the block title area.

Definition at line 60 of file moodleblock.class.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations