Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
ContentSourceModule.php
1 <?php
2 /**
3  * Gentics Portal.Node PHP
4  * Author & Copyright (c) by Gentics Software GmbH
5  * sales@gentics.com
6  * http://www.gentics.com
7  * Licenses can be found in the LICENSE.txt file in the root-folder of this installation
8  * You must not use this software without a valid license agreement.
9  *
10  * Module for working with File System Content Renderer and Dynamic Content Renderer.
11  * Configuration example:
12  *'contentSource' => array(
13  * 'class' => 'site.common.modules.contentSource.ContentSourceModule',
14  * 'sourceSettings' => array(
15  * 'DynamicContentSource' => array(
16  * 'storageFolder' => '/var/www/gPortal/DCR'
17  * ),
18  * 'FileSystemContentSource' => array(
19  * 'sourceFolder' => '/var/www/gPortal/FSCR'
20  * ),
21  * ),
22  * 'sourceClass' => 'DynamicContentSource'
23  * )
24  */
25 class ContentSourceModule extends CWebModule
26 {
27  /**
28  * @var array Content source settings
29  */
30  public $sourceSettings;
31  /**
32  * @var string Content source class
33  */
34  public $sourceClass;
35 
36  /**
37  * @var string home page
38  */
39  public $homePage;
40 
41  /**
42  * This value is used when startpage for some folder doesnt exists
43  *
44  * @public string
45  **/
46  public $startPageFallback = 'index.html';
47 
48  /**
49  * Method of displaying startpage to user. Can take following values:
50  * false - redirect user to the page
51  * true - (no redirect - just display/include the page without changing the URL)
52  *
53  * @public string
54  **/
55  public $startPageDynamic = true;
56 
57  /**
58  * Name of content attribute for locale
59  * $localizedAttributeName . $locale
60  *
61  * @public string
62  **/
63  public $localizedAttributeName = 'startpageurl_';
64 
65  /**
66  * the number of seconds in which the cached value will expire. 0 means never expire.
67  * used for caching content personalisation attributes and modification time
68  *
69  * @var
70  */
71  public $cacheTime;
72 
73  /**
74  * @var string content source object
75  */
76  private $_contentSource;
77 
78  /**
79  * Get object which represents Content Source
80  *
81  * @return ContentSource
82  */
83  public function getContentSource()
84  {
85  if (!$this->_contentSource) {
86  $settings = $this->sourceSettings[$this->sourceClass];
87  $settings['class'] = $this->sourceClass;
88  $this->_contentSource = Yii::createComponent($settings);
89  $this->_contentSource->init();
90  }
91  return $this->_contentSource;
92  }
93 
94 
95  /**
96  * Get static resource content. For example images, css, js
97  *
98  * @param string $path content path
99  *
100  * @return Content content
101  */
102  public function getContent($path)
103  {
104  return $this->getContentSource()->getContent($path);
105  }
106 
107  /**
108  * Module initial function
109  *
110  * @return void
111  */
112  public function init()
113  {
114  parent::init();
115  $this->setImport(
116  array(
117  'contentSource.components.*'
118  )
119  );
120  }
121 }