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

Public Member Functions

 __construct ()
 getCmsObjectCanBeExternal ($path, $attributes=array())
 getLastModificationTime ($path)
 getContentAttributes ($path, $attributes)
 getCmsObject ($path, $attributes=array())
 getBinaryContent ($path)
 addAdditionalParameters ($params, $type)
 clearCache ($contentid, $url="")
 request ($params, $attributes=array(), $timeout="")
 requestNavigation ($params, $attributes=array(), $timeout="")
 requestActivePath ($params, $attributes=array(), $timeout="")
 requestAutosuggest ($params, $attributes=array(), $timeout="")
 requestSearch ($params, $attributes=array(), $timeout="")

Public Attributes

const OBJ_TYPE_FOLDER = 10002
const OBJ_TYPE_PAGE = 10007
const OBJ_TYPE_BINARY = 10008
 $url
 $failover_urls = array()
 $contentRepositorySearch
 $binaryContent
 $navigation
 $activePath
 $autosuggest
 $search
 $clearCache
 $contentExternalHost
 $additionalRequestParameters = array()
 $additionalAttributes = array()
 $additionalSortingRules = array()

Protected Member Functions

 getContentRepositorySearchUrl ()
 getBinaryContentUrl ()
 getNavigationUrl ()
 getActivePathUrl ()
 getAutosuggestUrl ()
 getSearchUrl ()
 getUrl ()
 getAdditionalAttributesByRequestType ($type)
 getAdditionalAttributesByUrl ($url)

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.

Class for working with Gentics Content Connector

Definition at line 12 of file RepositoryApi.php.

Constructor & Destructor Documentation

RepositoryApi::__construct ( )

Set base options

Definition at line 146 of file RepositoryApi.php.

{
if (isset($_GET['lang']) && is_string($_GET['lang'])) {
Yii::app()->language = $_GET['lang'];
}
}

Member Function Documentation

RepositoryApi::addAdditionalParameters (   $params,
  $type 
)

Adds parameters to certain requests

Parameters
array$paramsarray of preset parameters
string$typetype of request from
Returns
array

Definition at line 276 of file RepositoryApi.php.

Referenced by getBinaryContent(), and getCmsObject().

{
if (!empty($this->additionalRequestParameters[$type])) {
foreach ($this->additionalRequestParameters[$type] as $name => $val) {
$params[$name] = !empty($params[$name]) ? $params[$name] . ' AND ' . $val : $params[$name];
}
}
return $params;
}
RepositoryApi::clearCache (   $contentid,
  $url = "" 
)

clears the CCR cache

Parameters
string$urlurl of CCR, if not set use configured url
string$contentidcontent-ID of page
Returns
array

Definition at line 294 of file RepositoryApi.php.

{
if (empty($url) || $url="") {
$url = $this->clearCache;
}
// /ccr/clearcache?contentid=10007.123
$url = $url . '?contentid=' . $contentid;
/* do not remove the @ sign below, it is required for exception handling */
@$content = file_get_contents($url, false);
return $content;
}
RepositoryApi::getActivePathUrl ( )
protected

Get api url which used to retrieve active path data

Returns
string

Definition at line 118 of file RepositoryApi.php.

Referenced by requestActivePath().

{
return $this->getUrl() . $this->activePath;
}
RepositoryApi::getAdditionalAttributesByRequestType (   $type)
protected

Gets additional attribute by request type

Parameters
string$typerequest type (navigation/content/search)
Returns
string additional attributes

Definition at line 313 of file RepositoryApi.php.

Referenced by getAdditionalAttributesByUrl().

{
$attributes = false;
if (isset($this->additionalAttributes[$type])) {
$attributes = $this->additionalAttributes[$type];
}
if ($attributes && $attributes = explode(',',$attributes)) {
$attributes = array_map('trim',$attributes);
$attributes = array_unique($attributes);
$attributes = '&attributes=' . implode('&attributes=', $attributes);
}
return $attributes;
}
RepositoryApi::getAdditionalAttributesByUrl (   $url)
protected

