CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Classification Class Reference

Metadata type representing hierarchical ("Tree") controlled vocabulary values. More...

Inheritance diagram for Classification:
[legend]
Collaboration diagram for Classification:
[legend]

## Public Member Functions
| Id ()
| Get Classification ID. More...
| FullName ()
| Get full classification name (all segments). More...
| Name ($NewValue=DB_NOVALUE)
| Get full classification name (all segments). More...
| VariantName ()
| Get variant name of classification, if any. More...
| Depth ()
| Get depth of classification in hierarchy. More...
| ResourceCount ()
| Get number of released resources having this classification assigned to them. More...
| FullResourceCount ()
| Get number of all resources (minus temporary ones) having this classification assigned to them. More...
| ParentId ()
| Get ID of parent Classification. More...
| SegmentName ($NewValue=DB_NOVALUE)
| Get or set the segment name. More...
| LinkString ($NewValue=DB_NOVALUE)
| Get or set the stored link string for the Classification. More...
| QualifierId ($NewValue=DB_NOVALUE)
| Get or set the Qualifier associated with the Classification by ID. More...
| FieldId ($NewValue=DB_NOVALUE)
| Get or set the ID of the MetadataField for the Classification. More...
| Qualifier ($NewValue=DB_NOVALUE)
| Get or set the Qualifier associated with the Classification. More...
| RecalcDepthAndFullName ()
| Rebuild classification full name and recalculate depth in hierarchy. More...
| UpdateLastAssigned ()
| Update the LastAssigned timestamp for this classification. More...
| RecalcResourceCount ($IdsToSkip=NULL)
| Recalculate number of resources assigned to class and any parent classes. More...
| ChildCount ()
| Get number of classifications that have this Classification as their direct parent. More...
| ChildList ()
| Get list of IDs of Classifications that have this class as an "ancestor" (parent, grandparent, great-grandparent, etc). More...
| Delete ($DeleteParents=FALSE, $DeleteIfHasResources=FALSE, $DeleteIfHasChildren=FALSE)
| Remove Classification (and accompanying associations) from database. More...
Public Member Functions inherited from Item
| __construct ($Id)
| Constructor, used to load existing items. More...
| Destroy ()
| Destroy item. More...
| Delete ()
| Destroy item. More...
| Id ()
| Get item ID. More...
| Name ($NewValue=DB_NOVALUE)
| Get/set name of item. More...
| DateCreated ($NewValue=DB_NOVALUE)
| Get/set when item was created. More...
| CreatedBy ($NewValue=DB_NOVALUE)
| Get/set ID of user who created the item. More...
| DateLastModified ($NewValue=DB_NOVALUE)
| Get/set when item was last modified. More...
| LastModifiedBy ($NewValue=DB_NOVALUE)
| Get/set ID of user who last modified the item. More...

## Static Public Member Functions
static | Create ($Name, $FieldId, $ParentId=NULL)
| Add new classification to the hierarchy. More...
static | SegmentsCreated ()
| Get number of new segments (Classifications) generated when creating a new Classification with a full name. More...
Static Public Member Functions inherited from Item
static | GetCanonicalId ($Id)
| Normalize item ID to canonical form. More...
static | ItemExists ($Id)
| Check whether an item exists with the specified ID. More...

## Public Attributes
const | NOPARENT = -1
| Parent value for classifications with no parent. More...
Public Attributes inherited from Item
const | NO_ITEM = -2123456789
| ID value used to indicate no item. More...

## Additional Inherited Members
Protected Member Functions inherited from Item
| UpdateValue ($ColumnName, $NewValue=DB_NOVALUE)
| Convenience function to supply parameters to Database::UpdateValue(). More...
| UpdateDateValue ($ColumnName, $NewValue=DB_NOVALUE)
| Convenience function to supply parameters to Database::UpdateValue(), with preprocessing of new values to convert them into an SQL-compatible date format. More...
Static Protected Member Functions inherited from Item
static | CreateWithValues ($Values)
| Create a new item, using specified initial database values. More...
static | SetDatabaseAccessValues ($ClassName)
| Set the database access values (table name, ID column name, name column name) for specified class. More...
Protected Attributes inherited from Item
| $DB
| $Id
| $ItemIdColumnName
| $ItemNameColumnName
| $ItemTableName
| $ValueCache = array()
Static Protected Attributes inherited from Item
static | $ItemIdColumnNames
static | $ItemNameColumnNames
static | $ItemTableNames

