contentbox.model.content

Class ContentService

railo-context.Component
        extended by coldbox.system.orm.hibernate.BaseORMService
            extended by coldbox.system.orm.hibernate.VirtualEntityService
                extended by contentbox.model.content.ContentService
Class Attributes:
  • singleton
  •  
  • synchronized : false
  •  
  • accessors : false
  •  
  • persistent : false
  •  
    Direct Known Subclasses:
    ContentStoreService , EntryService , PageService

    ContentBox - A Modular Content Platform Copyright 2012 by Luis Majano and Ortus Solutions, Corp www.ortussolutions.com Apache License, Version 2.0 Copyright Since [2012] [Luis Majano and Ortus Solutions,Corp] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. A generic content service for content objects

    Property Summary
    type property default serializable required
    any authorService


    • inject = authorService@cb
    true false
    any cacheBox


    • inject = cachebox
    true false
    any categoryService


    • inject = categoryService@cb
    true false
    any commentService


    • inject = commentService@cb
    true false
    any contentStoreService


    • inject = contentStoreService@cb
    true false
    any contentVersionService


    • inject = contentVersionService@cb
    true false
    any customFieldService


    • inject = customFieldService@cb
    true false
    any entryService


    • inject = entryService@cb
    true false
    any log


    • inject = logbox:logger:{this}
    true false
    any pageService


    • inject = pageService@cb
    true false
    any populator


    • inject = wirebox:populator
    true false
    any settingService


    • inject = id:settingService@cb
    true false
    any statsService


    • inject = statsService@cb
    true false
    any systemUtil


    • inject = SystemUtil@cb
    true false
    Constructor Summary
    init([any entityName='cbContent'])
          Constructor.
    Method Summary
    any bulkPublishStatus(any contentID, any status)
         Bulk Publish Status Updates.
    any clearAllCaches([boolean async='false'])
         Clear all content caches.
    any clearAllPageWrapperCaches([boolean async='false'])
         Clear all page wrapper caches.
    any clearPageWrapper(any slug, [boolean async='false'])
         Clear a page wrapper cache.
    any clearPageWrapperCaches(any slug, [boolean async='false'])
         Clear all page wrapper caches.
    ContentService deleteContent(any content)
         Delete a content object safely via hierarchies.
    any findBySlug(any slug, boolean showUnpublished='false')
         Find a published content object by slug and published unpublished flags, if not found it returns.
    any findPublishedContent([numeric max='0'], [numeric offset='0'], [any searchTerm=''], [any category=''], [boolean asQuery='false'], [any parent], [boolean showInMenu])
         Find published content objects.
    array getAllFlatContent()
         Returns an array of [contentID, title, slug] structures of all the content in the system.
    array getAllFlatSlugs()
         Returns an array of slugs of all the content objects in the system.
    array getAllForExport([any inData])
         Get all content for export as flat data.
    any getIDBySlug(any slug)
         Get an id from a slug of a content object.
    array getTopCommentedContent([numeric max='5'])
         Get the top commented content entries.
    array getTopVisitedContent([numeric max='5'])
         Get the top visited content entries.
    private any getUniqueSlugHash(string slug)
         Get a unique slug hash.
    string importFromData(any importData, [boolean override='false'], any importLog)
         Import data from an array of structures of content or just one structure of a content entry.
    string importFromFile(any importFile, [boolean override='false'])
         Import data from a ContentBox JSON file.
    any inflateFromStruct(any contentData, any importLog, [any parent], [struct newContent='[runtime expression]'])
         Inflate a content object from a ContentBox JSON structure.
    any isSlugUnique(any slug, [any contentID=''])
         Verify an incoming slug is unique or not.
    any searchContent([any searchTerm=''], [numeric max='0'], [numeric offset='0'], [boolean asQuery='false'], [any sortOrder='publishedDate DESC'], [any isPublished='true'], [boolean searchActiveContent='true'], [string contentTypes=''], [any excludeIDs=''], [boolean showInSearch='false'])
         Searches published content with cool paramters, remember published content only.
    ContentService updateHits(any contentID, [boolean async='true'])
         Update a content's hits with some async flava.
     
    Methods inherited from class coldbox.system.orm.hibernate.VirtualEntityService
    clear, convertIDValueToJavaType, convertValueToJavaType, count, countWhere, criteriaCount, criteriaQuery, deleteAll, deleteByID, deleteByQuery, deleteWhere, evict, executeQuery, exists, findAllWhere, findWhere, get, getAll, getDatasource, getEntityName, getKey, getPropertyNames, getSessionStatistics, getTableName, isSessionDirty, list, new, newCriteria, onMissingMethod, setDatasource, setEntityName
     
    Methods inherited from class coldbox.system.orm.hibernate.BaseORMService
    $delete, $deleteAll, $deleteByID, $deleteByQuery, $deleteWhere, $save, $saveAll, $transactioned, compileHQLFromDynamicMethod, createCriteriaQuery, createService, delete, evictEntity, evictQueries, findAll, findByExample, findDynamically, findIt, getDefaultAsQuery, getEntityGivenName, getEventHandling, getHQLDynamicCache, getORM, getORMEventHandler, getQueryCacheRegion, getRestrictions, getUseQueryCaching, getUseTransactions, merge, populate, populateFromJSON, populateFromQuery, populateFromXML, populateWithPrefix, refresh, save, saveAll, sessionContains, setDefaultAsQuery, setEventHandling, setHQLDynamicCache, setORM, setORMEventHandler, setQueryCacheRegion, setUseQueryCaching, setUseTransactions
     
    Methods inherited from class railo-context.Component
    None

    Constructor Detail

    init

    public init([any entityName='cbContent'])

    Constructor

    Parameters:
    entityName - The content entity name to bind this service to.

    Property Detail

    authorService

    property any authorService

    Attributes:
    required - false
    inject - authorService@cb
    serializable - true

    cacheBox

    property any cacheBox

    Attributes:
    required - false
    inject - cachebox
    serializable - true

    categoryService

    property any categoryService

    Attributes:
    required - false
    inject - categoryService@cb
    serializable - true

    commentService

    property any commentService

    Attributes:
    required - false
    inject - commentService@cb
    serializable - true

    contentStoreService

    property any contentStoreService

    Attributes:
    required - false
    inject - contentStoreService@cb
    serializable - true

    contentVersionService

    property any contentVersionService

    Attributes:
    required - false
    inject - contentVersionService@cb
    serializable - true

    customFieldService

    property any customFieldService

    Attributes:
    required - false
    inject - customFieldService@cb
    serializable - true

    entryService

    property any entryService

    Attributes:
    required - false
    inject - entryService@cb
    serializable - true

    log

    property any log

    Attributes:
    required - false
    inject - logbox:logger:{this}
    serializable - true

    pageService

    property any pageService

    Attributes:
    required - false
    inject - pageService@cb
    serializable - true

    populator

    property any populator

    Attributes:
    required - false
    inject - wirebox:populator
    serializable - true

    settingService

    property any settingService

    Attributes:
    required - false
    inject - id:settingService@cb
    serializable - true

    statsService

    property any statsService

    Attributes:
    required - false
    inject - statsService@cb
    serializable - true

    systemUtil

    property any systemUtil

    Attributes:
    required - false
    inject - SystemUtil@cb
    serializable - true

    Method Detail

    bulkPublishStatus

    public any bulkPublishStatus(any contentID, any status)

    Bulk Publish Status Updates

    Parameters:
    contentID - The list or array of ID's to bulk update
    status - The status either 'publish' or 'draft'

    clearAllCaches

    public any clearAllCaches([boolean async='false'])

    Clear all content caches

    Parameters:
    async - Run it asynchronously or not, defaults to false

    clearAllPageWrapperCaches

    public any clearAllPageWrapperCaches([boolean async='false'])

    Clear all page wrapper caches

    Parameters:
    async - Run it asynchronously or not, defaults to false

    clearPageWrapper

    public any clearPageWrapper(any slug, [boolean async='false'])

    Clear a page wrapper cache

    Parameters:
    slug - The slug to clean
    async - Run it asynchronously or not, defaults to false

    clearPageWrapperCaches

    public any clearPageWrapperCaches(any slug, [boolean async='false'])

    Clear all page wrapper caches

    Parameters:
    slug - The slug partial to clean on
    async - Run it asynchronously or not, defaults to false

    deleteContent

    public ContentService deleteContent(any content)

    Delete a content object safely via hierarchies

    Parameters:
    content - the Content object to delete

    findBySlug

    public any findBySlug(any slug, boolean showUnpublished='false')

    Find a published content object by slug and published unpublished flags, if not found it returns a new content object

    Parameters:
    slug - The slug to search
    showUnpublished - To also show unpublished content, defaults to false.

    findPublishedContent

    public any findPublishedContent([numeric max='0'], [numeric offset='0'], [any searchTerm=''], [any category=''], [boolean asQuery='false'], [any parent], [boolean showInMenu])

    Find published content objects

    Parameters:
    max - The maximum number of records to paginate
    offset - The offset in the pagination
    searchTerm - The search term to search
    category - The category to filter the content on
    asQuery - Return as query or array of objects, defaults to array of objects
    parent - The parent ID to filter on or not
    showInMenu - Whether to filter with the show in menu bit or not

    getAllFlatContent

    public array getAllFlatContent()

    Returns an array of [contentID, title, slug] structures of all the content in the system


    getAllFlatSlugs

    public array getAllFlatSlugs()

    Returns an array of slugs of all the content objects in the system.


    getAllForExport

    public array getAllForExport([any inData])

    Get all content for export as flat data

    Parameters:
    inData - The data to use for exporting, usually concrete implementtions can override this.

    getIDBySlug

    public any getIDBySlug(any slug)

    Get an id from a slug of a content object

    Parameters:
    slug - The slug to search an ID for.

    getTopCommentedContent

    public array getTopCommentedContent([numeric max='5'])

    Get the top commented content entries

    Parameters:
    max - The maximum to retrieve, defaults to 5 entries

    getTopVisitedContent

    public array getTopVisitedContent([numeric max='5'])

    Get the top visited content entries

    Parameters:
    max - The maximum to retrieve, defaults to 5 entries

    getUniqueSlugHash

    private any getUniqueSlugHash(string slug)

    Get a unique slug hash

    Parameters:
    slug - The slug to unique it

    importFromData

    public string importFromData(any importData, [boolean override='false'], any importLog)

    Import data from an array of structures of content or just one structure of a content entry

    Parameters:
    importData - The data to import
    override - Override records or not
    importLog - The import log buffer

    importFromFile

    public string importFromFile(any importFile, [boolean override='false'])

    Import data from a ContentBox JSON file. Returns the import log

    Parameters:
    importFile - The absolute file path to use for importing
    override - Override records or not

    inflateFromStruct

    public any inflateFromStruct(any contentData, any importLog, [any parent], [struct newContent='[runtime expression]'])

    Inflate a content object from a ContentBox JSON structure

    Parameters:
    contentData - The content structure inflated from JSON
    importLog - The string builder import log
    parent - If the inflated content object has a parent then it can be linked directly, no inflating necessary. Usually for recursions
    newContent - Map of new content by slug; useful for avoiding new content collisions with recusive relationships

    isSlugUnique

    public any isSlugUnique(any slug, [any contentID=''])

    Verify an incoming slug is unique or not

    Parameters:
    slug - The slug to search for uniqueness
    contentID - Limit the search to the passed contentID usually for updates

    searchContent

    public any searchContent([any searchTerm=''], [numeric max='0'], [numeric offset='0'], [boolean asQuery='false'], [any sortOrder='publishedDate DESC'], [any isPublished='true'], [boolean searchActiveContent='true'], [string contentTypes=''], [any excludeIDs=''], [boolean showInSearch='false'])

    Searches published content with cool paramters, remember published content only

    Parameters:
    searchTerm - The search term to search
    max - The maximum number of records to paginate
    offset - The offset in the pagination
    asQuery - Return as query or array of objects, defaults to array of objects
    sortOrder - The sorting of the search results, defaults to publishedDate DESC
    isPublished - Search for published, non-published or both content objects [true, false, 'all']
    searchActiveContent - Search only content titles or both title and active content. Defaults to both.
    contentTypes - Limit search to list of content types (comma-delimited). Leave blank to search all content types
    excludeIDs - List of IDs to exclude from search
    showInSearch - If true, it makes sure content has been stored as searchable, defaults to false, which means it searches no matter what this bit says

    updateHits

    public ContentService updateHits(any contentID, [boolean async='true'])

    Update a content's hits with some async flava

    Parameters:
    contentID - The content id to update
    async - Async or not