phpDocumentor SGL
cms
[ class tree: SGL ] [ index: SGL ] [ all elements ]

Class: SGL_Content

Source Location: /lib/Content.php

Class SGL_Content

Property Summary
mixed   $aAttribs  
mixed   $aClassifiers  
mixed   $createdById  
mixed   $createdByName  
mixed   $dateCreated  
mixed   $id  
mixed   $isCurrent  
mixed   $langCode  
mixed   $lastUpdated  
mixed   $media  
mixed   $name  
mixed   $numLinks  
mixed   $status  
mixed   $typeId  
mixed   $typeName  
mixed   $updatedById  
mixed   $version  

[ Top ]
Method Summary
static SGL_Content   createType()   Creates a new content type.
static SGL_Content   getById()   Returns a populated content object by id at current version
static SGL_Content   getByName()   Returns a content object matching supplied name at current version.
static SGL_Content   getByType()   Returns a content object structure with no data, according to type name or ID passed.
SGL_Content   __construct()   Consructor.
SGL_Content   addAttribute()   Adds an attribute object to a SGL_Content object instance.
void   delete()   Deletes an instance of content.
SGL_Content   ensureAllAttribsLoaded()   Ensures all attributes of a content item are loaded when editing the content item.
integer   getAttribId()   Returns ID for a given attrib name.
array   getLinkedContents()   Returns an array of content objects associated with current content object.
integer   getStatus()   Returns the status of a content object.
integer   getType()   Returns an integer representing the type id of the content object.
boolean   rename()   Renames a SGL_Content item.
SGL_Content   save()   Saves a content object and returns the object with PK.
void   setStatus()   Sets the status of a content object.
boolean   validate()   Returns false if any attribute names are empty, or duplicates are found.
string   __get()   Returns value property for searched SGL_Attribute.
boolean   __set()   Sets value property for searched SGL_Attribute.

[ Top ]
Properties
mixed   $aAttribs = array() [line 40]
API Tags:
Access:  public


[ Top ]
mixed   $aClassifiers = array() [line 41]
API Tags:
Access:  public


[ Top ]
mixed   $createdById [line 32]
API Tags:
Access:  public


[ Top ]
mixed   $createdByName [line 31]
API Tags:
Access:  public


[ Top ]
mixed   $dateCreated [line 34]
API Tags:
Access:  public


[ Top ]
mixed   $id [line 26]
API Tags:
Access:  public


[ Top ]
mixed   $isCurrent [line 28]
API Tags:
Access:  public


[ Top ]
mixed   $langCode [line 29]
API Tags:
Access:  public


[ Top ]
mixed   $lastUpdated [line 35]
API Tags:
Access:  public


[ Top ]
mixed   $media [line 42]
API Tags:
Access:  public


[ Top ]
mixed   $name [line 30]
API Tags:
Access:  public


[ Top ]
mixed   $numLinks [line 39]
API Tags:
Access:  public


[ Top ]
mixed   $status [line 38]
API Tags:
Access:  public


[ Top ]
mixed   $typeId [line 36]
API Tags:
Access:  public


[ Top ]
mixed   $typeName [line 37]
API Tags:
Access:  public


[ Top ]
mixed   $updatedById [line 33]
API Tags:
Access:  public


[ Top ]
mixed   $version [line 27]
API Tags:
Access:  public


[ Top ]
Methods
static method createType  [line 383]

  static SGL_Content createType( string $name  )

Creates a new content type.

  1.    $oRestoReview  SGL_Content::createType('RestaurantReview')
  2.        ->addAttribute(new SGL_Attribute(
  3.            array('name' => 'dateEaten''typeId' => SGL_CONTENT_ATTR_TYPE_DATE)))
  4.        ->addAttribute(new SGL_Attribute(
  5.            array('name' => 'dishName''typeId' => SGL_CONTENT_ATTR_TYPE_TEXT)))
  6.        ->addAttribute(new SGL_Attribute(
  7.            array('name' => 'overallRating''typeId' => SGL_CONTENT_ATTR_TYPE_FLOAT)))
  8.        ->save();

Parameters:
string   $name: 

API Tags:
Access:  public


[ Top ]
static method getById  [line 161]

  static SGL_Content getById( integer $id, [ $langCode = null], [ $version = null]  )

Returns a populated content object by id at current version

  1.    $oRestoReview  SGL_Content::getById($id);

Parameters:
integer   $id: 
   $langCode: 
   $version: 

API Tags:
Access:  public


[ Top ]
static method getByName  [line 238]

  static SGL_Content getByName( string $name  )

Returns a content object matching supplied name at current version.

  1.    $oRestoReview  SGL_Content::getByName('review of marcos spaghetti');

Parameters:
string   $name: 

API Tags:
Access:  public

Information Tags:
Todo:  ensure uniqueness of name property

