diff --git a/conlite/classes/class.version.php b/conlite/classes/class.version.php index 00dbadd..6e0107f 100644 --- a/conlite/classes/class.version.php +++ b/conlite/classes/class.version.php @@ -1,4 +1,5 @@ aCfg = $aCfg; - $this->aCfgClient = $aCfgClient; - $this->oDB = $oDB; - $this->iClient = $iClient; - $this->iRevisionNumber = 0; - $this->sArea = $sArea; - $this->iFrame = $iFrame; - $this->dActualTimestamp = time(); - $this->aVarForm = array(); - - self::$iDisplayNotification++; - - // Look if versioning is allowed, default is false - if(function_exists('getEffectiveSetting')) { - $this->bVersionCreatActive = getEffectiveSetting('versioning', 'activated', 'true'); - $this->sAlternativePath = getEffectiveSetting('versioning', 'path'); - } else { + * The Version object constructor, initializes class variables + * + * @param array $aCfg + * @param array $aCfgClient + * @param object $oDB + * @param integer $iClient + * @param object $sArea + * @param object $iFrame + * + * @return void + */ + public function __construct($aCfg, $aCfgClient, DB_ConLite $oDB, $iClient, $sArea, $iFrame) { + $this->aCfg = $aCfg; + $this->aCfgClient = $aCfgClient; + $this->oDB = $oDB; + $this->iClient = $iClient; + $this->iRevisionNumber = 0; + $this->sArea = $sArea; + $this->iFrame = $iFrame; + $this->dActualTimestamp = time(); + $this->aVarForm = array(); + + self::$iDisplayNotification++; + + // Look if versioning is allowed, default is false + if (function_exists('getEffectiveSetting')) { + $this->bVersionCreatActive = getEffectiveSetting('versioning', 'activated', 'true'); + $this->sAlternativePath = getEffectiveSetting('versioning', 'path'); + } else { $this->bVersionCreatActive = true; $this->sAlternativePath = ""; } - if($this->bVersionCreatActive == "true"){ - if(!is_dir($this->sAlternativePath) ){ - // Alternative Path is not true or is not exist, we use the frontendpath - if($this->sAlternativePath !="" AND self::$iDisplayNotification < 2){ - $oNotification = new Contenido_Notification(); - $sNotification = i18n('Alternative path %s does not exist. Version was saved in frondendpath.'); - $oNotification->displayNotification("warning", sprintf($sNotification, $this->sAlternativePath)); - - } - - $this->sAlternativePath = ""; + if ($this->bVersionCreatActive == "true") { + if (!is_dir($this->sAlternativePath)) { + // Alternative Path is not true or is not exist, we use the frontendpath + if ($this->sAlternativePath != "" AND self::$iDisplayNotification < 2) { + $oNotification = new Contenido_Notification(); + $sNotification = i18n('Alternative path %s does not exist. Version was saved in frondendpath.'); + $oNotification->displayNotification("warning", sprintf($sNotification, $this->sAlternativePath)); + } + + $this->sAlternativePath = ""; } - - // Look if versioning is set alternative path to save - $this->_checkPaths(); - } - } - - /** - * This function looks if maximum number of stored versions is achieved. If true, it will be delete the first version. - * - * @return void - */ + + // Look if versioning is set alternative path to save + $this->_checkPaths(); + } + } + + /** + * This function looks if maximum number of stored versions is achieved. If true, it will be delete the first version. + * + * @return void + */ protected function prune() { $this->initRevisions(); if (function_exists('getEffectiveSetting')) { $sVar = getEffectiveSetting('versioning', 'prune_limit', '0'); } else { $sVar = 0; - } - - $bDelete = true; - - while(count($this->aRevisionFiles) >= $sVar AND $bDelete AND (int) $sVar > 0) { + } + + $bDelete = true; + + while (count($this->aRevisionFiles) >= $sVar AND $bDelete AND (int) $sVar > 0) { $iIndex = end(array_keys($this->aRevisionFiles)); $bDelete = $this->deleteFile($this->getFirstRevision()); - unset($this->aRevisionFiles[$iIndex]); - } + unset($this->aRevisionFiles[$iIndex]); + } } - + /** - * This function checks if needed version paths exists and were created if neccessary - * @return boolean - */ + * This function checks if needed version paths exists and were created if neccessary + * @return boolean + */ protected function _checkPaths() { $aPath = array('', '/css', '/js', '/layout', '/module', '/templates'); $sFrontEndPath = ""; - if($this->sAlternativePath == "") { - $sFrontEndPath = $this->aCfgClient[$this->iClient]["path"]["frontend"] . "version"; + if ($this->sAlternativePath == "") { + $sFrontEndPath = $this->aCfgClient[$this->iClient]["path"]["frontend"] . "version"; } else { - $sFrontEndPath = $this->sAlternativePath . "/" . $this->iClient; + $sFrontEndPath = $this->sAlternativePath . "/" . $this->iClient; } - if(is_dir($sFrontEndPath) && is_writable($sFrontEndPath)) { + if (is_dir($sFrontEndPath) && is_writable($sFrontEndPath)) { foreach ($aPath as $sSubPath) { - if(!is_dir($sFrontEndPath.$sSubPath)){ - mkdir($sFrontEndPath.$sSubPath, 0777); - chmod ($sFrontEndPath.$sSubPath, 0777); + if (!is_dir($sFrontEndPath . $sSubPath)) { + mkdir($sFrontEndPath . $sSubPath, 0777); + chmod($sFrontEndPath . $sSubPath, 0777); } } } else { - trigger_error("Version path ".$sFrontEndPath." not writable in ".__FILE__." on line ".__LINE__, E_USER_WARNING); + trigger_error("Version path " . $sFrontEndPath . " not writable in " . __FILE__ . " on line " . __LINE__, E_USER_WARNING); $this->_bPathError = true; return false; } return true; } - /** - * This function initialize the body node of xml file - * - * @param string $sKey - * @param string $sValue - * - * @return array returns an array for body node - */ - public function setData($sKey, $sValue) { - $this->aBodyData[$sKey] = $sValue; + /** + * This function initialize the body node of xml file + * + * @param string $sKey + * @param string $sValue + * + * @return array returns an array for body node + */ + public function setData($sKey, $sValue) { + $this->aBodyData[$sKey] = $sValue; + } - } + /** + * This function creats an xml file. XML Writer helps for create this file. + * + * @return string returns content of xml file + */ + public function createNewXml() { + $oXW = new cXmlWriter(); + $oXW->openMemory(); + $oXW->setIndent(true); + $oXW->startDocument('1.0', 'UTF-8'); - /** - * This function creats an xml file. XML Writer helps for create this file. - * - * @return string returns content of xml file - */ - public function createNewXml() { - $oXW = new xmlWriter(); - $oXW->openMemory(); - $oXW->setIndent(true); - $oXW->startDocument('1.0', 'UTF-8'); - - $oXW->startElement('version'); - $oXW->writeAttribute('xml:lang', 'de'); - - $oXW->startElement('head'); - $oXW->writeElement('version_id', $this->iIdentity.'_'.$this->iVersion); - $oXW->writeElement('type', $this->sType); - $oXW->writeElement('date', date("Y-m-d H:i:s")); - $oXW->writeElement('author', $this->sAuthor); - $oXW->writeElement('client', $this->iClient); - $oXW->writeElement('created', $this->dCreated); - $oXW->writeElement('lastmodified', $this->dLastModified); - $oXW->endElement(); + $oXW->startElement('version'); + $oXW->writeAttribute('xml:lang', 'de'); - $oXW->startElement('body'); - - foreach ($this->aBodyData as $sKey => $sValue) { - $oXW->writeElement($sKey, clHtmlEntities($sValue)); - } + $oXW->startElement('head'); + $oXW->writeElement('version_id', $this->iIdentity . '_' . $this->iVersion); + $oXW->writeElement('type', $this->sType); + $oXW->writeElement('date', date("Y-m-d H:i:s")); + $oXW->writeElement('author', $this->sAuthor); + $oXW->writeElement('client', $this->iClient); + $oXW->writeElement('created', $this->dCreated); + $oXW->writeElement('lastmodified', $this->dLastModified); + $oXW->endElement(); - $oXW->endElement(); + $oXW->startElement('body'); - $oXW->endElement(); - - return $oXW->outputMemory(true); - } - - /** - * This function creats new version in right folder. - * - * @return void - */ - public function createNewVersion() { - if($this->_bPathError) return false; - $bCreate = false; - if($this->bVersionCreatActive == "true"){ - try { // Get version Name - $sRevisionName = $this->getRevision(); - - // Create xml version file - $sXmlFile = $this->createNewXml(); - - if(!is_dir($this->getFilePath())){ - - $bCreate = mkdir($this->getFilePath(), 0777); - chmod ($this->getFilePath(), 0777); - } - - $sHandle = fopen($this->getFilePath().$sRevisionName.'.xml', "w"); - fputs($sHandle, $sXmlFile); - $bCreate = fclose($sHandle); - - if($bCreate == false){ - throw new Exception('Couldnt Create New Version'); - } - - } catch(Exception $e) { - $bCreate = false; - echo '
Some error occured: ' . $e->getMessage() . ': ' . $e->getFile() . ' at line '.$e->getLine() . ' ('.$e->getTraceAsString().')'; - } - } - return $bCreate; - } - - /** - * This function inits version files. Its filter also timestamp and version files - * - * @return array returns xml file names - */ - protected function initRevisions() { + foreach ($this->aBodyData as $sKey => $sValue) { + $oXW->writeElement($sKey, clHtmlEntities($sValue)); + } + + $oXW->endElement(); + + $oXW->endElement(); + + return $oXW->outputMemory(true); + } + + /** + * This function creats new version in right folder. + * + * @return void + */ + public function createNewVersion() { + if ($this->_bPathError) + return false; + $bCreate = false; + if ($this->bVersionCreatActive == "true") { + try { // Get version Name + $sRevisionName = $this->getRevision(); + + // Create xml version file + $sXmlFile = $this->createNewXml(); + + if (!is_dir($this->getFilePath())) { + + $bCreate = mkdir($this->getFilePath(), 0777); + chmod($this->getFilePath(), 0777); + } + + $sHandle = fopen($this->getFilePath() . $sRevisionName . '.xml', "w"); + fputs($sHandle, $sXmlFile); + $bCreate = fclose($sHandle); + + if ($bCreate == false) { + throw new Exception('Couldnt Create New Version'); + } + } catch (Exception $e) { + $bCreate = false; + echo '
Some error occured: ' . $e->getMessage() . ': ' . $e->getFile() . ' at line ' . $e->getLine() . ' (' . $e->getTraceAsString() . ')'; + } + } + return $bCreate; + } + + /** + * This function inits version files. Its filter also timestamp and version files + * + * @return array returns xml file names + */ + protected function initRevisions() { $this->aRevisionFiles = array(); $this->dTimestamp = array(); - - // Open this Filepath and read then the content. - $sDir = $this->getFilePath(); - if (is_dir($sDir)) { - if ($dh = opendir($sDir)) { - - while (($file = readdir($dh)) !== false) { - if ($file != '.' && $file != '..'){ - $aData = explode('.', $file); - $aValues = explode('_', $aData[0]); - if ($aValues[0] > $this->iRevisionNumber) { - $this->iRevisionNumber = $aValues[0]; - } - - $this->dTimestamp[$aValues[0]] = $aValues[1]; - $this->aRevisionFiles[$aValues[0]] = $file; - } - } - closedir($dh); - } - } - return krsort($this->aRevisionFiles); - } - - /** - * This function deletes files and the the folder, for given path. - * - * @return bool return true if successful - */ - public function deleteFile($sFirstFile = "") { - // Open this Filepath and read then the content. - $sDir = $this->getFilePath(); - $bDelet = false; - if (is_dir($sDir) AND $sFirstFile =="") { - if ($dh = opendir($sDir)) { - while (($sFile = readdir($dh)) !== false) { - if($sFile != "." && $sFile !=".."){ - // Delete the files - $bDelete = unlink($sDir.$sFile); - } - } -// if the files be cleared, the delete the folder - $bDelete = rmdir($sDir); - } - } else if($sFirstFile !="") { - $bDelete = unlink($sDir . $sFirstFile); - } - if($bDelete){ - return true; - } else { - return false; - } - } - - /** - * Get the frontendpath to revision - * - * @return string returns path to revision file - */ - public function getFilePath() { - if($this->sAlternativePath =="") { - $sFrontEndPath = $this->aCfgClient[$this->iClient]["path"]["frontend"] . "version/"; - } else { - $sFrontEndPath = $this->sAlternativePath . "/" . $this->iClient . "/"; + // Open this Filepath and read then the content. + $sDir = $this->getFilePath(); + if (is_dir($sDir)) { + if ($dh = opendir($sDir)) { + + while (($file = readdir($dh)) !== false) { + if ($file != '.' && $file != '..') { + $aData = explode('.', $file); + $aValues = explode('_', $aData[0]); + if ($aValues[0] > $this->iRevisionNumber) { + $this->iRevisionNumber = $aValues[0]; + } + + $this->dTimestamp[$aValues[0]] = $aValues[1]; + $this->aRevisionFiles[$aValues[0]] = $file; + } + } + closedir($dh); + } } - return $sFrontEndPath . $this->sType.'/'. $this->iIdentity. '/'; - } + return krsort($this->aRevisionFiles); + } - /** - * Get the last revision file - * - * @return array returns Last Revision - */ + /** + * This function deletes files and the the folder, for given path. + * + * @return bool return true if successful + */ + public function deleteFile($sFirstFile = "") { + // Open this Filepath and read then the content. + $sDir = $this->getFilePath(); + + $bDelet = false; + if (is_dir($sDir) AND $sFirstFile == "") { + if ($dh = opendir($sDir)) { + while (($sFile = readdir($dh)) !== false) { + if ($sFile != "." && $sFile != "..") { + // Delete the files + $bDelete = unlink($sDir . $sFile); + } + } +// if the files be cleared, the delete the folder + $bDelete = rmdir($sDir); + } + } else if ($sFirstFile != "") { + $bDelete = unlink($sDir . $sFirstFile); + } + if ($bDelete) { + return true; + } else { + return false; + } + } + + /** + * Get the frontendpath to revision + * + * @return string returns path to revision file + */ + public function getFilePath() { + if ($this->sAlternativePath == "") { + $sFrontEndPath = $this->aCfgClient[$this->iClient]["path"]["frontend"] . "version/"; + } else { + $sFrontEndPath = $this->sAlternativePath . "/" . $this->iClient . "/"; + } + return $sFrontEndPath . $this->sType . '/' . $this->iIdentity . '/'; + } + + /** + * Get the last revision file + * + * @return array returns Last Revision + */ public function getLastRevision() { return reset($this->aRevisionFiles); } - + /** - * Makes new and init Revision Name - * - * @return integer returns number of Revison File - */ - private function getRevision() { - $this->iVersion = ($this->iRevisionNumber +1 ).'_'.$this->dActualTimestamp; - return $this->iVersion; - } - - /** - * Inits the first element of revision files - * - * @return string the name of xml files - */ - protected function getFirstRevision() { - $aKey = array(); - $this->initRevisions(); - $aKey = $this->aRevisionFiles; - $sFirstRevision = ""; + * Makes new and init Revision Name + * + * @return integer returns number of Revison File + */ + private function getRevision() { + $this->iVersion = ($this->iRevisionNumber + 1 ) . '_' . $this->dActualTimestamp; + return $this->iVersion; + } + + /** + * Inits the first element of revision files + * + * @return string the name of xml files + */ + protected function getFirstRevision() { + $aKey = array(); + $this->initRevisions(); + $aKey = $this->aRevisionFiles; + $sFirstRevision = ""; // to take first element, we use right sort - ksort($aKey); - foreach($aKey as $value){ - return $sFirstRevision = $value; - } - return $sFirstRevision; - } - - /** - * Revision Files - * - * @return array returns all Revison File - */ - public function getRevisionFiles() { - return $this->aRevisionFiles; - } - - /** - * This function generate version names for select-box - * - * @return array returns an array of revision file names - */ - public function getFormatTimestamp() { - $aTimes = array(); - if(count($this->dTimestamp) > 0){ - krsort($this->dTimestamp); - foreach($this->dTimestamp as $iKey=>$sTimeValue){ - $aTimes[$this->aRevisionFiles[$iKey]] = date('d.m.Y H:i:s', $sTimeValue). " - Revision: " .$iKey; - } - } - - return $aTimes; - } - - /** - * This function generate version names for select-box - * - * @return array returns an array of revision file names - */ - public function setVarForm($sKey, $sValue) { - $this->aVarForm[$sKey] = $sValue; - } - - /** - * The general SelectBox function for get Revision. - * - * @param string $sTableForm The name of Table_Form class - * @param string $sAddHeader The Header Label of SelectBox Widget - * @param string $sLabelOfSelectBox The Label of SelectBox Widget - * @param string $sIdOfSelectBox Id of Select Box - * - * return string if is exists Revision, then returns HTML Code of full SelectBox else returns empty string - */ - public function buildSelectBox($sTableForm, $sAddHeader, $sLabelOfSelectBox, $sIdOfSelectBox) { - $oForm = new UI_Table_Form("lay_history"); - $aMessage = array(); - // if exists xml files - if(count($this->dTimestamp) > 0) { - - foreach($this->aVarForm as $sKey=>$sValue) { - $oForm ->setVar($sKey, $sValue); - } - $aMessage = $this->getMessages(); - $oForm ->addHeader(i18n($sAddHeader)); - $oForm ->add(i18n($sLabelOfSelectBox), $this->getSelectBox($this->getFormatTimestamp(), $sIdOfSelectBox)); - $oForm ->setActionButton("clearhistory", "images/but_delete.gif", $aMessage["alt"], "c", "history_truncate"); - $oForm ->setConfirm("clearhistory", $aMessage["alt"], $aMessage["popup"]); - $oForm ->setActionButton("submit", "images/but_refresh.gif", i18n("Refresh"), "s"); - - return $oForm ->render().'
'; - } else { - return ''; - } + ksort($aKey); + foreach ($aKey as $value) { + return $sFirstRevision = $value; + } + return $sFirstRevision; } - + + /** + * Revision Files + * + * @return array returns all Revison File + */ + public function getRevisionFiles() { + return $this->aRevisionFiles; + } + + /** + * This function generate version names for select-box + * + * @return array returns an array of revision file names + */ + public function getFormatTimestamp() { + $aTimes = array(); + if (count($this->dTimestamp) > 0) { + krsort($this->dTimestamp); + foreach ($this->dTimestamp as $iKey => $sTimeValue) { + $aTimes[$this->aRevisionFiles[$iKey]] = date('d.m.Y H:i:s', $sTimeValue) . " - Revision: " . $iKey; + } + } + + return $aTimes; + } + + /** + * This function generate version names for select-box + * + * @return array returns an array of revision file names + */ + public function setVarForm($sKey, $sValue) { + $this->aVarForm[$sKey] = $sValue; + } + + /** + * The general SelectBox function for get Revision. + * + * @param string $sTableForm The name of Table_Form class + * @param string $sAddHeader The Header Label of SelectBox Widget + * @param string $sLabelOfSelectBox The Label of SelectBox Widget + * @param string $sIdOfSelectBox Id of Select Box + * + * return string if is exists Revision, then returns HTML Code of full SelectBox else returns empty string + */ + public function buildSelectBox($sTableForm, $sAddHeader, $sLabelOfSelectBox, $sIdOfSelectBox) { + $oForm = new UI_Table_Form("lay_history"); + $aMessage = array(); + // if exists xml files + if (count($this->dTimestamp) > 0) { + + foreach ($this->aVarForm as $sKey => $sValue) { + $oForm->setVar($sKey, $sValue); + } + $aMessage = $this->getMessages(); + $oForm->addHeader(i18n($sAddHeader)); + $oForm->add(i18n($sLabelOfSelectBox), $this->getSelectBox($this->getFormatTimestamp(), $sIdOfSelectBox)); + $oForm->setActionButton("clearhistory", "images/but_delete.gif", $aMessage["alt"], "c", "history_truncate"); + $oForm->setConfirm("clearhistory", $aMessage["alt"], $aMessage["popup"]); + $oForm->setActionButton("submit", "images/but_refresh.gif", i18n("Refresh"), "s"); + + return $oForm->render() . '
'; + } else { + return ''; + } + } + /** * Messagebox for build selectBox. Dynamic allocation for type. - * return array the attributes alt and poput returns - */ - private function getMessages(){ - $aMessage = array(); - switch($this->sType){ - case 'layout': - $aMessage["alt"] = i18n("Clear layout history"); - $aMessage["popup"] = i18n("Do you really want to clear layout history?")."

".i18n("Note: This only affects the current layout."); - break; - case 'module': - $aMessage["alt"] = i18n("Clear module history"); - $aMessage["popup"] = i18n("Do you really want to clear module history?")."

".i18n("Note: This only affects the current module."); - break; - case 'css': - $aMessage["alt"] = i18n("Clear style history"); - $aMessage["popup"] = i18n("Do you really want to clear style history?")."

".i18n("Note: This only affects the current style."); - break; - case 'js': - $aMessage["alt"] = i18n("Clear Java-Script history"); - $aMessage["popup"] = i18n("Do you really want to clear Java-Script history?")."

".i18n("Note: This only affects the current Java-Script."); - break; - case 'templates': - $aMessage["alt"] = i18n("Clear HTML-Template history"); - $aMessage["popup"] = i18n("Do you really want to clear HTML-Template history?")."

".i18n("Note: This only the affects current HTML-Template."); - break; - default: - $aMessage["alt"] = i18n("Clear history"); - $aMessage["popup"] = i18n("Do you really want to clear history?")."

".i18n("Note: This only affects the current history."); - break; - - } - return $aMessage; + * return array the attributes alt and poput returns + */ + private function getMessages() { + $aMessage = array(); + switch ($this->sType) { + case 'layout': + $aMessage["alt"] = i18n("Clear layout history"); + $aMessage["popup"] = i18n("Do you really want to clear layout history?") . "

