Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • PHP
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cContentVersioning
  • cVersion
  • cVersionFile
  • cVersionLayout
  • cVersionModule
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  * This file contains the file version class.
  5:  *
  6:  * @package    Core
  7:  * @subpackage Versioning
  8:  * @author     Bilal Arslan
  9:  * @author     Timo Trautmann
 10:  * @copyright  four for business AG <www.4fb.de>
 11:  * @license    http://www.contenido.org/license/LIZENZ.txt
 12:  * @link       http://www.4fb.de
 13:  * @link       http://www.contenido.org
 14:  */
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: /**
 19:  * Class of File System
 20:  * We use super class Version to create a new Version.
 21:  *
 22:  * @package    Core
 23:  * @subpackage Versioning
 24:  */
 25: class cVersionFile extends cVersion {
 26: 
 27:     /**
 28:      * Content code of current file.
 29:      *
 30:      * @var string
 31:      */
 32:     public $sCode;
 33: 
 34:     /**
 35:      * Description folder of history sub nav.
 36:      * Its not required to use it.
 37:      *
 38:      * @var string
 39:      */
 40:     public $sDescription;
 41: 
 42:     /**
 43:      * The path of style file.
 44:      *
 45:      * @var string
 46:      */
 47:     public $sPath;
 48: 
 49:     /**
 50:      * The id of Type.
 51:      *
 52:      * @var string
 53:      */
 54:     public $sFileName;
 55: 
 56:     /**
 57:      * Constructor to create an instance of this class.
 58:      *
 59:      * Initializes class variables.
 60:      *
 61:      * @param string $iIdOfType
 62:      *                                 The name of style file
 63:      * @param array  $aFileInfo
 64:      *                                 Get FileInformation from table file_information
 65:      * @param string $sFileName
 66:      * @param string $sTypeContent
 67:      * @param array  $aCfg
 68:      * @param array  $aCfgClient
 69:      * @param cDb    $oDB
 70:      *                                 CONTENIDO database object
 71:      * @param int    $iClient
 72:      * @param string $sArea
 73:      * @param int    $iFrame
 74:      * @param string $sVersionFileName [optional]
 75:      *
 76:      * @throws cInvalidArgumentException
 77:      */
 78:     public function __construct(
 79:         $iIdOfType, $aFileInfo, $sFileName, $sTypeContent, $aCfg, $aCfgClient,
 80:         $oDB, $iClient, $sArea, $iFrame, $sVersionFileName = ''
 81:     ) {
 82: 
 83:         // Set globals in super class constructer
 84:         parent::__construct($aCfg, $aCfgClient, $oDB, $iClient, $sArea, $iFrame);
 85: 
 86:         // Folder name is css or js ...
 87:         $this->sType = $sTypeContent;
 88: 
 89:         // File Name for xml node
 90:         $this->sFileName = $sFileName;
 91: 
 92:         // File Information, set for class Version to generate head xml nodes
 93:         $this->sDescription = $aFileInfo['description'];
 94:         $this->sAuthor = $aFileInfo['author'];
 95:         $this->dLastModified = $aFileInfo['lastmodified'];
 96:         $this->dCreated = $aFileInfo['created'];
 97: 
 98:         // Frontendpath to files
 99:         if ($sTypeContent == "templates") {
100:             $sTypeContent = "tpl";
101:         }
102: 
103:         $this->sPath = $this->aCfgClient[$this->iClient][$sTypeContent]["path"];
104: 
105:         // Identity the Id of Content Type
106:         $this->iIdentity = $iIdOfType;
107: 
108:         // This function looks if maximum number of stored versions is achieved
109:         $this->prune();
110: 
111:         // Take revision files if exists
112:         $this->initRevisions();
113: 
114:         // Get code of style
115:         $this->initFileContent();
116: 
117:         // Set Layout Table Iformation, currently not in use!
118:         // this->setLayoutTable();
119: 
120:         if ($sVersionFileName == '') {
121:             $sVersionFileName = $this->sFileName;
122:         }
123: 
124:         // Create Body Node of Xml File
125:         $this->setData("name", $sVersionFileName);
126:         $this->setData("code", $this->sCode);
127:         $this->setData("description", $this->sDescription);
128:     }
129: 
130:     /**
131:      * This function init the class member sCode with current file content
132:      *
133:      * @throws cInvalidArgumentException
134:      */
135:     protected function initFileContent() {
136:         if (cFileHandler::exists($this->sPath . $this->sFileName)) {
137:             $this->sCode = cFileHandler::read($this->sPath . $this->sFileName);
138:         } else {
139:             echo "<br>File not exists " . $this->sPath . $this->sFileName;
140:         }
141:     }
142: 
143:     /**
144:      * This function read an xml file nodes
145:      *
146:      * @param string $sPath
147:      *         Path to file
148:      *
149:      * @return array
150:      *         returns array width nodes
151:      * @throws cException
152:      */
153:     public function initXmlReader($sPath) {
154:         $aResult = array();
155:         if ($sPath != "") {
156:             $xml = new cXmlReader();
157:             $xml->load($sPath);
158: 
159:             $aResult['name'] = $xml->getXpathValue('/version/body/name');
160:             $aResult['desc'] = $xml->getXpathValue('/version/body/description');
161:             $aResult['code'] = $xml->getXpathValue('/version/body/code');
162:         }
163: 
164:         return $aResult;
165:     }
166: 
167:     /**
168:      * This function reads the path of file
169:      *
170:      * @return string
171:      *         the path of file
172:      */
173:     public function getPathFile() {
174:         return $this->sPath;
175:     }
176: 
177:     /**
178:      * Function returns javascript which refreshes CONTENIDO frames for file
179:      * list an subnavigation.
180:      * This is necessary, if filenames where changed, when a history entry is
181:      * restored
182:      *
183:      * @param string $sArea
184:      *         name of CONTENIDO area in which this procedure should be done
185:      * @param string $sFilename
186:      *         new filename of file which should be updated in other frames
187:      * @param object $sess
188:      *         CONTENIDO session object
189:      * @return string
190:      *         Javascript for refrehing frames
191:      */
192:     public function renderReloadScript($sArea, $sFilename, $sess) {
193:         $urlRightTop = $sess->url("main.php?area=$sArea&frame=3&file=$sFilename&history=true");
194:         $urlLeftBottom = $sess->url("main.php?area=$sArea&frame=2&file=$sFilename");
195:         $sReloadScript = <<<JS
196: <script type="text/javascript">
197: (function(Con, $) {
198:     var right_top = Con.getFrame('right_top'),
199:         left_bottom = Con.getFrame('left_bottom');
200: 
201:     if (right_top) {
202:         right_top.location.href = '{$urlRightTop}';
203:     }
204: 
205:     if (left_bottom) {
206:         left_bottom.location.href = '{$urlLeftBottom}';
207:     }
208: })(Con, Con.$);
209: </script>
210: JS;
211:         return $sReloadScript;
212:     }
213: 
214: }
215: 
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0