Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
ContentSource.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  * Abstract class for access to content repository
11  */
12 abstract class ContentSource extends CComponent
13 {
14 
15  /**
16  * If use personalization for current content source
17  *
18  * @var
19  */
20  public $usePersonalisation;
21 
22  /**
23  * Array of fields which will be additionally request from Gentics Content Connector
24  * and used in personalisation checking algorithm
25  *
26  * @var
27  */
28  public $personalisationFields = array();
29 
30  /**
31  * Method which receive content path and return content
32  *
33  * @param string $path content path
34  *
35  * @return mixed
36  */
37  public abstract function getContent($path);
38 
39  public abstract function getStartPage($folderPath, $locale);
40 
41  /**
42  * Get content file location
43  *
44  * @param string $path local path
45  *
46  * @return string
47  *
48  */
49  public abstract function contentFile($path);
50 
51  /**
52  * Return array of attributes which will be requested from API
53  *
54  * @abstract
55  * @return array array of attributes
56  */
57  public abstract function getRequestedAttributes();
58 
59  /**
60  * Check if file placed in $contentFolder folder. Prevent '../' attack.
61  *
62  * @param string $filePath relative file path
63  * @param string $folder in which file should placed
64  *
65  * @return bool
66  */
67  public static function fileAccessible($filePath, $folder)
68  {
69  if ($realPath = realpath($filePath)) {
70  return strpos($realPath, realpath($folder)) === 0;
71  }
72 
73  return false;
74  }
75 
76  /**
77  * Get repository api class
78  *
79  * @return RepositoryApi
80  */
81  public function getRepositoryApi()
82  {
83  return Yii::app()->repositoryApi;
84  }
85 }