Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | List of all members
portfolio_add_button Class Reference

Public Member Functions

 __construct ($options=null)
 Constructor. More...
 
 get_callbackargs ()
 Getter for $callbackargs property. More...
 
 get_callbackclass ()
 Getter for $callbackclass property. More...
 
 get_callbackcomponent ()
 Getter for $callbackcomponent property. More...
 
 get_formats ()
 Getter for $format property. More...
 
 render ($format=null, $addstr=null)
 Echo the form/button/icon/text link to the page. More...
 
 reset_formats ()
 Reset formats to the default, which is usually what base_supported_formats returns.
 
 set_callback_options ($class, array $argarray, $component)
 Function to set the callback options. More...
 
 set_format_by_file (stored_file $file, $extraformats=null)
 If we already know we have exactly one file, bypass set_formats and just pass the file so we can detect the formats by mimetype. More...
 
 set_format_by_intended_file ($extn, $extraformats=null)
 Correllary this is use to set_format_by_file, but it is also used when there is no stored_file and when we're writing out a new type of file (like csv or pdf) More...
 
 set_formats ($formats=null)
 Sets the available export formats for this content. More...
 
 to_html ($format=null, $addstr=null)
 Returns the form/button/icon/text link as html. More...
 

Constructor & Destructor Documentation

◆ __construct()

portfolio_add_button::__construct (   $options = null)

Constructor.

Either pass the options here or set them using the helper methods. Generally the code will be clearer if you use the helper methods.

Parameters
array$optionskeyed array of options: key 'callbackclass': name of the caller class (eg forum_portfolio_caller') key 'callbackargs': the array of callback arguments your caller class wants passed to it in the constructor key 'callbackcomponent': the file containing the class definition of your caller class. See set_callback_options for more information on these three. key 'formats': an array of PORTFOLIO_FORMATS this caller will support See set_formats or set_format_by_file for more information on this.

Member Function Documentation

◆ get_callbackargs()

portfolio_add_button::get_callbackargs ( )

Getter for $callbackargs property.

Return values
array

◆ get_callbackclass()

portfolio_add_button::get_callbackclass ( )

Getter for $callbackclass property.

Return values
string

◆ get_callbackcomponent()

portfolio_add_button::get_callbackcomponent ( )

Getter for $callbackcomponent property.

Return values
string

◆ get_formats()

portfolio_add_button::get_formats ( )

Getter for $format property.

Return values
array

◆ render()

portfolio_add_button::render (   $format = null,
  $addstr = null 
)

Echo the form/button/icon/text link to the page.

Parameters
int$formatformat to display the button or form or icon or link. See constants PORTFOLIO_ADD_XXX for more info. optional, defaults to PORTFOLIO_ADD_FULL_FORM
string$addstrstring to use for the button or icon alt text or link text. this is whole string, not key. optional, defaults to 'Export to portfolio';

◆ set_callback_options()

portfolio_add_button::set_callback_options (   $class,
array  $argarray,
  $component 
)

Function to set the callback options.

Parameters
string$className of the class containing the callback functions activity components should ALWAYS use their name_portfolio_caller other locations must use something unique
array$argarrayThis can be an array or hash of arguments to pass back to the callback functions (passed by reference) these MUST be primatives to be added as hidden form fields. and the values get cleaned to PARAM_ALPHAEXT or PARAM_FLOAT or PARAM_PATH
string$componentThis is the name of the component in Moodle, eg 'mod_forum'

◆ set_format_by_file()

portfolio_add_button::set_format_by_file ( stored_file  $file,
  $extraformats = null 
)

If we already know we have exactly one file, bypass set_formats and just pass the file so we can detect the formats by mimetype.

Parameters
stored_file$filefile to set the format from
array$extraformatsany additional formats other than by mimetype eg leap2a etc

◆ set_format_by_intended_file()

portfolio_add_button::set_format_by_intended_file (   $extn,
  $extraformats = null 
)

Correllary this is use to set_format_by_file, but it is also used when there is no stored_file and when we're writing out a new type of file (like csv or pdf)

Parameters
string$extnthe file extension we intend to generate
array$extraformatsany additional formats other than by mimetype eg leap2a etc

◆ set_formats()

portfolio_add_button::set_formats (   $formats = null)

Sets the available export formats for this content.

This function will also poll the static function in the caller class and make sure we're not overriding a format that has nothing to do with mimetypes. Eg: if you pass IMAGE here but the caller can export LEAP2A it will keep LEAP2A as well.

See also
portfolio_most_specific_formats for more information
portfolio_format_from_mimetype
Parameters
array$formatsif the calling code knows better than the static method on the calling class (base_supported_formats). Eg: if it's going to be a single file, or if you know it's HTML, you can pass it here instead. This is almost always the case so it should be use all the times portfolio_format_from_mimetype for how to get the appropriate formats to pass here for uploaded files. or just call set_format_by_file instead

◆ to_html()

portfolio_add_button::to_html (   $format = null,
  $addstr = null 
)

Returns the form/button/icon/text link as html.

Parameters
int$formatformat to display the button or form or icon or link. See constants PORTFOLIO_ADD_XXX for more info. Optional, defaults to PORTFOLIO_ADD_FULL_FORM
string$addstrstring to use for the button or icon alt text or link text. This is whole string, not key. optional, defaults to 'Add to portfolio';
Return values
void|string|moodle_url

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