## Detailed Description

Metadata type representing hierarchical ("Tree") controlled vocabulary values.

Definition at line 13 of file Classification.php.

## Member Function Documentation

Classification::ChildCount | ( |  | ) |

Get number of classifications that have this Classification as their direct parent.

Returns
  Count of child Classifications.

Definition at line 505 of file Classification.php.

References Id().

Referenced by Delete().

Here is the caller graph for this function:

Classification::ChildList | ( |  | ) |

Get list of IDs of Classifications that have this class as an "ancestor" (parent, grandparent, great-grandparent, etc).

Returns
  Array of child/grandchild/etc Classification IDs.

Definition at line 519 of file Classification.php.

References Id().

static Classification::Create | ( |  | $Name,
|  |  | $FieldId,
|  |  | $ParentId = `NULL`
| ) |  |
| static

Add new classification to the hierarchy.

Parameters

  string | $Name | Full name or segment name for new Classification. Segment name can be used if a parent ID is also supplied, otherwise full name is assumed.
  int | $FieldId | MetadataField ID for new Classification.
  int | $ParentId | ID of parent in hierachy of for new Classification. Use Classification::NOPARENT for new Classification with no parent (i.e. at top level of hierarchy). (OPTIONAL - only required if full classification name is not supplied)

Definition at line 31 of file Classification.php.

References Item\$DB.

Referenced by MetadataField\Drop(), ResourceFactory\ImportResourcesFromXmlFile(), Resource_Test\setUpBeforeClass(), and Classification_Test\testClassification().

Here is the caller graph for this function:

Classification::Delete | ( |  | $DeleteParents = `FALSE`,
|  |  | $DeleteIfHasResources = `FALSE`,
|  |  | $DeleteIfHasChildren = `FALSE`
| ) |  |

Remove Classification (and accompanying associations) from database.

Parameters

  bool | $DeleteParents | Flag indicating whether to also delete Classification entries above this one in the hierarchy. (OPTIONAL defaults to FALSE)
  bool | $DeleteIfHasResources | Flag indicating whether to delete the Classification if it still has Resources associated with it. (OPTIONAL - defaults to FALSE)
  bool | $DeleteIfHasChildren | Flag indicating whether to delete the Classification if others have it as a parent. (OPTIONAL - defaults to FALSE)

Returns
  int Number of classifications deleted.

Definition at line 553 of file Classification.php.

References ChildCount(), Id(), RecalcResourceCount(), and ResourceCount().

Classification::Depth | ( |  | ) |

Get depth of classification in hierarchy.

Top level is depth of 0.

Returns
  Depth in hierarchy.

Definition at line 233 of file Classification.php.

Classification::FieldId | ( |  | $NewValue = `DB_NOVALUE` | ) |

Get or set the ID of the MetadataField for the Classification.

Parameters

  int | $NewValue | ID of new MetadataField.

Returns
  ID of currently associated MetadataField.

Definition at line 315 of file Classification.php.

References Item\UpdateValue().

Classification::FullName | ( |  | ) |

Get full classification name (all segments).

Returns
  Classification name.

Definition at line 200 of file Classification.php.

Referenced by Name(), and ClassificationFactory\PruneClassificationsToTopLevel().

Here is the caller graph for this function:

Classification::FullResourceCount | ( |  | ) |

Get number of all resources (minus temporary ones) having this classification assigned to them.

This is only updated by RecalcResourceCount() and Delete().

Returns
  Count of all resources having this classification.

Definition at line 254 of file Classification.php.

Classification::Id | ( |  | ) |

Get Classification ID.

Returns
  Numerical Classification ID.

Definition at line 191 of file Classification.php.

References Item\$Id.

Referenced by ChildCount(), ChildList(), Delete(), RecalcDepthAndFullName(), RecalcResourceCount(), and UpdateLastAssigned().

