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

Go to the source code of this file.

Data Structures

class  filter_manager
class  null_filter_manager
class  performance_measuring_filter_manager
class  moodle_text_filter
class  legacy_filter
class  filterobject

Namespaces

namespace  core

Enumerations

enum  TEXTFILTER_ON
enum  TEXTFILTER_INHERIT
enum  TEXTFILTER_OFF
enum  TEXTFILTER_DISABLED
enum  TEXTFILTER_EXCL_SEPARATOR

Functions

 filter_get_name ($filter)
 filter_get_all_installed ()
 filter_set_global_state ($filter, $state, $sortorder=false)
 filter_is_enabled ($filter)
 filter_get_globally_enabled ()
 filter_get_string_filters ()
 filter_set_applies_to_strings ($filter, $applytostrings)
 filter_set_local_state ($filter, $contextid, $state)
 filter_set_local_config ($filter, $contextid, $name, $value)
 filter_unset_local_config ($filter, $contextid, $name)
 filter_get_local_config ($filter, $contextid)
 filter_get_all_local_settings ($contextid)
 filter_get_active_in_context ($context)
 filter_preload_activities (course_modinfo $modinfo)
 filter_get_available_in_context ($context)
 filter_get_global_states ()
 filter_delete_all_for_filter ($filter)
 filter_delete_all_for_context ($contextid)
 filter_has_global_settings ($filter)
 filter_has_local_settings ($filter)
 filter_context_may_have_filter_settings ($context)
 filter_phrases ($text, &$link_array, $ignoretagsopen=NULL, $ignoretagsclose=NULL, $overridedefaultignore=false)
 filter_remove_duplicates ($linkarray)
 filter_save_ignore_tags (&$text, $filterignoretagsopen, $filterignoretagsclose, &$ignoretags)
 filter_save_tags (&$text, &$tags)
 filter_add_javascript ($text)

Enumeration Type Documentation

The states a filter can be in, stored in the filter_active table.

Definition at line 36 of file filterlib.php.

Define one exclusive separator that we'll use in the temp saved tags keys. It must be something rare enough to avoid having matches with filterobjects. MDL-18165

Definition at line 43 of file filterlib.php.

The states a filter can be in, stored in the filter_active table.

Definition at line 32 of file filterlib.php.

The states a filter can be in, stored in the filter_active table.

Definition at line 34 of file filterlib.php.

The states a filter can be in, stored in the filter_active table.

Definition at line 30 of file filterlib.php.


Function Documentation

filter_add_javascript ( text)

Add missing openpopup javascript to HTML files.

Parameters:
string$text
Returns:
string

Definition at line 1421 of file filterlib.php.

Here is the caller graph for this function:

Certain types of context (block and user) may not have local filter settings. the function checks a context to see whether it may have local config.

Parameters:
object$contexta context.
Returns:
boolean whether this context may have local filter settings.

Definition at line 1118 of file filterlib.php.

Delete all the data in the database relating to a context, used when contexts are deleted.

Parameters:
integer$contextidThe id of the context being deleted.

Definition at line 1079 of file filterlib.php.

Here is the caller graph for this function:

Delete all the data in the database relating to a filter, prior to deleting it.

object

Parameters:
string$filterThe filter name, for example 'filter/tex' or 'mod/glossary'.

Definition at line 1065 of file filterlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Get the list of active filters, in the order that they should be used for a particular context, along with any local configuration variables.

object

Parameters:
object$contexta context
Returns:
array an array where the keys are the filter names, for example 'filter/tex' or 'mod/glossary' and the values are any local configuration for that filter, as an array of name => value pairs from the filter_config table. In a lot of cases, this will be an empty array. So, an example return value for this function might be array('filter/tex' => array(), 'mod/glossary' => array('glossaryid', 123))

Definition at line 829 of file filterlib.php.

Here is the caller graph for this function:

Get the names of all the filters installed in this Moodle.

object

Returns:
array path => filter name from the appropriate lang file. e.g. array('mod/glossary' => 'Glossary Auto-linking', 'filter/tex' => 'TeX Notation'); sorted in alphabetical order of name.

Definition at line 513 of file filterlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

This function is for use by backup. Gets all the filter information specific to one context.

object

Parameters:
int$contextid
Returns:
array Array with two elements. The first element is an array of objects with fields filter and active. These come from the filter_active table. The second element is an array of objects with fields filter, name and value from the filter_config table.

Definition at line 807 of file filterlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

List all of the filters that are available in this context, and what the local and inherited states of that filter are.

object

