Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/portfoliolib.php File Reference

Go to the source code of this file.

Data Structures

class  portfolio_add_button

Namespaces

namespace  core
namespace  moodlecore

Functions

 portfolio_instance_select ($instances, $callerformats, $callbackclass, $mimetype=null, $selectname='instance', $return=false, $returnarray=false)
 portfolio_instances ($visibleonly=true, $useronly=true)
 portfolio_supported_formats ()
 portfolio_format_from_mimetype ($mimetype)
 portfolio_supported_formats_intersect ($callerformats, $pluginformats)
 portfolio_format_is_abstract ($format)
 portfolio_most_specific_formats ($specificformats, $generalformats)
 portfolio_format_object ($name)
 portfolio_instance ($instanceid, $record=null)
 portfolio_static_function ($plugin, $function)
 portfolio_plugin_sanity_check ($plugins=null)
 portfolio_instance_sanity_check ($instances=null)
 portfolio_report_insane ($insane, $instances=false, $return=false)
 portfolio_handle_event ($eventdata)
 portfolio_cron ()
 portfolio_export_rethrow_exception ($exporter, $exception)
 portfolio_expected_time_file ($totest)
 portfolio_filesize_info ()
 portfolio_expected_time_db ($recordcount)
 portfolio_insane_notify_admins ($insane, $instances=false)
 portfolio_export_pagesetup ($PAGE, $caller)
 portfolio_export_type_to_id ($type, $userid)
 portfolio_existing_exports ($userid, $type=null)
 portfolio_existing_exports_by_plugin ($userid)
 portfolio_format_text_options ()
 portfolio_rewrite_pluginfile_url_callback ($contextid, $component, $filearea, $itemid, $format, $options, $matches)
 portfolio_rewrite_pluginfile_urls ($text, $contextid, $component, $filearea, $itemid, $format, $options=null)

Function Documentation

main portfolio cronjob currently just cleans up expired transfer records.

Todo:
add hooks in the plugins - either per instance or per plugin

Definition at line 947 of file portfoliolib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

portfolio_existing_exports ( userid,
type = null 
)

return a list of current exports for the given user this will not go through and call rewaken_object, because it's heavy it's really just used to figure out what exports are currently happening. this is useful for plugins that don't support multiple exports per session

Parameters:
int$useridthe user to check for
string$type(optional) the portfolio plugin to filter by
Returns:
array

Definition at line 1156 of file portfoliolib.php.

Here is the caller graph for this function:

Return an array of existing exports by type for a given user. This is much more lightweight than {

See also:
existing_exports} because it only returns the types, rather than the whole serialised data so can be used for checking availability of multiple plugins at the same time.

Definition at line 1172 of file portfoliolib.php.

Here is the caller graph for this function:

portfolio_expected_time_db ( recordcount)

try and determine expected_time for purely database based exports or exports that might include large parts of a database

object

Parameters:
integer$recordcount- number of records trying to export
Returns:
constant PORTFOLIO_TIME_XXX

Definition at line 1050 of file portfoliolib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

try and determine expected_time for purely file based exports or exports that might include large file attachments.

object

Parameters:
mixed$totest- either an array of stored_file objects or a single stored_file object
Returns:
constant PORTFOLIO_TIME_XXX

Definition at line 987 of file portfoliolib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

portfolio_export_pagesetup ( PAGE,
caller 
)

Definition at line 1124 of file portfoliolib.php.

Here is the call graph for this function:

portfolio_export_rethrow_exception ( exporter,
exception 
)

helper function to rethrow a caught portfolio_exception as an export exception

used because when a portfolio_export exception is thrown the export is cancelled

throws portfolio_export_exceptiog

Parameters:
portfolio_exporter$exportercurrent exporter object
exception$exceptionexception to rethrow
Returns:
void

Definition at line 975 of file portfoliolib.php.

Here is the caller graph for this function:

portfolio_export_type_to_id ( type,
userid 
)

Definition at line 1139 of file portfoliolib.php.

the default filesizes and threshold information for file based transfers this shouldn't need to be used outside the admin pages and the portfolio code

Definition at line 1029 of file portfoliolib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Deduce export format from file mimetype

This function returns the revelant portfolio export format which is used to determine which portfolio plugins can be used for exporting this content according to the given mime type this only works when exporting exactly one file, or generating a new one (like a pdf or csv export)

Parameters:
string$mimetype(usually $file->get_mimetype())
Returns:
string the format constant (see PORTFOLIO_FORMAT_XXX constants)

Definition at line 569 of file portfoliolib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

tiny helper to figure out whether a portfolio format is abstract

Parameters:
string$formatthe format to test

bool

Definition at line 641 of file portfoliolib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

helper function to return a format object from the constant

Parameters:
string$namethe constant PORTFOLIO_FORMAT_XXX
Returns:
portfolio_format object

Definition at line 738 of file portfoliolib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Return default common options for format_text() when preparing a content to be exported

It is important not to apply filters and not to clean the HTML in format_text()

Returns:
stdClass

Definition at line 1186 of file portfoliolib.php.

Here is the caller graph for this function:

portfolio_handle_event ( eventdata)

event handler for the portfolio_send event

Definition at line 929 of file portfoliolib.php.

Here is the call graph for this function:

portfolio_insane_notify_admins ( insane,
instances = false 
)

object

Definition at line 1070 of file portfoliolib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