Here is the caller graph for this function:

Classification::LinkString | ( |  | $NewValue = `DB_NOVALUE` | ) |

Get or set the stored link string for the Classification.

(This value is not used, updated, or manipulated in any way by Classification, and is only being stored as a UI optimization.)

Parameters

  string | $NewValue | New link string.

Returns
  Current link string.

Definition at line 294 of file Classification.php.

References Item\UpdateValue().

Classification::Name | ( |  | $NewValue = `DB_NOVALUE` | ) |

Get full classification name (all segments).

Parameters

  string | $NewValue | Argument for compatibility with parent class. (DO NOT USE)

Returns
  Segment name.

Definition at line 211 of file Classification.php.

References DB_NOVALUE, and FullName().

Classification::ParentId | ( |  | ) |

Get ID of parent Classification.

Returns Classification::NOPARENT if no parent (i.e. Classification is at top level of hierarchy).

Definition at line 272 of file Classification.php.

Classification::Qualifier | ( |  | $NewValue = `DB_NOVALUE` | ) |

Get or set the Qualifier associated with the Classification.

Parameters

  Qualifier | $NewValue | New Qualifier.

Returns
  Associated Qualifier (object) or NULL if no qualifier.

See also
  Classification::QualifierId()

Definition at line 326 of file Classification.php.

References DB_NOVALUE, Item\ItemExists(), and QualifierId().

Classification::QualifierId | ( |  | $NewValue = `DB_NOVALUE` | ) |

Get or set the Qualifier associated with the Classification by ID.

Parameters

  int | null | $NewValue | ID of new Qualifier or NULL if no qualifier.

Returns
  ID of current Qualifier.

See also
  Classifiaction::Qualifier()

Definition at line 305 of file Classification.php.

References Item\UpdateValue().

Referenced by Qualifier().

Here is the caller graph for this function:

Classification::RecalcDepthAndFullName | ( |  | ) |

Rebuild classification full name and recalculate depth in hierarchy.

This is a DB-intensive and recursive function, and so should not be called without some forethought.

Definition at line 362 of file Classification.php.

References Id(), and Item\UpdateValue().

Classification::RecalcResourceCount | ( |  | $IdsToSkip = `NULL` | ) |

Recalculate number of resources assigned to class and any parent classes.

This is a DB-intensive and recursive function, and so should not be called without some forethought.

Parameters

  array | $IdsToSkip | Classification IDs to skip during recalculation. (OPTIONAL)

Returns
  Array of IDs of the Classifications that were updated.

Definition at line 421 of file Classification.php.

References Item\$Id, User\GetAnonymousUser(), Id(), and Item\UpdateValue().

Referenced by Delete().

Here is the caller graph for this function:

Classification::ResourceCount | ( |  | ) |

Get number of released resources having this classification assigned to them.

This is only updated by RecalcResourceCount() and Delete().

Returns
  Count of released resources having this classification.

Definition at line 243 of file Classification.php.

Referenced by Delete().

Here is the caller graph for this function:

Classification::SegmentName | ( |  | $NewValue = `DB_NOVALUE` | ) |

Get or set the segment name.

Parameters

  string | $NewValue | New segment name. (OPTIONAL)

Returns
  Segment name.

Definition at line 282 of file Classification.php.

References Item\UpdateValue().

static Classification::SegmentsCreated | ( |  | ) |
| static

Get number of new segments (Classifications) generated when creating a new Classification with a full name.

Definition at line 263 of file Classification.php.

Referenced by Classification_Test\testClassification().

Here is the caller graph for this function:

Classification::UpdateLastAssigned | ( |  | ) |

Update the LastAssigned timestamp for this classification.

Definition at line 408 of file Classification.php.

References Id().

Classification::VariantName | ( |  | ) |

Get variant name of classification, if any.

Returns
  Variant name.

Definition at line 224 of file Classification.php.

## Member Data Documentation

const Classification::NOPARENT = -1

Parent value for classifications with no parent.

Definition at line 18 of file Classification.php.

Referenced by Classification_Test\testClassification().

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

- objects/Classification.php