Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

BaseTags Class Reference
[Basic Modules]

Inheritance diagram for BaseTags:

MyModule BaseModule List of all members.

Detailed Description

BaseTags is an object dealing with tags ala Web 2.0.

A class that simplifies the management, adding/editing of tags, and other things dealing with tagging of items.

Definition at line 8 of file base-tags.inc.php.

Public Member Functions

 __construct ($id, $tagTable, $joinerTable)
 our constructor
 getPagesXml ()
 get our xml...
 initViewPage ()
 this is our view page...
 drawViewPage ()
 here we draw it.
 drawRelatedTags ()
 draws the tags related to a tag
 initMainPage ()
 our main page is a cloud of all the cool tags we have.
 drawMainPage ()
 this draws a paragraph of the popular tags.
 addTag ($tag)
 this function adds the tag to the database.
 deleteTag ($tag)
 this function deletes a tag from the database
 findTag ($tag)
 here we are looking to see if a tag exists.
 getTags ()
 this function gets a list of tags that a our object is associated with
 delete ()
 getPrettyTags ()
 gets an array of tags for our object, except formated for humans
 getObjectsSql ($tagId)
 this function gets the ids of all the objects with a certain tag.
 getPopularTags ($count=30)
 this function gets a list of popular tags for use in a tag cloud or whatnot.
 getPopularTagsList ($count=60)
 this gets a list of all the popular tags.
 getWeightedPopularTagsList ($count=100)
 this gets a weighted list of all the popular tags.
 updateTagsForm ($form)
 update our object's tags from a form object
 updateTags ($data)
 update our object's tags in the database.
 addTagLink ($tag)
 this function links a tag to our object.
 removeTagLink ($tag)
 this function removes a tag from our object.
 removeTagLinkDb ($tagId)
 removes the link between our tag and the object in the db
 getRelatedTags ($tag)
 this function gets tags that are related to a tag.
 getLinkedTags ($tags)
 this function links up our tags to their view pages.
 getTagList ($tags=null)
 this function gets a list of our object's tags.
 getRelatedTagsList ($tag)
 this function gets a list of related tags.
 addTagField ($form)
 this function adds our tag field to our form.
 addPopularTagField ($form)
 this function adds our popular tags field to our object.
 addTagFields ($form)
 this function adds both the tag area and the popular tags field to our form.
 getCreateTableSql ()
 gets the table creation sql for the tags
 getTagFieldsArray ()
 get an array of fields in the table that stores the tags.
 getTagIndexesArray ()
 get an array of indexes on fields in the tag table
 getJoinerFieldsArray ()
 get an array of fields in the table that joins tags to objects
 getJoinerIndexesArray ()
 get an array of indexes on fields in the table that joins tags to objects

Static Public Member Functions

 cleanTag ($tag)
 this function cleans a tag for insertion into a database.
 prettyTag ($tag)
 this function takes a database tag and makes it pretty.

Public Attributes

 $plural
 plural form of the word of what the tags are...
 $objectId = 0
 the id of the object we're associating with.

Static Public Attributes

 $cachePopularTags = true
 do we cache our array of popular tags?
 $popularTagsCacheLife = 3600
 how long do we cache our popular tags for?
 $cacheRelatedTags = true
 do we cache our array of related tags?
 $relatedTagsCacheLife = 3600
 how long do we cache our related tags for?
 $weightStyles
 our styles for the weighted tags page

Protected Member Functions

 insertTag ($tag)
 this function inserts the tag into the database.
 getTagsWhere ()
 this gets sql code to get tags from the db for a certain object.
 getTagFieldParams ()
 this function gets the parameters for our tag entry field.
 getPopularFieldParams ()
 this function gets the parameters for our popular tag field.
 addTagLinkDb ($tagId)
 add a link in the db between our object and this tag
 getFormPopularCloud ()
 this function is for our tag form.

Protected Attributes

 $tagTable
 protected this is the table where we store our tags.
 $joinerTable
 protected this is the table we use to store relations between tags and objects.


Member Function Documentation

BaseTags::__construct id,
tagTable,
joinerTable
 

our constructor

Parameters:
$id the id of the BaseObject we're associating with.
$tagTable the table to store our tags in.
$joinerTable optional table to join with whatever object we're using.

