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: * @access private
31: */
32: private $sName;
33:
34: /**
35: * The code of Layout
36: *
37: * @access private
38: */
39: private $sCode;
40:
41: /**
42: * The Description of Layout
43: *
44: * @access private
45: */
46: private $sDescripion;
47:
48: /**
49: * The Metainformation about layout
50: *
51: * @access private
52: */
53: private $sDeletabel;
54:
55: /**
56: * The class versionLayout object constructor, initializes class variables
57: *
58: * @param string $iIdLayout The name of style file
59: * @param array $aCfg
60: * @param array $aCfgClient
61: * @param object $oDB
62: * @param integer $iClient
63: * @param object $sArea
64: * @param object $iFrame
65: */
66: public function __construct($iIdLayout, $aCfg, $aCfgClient, $oDB, $iClient, $sArea, $iFrame) {
67: // Init class members in super class
68: parent::__construct($aCfg, $aCfgClient, $oDB, $iClient, $sArea, $iFrame);
69:
70: // folder layout
71: $this->sType = "layout";
72: $this->iIdentity = $iIdLayout;
73:
74: // This function looks if maximum number of stored versions is achieved
75: $this->prune();
76:
77: $this->initRevisions();
78:
79: // Set Layout Table Iformation
80: $this->setLayoutTable();
81:
82: // Create Body Node of Xml File
83: $this->setData("name", $this->sName);
84: $this->setData("description", $this->sDescripion);
85: $this->setData("code", $this->sCode);
86: $this->setData("deletable", $this->bDeletabel);
87: }
88:
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 Path to file
131: *
132: * @return array returns array width this three nodes
133: */
134: public function initXmlReader($sPath) {
135: $aResult = array();
136: if ($sPath != "") {
137: // Output this xml file
138: $sXML = simplexml_load_file($sPath);
139:
140: if ($sXML) {
141: foreach ($sXML->body as $oBodyValues) {
142: // if choose xml file read value an set it
143: $aResult["name"] = $oBodyValues->name;
144: $aResult["desc"] = $oBodyValues->description;
145: $aResult["code"] = $oBodyValues->code;
146: }
147: }
148: }
149: return $aResult;
150: }
151:
152: /**
153: * Function returns javascript which refreshes CONTENIDO frames for file
154: * list an subnavigation.
155: * This is neccessary, if filenames where changed, when a history entry is
156: * restored
157: *
158: * @param integer $iIdClient - id of client which contains this file
159: * @param string $sArea - name of CONTENIDO area in which this procedure
160: * should be done
161: * @param integer $iIdLayout - Id of layout to highlight
162: * @param object $sess - CONTENIDO session object
163: *
164: * @return string - Javascript for refrehing frames
165: */
166: public function renderReloadScript($sArea, $iIdLayout, $sess) {
167: $sReloadScript = "<script type=\"text/javascript\">
168: var left_bottom = top.content.left.left_bottom;
169: if (left_bottom) {
170: var href = '" . $sess->url("main.php?area=$sArea&frame=2&idlay=$iIdLayout") . "';
171: left_bottom.location.href = href;
172: }
173: </script>";
174: return $sReloadScript;
175: }
176:
177: }
178: