1: <?php
2:
3: /**
4: * This file contains the layout version class.
5: *
6: * @package Core
7: * @subpackage Versioning
8: * @author Bilal Arslan, Timo Trautmann
9: * @copyright four for business AG <www.4fb.de>
10: * @license http://www.contenido.org/license/LIZENZ.txt
11: * @link http://www.4fb.de
12: * @link http://www.contenido.org
13: */
14:
15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
16:
17: /**
18: * Class of Layout Revision
19: * We use super class Version to create a new Version.
20: *
21: * @package Core
22: * @subpackage Versioning
23: */
24: class cVersionLayout extends cVersion {
25:
26: /**
27: * The name of Layout
28: *
29: * @var string
30: */
31: private $sName;
32:
33: /**
34: * The code of Layout
35: *
36: * @var string
37: */
38: private $sCode;
39:
40: /**
41: * The Description of Layout
42: *
43: * @var string
44: */
45: protected $sDescripion;
46:
47: /**
48: * The Metainformation about layout
49: *
50: * @var string
51: */
52: private $sDeletabel;
53:
54: /**
55: * Constructor to create an instance of this class.
56: *
57: * Initializes class variables.
58: *
59: * @param string $iIdLayout
60: * The name of style file
61: * @param array $aCfg
62: * @param array $aCfgClient
63: * @param cDb $oDB
64: * CONTENIDO database object
65: * @param int $iClient
66: * @param object $sArea
67: * @param int $iFrame
68: *
69: * @throws cInvalidArgumentException
70: * @throws cDbException
71: */
72: public function __construct($iIdLayout, $aCfg, $aCfgClient, $oDB, $iClient, $sArea, $iFrame) {
73: // Init class members in super class
74: parent::__construct($aCfg, $aCfgClient, $oDB, $iClient, $sArea, $iFrame);
75:
76: // folder layout
77: $this->sType = "layout";
78: $this->iIdentity = $iIdLayout;
79:
80: // This function looks if maximum number of stored versions is achieved
81: $this->prune();
82:
83: $this->initRevisions();
84:
85: // Set Layout Table Iformation
86: $this->setLayoutTable();
87:
88: // Create Body Node of Xml File
89: $this->setData("name", $this->sName);
90: $this->setData("description", $this->sDescripion);
91: $this->setData("code", $this->sCode);
92: $this->setData("deletable", $this->sDeletabel);
93: }
94:
95: /**
96: * Set code to data ...
97: *
98: * @param string $code
99: */
100: public function setCode($code) {
101: $this->setData('code', $code);
102: }
103:
104: /**
105: * Function reads rows variables from table con_layout and init with the
106: * class members.
107: *
108: * @throws cDbException
109: */
110: private function setLayoutTable() {
111: if (!is_object($this->oDB)) {
112: $this->oDB = cRegistry::getDb();
113: }
114:
115: $sSql = "";
116: $aLayout = array();
117:
118: $sSql = "SELECT * FROM " . $this->aCfg["tab"]["lay"] . "
119: WHERE idlay = '" . cSecurity::toInteger($this->iIdentity) . "'";
120:
121: if ($this->oDB->query($sSql)) {
122: $this->oDB->nextRecord();
123: $this->iClient = $this->oDB->f("idclient");
124: $this->sName = $this->oDB->f("name");
125: $this->sDescripion = $this->oDB->f("description");
126: $this->sDeletabel = $this->oDB->f("deletable");
127: $this->sAuthor = $this->oDB->f("author");
128: $this->dCreated = $this->oDB->f("created");
129: $this->dLastModified = $this->oDB->f("lastmodified");
130: }
131: }
132:
133: /**
134: * This function read an xml file nodes
135: *
136: * @param string $sPath
137: * Path to file
138: * @return array
139: * returns array width this three nodes
140: */
141: public function initXmlReader($sPath) {
142: $aResult = array();
143: if ($sPath != "") {
144: // Output this xml file
145: $sXML = simplexml_load_file($sPath);
146:
147: if ($sXML) {
148: foreach ($sXML->body as $oBodyValues) {
149: // if choose xml file read value an set it
150: $aResult["name"] = $oBodyValues->name;
151: $aResult["desc"] = $oBodyValues->description;
152: $aResult["code"] = $oBodyValues->code;
153: }
154: }
155: }
156: return $aResult;
157: }
158:
159: /**
160: * Function returns javascript which refreshes CONTENIDO frames for file
161: * list an subnavigation.
162: * This is necessary, if filenames where changed, when a history entry is
163: * restored
164: *
165: * @param string $sArea
166: * name of CONTENIDO area in which this procedure should be done
167: * @param int $iIdLayout
168: * Id of layout to highlight
169: * @param object $sess
170: * CONTENIDO session object
171: * @return string
172: * Javascript for refrehing frames
173: */
174: public function renderReloadScript($sArea, $iIdLayout, $sess) {
175: $urlLeftBottom = $sess->url("main.php?area=$sArea&frame=2&idlay=$iIdLayout");
176: $sReloadScript = <<<JS
177: <script type="text/javascript">
178: (function(Con, $) {
179: var frame = Con.getFrame('left_bottom');
180: if (frame) {
181: frame.location.href = '{$urlLeftBottom}';
182: }
183: })(Con, Con.$);
184: </script>
185: JS;
186: return $sReloadScript;
187: }
188:
189: }
190: