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