[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
[Code source] [Imprimer] [Statistiques]
Gordon Luk's Freetag - Generalized Open Source Tagging and Folksonomy. Copyright (C) 2004-2005 Gordon D. Luk <gluk AT getluky DOT net> Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. See License.txt.
Poids: | 1162 lignes (40 kb) |
Inclus ou requis: | 6 fois |
Référencé: | 0 fois |
Nécessite: | 0 fichiers |
freetag:: (23 méthodes):
freetag()
get_objects_with_tag()
get_objects_with_tag_all()
get_objects_with_tag_combo()
get_objects_with_tag_id()
get_tags_on_object()
safe_tag()
normalize_tag()
delete_object_tag()
delete_all_object_tags()
delete_all_object_tags_for_user()
get_tag_id()
get_raw_tag_id()
tag_object()
_tag_object_array()
_parse_tags()
get_most_popular_tags()
count_tags()
get_tag_cloud_html()
get_tag_cloud_tags()
similar_tags()
similar_objects()
debug_text()
freetag($options = NULL) X-Ref |
freetag Constructor for the freetag class. param: array An associative array of options to pass to the instance of Freetag. |
get_objects_with_tag($tag, $offset = 0, $limit = 100, $tagger_id = NULL) X-Ref |
get_objects_with_tag Use this function to build a page of results that have been tagged with the same tag. Pass along a tagger_id to collect only a certain user's tagged objects, and pass along none in order to get back all user-tagged objects. Most of the get_*_tag* functions operate on the normalized form of tags, because most interfaces for navigating tags should use normal form. param: string - Pass the normalized tag form along to the function. param: int (Optional) - The numerical offset to begin display at. Defaults to 0. param: int (Optional) - The number of results per page to show. Defaults to 100. param: int (Optional) - The unique ID of the 'user' who tagged the object. return: An array of Object ID numbers that reference your original objects. |
get_objects_with_tag_all($tag, $tagger_id = NULL) X-Ref |
get_objects_with_tag_all Use this function to build a page of results that have been tagged with the same tag. This function acts the same as get_objects_with_tag, except that it returns an unlimited number of results. Therefore, it's more useful for internal displays, not for API's. Pass along a tagger_id to collect only a certain user's tagged objects, and pass along none in order to get back all user-tagged objects. Most of the get_*_tag* functions operate on the normalized form of tags, because most interfaces for navigating tags should use normal form. param: string - Pass the normalized tag form along to the function. param: int (Optional) - The unique ID of the 'user' who tagged the object. return: An array of Object ID numbers that reference your original objects. |
get_objects_with_tag_combo($tagArray, $offset = 0, $limit = 100, $tagger_id = NULL) X-Ref |
get_objects_with_tag_combo Returns an array of object ID's that have all the tags passed in the tagArray parameter. Use this to provide tag combo services to your vtiger_users. param: array - Pass an array of normalized form tags along to the function. param: int (Optional) - The numerical offset to begin display at. Defaults to 0. param: int (Optional) - The number of results per page to show. Defaults to 100. param: int (Optional) - Restrict the result to objects tagged by a particular user. return: An array of Object ID numbers that reference your original objects. |
get_objects_with_tag_id($tag_id, $offset = 0, $limit = 100, $tagger_id = NULL) X-Ref |
get_objects_with_tag_id Use this function to build a page of results that have been tagged with the same tag. This function acts the same as get_objects_with_tag, except that it accepts a numerical tag_id instead of a text tag. Pass along a tagger_id to collect only a certain user's tagged objects, and pass along none in order to get back all user-tagged objects. param: int - Pass the ID number of the tag. param: int (Optional) - The numerical offset to begin display at. Defaults to 0. param: int (Optional) - The number of results per page to show. Defaults to 100. param: int (Optional) - The unique ID of the 'user' who tagged the object. return: An array of Object ID numbers that reference your original objects. |
get_tags_on_object($object_id, $offset = 0, $limit = 10, $tagger_id = NULL) X-Ref |
get_tags_on_object You can use this function to show the tags on an object. Since it supports both user-specific and general modes with the $tagger_id parameter, you can use it twice on a page to make it work similar to upcoming.org and flickr, where the page displays your own tags differently than other vtiger_users' tags. param: int The unique ID of the object in question. param: int The offset of tags to return. param: int The size of the tagset to return. Use a zero size to get all tags. param: int The unique ID of the person who tagged the object, if user-level tags only are preferred. return: array Returns a PHP array with object elements ordered by object ID. Each element is an associative |
safe_tag($tagger_id, $object_id, $tag, $module) X-Ref |
safe_tag Pass individual tag phrases along with object and person ID's in order to set a tag on an object. If the tag in its raw form does not yet exist, this function will create it. Fails transparently on duplicates, and checks for dupes based on the block_multiuser_tag_on_object constructor param. param: int The unique ID of the person who tagged the object with this tag. param: int The unique ID of the object in question. param: string A raw string from a web form containing tags. return: boolean Returns true if successful, false otherwise. Does not operate as a transaction. |
normalize_tag($tag) X-Ref |
normalize_tag This is a utility function used to take a raw tag and convert it to normalized form. Normalized form is essentially lowercased alphanumeric characters only, with no spaces or special characters. Customize the normalized valid chars with your own set of special characters in regex format within the option 'normalized_valid_chars'. It acts as a filter to let a customized set of characters through. After the filter is applied, the function also lowercases the characters using strtolower in the current locale. The default for normalized_valid_chars is a-zA-Z0-9, or english alphanumeric. param: string An individual tag in raw form that should be normalized. return: string Returns the tag in normalized form. |
delete_object_tag($tagger_id, $object_id, $tag) X-Ref |
delete_object_tag Removes a tag from an object. This does not delete the tag itself from the database. Since most applications will only allow a user to delete their own tags, it supports raw-form tags as its tag parameter, because that's what is usually shown to a user for their own tags. param: int The unique ID of the person who tagged the object with this tag. param: int The ID of the object in question. param: string The raw string form of the tag to delete. See above for vtiger_notes. return: string Returns the tag in normalized form. |
delete_all_object_tags($object_id) X-Ref |
delete_all_object_tags Removes all tag from an object. This does not delete the tag itself from the database. This is most useful for cleanup, where an item is deleted and all its tags should be wiped out as well. param: int The ID of the object in question. return: boolean Returns true if successful, false otherwise. It will return true if the tagged object does not exist. |
delete_all_object_tags_for_user($tagger_id, $object_id) X-Ref |
delete_all_object_tags_for_user Removes all tag from an object for a particular user. This does not delete the tag itself from the database. This is most useful for implementations similar to del.icio.us, where a user is allowed to retag an object from a text box. That way, it becomes a two step operation of deleting all the tags, then retagging with whatever's left in the input. param: int The unique ID of the person who tagged the object with this tag. param: int The ID of the object in question. return: boolean Returns true if successful, false otherwise. It will return true if the tagged object does not exist. |
get_tag_id($tag) X-Ref |
get_tag_id Retrieves the unique ID number of a tag based upon its normal form. Actually, using this function is dangerous, because multiple tags can exist with the same normal form, so be careful, because this will only return one, assuming that if you're going by normal form, then the individual tags are interchangeable. param: string The normal form of the tag to fetch. return: string Returns the tag in normalized form. |
get_raw_tag_id($tag) X-Ref |
get_raw_tag_id Retrieves the unique ID number of a tag based upon its raw form. If a single unique record is needed, then use this function instead of get_tag_id, because raw_tags are unique. param: string The raw string form of the tag to fetch. return: string Returns the tag in normalized form. |
tag_object($tagger_id, $object_id, $tag_string, $module, $skip_updates = 1) X-Ref |
tag_object This function allows you to pass in a string directly from a form, which is then parsed for quoted phrases and special characters, normalized and converted into tags. The tag phrases are then individually sent through the safe_tag() method for processing and the object referenced is set with that tag. This method has been refactored to automatically look for existing tags and run adds/updates/deletes as appropriate. param: int The unique ID of the person who tagged the object with this tag. param: int The ID of the object in question. param: string The raw string form of the tag to delete. See above for vtiger_notes. param: int Whether to skip the update portion for objects that haven't been tagged. (Default: 1) return: string Returns the tag in normalized form. |
_tag_object_array($tagger_id, $object_id, $tagArray, $module) X-Ref |
_tag_object_array Private method to add tags to an object from an array. param: int Unique ID of tagger param: int Unique ID of object param: array Array of tags to add. return: boolean True if successful, false otherwise. |
_parse_tags($tag_string) X-Ref |
_parse_tags Private method to parse tags out of a string and into an array. param: string String to parse. return: array Returns an array of the raw "tags" parsed according to the freetag settings. |
get_most_popular_tags($tagger_id = NULL, $offset = 0, $limit = 25) X-Ref |
get_most_popular_tags This function returns the most popular tags in the freetag system, with offset and limit support for pagination. It also supports restricting to an individual user. Call it with no parameters for a list of 25 most popular tags. param: int The unique ID of the person to restrict results to. param: int The offset of the tag to start at. param: int The number of tags to return in the result set. return: array Returns a PHP array with tags ordered by popularity descending. |
count_tags($tagger_id = NULL) X-Ref |
count_tags Returns the total number of tag->object links in the system. It might be useful for pagination at times, but i'm not sure if I actually use this anywhere. Restrict to a person's tagging by using the $tagger_id parameter. param: int The unique ID of the person to restrict results to. return: int Returns the count |
get_tag_cloud_html($module="",$tagger_id = NULL,$obj_id= NULL,$num_tags = 100, $min_font_size = 10, $max_font_size = 20, $font_units = 'px', $span_class = '', $tag_page_url = '/tag/') X-Ref |
get_tag_cloud_html This is a pretty straightforward, flexible method that automatically generates some html that can be dropped in as a tag cloud. It uses explicit font sizes inside of the style attribute of SPAN elements to accomplish the differently sized objects. It will also link every tag to $tag_page_url, appended with the normalized form of the tag. You should adapt this value to your own tag detail page's URL. param: int The maximum number of tags to return. (default: 100) param: int The minimum font size in the cloud. (default: 10) param: int The maximum number of tags to return. (default: 20) param: string The "units" for the font size (i.e. 'px', 'pt', 'em') (default: px) param: string The class to use for all spans in the cloud. (default: cloud_tag) param: string The tag page URL (default: /tag/) return: string Returns an HTML snippet that can be used directly as a tag cloud. |
get_tag_cloud_tags($max = 100, $tagger_id = NULL,$module = "",$obj_id = NULL) X-Ref |
Pas de description |
similar_tags($tag, $max = 100) X-Ref |
similar_tags Finds tags that are "similar" or related to the given tag. It does this by looking at the other tags on objects tagged with the tag specified. Confusing? Think of it like e-commerce's "Other vtiger_users who bought this also bought," as that's exactly how this works. Returns an empty array if no tag is passed, or if no related tags are found. Hint: You can detect related tags returned with count($retarr > 0) It's important to note that the quantity passed back along with each tag is a measure of the *strength of the relation* between the original tag and the related tag. It measures the number of objects tagged with both the original tag and its related tag. Thanks to Myles Grant for contributing this function! param: string The raw normalized form of the tag to fetch. param: int The maximum number of tags to return. return: array Returns an array where the keys are normalized tags, and the |
similar_objects($object_id, $threshold = 1, $max_objects = 5, $tagger_id = NULL) X-Ref |
similar_objects This method implements a simple ability to find some objects in the database that might be similar to an existing object. It determines this by trying to match other objects that share the same tags. The user of the method has to use a threshold (by default, 1) which specifies how many tags other objects must have in common to match. If the original object has no tags, then it won't match anything. Matched objects are returned in order of most similar to least similar. The more tags set on a database, the better this method works. Since this is such an expensive operation, it requires a limit to be set via max_objects. param: int The unique ID of the object to find similar objects for. param: int The Threshold of tags that must be found in common (default: 1) param: int The maximum number of similar objects to return (default: 5). param: int Optionally pass a tagger id to restrict similarity to a tagger's view. return: array Returns a PHP array with matched objects ordered by strength of match descending. |
debug_text($text) X-Ref |
Pas de description |
Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |