From 450ad630b5caecc8286451e2c494bd4902caac0c Mon Sep 17 00:00:00 2001
From: Oldperl <44996956+oldperl@users.noreply.github.com>
Date: Tue, 23 Jul 2019 11:00:58 +0000
Subject: [PATCH] fixes PHP 7.3; setup updates for PHP >= 7,0
---
conlite/classes/class.version.php | 1097 +++++++++++------------
conlite/classes/class.versionImport.php | 512 +++++------
2 files changed, 802 insertions(+), 807 deletions(-)
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().'