Gets additional attribute by url

Parameters
string$urlurl
Returns
string additional attributes

Definition at line 333 of file RepositoryApi.php.

References getAdditionalAttributesByRequestType().

{
$type = false;
if (strpos($url, $this->navigation)) {
$type = 'navigation';
} elseif(strpos($url, $this->binaryContent)) {
$type = 'content';
} elseif(strpos($url, $this->contentRepositorySearch)
|| strpos($url, $this->search)) {
$type = 'search';
}
}
RepositoryApi::getAutosuggestUrl ( )
protected

Get api url which used to retrieve autosuggest data

Returns
string

Definition at line 128 of file RepositoryApi.php.

Referenced by requestAutosuggest().

{
return $this->getUrl() . $this->autosuggest;
}
RepositoryApi::getBinaryContent (   $path)

Download binary content

Parameters
string$pathcontent path
Returns
string binary content

Definition at line 257 of file RepositoryApi.php.

References addAdditionalParameters(), and getBinaryContentUrl().

Referenced by getCmsObject().

{
$params = array(
'filter' => "object.url==\"$path\"",
);
$params = $this->addAdditionalParameters($params, 'binaryContent');
$response = $this->_request($this->getBinaryContentUrl(), $params);
return $response;
}
RepositoryApi::getBinaryContentUrl ( )
protected

Get api url which used to retrieve static objects(images, js, css, etc.)

Returns
string

Definition at line 98 of file RepositoryApi.php.

Referenced by getBinaryContent().

{
return $this->getUrl() . $this->binaryContent;
}
RepositoryApi::getCmsObject (   $path,
  $attributes = array() 
)

Get CMS content object If object is binary, make additional request to get binarycontent and put it to 'content' field

Parameters
string$pathcontent path
array$attributesrequested content attributes
Returns
array|bool

Definition at line 230 of file RepositoryApi.php.

References addAdditionalParameters(), getBinaryContent(), and getContentRepositorySearchUrl().

Referenced by getCmsObjectCanBeExternal(), and getContentAttributes().

{
$params = array(
'filter' => "object.url==\"$path\"",
'type' => 'php',
);
$params = $this->addAdditionalParameters($params, 'contentRepositorySearch');
$response = $this->_request($this->getContentRepositorySearchUrl(), $params, $attributes);
$cmsObject = self::_prepareResponse($response);
if (!$cmsObject) {
return false;
}
if (in_array('content', $attributes) && $cmsObject['obj_type'] == self::OBJ_TYPE_BINARY) {
$cmsObject['attributes']['content'] = $this->getBinaryContent($path);
}
return $cmsObject;
}
RepositoryApi::getCmsObjectCanBeExternal (   $path,
  $attributes = array() 
)

Do almost the same as getCmsObject. But in case relative path $path not found in the CMS it adds host address in front of $path and try second time

Parameters
$path
array$attributes
Returns
array|bool

Definition at line 172 of file RepositoryApi.php.

References getCmsObject().

{
$cmsObject = $this->getCmsObject($path, $attributes);
if (!$cmsObject && !preg_match('/.+\.(php|html)$/', $path)) {
$externalPath = (!empty($this->contentExternalHost) ? $this->contentExternalHost : Yii::app()->request->getHostInfo()) . $path;
return $this->getCmsObject($externalPath, $attributes);
}
return $cmsObject;
}
RepositoryApi::getContentAttributes (   $path,
  $attributes 
)

This method is used for retrieving only content attributes from Gentics Content Connector

Parameters
string$pathcontent path
array$attributesarray of personalization attributes
Returns
array

Definition at line 213 of file RepositoryApi.php.

References getCmsObject().

Referenced by getLastModificationTime().

{
$cmsObject = $this->getCmsObject($path, array_filter($attributes, function ($el) {
return $el != 'content';
}));
return $cmsObject['attributes'];
}
RepositoryApi::getContentRepositorySearchUrl ( )
protected

