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