Public Member Functions | Data Fields

SurveyCategories Class Reference
[Modules/SurveyQuestionPool]

Class SurveyCategories. More...

Public Member Functions

 SurveyCategories ()
 Constructor public.
 getCategoryCount ()
 Returns the number of categories.
 addCategoryAtPosition ($categoryname, $position)
 Adds a category at a given position.
 addCategory ($categoryname)
 Adds a category.
 addCategoryArray ($categories)
 Adds a category array.
 removeCategory ($index)
 Removes a category from the list of categories.
 removeCategories ($array)
 Removes many categories from the list of categories.
 removeCategoryWithName ($name)
 Removes a category from the list of categories.
 getCategory ($index)
 Returns the name of a category for a given index.
 getCategoryIndex ($name)
 Returns the index of a category with a given name.
 flushCategories ()
 Empties the categories list.

Data Fields

 $categories

Detailed Description

Class SurveyCategories.

Author:
Helmut Schottmüller <helmut.schottmueller@mac.com>
Version:
Id:
class.SurveyCategories.php 12484 2006-11-09 10:52:16Z hschottm

Definition at line 35 of file class.SurveyCategories.php.


Member Function Documentation

SurveyCategories::addCategory ( categoryname  ) 

Adds a category.

Adds a category

Parameters:
integer $categoryname The name of the category public
See also:
$categories

Definition at line 103 of file class.SurveyCategories.php.

        {
                array_push($this->categories, $categoryname);
        }

SurveyCategories::addCategoryArray ( categories  ) 

Adds a category array.

Adds a category array

Parameters:
array $categories An array with categories public
See also:
$categories

Definition at line 117 of file class.SurveyCategories.php.

References $categories.

        {
                $this->categories = array_merge($this->categories, $categories);
        }

SurveyCategories::addCategoryAtPosition ( categoryname,
position 
)

Adds a category at a given position.

Adds a category at a given position

Parameters:
string $categoryname The name of the category
integer $position The position of the category (starting with index 0) public
See also:
$categories

Definition at line 80 of file class.SurveyCategories.php.

        {
                if (array_key_exists($position, $this->categories))
                {
                        $head = array_slice($this->categories, 0, $position);
                        $tail = array_slice($this->categories, $position);
                        $this->categories = array_merge($head, array($categoryname), $tail);
                }
                else
                {
                        array_push($this->categories, $categoryname);
                }
        }

SurveyCategories::flushCategories (  ) 

Empties the categories list.

Empties the categories list

public

See also:
$categories

Definition at line 215 of file class.SurveyCategories.php.

        {
                $this->categories = array();
        }

SurveyCategories::getCategory ( index  ) 

Returns the name of a category for a given index.

Returns the name of a category for a given index

Parameters:
integer $index The index of the category
Returns:
string Category name public
See also:
$categories

Definition at line 180 of file class.SurveyCategories.php.

        {
                if (array_key_exists($index, $this->categories))
                {
                        return $this->categories[$index];
                }
                else
                {
                        return "";
                }
        }

SurveyCategories::getCategoryCount (  ) 

Returns the number of categories.

Returns the number of categories

Returns:
integer The number of contained categories public
See also:
$categories

Definition at line 65 of file class.SurveyCategories.php.

        {
                return count($this->categories);
        }

SurveyCategories::getCategoryIndex ( name  ) 

Returns the index of a category with a given name.

Returns the index of a category with a given name.

Parameters:
string $name The name of the category public
See also:
$categories

Definition at line 201 of file class.SurveyCategories.php.

        {
                return array_search($name, $this->categories);
        }

SurveyCategories::removeCategories ( array  ) 

Removes many categories from the list of categories.

Removes many categories from the list of categories

Parameters:
array $array An array containing the index positions of the categories to be removed public
See also:
$categories

Definition at line 146 of file class.SurveyCategories.php.

        {
                foreach ($array as $index)
                {
                        unset($this->categories[$index]);
                }
                $this->categories = array_values($this->categories);
        }

SurveyCategories::removeCategory ( index  ) 

Removes a category from the list of categories.

Removes a category from the list of categories

Parameters:
integer $index The index of the category to be removed public
See also:
$categories

Definition at line 131 of file class.SurveyCategories.php.

Referenced by removeCategoryWithName().

        {
                unset($this->categories[$index]);
                $this->categories = array_values($this->categories);
        }

Here is the caller graph for this function:

SurveyCategories::removeCategoryWithName ( name  ) 

Removes a category from the list of categories.

Removes a category from the list of categories

Parameters:
string $name The name of the category to be removed public
See also:
$categories

Definition at line 164 of file class.SurveyCategories.php.

References removeCategory().

        {
                $index = array_search($name, $this->categories);
                $this->removeCategory($index);
        }

Here is the call graph for this function:

SurveyCategories::SurveyCategories (  ) 

Constructor public.

Definition at line 51 of file class.SurveyCategories.php.

        {
                $this->categories = array();
        }


Field Documentation

SurveyCategories::$categories

Definition at line 45 of file class.SurveyCategories.php.

Referenced by addCategoryArray().


The documentation for this class was generated from the following file: