Zikula: A Flexible Open Source Content Management System
home | forum | international support | contact us

Docs For Class CategoryUtil

Class: CategoryUtil

Source Location: /pnobjlib/CategoryUtil.class.php

Class Overview


CategoryUtil

Methods


Inherited Variables

Inherited Methods


Class Details

[line 19] CategoryUtil



[ Top ]

Class Methods


method buildPaths [line 1170]

The buildPaths( cats $cats, [field $field = 'name'])

Given an array of categories (with the category-IDs being the keys of the array), return an (idenically indexed) array of category-paths based on the given field (name or id make sense)



Tags:

return:  resulting folder path array


Parameters:

cats   $cats   The associative categories object array
field   $field   Which field to use the building the path (optional) (default='name')

[ Top ]

method buildRelativePaths [line 1091]

The buildRelativePaths( rootCatIDs $rootCatIDs, cats &$cats, [includeRoot $includeRoot = false])

Given an array of categories (with the Property-Names being

the keys of the array) and it corresponding Parent categories (indexed with the Property-Names too), return an (identically indexed) array of category-paths based on the given field (name or id make sense)




Tags:

return:  resulting folder path array (which is also altered in place)


Parameters:

rootCatIDs   $rootCatIDs   The root/parent categories ID
cats   &$cats   The associative categories object array
includeRoot   $includeRoot   If true, the root portion of the path is preserved

[ Top ]

method buildRelativePathsForCategory [line 1119]

The buildRelativePathsForCategory( rootCategory $rootCategory, cat &$cat, [includeRoot $includeRoot = false])

Given a category with its parent category, return an (idenically indexed) array of category-paths based on the given field (name or id make sense)



Tags:

return:  resulting folder path array (which is also altered in place)


Parameters:

rootCategory   $rootCategory   The root/parent category
cat   &$cat   The category to process
includeRoot   $includeRoot   If true, the root portion of the path is preserved

[ Top ]

method cmpDesc [line 1027]

The cmpDesc( catA $catA, catB $catB)

Compare function for ML description field



Tags:

return:  resulting compare value


Parameters:

catA   $catA   1st category
catB   $catB   2nd category

[ Top ]

method cmpName [line 1003]

The cmpName( catA $catA, catB $catB)

Compare function for ML name field



Tags:

return:  resulting compare value


Parameters:

catA   $catA   1st category
catB   $catB   2nd category

[ Top ]

method copyCategoriesByID [line 617]

true copyCategoriesByID( cid $cid, newparent_id $newparent_id)

Copy categories by ID (recursive copy)



Tags:

return:  or false


Parameters:

cid   $cid   The categoryID we wish to copy
newparent_id   $newparent_id   The categoryID of the new parent category

[ Top ]

method copyCategoriesByPath [line 654]

true copyCategoriesByPath( apath $apath, newparent_id $newparent_id, [field $field = 'ipath'], [includeRoot $includeRoot = true])

Copy Categories by Path (recurisve copy)



Tags:

return:  or false


Parameters:

apath   $apath   The path to copy from
newparent_id   $newparent_id   The categoryID of the new parent category
field   $field   The field to use for the path reference (optional) (default='ipath')
includeRoot   $includeRoot   whether or not to also move the root folder (optional) (default=true)

[ Top ]

method copySubCategoriesByPath [line 638]

true copySubCategoriesByPath( apath $apath, newparent_id $newparent_id, [field $field = 'ipath'])

Copy SubCategories by Path (recurisve copy)



Tags:

return:  or false


Parameters:

apath   $apath   The path to copy from
newparent_id   $newparent_id   The categoryID of the new parent category
field   $field   The field to use for the path reference (optional) (default='ipath')

[ Top ]

method deleteCategoriesByPath [line 490]

The deleteCategoriesByPath( apath $apath, [field $field = 'ipath'])

Delete categories by Path



Tags:

return:  DB result set


Parameters:

apath   $apath   The path we wish to delete
field   $field   The (path) field we delete from (either path or ipath) (optional) (default='ipath')

[ Top ]

method deleteCategoryByID [line 467]

The deleteCategoryByID( cid $cid)

Delete a category by it's ID



Tags:

return:  DB result set


Parameters:

cid   $cid   The categoryID to delete

[ Top ]

method getCategories [line 69]

The getCategories( [where $where = ''], [sort $sort = ''], [assocKey $assocKey = ''], [ $enablePermissionFilter = true])

Return an array of categories objects according the specified where-clause and sort criteria.



Tags:

return:  resulting folder object array


Parameters:

where   $where   The where clause to use in the select (optional) (default='')
sort   $sort   The order-by clause to use in the select (optional) (default='')
assocKey   $assocKey   The field to use as the associated array key (optional) (default='')
   $enablePermissionFilter  

