Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
Public Member Functions | List of all members
Content Class Reference

Public Member Functions

 getPath ()
 getFile ()
 setAttributes ($attributes)
 getAttributes ()
 getPersonalisationAttributes ()
 __construct (ContentSource $source, $path, $attributes=null)
 hasAccess ($user)

Detailed Description

Gentics Portal.Node PHP Author & Copyright (c) by Gentics Software GmbH sales.nosp@m.@gen.nosp@m.tics..nosp@m.com http://www.gentics.com Licenses can be found in the LICENSE.txt file in the root-folder of this installation You must not use this software without a valid license agreement.

This class represents content taken from Gentics Content Connector. The main purpose is to store content attributes in cache and in case cache expired or crashed reload this attributes.

Definition at line 14 of file Content.php.

Constructor & Destructor Documentation

Content::__construct ( ContentSource  $source,
  $path,
  $attributes = null 
)

Constructor

Parameters
ContentSource$sourcecontent source. Used for getting current personalisation configuration
string$pathcontent active path
array$attributescontent attributes
Returns

Definition at line 114 of file Content.php.

References setAttributes().

{
$this->_source = $source;
$this->_path = $path;
if ($attributes !== null) {
$this->setAttributes($attributes);
}
}

Member Function Documentation

Content::getAttributes ( )

Get content attributes from cache if $this->_source->usePersonalization== true If cache is empty but personalisation enabled, request api for content attributes

Exceptions
Exception
Returns
mixed

Definition at line 68 of file Content.php.

References setAttributes().

Referenced by getPersonalisationAttributes().

{
if ($this->_attributes === null && $this->_source->usePersonalisation) {
$this->_attributes = Yii::app()->cache->get($this->_cachePrefix . $this->_path);
if ($this->_attributes === false) {
$attributes = $this->_source->getRepositoryApi()->getContentAttributes($this->_path, $this->_source->getRequestedAttributes());
if ($attributes !== false) {
$this->setAttributes($attributes);
} else {
$this->_attributes = false;
}
}
}
return $this->_attributes;
}
Content::getFile ( )

Content file location

Returns
string

Definition at line 41 of file Content.php.

References getPath().

{
return $this->_source->contentFile($this->getPath());
}
Content::getPath ( )

Content active path

Returns
string

Definition at line 31 of file Content.php.

Referenced by getFile().

{
return $this->_path;
}
Content::getPersonalisationAttributes ( )

Get content personalisation attributes

Returns
mixed

Definition at line 90 of file Content.php.

References getAttributes().

Referenced by hasAccess().

{
if ($this->_personalisationAttributes === null) {
$this->_personalisationAttributes = array();
if ($attributes = $this->getAttributes()) {
foreach ($this->_source->personalisationFields as $pf) {
if (isset($attributes[$pf]) && is_array($attributes[$pf])) {
$this->_personalisationAttributes = array_merge($this->_personalisationAttributes, $attributes[$pf]);
}
}
}
}
return $this->_personalisationAttributes;
}
Content::hasAccess (   $user)

Check if user has access to this content

Parameters
object$useruser
Returns
bool

Definition at line 130 of file Content.php.

References getPersonalisationAttributes().

{
if ($this->_source->usePersonalisation) {
$hasAccess = Yii::app()->getModule('personalisation')->rule->checkAccess($user->id, $this->getPersonalisationAttributes());
Yii::trace("Check personalisation access. Result: [$hasAccess].".print_r($this->getPersonalisationAttributes(), true),'personalisation');
return $hasAccess;
}
return true;
}
Content::setAttributes (   $attributes)

Save content attributes to cache

Parameters
array$attributescontent attributes
Returns
void

Definition at line 53 of file Content.php.

Referenced by __construct(), and getAttributes().

{
$this->_attributes = $attributes;
if ($this->_source->usePersonalisation) {
Yii::app()->cache->set($this->_cachePrefix . $this->_path, $attributes, Yii::app()->getModule('contentSource')->cacheTime);
}
}

The documentation for this class was generated from the following file: