Subversion Repositories travelsized

Rev

Rev 434 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * This file is part of Travelsized CMS
 *              A content management system with modules, based on wiki syntax
 *
 * Author: Dan Jensen <admin@leinir.dk>
 * Copyright 2003/2004
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * The GNU General Public License is available at: http://www.gnu.org/copyleft/
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */


class TagsHandler
{
        var $globalIDs; ///< @var       Array   An  array containing references to instances of TagGlobalID
        var $users;     ///< @var       Array   An array containing references to instances of TagUser
        var $keywords;  ///< @var       Array   An array containing references to instances of TagKeyword
       
        function TagsHandler()
        {
                $this->globalIDs = array();
                $this->users = array();
                $this->keywords = array();
        }
       
        /**
         * Get a reference to the TagGlobalID instance for the specified globalID
         *
         * @param       string  globalID        The globalID to get the reference for
         *
         * @return      TagGlobalID     reference to the TagGlobalID instance
         */

        function & getGlobalID( $globalID )
        {
                if( !array_key_exists( $globalID, $this->globalIDs ) )
                        $this->globalIDs[$globalID] = new TagGlobalID($this, $globalID);
                return $this->globalIDs[$globalID];
        }
       
        /**
         * Get a reference to the TagUser instance for the specified username
         *
         * @param       string  username        The username to get the reference for
         *
         * @return      TagUser reference to the TagUser instance
         */

        function & getUser( $username )
        {
                if( !array_key_exists( $username, $this->users ) )
                        $this->users[$username] = new TagUser($this, $username);
                return $this->users[$username];
        }
       
        /**
         * Get a reference to the TagKeyword instance for the specified keyword
         *
         * @param       string  keyword The keyword to get the reference for
         *
         * @return      TagKeyword      reference to the TagKeyword instance
         */

        function & getKeyword( $keyword )
        {
                if( !array_key_exists( $keyword, $this->keywords ) )
                        $this->keywords[$keyword] = new TagKeyword($this, $keyword);
                return $this->keywords[$keyword];
        }
       
        /**
        * Add an association between globalID, username and keyword
        *
        * @param        string  globalID        The globalID to which you wish to create an association
        * @param        string  username        The username to which you wish to create an association
        * @param        string  keyword The keyword to which you wish to create an association
        *
        * @return       bool    Wether or not the tag was created successfully
        */

        function createTag( $globalID, $username, $keyword )
        {
                $thisID =& $this->getGlobalID($globalID);
                return $thisID->addTag( $username, $keyword );
        }
       
        /**
        * Remove the association between globalID, username and keyword
        *
        * @param        string  globalID        The globalID from which you wish to remove the association
        * @param        string  username        The username from which you wish to remove the association
        * @param        string  keyword The keyword from which you wish to remove the association
        *
        * @return       bool    Wether or not the association between the three items was successfully removed
        */

        function removeTag( $globalID, $username, $keyword )
        {
                $thisID =& $this->getGlobalID($globalID);
                return $thisID->removeTag( $username, $keyword );
        }
}
?>