[ Top ]

method getCategoriesByParentID [line 192]

The getCategoriesByParentID( id $id, [sort $sort = ''], [relative $relative = false], [all $all = false], [assocKey $assocKey = ''], [attributes $attributes = null])

Return the direct subcategories of the specified category



Tags:

return:  resulting folder object


Parameters:

id   $id   The folder id to retrieve
sort   $sort   The order-by clause (optional) (default='')
relative   $relative   whether or not to also generate relative paths (optional) (default=false)
all   $all   whether or not to return all (or only active) categories (optional) (default=false)
assocKey   $assocKey   The field to use as the associated array key (optional) (default='')
attributes   $attributes   The associative array of attribute field names to filter by (optional) (default=null)

[ Top ]

method getCategoriesByPath [line 279]

The getCategoriesByPath( apath $apath, [sort $sort = ''], [field $field = 'ipath'], [includeLeaf $includeLeaf = true], [all $all = false], [exclPath $exclPath = ''], [assocKey $assocKey = ''], [attributes $attributes = null])

Return an array of category objects by path without the root category



Tags:

return:  resulting folder object array


Parameters:

apath   $apath   The path to retrieve categories by
sort   $sort   The sort field (optional) (default='')
field   $field   The the (path) field to use (path or ipath) (optional) (default='ipath')
includeLeaf   $includeLeaf   whether or not to also return leaf nodes (optional) (default=true)
all   $all   whether or not to return all (or only active) categories (optional) (default=false)
exclPath   $exclPath   The path to exclude from the retrieved categories (optional) (default='')
assocKey   $assocKey   The field to use to build an associative key (optional) (default='')
attributes   $attributes   The associative array of attribute field names to filter by (optional) (default=null)

[ Top ]

method getCategoriesByRegistry [line 151]

The getCategoriesByRegistry( registry $registry)

Return an array of categories by the registry info



Tags:

return:  resulting folder object array


Parameters:

registry   $registry   The registered categories to retrieve

[ Top ]

method getCategoryByID [line 28]

The getCategoryByID( cid $cid)

Return a category object by ID



Tags:

return:  resulting folder object


Parameters:

cid   $cid   The category-ID to retrieve

[ Top ]

method getCategoryByPath [line 120]

The getCategoryByPath( apath $apath, [field $field = 'path'])

Return a folder object by it's path



Tags:

return:  resulting folder object


Parameters:

apath   $apath   The path to retrieve by (simple path or array of paths)
field   $field   The (path) field we search for (either path or ipath) (optional) (default='path')

[ Top ]

method getCategoryTreeJS [line 815]

generated getCategoryTreeJS( cats $cats, [doReplaceRootCat $doReplaceRootCat = true])

Get the java-script for the tree menu



Tags:

return:  tree JS text


Parameters:

cats   $cats   The categories array to represent in the tree
doReplaceRootCat   $doReplaceRootCat   Whether or not to replace the root category with a localized string (optional) (default=true)

[ Top ]

method getCategoryTreeStructure [line 842]

The getCategoryTreeStructure( cats $cats)

Return an array of folders the user has at least access/view rights to.



Tags:

return:  resulting folder path array


Parameters:

cats   $cats   The username we wish to get the folder list for

[ Top ]

method getParentCategories [line 237]

The getParentCategories( id $id, [assocKey $assocKey = 'id'])

Return all parent categories starting from id



Tags:

return:  resulting folder object array


Parameters:

id   $id   The (leaf) folder id to retrieve
assocKey   $assocKey   whether or not to return an assocKeyiative array (optional) (default='id')

[ Top ]

method getSelector_Categories [line 905]

The getSelector_Categories( cats $cats, [field $field = 'id'], [selected $selectedValue = '0'], [name $name = 'category[parent_id]'], defaultValue $defaultValue, [defaultText $defaultText = ''], allValue $allValue, [allText $allText = ''], [submit $submit = false], [displayPath $displayPath = false], [doReplaceRootCat $doReplaceRootCat = true], [multipleSize $multipleSize = 1], [ $fieldIsAttribute = false])

Return the HTML selector code for the given category hierarchy



Tags:

return:  HTML selector code for the given category hierarchy


Parameters:

cats   $cats   The category hierarchy to generate a HTML selector for
field   $field   The field value to return (optional) (default='id')
selected   $selectedValue   The selected category (optional) (default=0)
name   $name   The name of the selector field to generate (optional) (default='category[parent_id]')
defaultValue   $defaultValue   The default value to present to the user (optional) (default=0)
defaultText   $defaultText   The default text to present to the user (optional) (default='')
allValue   $allValue   The value to assign to the "all" option (optional) (default=0)
allText   $allText   The text to assign to the "all" option (optional) (default='')
submit   $submit   whether or not to submit the form upon change (optional) (default=false)
displayPath   $displayPath   If false, the path is simulated, if true, the full path is shown (optional) (default=false)
doReplaceRootCat   $doReplaceRootCat   Whether or not to replace the root category with a localized string (optional) (default=true)
multipleSize   $multipleSize   If > 1, a multiple selector box is built, otherwise a normal/single selector box is build (optional) (default=1)
   $fieldIsAttribute  

[ Top ]

method getSubCategories [line 329]

The getSubCategories( cid $cid, [recurse $recurse = true], [relative $relative = true], [includeRoot $includeRoot = false], [includeLeaf $includeLeaf = true], [all $all = false], [excludeCid $excludeCid = ''], [assocKey $assocKey = ''], [attributes $attributes = null])

Return an array of Subcategories for the specified folder



Tags:

return:  resulting folder object array


Parameters:

cid   $cid   The root-category category-id
recurse   $recurse   whether or not to generate a recursive subcategory result set (optional) (default=true)
relative   $relative   whether or not to generate relative path indexes (optional) (default=true)
includeRoot   $includeRoot   whether or not to include the root folder in the result set (optional) (default=false)
includeLeaf   $includeLeaf   whether or not to also return leaf nodes (optional) (default=true)
all   $all   whether or not to include all (or only active) folders in the result set (optional) (default=false)
excludeCid   $excludeCid   CategoryID (root folder) to exclude from the result set (optional) (default='')
assocKey   $assocKey   The field to use as the associated array key (optional) (default='')
attributes   $attributes   The associative array of attribute field names to filter by (optional) (default=null)

[ Top ]

method getSubCategoriesByPath [line 374]

The getSubCategoriesByPath( apath $apath, [field $field = 'ipath'], [recurse $recurse = true], [relative $relative = true], [includeRoot $includeRoot = false], [includeLeaf $includeLeaf = true], [all $all = false], [excludeCid $excludeCid = ''], [assocKey $assocKey = ''], [attributes $attributes = null])

Return an array of Subcategories for the specified folder



Tags:

return:  resulting folder object array


Parameters:

apath   $apath   The path to get categories by
field   $field   The (path) field we match by (either path or ipath) (optional) (default='ipath')
recurse   $recurse   whether or not to generate a recursive subcategory result set (optional) (default=true)
relative   $relative   whether or not to generate relative path indexes (optional) (default=true)
includeRoot   $includeRoot   whether or not to include the root folder in the result set (optional) (default=false)
includeLeaf   $includeLeaf   whether or not to also return leaf nodes (optional) (default=true)
all   $all   whether or not to include all (or only active) folders in the result set (optional) (default=false)
excludeCid   $excludeCid   CategoryID (root folder) to exclude from the result set (optional) (default='')
assocKey   $assocKey   The field to use as the associated array key (optional) (default='')
attributes   $attributes   The associative array of attribute field names to filter by (optional) (default=null)

[ Top ]

method getSubCategoriesForCategory [line 420]

The getSubCategoriesForCategory( category $category, [recurse $recurse = true], [relative $relative = true], [includeRoot $includeRoot = false], [includeLeaf $includeLeaf = true], [all $all = false], [excludeCat $excludeCat = null], [assocKey $assocKey = ''], [attributes $attributes = null], [sortField $sortField = null])

Return an array of Subcategories by for the given category



Tags:

return:  resulting folder object array


Parameters:

category   $category   The root category to retrieve
recurse   $recurse   whether or not to recruse (if false, only direct subfolders are retrieved) (optional) (default=true)
relative   $relative   whether or not to also generate relative paths (optional) (default=true)
includeRoot   $includeRoot   whether or not to include the root folder in the result set (optional) (default=false)
includeLeaf   $includeLeaf   whether or not to also return leaf nodes (optional) (default=true)
all   $all   whether or not to return all (or only active) categories (optional) (default=false)
excludeCat   $excludeCat   The root category of the hierarchy to exclude from the result set (optional) (default='')
assocKey   $assocKey   The field to use as the associated array key (optional) (default='')
attributes   $attributes   The associative array of attribute field names to filter by (optional) (default=null)
sortField   $sortField   The field to sort the resulting category array by (optional) (default=null)

[ Top ]

method hasCategoryAccess [line 1241]

bool hasCategoryAccess( array $categories, $module, [int $permLevel = ACCESS_OVERVIEW])

Check for access to a certain set of categories