" . i18n("Note: This only affects the current layout."); + break; + case 'module': + $aMessage["alt"] = i18n("Clear module history"); + $aMessage["popup"] = i18n("Do you really want to clear module history?") . "

" . i18n("Note: This only affects the current module."); + break; + case 'css': + $aMessage["alt"] = i18n("Clear style history"); + $aMessage["popup"] = i18n("Do you really want to clear style history?") . "

" . i18n("Note: This only affects the current style."); + break; + case 'js': + $aMessage["alt"] = i18n("Clear Java-Script history"); + $aMessage["popup"] = i18n("Do you really want to clear Java-Script history?") . "

" . i18n("Note: This only affects the current Java-Script."); + break; + case 'templates': + $aMessage["alt"] = i18n("Clear HTML-Template history"); + $aMessage["popup"] = i18n("Do you really want to clear HTML-Template history?") . "

" . i18n("Note: This only the affects current HTML-Template."); + break; + default: + $aMessage["alt"] = i18n("Clear history"); + $aMessage["popup"] = i18n("Do you really want to clear history?") . "

" . i18n("Note: This only affects the current history."); + break; + } + return $aMessage; } - - /** - * A Class Function for fill version files - * - * @param string $sTableForm The name of Table_Form class - * @param string $sAddHeader The Header Label of SelectBox Widget - * - * return string returns select-box with filled files - */ + + /** + * A Class Function for fill version files + * + * @param string $sTableForm The name of Table_Form class + * @param string $sAddHeader The Header Label of SelectBox Widget + * + * return string returns select-box with filled files + */ private function getSelectBox($aTempVesions, $sIdOfSelectBox) { - $sSelected = $_POST[$sIdOfSelectBox]; - $oSelectMenue = new cHTMLSelectElement($sIdOfSelectBox); - $oSelectMenue->autoFill($aTempVesions); - - if($sSelected !=""){ - $oSelectMenue->setDefault($sSelected); - } - - return $oSelectMenue->render(); - } + $sSelected = $_POST[$sIdOfSelectBox]; + $oSelectMenue = new cHTMLSelectElement($sIdOfSelectBox); + $oSelectMenue->autoFill($aTempVesions); - /** - * Build new Textarea with below parameters - * - * @param string $sName The name of Textarea. - * @param string $sValue The value of Input Textarea - * @param integer $iWidth width of Textarea - * @param integer $iHeight height of Textarea - * - * @return string HTML Code of Textarea - */ - public function getTextarea($sName, $sInitValue, $iWidth, $iHeight, $sId = "") { - if($sId !="") { - $oHTMLTextarea = new cHTMLTextarea($sName, $sInitValue, $iWidth, $iHeight, $sId); - } else { - $oHTMLTextarea = new cHTMLTextarea($sName, $sInitValue, $iWidth, $iHeight); - } - - $oHTMLTextarea->setStyle("font-family: monospace; width: 100%;"); - $oHTMLTextarea->updateAttributes(array("wrap" => "off")); - - return $oHTMLTextarea->render(); - - } - - /** - * Build new Textfield with below parameters - * - * @param string $sName The name of Input Textfield. - * @param string $sValue The value of Input Textfield - * @param integer $iWidth width of Input Textfield - * - * @return string HTML Code of Input Textfield - */ - public function getTextBox($sName, $sInitValue, $iWidth, $bDisabled = false) { - $oHTMLTextbox = new cHTMLTextbox($sName, clHtmlEntityDecode($sInitValue), $iWidth, "", "", $bDisabled); - $oHTMLTextbox->setStyle("font-family: monospace; width: 100%;"); - $oHTMLTextbox->updateAttributes(array("wrap" => "off")); - - return $oHTMLTextbox->render(); - } - - /** - * Displays your notification - * - * @param string $sOutPut - * - * @return void - */ - public function displayNotification($sOutPut) { - if($sOutPut !="") { - print $sOutPut; - } - } - - /** - * Set new node for xml file of description - * - * @param string $sDesc Content of node - * - */ - public function setBodyNodeDescription($sDesc) { - if($sDesc != ""){ - $this->sDescripion = clHtmlEntities($sDesc); - $this->setData("description", $this->sDescripion); - } + if ($sSelected != "") { + $oSelectMenue->setDefault($sSelected); + } + + return $oSelectMenue->render(); } -} // end of class + /** + * Build new Textarea with below parameters + * + * @param string $sName The name of Textarea. + * @param string $sValue The value of Input Textarea + * @param integer $iWidth width of Textarea + * @param integer $iHeight height of Textarea + * + * @return string HTML Code of Textarea + */ + public function getTextarea($sName, $sInitValue, $iWidth, $iHeight, $sId = "") { + if ($sId != "") { + $oHTMLTextarea = new cHTMLTextarea($sName, $sInitValue, $iWidth, $iHeight, $sId); + } else { + $oHTMLTextarea = new cHTMLTextarea($sName, $sInitValue, $iWidth, $iHeight); + } + $oHTMLTextarea->setStyle("font-family: monospace; width: 100%;"); + $oHTMLTextarea->updateAttributes(array("wrap" => "off")); + + return $oHTMLTextarea->render(); + } + + /** + * Build new Textfield with below parameters + * + * @param string $sName The name of Input Textfield. + * @param string $sValue The value of Input Textfield + * @param integer $iWidth width of Input Textfield + * + * @return string HTML Code of Input Textfield + */ + public function getTextBox($sName, $sInitValue, $iWidth, $bDisabled = false) { + $oHTMLTextbox = new cHTMLTextbox($sName, clHtmlEntityDecode($sInitValue), $iWidth, "", "", $bDisabled); + $oHTMLTextbox->setStyle("font-family: monospace; width: 100%;"); + $oHTMLTextbox->updateAttributes(array("wrap" => "off")); + + return $oHTMLTextbox->render(); + } + + /** + * Displays your notification + * + * @param string $sOutPut + * + * @return void + */ + public function displayNotification($sOutPut) { + if ($sOutPut != "") { + print $sOutPut; + } + } + + /** + * Set new node for xml file of description + * + * @param string $sDesc Content of node + * + */ + public function setBodyNodeDescription($sDesc) { + if ($sDesc != "") { + $this->sDescripion = clHtmlEntities($sDesc); + $this->setData("description", $this->sDescripion); + } + } + +} + +// end of class ?> \ No newline at end of file diff --git a/conlite/classes/class.versionImport.php b/conlite/classes/class.versionImport.php index 65845a4..4b72c3f 100644 --- a/conlite/classes/class.versionImport.php +++ b/conlite/classes/class.versionImport.php @@ -1,4 +1,5 @@ aCfgClient = $aCfgClient; $this->oDB = $oDB; - - if(!is_object($this->oDB)) - $this->oDB = new DB_ConLite; - -// folder layout - $this->sType = "module"; - - - if(isset($_SESSION["dbprefix"])){ - $this->sTableName = $_SESSION["dbprefix"]."_mod_history"; - } else { - $this->sTableName = $this->aCfg['sql']['sqlprefix']."_mod_history"; - } -// init class member - $this->aCreateVesion = array(); - -// Init class members with table con_history - $this->getModuleHistoryTable(); - - } // end of constructor - - /** - * Creats xml files from table mod_history if exists any rows. After create a version it will be delete the current row. - * If no rows any available, it will be drop the table mod_history. - * - * @return void - */ - public function CreateHistoryVersion() { - if($this->getRows() > 0) { - // Sort the version files true - ksort($this->aCreateVersion); - - // All array read - foreach( $this->aCreateVersion as $sKey=>$sLevelOne) { - foreach($sLevelOne as $sKey2=>$sLevelTwo) { - if (is_array($this->aCfgClient[$sKey])) { - parent::__construct($aCfg, $this->aCfgClient, $this->oDB, $sKey, $sArea, $iFrame); - foreach($sLevelTwo as $sKey3=>$sLevelThree) { - $this->iIdentity = $sKey2; - $this->sName = Contenido_Security::unFilter($sLevelThree["name"]); - $this->sModType = Contenido_Security::unFilter($sLevelThree["type"]); - $this->sError = Contenido_Security::unFilter($sLevelThree["error"]); - $this->sDescripion = Contenido_Security::unFilter($sLevelThree["description"]); - $this->sDeletabel = Contenido_Security::unFilter($sLevelThree ["deletable"]); - $this->sCodeInput = Contenido_Security::unFilter($sLevelThree ["input"]); - $this->sCodeOutput = Contenido_Security::unFilter($sLevelThree ["output"]); - $this->sTemplate = Contenido_Security::unFilter($sLevelThree["template"]); - $this->sStatic = Contenido_Security::unFilter($sLevelThree["static"]); - $this->sPackageGuid = Contenido_Security::unFilter($sLevelThree["package_guid"]); - $this->sPackageData = Contenido_Security::unFilter($sLevelThree["package_data"]); - $this->sAuthor = Contenido_Security::unFilter($sLevelThree["changedby"]); - $this->dCreated = Contenido_Security::unFilter($sLevelThree["created"]); - $this->dLastModified = Contenido_Security::unFilter($sLevelThree["changed"]); - $this->dActualTimestamp = Contenido_Security::unFilter($sLevelThree["changed"]); - - $this->initRevisions(); - - $this->createBodyXML(); - - if($this->createNewVersion()) { - $this->deleteRows($sLevelThree["idmodhistory"]); - } - } + if (!is_object($this->oDB)) + $this->oDB = new DB_ConLite; + +// folder layout + $this->sType = "module"; + + + if (isset($_SESSION["dbprefix"])) { + $this->sTableName = $_SESSION["dbprefix"] . "_mod_history"; + } else { + $this->sTableName = $this->aCfg['sql']['sqlprefix'] . "_mod_history"; + } +// init class member + $this->aCreateVesion = array(); + +// Init class members with table con_history + $this->getModuleHistoryTable(); + } + +// end of constructor + + /** + * Creats xml files from table mod_history if exists any rows. After create a version it will be delete the current row. + * If no rows any available, it will be drop the table mod_history. + * + * @return void + */ + public function CreateHistoryVersion() { + if ($this->getRows() > 0) { + // Sort the version files true + ksort($this->aCreateVersion); + + // All array read + foreach ($this->aCreateVersion as $sKey => $sLevelOne) { + foreach ($sLevelOne as $sKey2 => $sLevelTwo) { + if (is_array($this->aCfgClient[$sKey])) { + parent::__construct($aCfg, $this->aCfgClient, $this->oDB, $sKey, $sArea, $iFrame); + + foreach ($sLevelTwo as $sKey3 => $sLevelThree) { + $this->iIdentity = $sKey2; + $this->sName = Contenido_Security::unFilter($sLevelThree["name"]); + $this->sModType = Contenido_Security::unFilter($sLevelThree["type"]); + $this->sError = Contenido_Security::unFilter($sLevelThree["error"]); + $this->sDescripion = Contenido_Security::unFilter($sLevelThree["description"]); + $this->sDeletabel = Contenido_Security::unFilter($sLevelThree ["deletable"]); + $this->sCodeInput = Contenido_Security::unFilter($sLevelThree ["input"]); + $this->sCodeOutput = Contenido_Security::unFilter($sLevelThree ["output"]); + $this->sTemplate = Contenido_Security::unFilter($sLevelThree["template"]); + $this->sStatic = Contenido_Security::unFilter($sLevelThree["static"]); + $this->sPackageGuid = Contenido_Security::unFilter($sLevelThree["package_guid"]); + $this->sPackageData = Contenido_Security::unFilter($sLevelThree["package_data"]); + $this->sAuthor = Contenido_Security::unFilter($sLevelThree["changedby"]); + $this->dCreated = Contenido_Security::unFilter($sLevelThree["created"]); + $this->dLastModified = Contenido_Security::unFilter($sLevelThree["changed"]); + $this->dActualTimestamp = Contenido_Security::unFilter($sLevelThree["changed"]); + + $this->initRevisions(); + + $this->createBodyXML(); + + if ($this->createNewVersion()) { + $this->deleteRows($sLevelThree["idmodhistory"]); + } + } } - } - }// end of foreach - } - - - if($this->getRows() == 0) { - $this->dropTable(); - } - } - - - /** - * Function reads rows variables from table con_mod and init with the class members. - * - * @return void - */ - private function getModuleHistoryTable() { - $sSql = ""; - $sSql = "SELECT * - FROM ". $this->sTableName; - $this->oDB->query($sSql); + } + }// end of foreach + } + + + if ($this->getRows() == 0) { + $this->dropTable(); + } + } + + /** + * Function reads rows variables from table con_mod and init with the class members. + * + * @return void + */ + private function getModuleHistoryTable() { + $sSql = ""; + $sSql = "SELECT * + FROM " . $this->sTableName; + $this->oDB->query($sSql); // save mod_history in three dimension array - while($this->oDB->next_record()) { - $this->aCreateVersion[$this->oDB->f("idclient")][$this->oDB->f("idmod")][$this->oDB->f("idmodhistory")] = - array("idmodhistory"=>$this->oDB->f("idmodhistory"), "idmod"=>$this->oDB->f("idmod"), - "idclient"=>$this->oDB->f("idclient"), "name"=>$this->oDB->f("name"), - "type"=>$this->oDB->f("type"), "description"=>$this->oDB->f("description"), - "input"=>$this->oDB->f("input"), "output"=>$this->oDB->f("output"), - "template"=>$this->oDB->f("template"), "changedby"=>$this->oDB->f("changedby"), - "changed"=>$this->oDB->f("changed")); - } - } // end of function - - /** - * Set with the body nodes of xml file - * - * @return void - */ - private function createBodyXML() { + while ($this->oDB->next_record()) { + $this->aCreateVersion[$this->oDB->f("idclient")][$this->oDB->f("idmod")][$this->oDB->f("idmodhistory")] = array("idmodhistory" => $this->oDB->f("idmodhistory"), "idmod" => $this->oDB->f("idmod"), + "idclient" => $this->oDB->f("idclient"), "name" => $this->oDB->f("name"), + "type" => $this->oDB->f("type"), "description" => $this->oDB->f("description"), + "input" => $this->oDB->f("input"), "output" => $this->oDB->f("output"), + "template" => $this->oDB->f("template"), "changedby" => $this->oDB->f("changedby"), + "changed" => $this->oDB->f("changed")); + } + } + +// end of function + + /** + * Set with the body nodes of xml file + * + * @return void + */ + private function createBodyXML() { // Create Body Node of Xml File - $this->setData("Name", $this->sName); - $this->setData("Modul_Type", $this->sModType); - $this->setData("Error", $this->sError); - $this->setData("Description", $this->sDescripion); - $this->setData("Deletable", $this->bDeletabel); - $this->setData("CodeInput", $this->sCodeInput); - $this->setData("CodeOutput", $this->sCodeOutput); - $this->setData("Template", $this->sTemplate); - $this->setData("Static", $this->sStatic); - $this->setData("PackageGuid", $this->sPackageGuid); - $this->setData("PackageData", $this->sPackageData); - - } - - /** - * Get all rows in tabel mod_con_history - * - * @return integer count of rows - */ - private function getRows() { - $sSqlCount = ""; - $iAnz = 0; - $sSqlCount = "SELECT * FROM ". $this->sTableName; + $this->setData("Name", $this->sName); + $this->setData("Modul_Type", $this->sModType); + $this->setData("Error", $this->sError); + $this->setData("Description", $this->sDescripion); + $this->setData("Deletable", $this->bDeletabel); + $this->setData("CodeInput", $this->sCodeInput); + $this->setData("CodeOutput", $this->sCodeOutput); + $this->setData("Template", $this->sTemplate); + $this->setData("Static", $this->sStatic); + $this->setData("PackageGuid", $this->sPackageGuid); + $this->setData("PackageData", $this->sPackageData); + } + + /** + * Get all rows in tabel mod_con_history + * + * @return integer count of rows + */ + private function getRows() { + $sSqlCount = ""; + $iAnz = 0; + $sSqlCount = "SELECT * FROM " . $this->sTableName; $this->oDB->query($sSqlCount); $iAnz = $this->oDB->num_rows(); - - return $iAnz; - } - - /** - * Drops table if table exists - * - * @return void - */ - public function dropTable() { - $sSqlDropTable = ""; - $sSqlDropTable = "DROP TABLE IF EXISTS ". $this->sTableName; - $this->oDB->query($sSqlDropTable); - } - - /** - * Deletes the row wich id of mod_history - * - * @return void - */ - public function deleteRows($iModHistory) { - $iModHistory = Contenido_Security::unFilter($iModHistory); - $sSql2 = "DELETE FROM ". $this->sTableName . - " WHERE idmodhistory = ". $iModHistory; - $this->oDB->query($sSql2); - } - -} + return $iAnz; + } + + /** + * Drops table if table exists + * + * @return void + */ + public function dropTable() { + $sSqlDropTable = ""; + $sSqlDropTable = "DROP TABLE IF EXISTS " . $this->sTableName; + $this->oDB->query($sSqlDropTable); + } + + /** + * Deletes the row wich id of mod_history + * + * @return void + */ + public function deleteRows($iModHistory) { + $iModHistory = Contenido_Security::unFilter($iModHistory); + $sSql2 = "DELETE FROM " . $this->sTableName . + " WHERE idmodhistory = " . $iModHistory; + $this->oDB->query($sSql2); + } + +} + ?> \ No newline at end of file