[ Top ]
static method getByType  [line 274]

  static SGL_Content getByType( mixed $type  )

Returns a content object structure with no data, according to type name or ID passed.

  1.    $oRestoReview SGL_Content::getByType('RestaurantReview');
  2.    $oRestoReview->rename('Foo');

Parameters:
mixed   $type:  An integer or string referencing a content type

API Tags:
Access:  public


[ Top ]
Constructor __construct  [line 72]

  SGL_Content __construct( [object $oData = null], [ $loadAttribs = true]  )

Consructor.

Populates the object if $oData is supplied. Here's an example using data from a web form:

  1.    $oContent new SGL_Content($oContext->process());

Parameters:
object   $oData: 
   $loadAttribs: 


[ Top ]
addAttribute  [line 410]

  SGL_Content addAttribute( SGL_Attribute $oAttrib  )

Adds an attribute object to a SGL_Content object instance.

  1.    $oRestoReview  SGL_Content::createType('RestaurantReview')
  2.        ->addAttribute(new SGL_Attribute(
  3.            array('name' => 'dateEaten''typeId' => SGL_CONTENT_ATTR_TYPE_DATE))
  4.        );

Parameters:
SGL_Attribute   $oAttrib: 

API Tags:
Access:  public


[ Top ]
delete  [line 490]

  void delete( [boolean $safe = true]  )

Deletes an instance of content.

  1.    $oRestoReview  SGL_Content::getById($id);
  2.    $oRestoReview->delete();

Parameters:
boolean   $safe: 

API Tags:
Access:  public


[ Top ]
ensureAllAttribsLoaded  [line 214]

  SGL_Content ensureAllAttribsLoaded( )

Ensures all attributes of a content item are loaded when editing the content item.

This is useful when a content type has been modified and extra attributes have been added.


API Tags:
Access:  public

Information Tags:
Todo:  remove, never called
Todo:  contains hard-coded content type ID

[ Top ]
getAttribId  [line 143]

  integer getAttribId( string $attribName  )

Returns ID for a given attrib name.

  1.    $oRestoReview  SGL_Content::getById($id);
  2.    $id $oRestoReview->getAttribId('dishName');

Parameters:
string   $attribName: 

API Tags:
Access:  public


[ Top ]
getLinkedContents  [line 305]

  array getLinkedContents( [integer $typeId = null]  )

Returns an array of content objects associated with current content object.

Alternatively associated contents can be constrained by type.

  1.    $oRestoReview  SGL_Content::getById($id);
  2.    // get all associated comments
  3.    $aComments $oRestoReview->getLinkedContents(SGL_CMS_CONTENTTYPE_REVIEW_COMMENTS);

Parameters:
integer   $typeId: 

API Tags:
Access:  public


[ Top ]
getStatus  [line 345]

  integer getStatus( )

Returns the status of a content object.

  1.    $oRestoReview  SGL_Content::getById($id);
  2.    $status $oRestoReview->getStatus();


API Tags:
Access:  public


[ Top ]
getType  [line 330]

  integer getType( )

Returns an integer representing the type id of the content object.

  1.    $oRestoReview  SGL_Content::getById($id);
  2.    $type $oRestoReview->getType();
  3.    if ($type != SGL_CMS_CONTENTTYPE_RESTAURANT_REVIEW// do something ...}


API Tags:
Access:  public


[ Top ]
rename  [line 466]

  boolean rename( string $newName  )

Renames a SGL_Content item.

  1.    $oRestoReview  SGL_Content::getByType('RestaurantReview');
  2.    $oRestoReview->rename('Foo');

Parameters:
string   $newName: 

API Tags:
Access:  public


[ Top ]
save  [line 445]

  SGL_Content save( [ $newVersion = false], [ $newLang = false]  )

Saves a content object and returns the object with PK.

Parameters:
   $newVersion: 
   $newLang: 

API Tags:
See:  SGL_Content::createType();
Access:  public


[ Top ]
setStatus  [line 360]

  void setStatus( integer $status  )

Sets the status of a content object.

  1.    $oRestoReview  SGL_Content::getById($id);
  2.    $oRestoReview->setStatus(SGL_CMS_STATUS_PUBLISHED);

Parameters:
integer   $status: 

API Tags:
Access:  public


[ Top ]
validate  [line 424]

  boolean validate( )

Returns false if any attribute names are empty, or duplicates are found.


API Tags:
Access:  public


[ Top ]
__get  [line 123]

  string __get( string $propName  )

Returns value property for searched SGL_Attribute.

Parameters:
string   $propName: 


[ Top ]
__set  [line 107]

  boolean __set( string $propName, string $propValue  )

Sets value property for searched SGL_Attribute.

Parameters:
string   $propName: 
string   $propValue: 


[ Top ]

Documentation generated on Thu, 25 Dec 2008 22:04:52 +0000 by phpDocumentor 1.4.1