For each category property in the list, check if we have access to that category in that property. Check is done as "Categories:Property:$propertyName", "$cat[id]::"




Tags:

return:  True if access is allowed to at least one of the categories


Parameters:

array   $categories   Array of category data (as returned from ObjectUtil::expandObjectWithCategories).
int   $permLevel   Required permision level.
   $module  

[ Top ]

method haveDirectSubcategories [line 785]

true haveDirectSubcategories( cid $cid, [countOnly $countOnly = false], [all $all = true])

Check whether the category $cid has subcategories (optional checks for leafe )



Tags:

return:  or false


Parameters:

cid   $cid   The parent category
countOnly   $countOnly   whether or not to explicitly check for leaf nodes in the subcategories
all   $all   whether or not to return all (or only active) subcategories

[ Top ]

method isDirectSubCategory [line 728]

true isDirectSubCategory( rootCat $rootCat, cat $cat)

Check whether $cid is a direct subcategory of $root_id



Tags:

return:  or false


Parameters:

rootCat   $rootCat   The root/parent category
cat   $cat   The category we wish to check for subcategory-ness.

[ Top ]

method isDirectSubCategoryByID [line 704]

true isDirectSubCategoryByID( root_id $root_id, cid $cid)

Check whether $cid is a direct subcategory of $root_id



Tags:

return:  or false


Parameters:

root_id   $root_id   The root/parent ID
cid   $cid   The categoryID we wish to check for subcategory-ness.

[ Top ]

method isSubCategory [line 767]

true isSubCategory( rootCat $rootCat, cat $cat)

Check whether $cat is a subcategory of $rootCat



Tags:

return:  or false


Parameters:

rootCat   $rootCat   The root/parent category
cat   $cat   The category we wish to check for subcategory-ness.

[ Top ]

method isSubCategoryByID [line 742]

true isSubCategoryByID( root_id $root_id, cid $cid)

Check whether $cid is a subcategory of $root_id



Tags:

return:  or false


Parameters:

root_id   $root_id   The ID of the root category we wish to check from
cid   $cid   The category-id we wish to check for subcategory-ness.

[ Top ]

method moveCategoriesByID [line 516]

true moveCategoriesByID( cid $cid, newparent_id $newparent_id)

Move categories by ID (recursive move)



Tags:

return:  or false


Parameters:

cid   $cid   The categoryID we wish to move
newparent_id   $newparent_id   The categoryID of the new parent category

[ Top ]

method moveCategoriesByPath [line 558]

true moveCategoriesByPath( apath $apath, newparent_id $newparent_id, [field $field = 'ipath'], [includeRoot $includeRoot = true])

Move Categories by Path (recursive move)



Tags:

return:  or false


Parameters:

apath   $apath   The path to move from
newparent_id   $newparent_id   The categoryID of the new parent category
field   $field   The field to use for the path reference (optional) (default='ipath')
includeRoot   $includeRoot   whether or not to also move the root folder (optional) (default=true)

[ Top ]

method moveSubCategoriesByPath [line 542]

true moveSubCategoriesByPath( apath $apath, newparent_id $newparent_id, [field $field = 'ipath'])

Move SubCategories by Path (recurisve move)



Tags:

return:  or false


Parameters:

apath   $apath   The path to move from
newparent_id   $newparent_id   The categoryID of the new parent category
field   $field   The field to use for the path reference (optional) (default='ipath')

[ Top ]

method rebuildPaths [line 1205]

void rebuildPaths( [field $field = 'path'], [sourceField $sourceField = 'name'], leaf_id $leaf_id)

Rebuild the path field for all categories in the database Note that the





Parameters:

field   $field   The field which we wish to populate (optional) (default='path')
sourceField   $sourceField   The field we use to build the path with (optional) (default='name')
leaf_id   $leaf_id  

The leaf-category category-id (ie: we'll rebuild the path of this category and all it's parents) (optional) (default=0)

Note that field and sourceField go in pairs (that is, if you want sensical results)!


[ Top ]

method resequence [line 1063]

True resequence( cats $cats, [step $step = 1])

Resequence the sort fields for the given category



Tags:

return:  if something was done, false if an emtpy $cats was passed in


Parameters:

cats   $cats   The categories array
step   $step   The counting step/interval (optional) (default=1)

[ Top ]

method sortByLocale [line 1048]

The sortByLocale( cats &$cats, [func $func = 'cmpName'])

Utility function to sort a category array by the current locate of either the ML name or description



Tags:

return:  resulting sorted category array (original array altered in place)


Parameters:

cats   &$cats   The categories array
func   $func   Which compare function to use (determines field to be used for comparison) (optional) (defaylt='cmpName')

[ Top ]

Packages:

Files:

Classes: