[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/blocks/ -> moodleblock.class.php (summary)

This file contains the parent class for moodle blocks, block_base.

Author: Jon Papaioannou
License: http://www.gnu.org/copyleft/gpl.html GNU Public License
Version: $Id: moodleblock.class.php,v 1.92.2.9 2008/08/06 05:08:36 skodak Exp $
File Size: 848 lines (30 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

block_base:: (43 methods):
  block_base()
  __construct()
  after_install()
  before_delete()
  after_restore()
  backuprestore_instancedata_used()
  instance_backup()
  instance_restore()
  get_backup_encoded_config()
  encode_content_links()
  decode_content_links_caller()
  decode_content_links()
  name()
  get_content()
  get_title()
  get_content_type()
  get_version()
  is_empty()
  refresh_content()
  _print_block()
  _print_shadow()
  _title_html()
  _add_edit_controls()
  _self_test()
  has_config()
  config_print()
  config_save()
  applicable_formats()
  preferred_width()
  hide_header()
  html_attributes()
  _load_instance()
  specialization()
  instance_allow_config()
  instance_allow_multiple()
  instance_config_print()
  instance_config_save()
  instance_config_commit()
  instance_create()
  instance_delete()
  user_can_edit()
  user_can_addto()
  get_extra_capabilities()

block_list:: (2 methods):
  is_empty()
  _print_block()


Class: block_base  - X-Ref

Class for describing a moodle block, all Moodle blocks derive from this class

block_base()   X-Ref
The class constructor


__construct()   X-Ref
Fake constructor to keep PHP5 happy


after_install()   X-Ref
Function that can be overridden to do extra setup after
the database install. (Called once per block, not per instance!)


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


after_restore($restore)   X-Ref
Function that can be overridden to do extra setup after a block instance has been
restored from backup. For example, it may need to alter any dates that the block
stores, if the $restore->course_startdateoffset is set.


backuprestore_instancedata_used()   X-Ref
Enable custom instance data section in backup and restore.

If return true, then {@link instance_backup()} and
{@link instance_restore()} will be called during
backup/restore routines.

return: boolean

instance_backup($bf, $preferences)   X-Ref
Allows the block class to have a backup routine.  Handy
when the block has its own tables that have foreign keys to
other tables (example: user table).

Note: at the time of writing this comment, the indent level
for the {@link full_tag()} should start at 5.

param: resource $bf Backup File
param: object $preferences Backup preferences
return: boolean

instance_restore($restore, $data)   X-Ref
Allows the block class to restore its backup routine.

Should not return false if data is empty
because old backups would not contain block instance backup data.

param: object $restore Standard restore object
param: object $data Object from backup_getid for this block instance
return: boolean

get_backup_encoded_config()   X-Ref
Will be called before an instance of this block is backed up, so that any links in
in config can be encoded. For example config->text, for the HTML block

return: string

encode_content_links($content, $restore)   X-Ref
Return the content encoded to support interactivities linking. This function is
called automatically from the backup procedure by {@link backup_encode_absolute_links()}.

NOTE: There is no block instance when this method is called.

param: string $content Content to be encoded
param: object $restore Restore preferences object
return: string The encoded content

decode_content_links_caller($restore)   X-Ref
This function makes all the necessary calls to {@link restore_decode_content_links_worker()}
function in order to decode contents of this block from the backup
format to destination site/course in order to mantain inter-activities
working in the backup/restore process.

This is called from {@link restore_decode_content_links()} function in the restore process.

NOTE: There is no block instance when this method is called.

param: object $restore Standard restore object
return: boolean

decode_content_links($content, $restore)   X-Ref
Return content decoded to support interactivities linking.
This is called automatically from
{@link restore_decode_content_links_worker()} function
in the restore process.

NOTE: There is no block instance when this method is called.

param: string $content Content to be dencoded
param: object $restore Restore preferences object
return: string The dencoded content

name()   X-Ref
Returns the block name, as present in the class name,
the database, the block directory, etc etc.

return: string

get_content()   X-Ref
Parent class version of this function simply returns NULL
This should be implemented by the derived class to return
the content object.

return: stdObject

get_title()   X-Ref
Returns the class $title var value.

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

return: string $this->title

get_content_type()   X-Ref
Returns the class $content_type var value.

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

return: string $this->content_type

get_version()   X-Ref
Returns the class $version var value.

Intentionally doesn't check if a version is set.
This is already done in {@link _self_test()}

return: string $this->version

is_empty()   X-Ref
Returns true or false, depending on whether this block has any content to display
and whether the user has permission to view the block

return: boolean

refresh_content()   X-Ref
First sets the current value of $this->content to NULL
then calls the block's {@link get_content()} function
to set its value back.

return: stdObject

_print_block()   X-Ref
Display the block!


_print_shadow()   X-Ref
Block contents are missing. Simply display an empty block so that
edit controls are accessbile to the user and they are aware that this
block is in place, even if empty.


_title_html()   X-Ref
No description

_add_edit_controls($options)   X-Ref
Sets class $edit_controls var with correct block manipulation links.

param: stdObject $options ?

_self_test()   X-Ref
Tests if this block has been implemented correctly.
Also, $errors isn't used right now

return: boolean

has_config()   X-Ref
Subclasses should override this and return true if the
subclass block has a config_global.html file.

return: boolean

config_print()   X-Ref
Default behavior: print the config_global.html file
You don't need to override this if you're satisfied with the above

return: boolean

config_save($data)   X-Ref
Default behavior: save all variables as $CFG properties
You don't need to override this if you 're satisfied with the above

param: array $data
return: boolean

applicable_formats()   X-Ref
Default case: the block can be used in all course types

return: array

preferred_width()   X-Ref
Default case: the block wants to be 180 pixels wide

return: int

hide_header()   X-Ref
Default return is false - header will be shown

return: boolean

html_attributes()   X-Ref
Default case: an id with the instance and a class with our name in it

return: array

_load_instance($instance)   X-Ref
Given an instance set the class var $instance to it and
load class var $config

param: block $instance

specialization()   X-Ref
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)


instance_allow_config()   X-Ref
Is each block of this type going to have instance-specific configuration?
Normally, this setting is controlled by {@link 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 {@link instance_allow_multiple} returns false.

return: boolean

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

return: boolean

instance_config_print()   X-Ref
Default behavior: print the config_instance.html file
You don't need to override this if you're satisfied with the above

return: boolean

instance_config_save($data,$pinned=false)   X-Ref
Serialize and store config data

return: boolean

instance_config_commit($pinned=false)   X-Ref
Replace the instance's configuration data with those currently in $this->config;

return: boolean

instance_create()   X-Ref
Do any additional initialization you may need at the time a new block instance is created

return: boolean

instance_delete()   X-Ref
Delete everything related to this instance if you have been using persistent storage other than the configdata field.

return: boolean

user_can_edit()   X-Ref
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.

return: boolean

user_can_addto(&$page)   X-Ref
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.

return: boolean

get_extra_capabilities()   X-Ref
No description

Class: block_list  - X-Ref

Specialized class for displaying a block with a list of icons/text labels

is_empty()   X-Ref
No description

_print_block()   X-Ref
No description



Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7