Parameters:
object$contexta context that is not the system context.
Returns:
array an array with filter names, for example 'filter/tex' or 'mod/glossary' as keys. and and the values are objects with fields: ->filter filter name, same as the key. ->localstate TEXTFILTER_ON/OFF/INHERIT ->inheritedstate TEXTFILTER_ON/OFF - the state that will be used if localstate is set to TEXTFILTER_INHERIT.

Definition at line 1015 of file filterlib.php.

Here is the caller graph for this function:

This function is for use by the filter administration page.

object

Returns:
array 'filtername' => object with fields 'filter' (=filtername), 'active' and 'sortorder'

Definition at line 1053 of file filterlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Return a list of all the filters that may be in use somewhere.

array $enabledfilters

Returns:
array where the keys and values are both the filter name, like 'filter/tex'.

Definition at line 638 of file filterlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

filter_get_local_config ( filter,
contextid 
)

Get local config variables for a filter in a context. Normally (when your filter is running) you don't need to call this, becuase the config is fetched for you automatically. You only need this, for example, when you are getting the config so you can show the user an editing from.

object

Parameters:
string$filterThe filter name, for example 'filter/tex' or 'mod/glossary'.
integer$contextidThe ID of the context to get the local config for.
Returns:
array of name => value pairs.

Definition at line 791 of file filterlib.php.

Here is the caller graph for this function:

filter_get_name ( filter)

Look up the name of this filter in the most appropriate location. If $filterlocation = 'mod' then does get_string('filtername', $filter); else if $filterlocation = 'filter' then does get_string('filtername', 'filter_' . $filter); with a fallback to get_string('filtername', $filter) for backwards compatibility. These are the only two options supported at the moment.

Parameters:
string$filterthe folder name where the filter lives.
Returns:
string the human-readable name for this filter.

Definition at line 480 of file filterlib.php.

Here is the caller graph for this function:

Return the names of the filters that should also be applied to strings (when they are enabled).

object

Returns:
array where the keys and values are both the filter name, like 'filter/tex'.

Definition at line 659 of file filterlib.php.

Here is the caller graph for this function:

Does this filter have a global settings page in the admin tree? (The settings page for a filter must be called, for example, filtersettingfiltertex or filtersettingmodglossay.)

Parameters:
string$filterThe filter name, for example 'filter/tex' or 'mod/glossary'.
Returns:
boolean Whether there should be a 'Settings' link on the config page.

Definition at line 1093 of file filterlib.php.

Here is the caller graph for this function:

Does this filter have local (per-context) settings?

Parameters:
string$filterThe filter name, for example 'filter/tex' or 'mod/glossary'.
Returns:
boolean Whether there should be a 'Settings' link on the manage filters in context page.

Definition at line 1105 of file filterlib.php.

filter_is_enabled ( filter)
Parameters:
string$filterThe filter name, for example 'filter/tex' or 'mod/glossary'.
Returns:
boolean is this filter allowed to be used on this site. That is, the admin has set the global 'active' setting to On, or Off, but available.

Definition at line 628 of file filterlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

filter_phrases ( text,
&$  link_array,
ignoretagsopen = NULL,
ignoretagsclose = NULL,
overridedefaultignore = false 
)

Process phrases intelligently found within a HTML text (such as adding links)

array $usedpharses

Parameters:
string$textthe text that we are filtering
array$link_arrayan array of filterobjects
array$ignoretagsopenan array of opening tags that we should ignore while filtering
array$ignoretagsclosean array of corresponding closing tags
bool$overridedefaultignoreTrue to only use tags provided by arguments
Returns:
string