Definition at line 68 of file base-tags.inc.php.

BaseTags::addPopularTagField form  ) 
 

this function adds our popular tags field to our object.

Parameters:
$form the form object to add the field to

Definition at line 785 of file base-tags.inc.php.

References BaseModule::needsJs().

Referenced by addTagFields().

BaseTags::addTag tag  ) 
 

this function adds the tag to the database.

if it exists, then the id is returned.

Parameters:
$tag the tag to be added
Returns:
the id of the tag.

Definition at line 188 of file base-tags.inc.php.

References findTag(), and insertTag().

Referenced by addTagLink().

BaseTags::addTagField form  ) 
 

this function adds our tag field to our form.

Parameters:
$form the form object to add the field to

Definition at line 775 of file base-tags.inc.php.

Referenced by addTagFields().

BaseTags::addTagFields form  ) 
 

this function adds both the tag area and the popular tags field to our form.

Parameters:
$form the form object to add the fields to

Definition at line 797 of file base-tags.inc.php.

References addPopularTagField(), and addTagField().

BaseTags::addTagLink tag  ) 
 

this function links a tag to our object.

it will also create the tag.

Parameters:
$tag. the tag to be linked.

Definition at line 570 of file base-tags.inc.php.

References addTag(), and addTagLinkDb().

Referenced by updateTags().

BaseTags::addTagLinkDb tagId  )  [protected]
 

add a link in the db between our object and this tag

Parameters:
$tagId the id of the tag in the tag table

Definition at line 591 of file base-tags.inc.php.

References dbExecute().

Referenced by addTagLink().

BaseTags::cleanTag tag  )  [static]
 

this function cleans a tag for insertion into a database.

spaces and whitespace will be replaced with underscores, and any non-alphanumeric characters will be removed.

Parameters:
the tag to be cleaned.
Returns:
the tag cleaned

Definition at line 154 of file base-tags.inc.php.

BaseTags::delete  ) 
 

Definition at line 310 of file base-tags.inc.php.

References dbExecute().

BaseTags::deleteTag tag  ) 
 

this function deletes a tag from the database

Parameters:
the tag to delete
Returns:
the number of rows affected

Definition at line 232 of file base-tags.inc.php.

References dbExecute().

BaseTags::drawMainPage  ) 
 

this draws a paragraph of the popular tags.

Reimplemented from BaseModule.

Definition at line 140 of file base-tags.inc.php.

References getWeightedPopularTagsList().

BaseTags::drawRelatedTags  ) 
 

draws the tags related to a tag

Definition at line 121 of file base-tags.inc.php.

References getRelatedTagsList().

Referenced by drawViewPage().

BaseTags::drawViewPage  ) 
 

here we draw it.

provided by default is the list of related tags.

Definition at line 113 of file base-tags.inc.php.

References drawRelatedTags().

BaseTags::findTag tag  ) 
 

here we are looking to see if a tag exists.

Parameters:
the tag to search for.
Returns:
the id of the tag if found, false if not.

Definition at line 254 of file base-tags.inc.php.

References dbFetchAssoc(), dbGetNumRows(), and dbQuery().

Referenced by addTag(), getRelatedTags(), initViewPage(), and removeTagLink().

BaseTags::getCreateTableSql  ) 
 

gets the table creation sql for the tags

Returns:
the create table sql statement(s)

Reimplemented from BaseModule.

Definition at line 808 of file base-tags.inc.php.

BaseTags::getFormPopularCloud  )  [protected]
 

this function is for our tag form.

it shows popular tags that are clickable and when clicked will add them to the form.

Returns:
a html string of tags that add themselves to the tag form when clicked.

Definition at line 748 of file base-tags.inc.php.

References getPopularTags(), and getTags().

BaseTags::getJoinerFieldsArray  ) 
 

get an array of fields in the table that joins tags to objects

Returns:
an array of field definitions with keys that are the same as the field name.

Definition at line 856 of file base-tags.inc.php.

BaseTags::getJoinerIndexesArray  ) 
 

get an array of indexes on fields in the table that joins tags to objects

Returns:
a keyed array with keys as the field/index name and values as the index creation sql.

Definition at line 871 of file base-tags.inc.php.

BaseTags::getLinkedTags tags  ) 
 

this function links up our tags to their view pages.

Parameters:
$tags an array of tags
Returns:
an array of tags linked to their view page.

Definition at line 692 of file base-tags.inc.php.

References BaseModule::getLink().

Referenced by getPopularTagsList(), getRelatedTagsList(), getTagList(), and getWeightedPopularTagsList().

BaseTags::getObjectsSql tagId  ) 
 

this function gets the ids of all the objects with a certain tag.

Parameters:
$tagId the tag id to search on
Returns:
the string used to get all our objects.

Definition at line 349 of file base-tags.inc.php.

Referenced by getRelatedTags().

BaseTags::getPagesXml  ) 
 

get our xml...

see BaseModule::getPagesXml() for more info.

Returns:
the xml page string.

Reimplemented from BaseModule.

Definition at line 83 of file base-tags.inc.php.

BaseTags::getPopularFieldParams  )  [protected]
 

this function gets the parameters for our popular tag field.

it is a labelfield that has our popular tags as javascript that adds them to the tag field.

Returns:
an array of parameters for the LabelField

Definition at line 501 of file base-tags.inc.php.

BaseTags::getPopularTags count = 30  ) 
 

this function gets a list of popular tags for use in a tag cloud or whatnot.

Parameters:
$count the number of tags to get. default 30
Returns:
an array with keys that are our tags, and values which are the counts of tag occurrence

Definition at line 367 of file base-tags.inc.php.

References dbFetchAssoc(), dbQuery(), CacheBot::get(), and CacheBot::set().

Referenced by getFormPopularCloud(), getPopularTagsList(), and getWeightedPopularTagsList().

BaseTags::getPopularTagsList count = 60  ) 
 

this gets a list of all the popular tags.

Parameters:
$count the number of tags to get
Returns:
an html string with tags linked to their view pages.

Definition at line 412 of file base-tags.inc.php.

References getLinkedTags(), and getPopularTags().

BaseTags::getPrettyTags  ) 
 

gets an array of tags for our object, except formated for humans

Returns:
an array of pretty tags

Definition at line 332 of file base-tags.inc.php.

References getTags().

BaseTags::getRelatedTags tag  ) 
 

this function gets tags that are related to a tag.

that is, other tags that objects with this tag are related to.

Parameters:
$tag the tag to search on.
Returns:
an array of tags.

Definition at line 638 of file base-tags.inc.php.

References dbFetchAssoc(), dbQuery(), findTag(), CacheBot::get(), getObjectsSql(), and CacheBot::set().

Referenced by getRelatedTagsList().

BaseTags::getRelatedTagsList tag  ) 
 

this function gets a list of related tags.

see getRelatedTags() for more info.

Parameters:
$tag the tag to search on.
Returns:
an html string of related tags. linked to their view pages.

Definition at line 732 of file base-tags.inc.php.

References getLinkedTags(), and getRelatedTags().

Referenced by drawRelatedTags().

BaseTags::getTagFieldParams  )  [protected]
 

this function gets the parameters for our tag entry field.

Returns:
an array of parameters for the TextAreaField

Definition at line 482 of file base-tags.inc.php.

BaseTags::getTagFieldsArray  ) 
 

get an array of fields in the table that stores the tags.

Returns:
an array of field definitions with keys that are the same as the field name.

Definition at line 826 of file base-tags.inc.php.

BaseTags::getTagIndexesArray  ) 
 

get an array of indexes on fields in the tag table

Returns:
a keyed array with keys as the field/index name and values as the index creation sql.

Definition at line 841 of file base-tags.inc.php.

BaseTags::getTagList tags = null  ) 
 

this function gets a list of our object's tags.

Parameters:
$tags an array of tags to link. defaults to getTags()
Returns:
a html string of tags each of which link to their view page.

Definition at line 712 of file base-tags.inc.php.

References getLinkedTags(), and getTags().

BaseTags::getTags  ) 
 

this function gets a list of tags that a our object is associated with

Returns:
an array of tag strings

Definition at line 282 of file base-tags.inc.php.

References dbFetchAssoc(), dbQuery(), and getTagsWhere().

