ContentOperations
in package
Class for static methods related to content
Tags
Table of Contents
Methods
- CheckAliasError() : string
- Checks to see if a content alias is valid and not in use.
- CheckAliasUsed() : bool
- Check if a content alias is used
- CheckAliasValid() : bool
- Check if a potential alias is valid.
- CheckPageAuthorship() : bool
- Check if the specified user has the ability to edit the specified page id
- CheckPageOwnership() : bool
- Test if the user specified owns the specified page
- CheckParentage() : bool
- Check if the supplied page id is a parent of the specified base page (or the current page)
- CheckPeerAuthorship() : bool
- Test if the specified user account has edit access to all of the peers of the specified page id
- CreateFriendlyHierarchyPosition() : string
- Converts a friendly hierarchy (1.1.1) to an unfriendly hierarchy (00001.00001.00001) for use in the database.
- CreateHierarchyDropdown() : string
- Create a hierarchical ordered dropdown of all the content objects in the system for use in the admin and various modules. If $current or $parent variables are passed, care is taken to make sure that children which could cause a loop are hidden, in cases of when you're creating a dropdown for changing a content object's parent.
- CreateNewContent() : ContentBase
- Creates a new, empty content object of the given type.
- CreateUnfriendlyHierarchyPosition() : string
- Converts an unfriendly hierarchy (00001.00001.00001) to a friendly hierarchy (1.1.1) for use in the database.
- get_instance() : ContentOperations
- Return a reference to the only allowed instance of this singleton object
- GetAllContent() : array<string|int, mixed>
- Returns an array of all content objects in the system, active or not.
- GetAllContentAsHierarchy() : cms_content_tree
- Loads a set of content objects into the cached tree.
- getContentObject() : ContentBase
- Return a content object for the currently requested page.
- GetDefaultContent() : int
- Returns the id of the content marked as default.
- GetDefaultPageID() : int
- Gets the content id of the page marked as default
- GetLastContentModification() : unix
- Get the date of last content modification
- GetOwnedPages() : array<string|int, mixed>
- Return a list of pages that the user is owner of.
- GetPageAccessForUser() : array<string|int, int>
- Return a list of pages that the user has edit access to.
- GetPageAliasFromID() : string
- Returns the content alias given a valid content id.
- GetPageIDFromAlias() : int
- Returns the content id given a valid content alias.
- GetPageIDFromHierarchy() : int
- Returns the content id given a valid hierarchical position.
- ListContentTypes() : array<string|int, mixed>
- Returns a hash of valid content types (classes that extend ContentBase) The key is the name of the class that would be saved into the database. The value would be the text returned by the type's FriendlyName() method.
- LoadAllContent() : mixed
- Load All content in thedatabase into memory Use with caution this can chew up alot of memory on larger sites.
- LoadChildren() : mixed
- Loads additional, active children into a given tree object
- LoadContentFromAlias() : ContentBase
- Given a content alias, load and return the loaded content object.
- LoadContentFromId() : mixed
- Given a content id, load and return the loaded content object.
- LoadContentFromSerializedData() : ContentBase
- Given an array of content_type and seralized_content, reconstructs a content object. It will handled loading the content type if it hasn't already been loaded.
- quickfind_node_by_id() : cms_content_tree
- A convenience function to find a hierarchy node given the page id This method will be moved to cms_content_tree at a later date.
- register_content_type() : mixed
- Register a new content type
- SetAllHierarchyPositions() : mixed
- Updates the hierarchy position of all content items.
- SetDefaultContent() : mixed
- Sets the default content to the given id
Methods
CheckAliasError()
Checks to see if a content alias is valid and not in use.
public
CheckAliasError(string $alias[, int $content_id = -1 ]) : string
Parameters
- $alias : string
-
The content alias to check
- $content_id : int = -1
-
The id of the current page, for used alias checks on existing pages
Return values
string —The error, if any. If there is no error, returns FALSE.
CheckAliasUsed()
Check if a content alias is used
public
CheckAliasUsed(string $alias[, int $content_id = -1 ]) : bool
Parameters
- $alias : string
-
The alias to check
- $content_id : int = -1
-
The id of hte current page, if any
Tags
Return values
boolCheckAliasValid()
Check if a potential alias is valid.
public
CheckAliasValid(string $alias) : bool
Parameters
- $alias : string
-
The alias to check
Tags
Return values
boolCheckPageAuthorship()
Check if the specified user has the ability to edit the specified page id
public
CheckPageAuthorship(int $userid, int $contentid) : bool
Parameters
- $userid : int
- $contentid : int
Return values
boolCheckPageOwnership()
Test if the user specified owns the specified page
public
CheckPageOwnership(int $userid, int $pageid) : bool
Parameters
- $userid : int
- $pageid : int
Return values
boolCheckParentage()
Check if the supplied page id is a parent of the specified base page (or the current page)
public
CheckParentage(int $test_id[, int $base_id = null ]) : bool
Parameters
- $test_id : int
-
Page ID to test
- $base_id : int = null
-
(optional) Page ID to act as the base page. The current page is used if not specified.
Tags
Return values
boolCheckPeerAuthorship()
Test if the specified user account has edit access to all of the peers of the specified page id
public
CheckPeerAuthorship(int $userid, int $contentid) : bool
Parameters
- $userid : int
- $contentid : int
Return values
boolCreateFriendlyHierarchyPosition()
Converts a friendly hierarchy (1.1.1) to an unfriendly hierarchy (00001.00001.00001) for use in the database.
public
CreateFriendlyHierarchyPosition(string $position) : string
Parameters
- $position : string
-
The hierarchy position to convert
Return values
string —The unfriendly version of the hierarchy string
CreateHierarchyDropdown()
Create a hierarchical ordered dropdown of all the content objects in the system for use in the admin and various modules. If $current or $parent variables are passed, care is taken to make sure that children which could cause a loop are hidden, in cases of when you're creating a dropdown for changing a content object's parent.
public
CreateHierarchyDropdown([int $current = '' ][, int $value = '' ][, string $name = 'parent_id' ][, bool $allowcurrent = 0 ][, bool $use_perms = 0 ][, bool $ignore_current = 0 ][, bool $allow_all = false ][, bool $for_child = false ]) : string
This method was rewritten for 2.0 to use the jquery hierselector plugin to better accommodate larger websites.
Since many parameters are now ignored, A new method needs to be writtent o replace this archaic method... so consider this method to be deprecateed.
Parameters
- $current : int = ''
-
The id of the content object we are working with. Used with allowcurrent to not show children of the current conrent object, or itself.
- $value : int = ''
-
The id of the currently selected content object.
- $name : string = 'parent_id'
-
The html name of the dropdown.
- $allowcurrent : bool = 0
-
Ensures that the current value cannot be selected, or $current and it's childrern. Used to prevent circular deadlocks.
- $use_perms : bool = 0
-
If true, checks authorship permissions on pages and only shows those the current user has authorship of (can edit)
- $ignore_current : bool = 0
-
(ignored as of 2.0) (Before 2.2 this parameter was called ignore_current and
- $allow_all : bool = false
-
If true, show all items, even if the content object doesn't have a valid link. Defaults to false.
- $for_child : bool = false
-
If true, assume that we want to add a new child and obey the WantsChildren flag of each content page. (new in 2.2).
Return values
string —The html dropdown of the hierarchy.
CreateNewContent()
Creates a new, empty content object of the given type.
public
CreateNewContent(mixed $type) : ContentBase
if the content type is registered with the system, and the class does not exist, the appropriate filename will be included and then, if possible a new object of the designated type will be instantiated.
Parameters
- $type : mixed
-
The type. Either a string, or an instance of CmsContentTypePlaceHolder
Return values
ContentBase —(A valid object derived from ContentBase)
CreateUnfriendlyHierarchyPosition()
Converts an unfriendly hierarchy (00001.00001.00001) to a friendly hierarchy (1.1.1) for use in the database.
public
CreateUnfriendlyHierarchyPosition(string $position) : string
Parameters
- $position : string
-
The hierarchy position to convert
Return values
string —The friendly version of the hierarchy string
get_instance()
Return a reference to the only allowed instance of this singleton object
public
static get_instance() : ContentOperations
Return values
ContentOperationsGetAllContent()
Returns an array of all content objects in the system, active or not.
public
& GetAllContent([bool $loadprops = true ]) : array<string|int, mixed>
Caution: it is entirely possible that this method (and other similar methods of loading content) will result in a memory outage if there are large amounts of content objects AND/OR large amounts of content properties. Use with caution.
Parameters
- $loadprops : bool = true
-
Not implemented
Return values
array<string|int, mixed> —The array of content objects
GetAllContentAsHierarchy()
Loads a set of content objects into the cached tree.
public
& GetAllContentAsHierarchy([bool $loadcontent = false ]) : cms_content_tree
Parameters
- $loadcontent : bool = false
-
If false, only create the nodes in the tree, don't load the content objects
Return values
cms_content_tree —The cached tree of content
getContentObject()
Return a content object for the currently requested page.
public
getContentObject() : ContentBase
Tags
Return values
ContentBaseGetDefaultContent()
Returns the id of the content marked as default.
public
GetDefaultContent() : int
Return values
int —The id of the default content page
GetDefaultPageID()
Gets the content id of the page marked as default
public
GetDefaultPageID() : int
Return values
int —The id of the default page. false if not found.
GetLastContentModification()
Get the date of last content modification
public
GetLastContentModification() : unix
Tags
Return values
unix —timestamp representing the last time a content page was modified.
GetOwnedPages()
Return a list of pages that the user is owner of.
public
GetOwnedPages(int $userid) : array<string|int, mixed>
Parameters
- $userid : int
-
The userid
Tags
Return values
array<string|int, mixed> —Array of integer page id's
GetPageAccessForUser()
Return a list of pages that the user has edit access to.
public
GetPageAccessForUser(int $userid) : array<string|int, int>
Parameters
- $userid : int
-
The userid
Tags
Return values
array<string|int, int> —Array of page id's
GetPageAliasFromID()
Returns the content alias given a valid content id.
public
GetPageAliasFromID(int $id) : string
Parameters
- $id : int
-
The content id to query
Return values
string —The resulting content alias. false if not found.
GetPageIDFromAlias()
Returns the content id given a valid content alias.
public
GetPageIDFromAlias(string $alias) : int
Parameters
- $alias : string
-
The alias to query
Return values
int —The resulting id. null if not found.
GetPageIDFromHierarchy()
Returns the content id given a valid hierarchical position.
public
GetPageIDFromHierarchy(string $position) : int
Parameters
- $position : string
-
The position to query
Return values
int —The resulting id. false if not found.
ListContentTypes()
Returns a hash of valid content types (classes that extend ContentBase) The key is the name of the class that would be saved into the database. The value would be the text returned by the type's FriendlyName() method.
public
ListContentTypes([bool $byclassname = false ][, bool $allowed = false ][, bool $system = FALSE ]) : array<string|int, mixed>
Parameters
- $byclassname : bool = false
-
optionally return keys as class names.
- $allowed : bool = false
-
optionally trim the list of content types that are allowed by the site preference.
- $system : bool = FALSE
-
return only system content types.
Return values
array<string|int, mixed> —List of content types registered in the system.
LoadAllContent()
Load All content in thedatabase into memory Use with caution this can chew up alot of memory on larger sites.
public
LoadAllContent([bool $loadprops = FALSE ][, bool $inactive = FALSE ][, bool $showinmenu = FALSE ]) : mixed
Parameters
- $loadprops : bool = FALSE
-
Load extended content properties or just the page structure and basic properties
- $inactive : bool = FALSE
-
Load inactive pages as well
- $showinmenu : bool = FALSE
-
Load pages marked as show in menu
LoadChildren()
Loads additional, active children into a given tree object
public
LoadChildren(int $id[, bool $loadprops = false ][, bool $all = false ][, array<string|int, mixed> $explicit_ids = array() ]) : mixed
Parameters
- $id : int
-
The parent of the content objects to load into the tree
- $loadprops : bool = false
-
If true, load the properties of all loaded content objects
- $all : bool = false
-
If true, load all content objects, even inactive ones.
- $explicit_ids : array<string|int, mixed> = array()
-
(optional) array of explicit content ids to load
Tags
LoadContentFromAlias()
Given a content alias, load and return the loaded content object.
public
& LoadContentFromAlias(int $alias[, bool $only_active = false ]) : ContentBase
Parameters
- $alias : int
-
The alias of the content object to load
- $only_active : bool = false
-
If true, only return the object if it's active flag is true. Defaults to false.
Return values
ContentBase —The loaded content object. If nothing is found, returns NULL.
LoadContentFromId()
Given a content id, load and return the loaded content object.
public
LoadContentFromId(int $id[, bool $loadprops = false ]) : mixed
Parameters
- $id : int
-
The id of the content object to load
- $loadprops : bool = false
-
Also load the properties of that content object. Defaults to false.
Return values
mixed —The loaded content object. If nothing is found, returns FALSE.
LoadContentFromSerializedData()
Given an array of content_type and seralized_content, reconstructs a content object. It will handled loading the content type if it hasn't already been loaded.
public
LoadContentFromSerializedData(array<string|int, mixed> &$data) : ContentBase
Expects an associative array with 2 elements: content_type: string A content type name serialized_content: string Serialized form data
Parameters
- $data : array<string|int, mixed>
Tags
Return values
ContentBase —A content object derived from ContentBase
quickfind_node_by_id()
A convenience function to find a hierarchy node given the page id This method will be moved to cms_content_tree at a later date.
public
quickfind_node_by_id(int $id) : cms_content_tree
Parameters
- $id : int
-
The page id
Return values
cms_content_treeregister_content_type()
Register a new content type
public
register_content_type(CmsContentTypePlaceHolder &$obj) : mixed
Parameters
- $obj : CmsContentTypePlaceHolder
Tags
SetAllHierarchyPositions()
Updates the hierarchy position of all content items.
public
SetAllHierarchyPositions() : mixed
This is an expensive operation on the database, but must be called once each time one or more content pages are updated if positions have changed in the page structure.
SetDefaultContent()
Sets the default content to the given id
public
SetDefaultContent(int $id) : mixed
Parameters
- $id : int
-
The id to set as default