Invalid prefixes and suffixes for the fullmatch searches Every "word" character, but the underscore, is a invalid suffix or prefix. (nice to use this because it includes national characters (accents...) as word characters.

Remove tags from $text

Time to cycle through each phrase to be linked

Set some defaults if certain properties are missing Properties may be missing if the filterobject class has not been used to construct the object

Avoid integers < 1000 to be linked. See bug 1446.

All this work has to be done ONLY it it hasn't been done before

Double up chars to protect true duplicates be cleared up before returning to the user.

Strip tags out of the phrase

Double up chars that might cause a false match -- the duplicates will be cleared up before returning to the user.

Set the replacement phrase properly

Strip tags

Quote any regular expression characters and the delimiter in the work phrase to be searched

Work calculated

If $CFG->filtermatchoneperpage, avoid previously (request) linked phrases

Regular expression modifiers

Do we need to do a fullmatch? If yes then go through and remove any non full matching entries

Finally we do our highlighting

If the text has changed we have to look for links again

Set $text to $resulttext

Remove everything enclosed by the ignore tags from $text

Remove tags from $text

If $CFG->filtermatchoneperpage, save linked phrases to request

Replace the not full matches before cycling to next link object

Rebuild the text with all the excluded areas

Reversed so "progressive" str_replace() will solve some nesting problems.

Add missing javascript for popus

Definition at line 1133 of file filterlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Preloads the list of active filters for all activities (modules) on the course using two database queries.

Parameters:
course_modinfo$modinfoCourse object from get_fast_modinfo

Definition at line 881 of file filterlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

filter_remove_duplicates ( linkarray)
Todo:
Document this function
Parameters:
array$linkarray
Returns:
array

Definition at line 1339 of file filterlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

filter_save_ignore_tags ( &$  text,
filterignoretagsopen,
filterignoretagsclose,
&$  ignoretags 
)

Extract open/lose tags and their contents to avoid being processed by filters. Useful to extract pieces of code like ... tags. It returns the text converted with some <#xTEXTFILTER_EXCL_SEPARATORx#> codes replacing the extracted text. Such extracted texts are returned in the ignoretags array (as values), with codes as keys.

Parameters:
string$textthe text that we are filtering (in/out)
array$filterignoretagsopenan array of open tags to start searching
array$filterignoretagsclosean array of close tags to end searching
array$ignoretagsan array of saved strings useful to rebuild the original text (in/out)

Remove everything enclosed by the ignore tags from $text

form regular expression

Definition at line 1374 of file filterlib.php.

Here is the caller graph for this function:

filter_save_tags ( &$  text,
&$  tags 
)

Extract tags (any text enclosed by < and > to avoid being processed by filters. It returns the text converted with some <xTEXTFILTER_EXCL_SEPARATORx%> codes replacing the extracted text. Such extracted texts are returned in the tags array (as values), with codes as keys.

Parameters:
string$textthe text that we are filtering (in/out)
array$tagsan array of saved strings useful to rebuild the original text (in/out)

Definition at line 1403 of file filterlib.php.

Here is the caller graph for this function:

filter_set_applies_to_strings ( filter,
applytostrings 
)

Sets whether a particular active filter should be applied to all strings by format_string, or just used by format_text.

Parameters:
string$filterThe filter name, for example 'filter/tex' or 'mod/glossary'.
boolean$applytostringsif true, this filter will apply to format_string and format_text, when it is enabled.

Definition at line 677 of file filterlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

filter_set_global_state ( filter,
state,
sortorder = false 
)

Set the global activated state for a text filter.

object

Parameters:
string$filterThe filter name, for example 'filter/tex' or 'mod/glossary'.
integer$stateOne of the values TEXTFILTER_ON, TEXTFILTER_OFF or TEXTFILTER_DISABLED.
integer$sortorder(optional) a position in the sortorder to place this filter. If not given defaults to: No change in order if we are updating an existing record, and not changing to or from TEXTFILTER_DISABLED. Just after the last currently active filter when adding an unknown filter in state TEXTFILTER_ON or TEXTFILTER_OFF, or enabling/disabling an existing filter. Just after the very last filter when adding an unknown filter in state TEXTFILTER_DISABLED

Definition at line 550 of file filterlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

filter_set_local_config ( filter,
contextid,
name,
value 
)

Set a particular local config variable for a filter in a context.

object

Parameters:
string$filterThe filter name, for example 'filter/tex' or 'mod/glossary'.
integer$contextidThe id of the context to get the local config for.
string$namethe setting name.
string$valuethe corresponding value.

Definition at line 746 of file filterlib.php.

Here is the caller graph for this function:

filter_set_local_state ( filter,
contextid,
state 
)

Set the local activated state for a text filter.

object

Parameters:
string$filterThe filter name, for example 'filter/tex' or 'mod/glossary'.
integer$contextidThe id of the context to get the local config for.
integer$stateOne of the values TEXTFILTER_ON, TEXTFILTER_OFF or TEXTFILTER_INHERIT.
Returns:
void

Definition at line 700 of file filterlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

filter_unset_local_config ( filter,
contextid,
name 
)

Remove a particular local config variable for a filter in a context.

object

Parameters:
string$filterThe filter name, for example 'filter/tex' or 'mod/glossary'.
integer$contextidThe id of the context to get the local config for.
string$namethe setting name.

Definition at line 775 of file filterlib.php.

Here is the caller graph for this function:

 All Data Structures Namespaces Files Functions Variables Enumerations