Referenced by getFormPopularCloud(), getPrettyTags(), getTagList(), and updateTags().

BaseTags::getTagsWhere  )  [protected]
 

this gets sql code to get tags from the db for a certain object.

Returns:
the sql WHERE code to use to get the tags for an object

Definition at line 322 of file base-tags.inc.php.

Referenced by getTags().

BaseTags::getWeightedPopularTagsList count = 100  ) 
 

this gets a weighted list of all the popular tags.

Parameters:
$count the number of tags to get
Returns:
an html string with tags linked to their view pages.

Definition at line 430 of file base-tags.inc.php.

References getLinkedTags(), and getPopularTags().

Referenced by drawMainPage().

BaseTags::initMainPage  ) 
 

our main page is a cloud of all the cool tags we have.

Reimplemented from BaseModule.

Definition at line 130 of file base-tags.inc.php.

BaseTags::initViewPage  ) 
 

this is our view page...

view info on a tag.

Definition at line 97 of file base-tags.inc.php.

References findTag(), and BaseModule::params().

BaseTags::insertTag tag  )  [protected]
 

this function inserts the tag into the database.

it does the actual insertion.

Parameters:
$tag the tag to be inserted. make sure its clean before its called.
Returns:
the id of the new tag.

Definition at line 210 of file base-tags.inc.php.

References dbExecute().

Referenced by addTag().

BaseTags::prettyTag tag  )  [static]
 

this function takes a database tag and makes it pretty.

aka replaces underscores with spaces

Parameters:
$tag the tag to format
Returns:
the prettified tag

Definition at line 175 of file base-tags.inc.php.

BaseTags::removeTagLink tag  ) 
 

this function removes a tag from our object.

Parameters:
$tag. the tag to be unlinked.

Definition at line 606 of file base-tags.inc.php.

References findTag(), and removeTagLinkDb().

Referenced by updateTags().

BaseTags::removeTagLinkDb tagId  ) 
 

removes the link between our tag and the object in the db

Parameters:
$tagId the id of the tag in the db.

Definition at line 621 of file base-tags.inc.php.

References dbExecute().

Referenced by removeTagLink().

BaseTags::updateTags data  ) 
 

update our object's tags in the database.

Parameters:
$data an array of tags to update.

Definition at line 529 of file base-tags.inc.php.

References addTagLink(), getTags(), and removeTagLink().

Referenced by updateTagsForm().

BaseTags::updateTagsForm form  ) 
 

update our object's tags from a form object

Parameters:
$form the form with our new tag data in it.

Definition at line 514 of file base-tags.inc.php.

References updateTags().


Member Data Documentation

BaseTags::$cachePopularTags = true [static]
 

do we cache our array of popular tags?

Definition at line 33 of file base-tags.inc.php.

BaseTags::$cacheRelatedTags = true [static]
 

do we cache our array of related tags?

Definition at line 43 of file base-tags.inc.php.

BaseTags::$joinerTable [protected]
 

protected this is the table we use to store relations between tags and objects.

Definition at line 18 of file base-tags.inc.php.

BaseTags::$objectId = 0
 

the id of the object we're associating with.

Definition at line 28 of file base-tags.inc.php.

BaseTags::$plural
 

plural form of the word of what the tags are...

Definition at line 23 of file base-tags.inc.php.

BaseTags::$popularTagsCacheLife = 3600 [static]
 

how long do we cache our popular tags for?

Definition at line 38 of file base-tags.inc.php.

BaseTags::$relatedTagsCacheLife = 3600 [static]
 

how long do we cache our related tags for?

Definition at line 48 of file base-tags.inc.php.

BaseTags::$tagTable [protected]
 

protected this is the table where we store our tags.

Definition at line 13 of file base-tags.inc.php.

BaseTags::$weightStyles [static]
 

Initial value:

 array(
        'font-size: 35px;',
        'font-size: 25px;',
        'font-size: 20px;', 
        'font-side: 16px;',
        'font-size: 11px;'
    )
our styles for the weighted tags page

Definition at line 53 of file base-tags.inc.php.


The documentation for this class was generated from the following file:
Generated on Fri Oct 27 12:26:41 2006 for BaseJumper by doxygen 1.3.9.1