Placeholder Image

ADN Informatique

Consultant Ingénierie Informatique

Saguenay (Jonquière), Québec, Canada. Tél: (581) 683-9887 Téléc: (581) 221-0874

Placeholder Picture

Retour

Content Storage

2008-04-28 13:59:47 (ID: 79, Parent: 0, Type: page)
There is a premice of a Ning API content storage implementation in PHP.

The source code will be available as soon as I can remember where I've store it ;)

Content Storage API

CS_Attribute

Define a custom attribute added to a CS_Content object An attribute if automaticly created when a non existant CS_Content attribute is assigned. We can also create our own CS_Attribute and assign them to one or mode CS_Content.

CS_Attribute($name)

Must be instantied with an attribute name

set($value)

Set the content of a CS_Attribute object. If the content was a CS_Content it is automaticly refered if it exist in the content storage or rejected. Otherwise data is copied into the attribute.

type()

Return attribute type. This is any php object type or CS_Content if a refered object.

get() or $a->data

Return the content of the attribute. If it's a ref return the pointer.

getContent()

Return the content of the attribute. If it's a ref fetch the object and return it instead of the ref.

name()

Return the attribute name.

CS_Content

Data container stored in the content storage. This container have system attribute and custom attribute. Custom attribute can be any data but must be assigned within a CS_Attribute. Every object MUST have a type. The type is user defined. It must be consistent along an apps to allow easy retrieval of objects from storage. System attribures are:
  • id : private internal object id.
  • type : user defined object type
  • title : user defined object title
  • cdate : creation date
  • mdate : last modification date
  • owner : user defined data owner
  • perms : user defined permission scheme
  • app : user defined application name
  • lang : user defined language (default null meaning all languages match)
Custom attribute could have any name but system attribute names.

CS_Content($type="")

Constructor method. Could be defined with the object type. CS_Content MUST HAVE a type before saving it. Type could be defined in constructor, or with assignment.

type() or getType()

Return object type of this content.

title($title="")

If an title is provided, set it. Else return the current content title.

getTitle()

Return the content title.

setTitle($title)

Set the content title.

addAttribute(CS_Attribute $attribute)

Add an attribute from an existing CS_Attribute Attribute could also be created by assigning a value to an unexisting attribute. $a->newattrib = "value";

delAttribute($attribute_name)

Remove an attribute from a CS_Content.

listAttribute()

List (as an aray) all the attrbuts-name : attributs-value pairs.

save()

Save content to the storage.

load($id)

Load content from the storage using object id. If id is unknown, we retrieve object using the CS_Query class that find object in the storage.

CS_Query

Storage query class. This class allow retrieval of CS_Content from the storage media using common request. Query are based on a series of filters.

CS_Query

Constructor

filter($field,$oper,$value)

Add a filter to the query. This could be a field, or a certain value in a field.

order()

execute()

Execute the query and return an array of CS_Content.

show()

Show the query to be executed. (Relfexion function)

Reserved names

Reserved types (can't be used as CS_Content type)
  • Every PHP object types
    • boolean
    • integer
    • float
    • string
    • array
    • object
    • resource
    • NULL
    • mixed
    • number
    • callback
  • Internally defined types
    • CS_Storage
Note: Everything is case sensitive.

Document Informatif

ADN Informatique

2015

Rev. 1

Jean-Luc Cyr