Get api url which used to retrieve CMS objects

Returns
string

Definition at line 88 of file RepositoryApi.php.

Referenced by getCmsObject(), and request().

{
return $this->getUrl() . $this->contentRepositorySearch;
}
RepositoryApi::getLastModificationTime (   $path)

Get CMS content last modification time

Parameters
string$pathpath of node
Returns
bool

Definition at line 190 of file RepositoryApi.php.

References getContentAttributes().

{
$cacheId = 'updateTMSTMP_'.md5($path);
$updateTMSTMP = false;
if (!($updateTMSTMP = Yii::app()->cache->get($cacheId, false))
|| (isset($_GET['refresh']) && $_GET['refresh']=='true')) {
$attributes = $this->getContentAttributes($path, array('updatetimestamp'));
if($attributes) {
$updateTMSTMP = $attributes['updatetimestamp'];
Yii::app()->cache->set($cacheId, $updateTMSTMP, Yii::app()->getModule('contentSource')->cacheTime);
}
}
return $updateTMSTMP;
}
RepositoryApi::getNavigationUrl ( )
protected

Get api url which used to retrieve navigation data

Returns
string

Definition at line 108 of file RepositoryApi.php.

Referenced by requestNavigation().

{
return $this->getUrl() . $this->navigation;
}
RepositoryApi::getSearchUrl ( )
protected

Get api url which used to retrieve search data

Returns
string

Definition at line 138 of file RepositoryApi.php.

Referenced by requestSearch().

{
return $this->getUrl() . $this->search;
}
RepositoryApi::request (   $params,
  $attributes = array(),
  $timeout = "" 
)

Requesting for content object

Parameters
array$paramsurl params
array$attributesrequested attributes
string$timeoutspecific request timeout in seconds (if not set standard timeout 60 seconds is used)
Returns
string

Definition at line 429 of file RepositoryApi.php.

References getContentRepositorySearchUrl().

{
return $this->_request($this->getContentRepositorySearchUrl(), $params, $attributes, $timeout);
}
RepositoryApi::requestActivePath (   $params,
  $attributes = array(),
  $timeout = "" 
)

Requesting for active path object

Parameters
array$paramsurl params
array$attributesrequested attributes
string$timeoutspecific request timeout in seconds (if not set standard timeout 60 seconds is used)
Returns
string

Definition at line 457 of file RepositoryApi.php.

References getActivePathUrl().

{
return $this->_request($this->getActivePathUrl(), $params, $attributes, $timeout);
}
RepositoryApi::requestAutosuggest (   $params,
  $attributes = array(),
  $timeout = "" 
)

Requesting for autosuggest data

Parameters
array$paramsurl params
array$attributesrequested attributes
string$timeoutspecific request timeout in seconds (if not set standard timeout 60 seconds is used)
Returns
string

Definition at line 471 of file RepositoryApi.php.

References getAutosuggestUrl().

{
return $this->_request($this->getAutosuggestUrl(), $params, $attributes, $timeout);
}
RepositoryApi::requestNavigation (   $params,
  $attributes = array(),
  $timeout = "" 
)

Requesting for navigation object

Parameters
array$paramsurl params
array$attributesrequested attributes
string$timeoutspecific request timeout in seconds (if not set standard timeout 60 seconds is used)
Returns
string

Definition at line 443 of file RepositoryApi.php.

References getNavigationUrl().

{
return $this->_request($this->getNavigationUrl(), $params, $attributes, $timeout);
}
RepositoryApi::requestSearch (   $params,
  $attributes = array(),
  $timeout = "" 
)

Requesting for search data

Parameters
array$paramsurl params
array$attributesrequested attributes
string$timeoutspecific request timeout in seconds (if not set standard timeout 60 seconds is used)
Returns
string

Definition at line 485 of file RepositoryApi.php.

References getSearchUrl().

{
return $this->_request($this->getSearchUrl(), $params, $attributes, $timeout);
}

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