portfolio_instance ( instanceid,
record = null 
)

helper function to return an instance of a plugin (with config loaded)

Parameters:
int$instanceid of instance
array$recorddatabase row that corresponds to this instance this is passed to avoid unnecessary lookups Optional, and the record will be retrieved if null.
Returns:
subclass of portfolio_plugin_base

Definition at line 755 of file portfoliolib.php.

Here is the caller graph for this function:

portfolio_instance_sanity_check ( instances = null)

helper function to check all the instances for sanity and set any insane ones to invisible.

Parameters:
array$instancesto check (if null, defaults to all) one instance or id will work too
Returns:
array array of insane instances (keys= id, values = reasons (keys for plugin lang)

Definition at line 846 of file portfoliolib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

portfolio_instance_select ( instances,
callerformats,
callbackclass,
mimetype = null,
selectname = 'instance',
return = false,
returnarray = false 
)

returns a drop menu with a list of available instances.

Parameters:
array$instancesarray of portfolio plugin instance objects - the instances to put in the menu
array$callerformatsarray of PORTFOLIO_FORMAT_XXX constants - the formats the caller supports (this is used to filter plugins)
array$callbackclassthe callback class name - used for debugging only for when there are no common formats
mimetype$mimetypeif we already know we have exactly one file, or are going to write one, pass it here to do mime filtering.
string$selectnamethe name of the select element. Optional, defaults to instance.
boolean$returnwhether to print or return the output. Optional, defaults to print.
booealn$returnarrayif returning, whether to return the HTML or the array of options. Optional, defaults to HTML.
Returns:
string the html, from <select> to </select> inclusive.

Definition at line 435 of file portfoliolib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

portfolio_instances ( visibleonly = true,
useronly = true 
)

return all portfolio instances

Todo:
check capabilities here - see MDL-15768
Parameters:
booleanvisibleonly Don't include hidden instances. Defaults to true and will be overridden to true if the next parameter is true
booleanuseronly Check the visibility preferences and permissions of the logged in user. Defaults to true.
Returns:
array of portfolio instances (full objects, not just database records)

Definition at line 501 of file portfoliolib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

portfolio_most_specific_formats ( specificformats,
generalformats 
)

return the combination of the two arrays of formats with duplicates in terms of specificity removed and also removes conflicting formats use case: a module is exporting a single file, so the general formats would be FILE and MBKP while the specific formats would be the specific subclass of FILE based on mime (say IMAGE) and this function would return IMAGE and MBKP

Parameters:
array$specificformatsarray of more specific formats (eg based on mime detection)
array$generalformatsarray of more general formats (usually more supported)
Returns:
array merged formats with dups removed

Definition at line 671 of file portfoliolib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

portfolio_plugin_sanity_check ( plugins = null)

helper function to check all the plugins for sanity and set any insane ones to invisible.

Parameters:
array$pluginsto check (if null, defaults to all) one string will work too for a single plugin.
Returns:
array array of insane instances (keys= id, values = reasons (keys for plugin lang)

Definition at line 814 of file portfoliolib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

portfolio_report_insane ( insane,
instances = false,
return = false 
)

helper function to display a table of plugins (or instances) and reasons for disabling

Parameters:
array$insanearray of insane plugins (key = plugin (or instance id), value = reason)
array$instancesif reporting instances rather than whole plugins, pass the array (key = id, value = object) here

Definition at line 886 of file portfoliolib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

portfolio_rewrite_pluginfile_url_callback ( contextid,
component,
filearea,
itemid,
format,
options,
matches 
)

callback function from portfolio_rewrite_pluginfile_urls looks through preg_replace matches and replaces content with whatever the active portfolio export format says

Definition at line 1202 of file portfoliolib.php.

Here is the call graph for this function:

portfolio_rewrite_pluginfile_urls ( text,
contextid,
component,
filearea,
itemid,
format,
options = null 
)

go through all the @PLUGINFILE@ matches in some text, extract the file information and pass it back to the portfolio export format to regenerate the html to output

Parameters:
string$textthe text to search through
int$contextidnormal file_area arguments
string$component
string$fileareanormal file_area arguments
int$itemidnormal file_area arguments
portfolio_format$formatthe portfolio export format
array$optionsextra options to pass through to the file_output function in the format (optional)
Returns:
string

Definition at line 1256 of file portfoliolib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

portfolio_static_function ( plugin,
function 
)

Helper function to call a static function on a portfolio plugin class

This will figure out the classname and require the right file and call the function. you can send a variable number of arguments to this function after the first two and they will be passed on to the function you wish to call.

Parameters:
string$pluginname of plugin
string$functionfunction to call

Definition at line 781 of file portfoliolib.php.

Here is the caller graph for this function:

Supported formats currently in use.

Canonical place for a list of all formats that portfolio plugins and callers can use for exporting content

Returns:
keyed array of all the available export formats (constant => classname)

Definition at line 537 of file portfoliolib.php.

Here is the caller graph for this function:

portfolio_supported_formats_intersect ( callerformats,
pluginformats 
)

Intersection of plugin formats and caller formats

Walks both the caller formats and portfolio plugin formats and looks for matches (walking the hierarchy as well) and returns the intersection

Parameters:
array$callerformatsformats the caller supports
array$pluginformatsformats the portfolio plugin supports

Definition at line 605 of file portfoliolib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

 All Data Structures Namespaces Files Functions Variables Enumerations