Made to Order Software Corporation Logo

MO Tag: mo_tag.page.inc File Reference

mo_tag.page.inc File Reference

The set of functions used to replace the tags. More...

Functions

 _mo_tag_load_tags_conf ()
 Load the tags.conf file in memory.

 _mo_tag_get_tag_by_name ($name, $load, $vid)
 Load a tag by name.

 _mo_tag_formatted_description ($tag)
 Format the tag description for display.

 _mo_tag_replace ($matches, $vid)
 Replace a tag with its content.

 _mo_tag_insert ($text, $description, $position)
 Function inserts the tag description at the right place.

 _mo_tag_autoreplace ($text, $vid)
 Add tags automatically to the node.

 _mo_tag_process ($text, $format)
 Process the mo_tag tags.


Detailed Description

This file certainly includes the core functionality of the filter. The functions defined here are those that will replace the mo_tag tags with the corresponding term descriptions.

Copyright (c) 2009-2011 Made to Order Software Corp.

http://www.m2osw.com/mo_tag contact@m2osw.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Function Documentation

_mo_tag_autoreplace ( text,
vid 
)

If we could not find a corresponding mo_tag entries for automatic tags, then we attempt to add them now. The user defines how this works for each term. By default, terms descriptions are not auto-inserted.

The user can also use the [mo_tag no <name>] in order to turn off the automatic feature.

Parameters:
[in] $text The text where the auto-tag will be inserted
[in] $vid The vocabulary identifier
Returns:
The possibly modified text.

References _mo_tag_formatted_description(), _mo_tag_get_tag_by_name(), and _mo_tag_insert().

Referenced by _mo_tag_process().

_mo_tag_formatted_description ( tag  ) 

This function ensures that the tag description is formatted as intended by the user. It uses the format as defined for that very tag.

Parameters:
[in] $tag The tag from which we want the description.
Returns:
The formatted description.

Referenced by _mo_tag_autoreplace(), and _mo_tag_replace().

_mo_tag_get_tag_by_name ( name,
load,
vid 
)

This function loads the tag from the database and caches it.

The tag is created, but not loaded, if $load is set to FALSE. This enables us to call the function without having to load the variable if all the user is doing is to prevent the automatic insert feature.

The $load parameter can be set to:

  • 0 -- do not load the tag (i.e. [mo_tag no <name>])
  • 1 -- load the tag (i.e. [mo_tag <name>]
  • 2 -- check whether the tag was used (i.e. auto-insert)
Parameters:
[in] $name The tag name, if empty, use 'no name'
[in] $load Whether to load or not load the tag
[in] $vid The vocabulary we're using in link with all of this
Returns:
A tag object with the term description, mo_tag_enabled, and mo_tag_format

References _mo_tag_load_tags_conf().

Referenced by _mo_tag_autoreplace(), and _mo_tag_replace().

_mo_tag_insert ( text,
description,
position 
)

The function counts the number of paragraphs (i.e. <p> tags) and insert the tag after $position end paragraphs. In other words, if $position is 3, then the $description will be added after the 3rd paragraph.

Parameters:
[in] $text The text to be tweaked
[in] $description The description from the tag, adding to the paragraph
[in] $position Add $description at this position
Returns:
The text with the automatic tag inserted

Referenced by _mo_tag_autoreplace().

_mo_tag_load_tags_conf (  ) 

This function loads the tag description from the tags.conf file.

The function reads the file once and caches it. Following calls just return the cached array.

Remember that tags read from the tags.conf file are not filtered. The file should be protected so the web server cannot create or modified the file.

Returns:
An array of tags keyed by tag name and with a description field.

Referenced by _mo_tag_get_tag_by_name().

_mo_tag_process ( text,
format 
)

This function replaces the mo_tag tags with the corresponding term description.

Then it removes any mo_tag no <name> tag.

If no mo_tag and no mo_tag no <name> were found, then the function eventually adds a default tag as specified in the format settings.

All replacements can also be turned off with the user of mo_tag off.

Parameters:
[in] $text The text to be filtered
[in] $format The format used to filter the text, this number is used to determines the taxonomy.
Returns:
The processed input text

References _mo_tag_autoreplace().

Referenced by mo_tag_filter().

_mo_tag_replace ( matches,
vid 
)

Replace the [mo_tag <name>] with the content of the term description.

Parameters:
[in] $matches The matches found in the input text
[in] $vid The vocabulary we're dealing with
Returns:
The replacement text. In other words, the tag value.

References _mo_tag_formatted_description(), and _mo_tag_get_tag_by_name().

Documentation generated by Doxygen on Sat Mar 12 16:25:23 2011