Merge remote-tracking branch 'origin/switch-to-adodb' into switch-to-adodb

Dieser Commit ist enthalten in:
Ortwin Pinke 2025-07-02 20:45:28 +02:00
Commit b351c063d6
10 geänderte Dateien mit 169 neuen und 111 gelöschten Zeilen

53
.gitignore gevendort
Datei anzeigen

@ -1,12 +1,52 @@
/nbproject/private/
/.idea/workspace.xml
/data/config/production/config.php
# Ignore all files in the .idea folder
.idea/*
# Except for the following:
!.idea/codeStyles
!.idea/fileTemplates
!.idea/inspectionProfiles
!.idea/keymaps
!.idea/libraries
!.idea/modules.xml
!.idea/vcs.xml
!.idea/workspace.xml
!.idea/tasks.xml
# Ignore workspace-related files
.idea/workspace.xml
.idea/tasks.xml
.idea/usage.statistics.xml
.idea/dictionaries
.idea/shelf
# Ignore OS-specific files
.idea/**/Desktop.xml
.idea/**/Find.xml
.idea/**/Usage Statistics.xml
.idea/**/Deployment.xml
.idea/**/dataSources
.idea/**/dataSources.local.xml
.idea/**/databaseDrivers
.idea/**/databaseServers.xml
.idea/**/sqlDataSources.xml
.idea/**/sqlDialects.xml
.idea/**/webServers.xml
.idea/**/jsLibraryMappings.xml
# Ignore .iml files (module files) if you use Maven or Gradle
*.iml
modules.xml
.idea/modules.xml
# conlite config
/data/config/*/config.php
*.local.php
/_dev/
/conlite/plugins/pluginmanager/_src
/.project
/_api/
/cl-releasetool
/data/config/production/config.local.php
/cms/data/modules/up-download/
/cms/captcha/
!/cms/data/modules/
@ -14,17 +54,12 @@
!/cms/data/layouts/
/cms/data/layouts/*
/conlite/includes/include.style_edit_form_1.php
/cms/config.local.php
/cms/dflip/
/cms/js/firstlevel/
/conlite/external/**/.git
/conlite/logs/debug.log
/cms/data/config/production/config.mod_rewrite.php
/cms/data/config/production/config.local.php
/cms/cache/*
composer.phar
/conlite/vendor/
*.old.php
/conlite/plugins/smarty/.idea/modules.xml
/conlite/plugins/smarty/.idea/smarty.iml
/conlite/plugins/smarty/.idea/workspace.xml

Datei anzeigen

@ -12,7 +12,10 @@
"php": "^8.0",
"phpmailer/phpmailer": "v6.9.1",
"adodb/adodb-php": "^5.22",
"ext-zlib": "*"
"ext-zlib": "*",
"ext-mysqli": "*",
"ext-dom": "*",
"ext-simplexml": "*"
},
"require-dev": {
"phpstan/phpstan": "^1.10",

Datei anzeigen

@ -97,6 +97,7 @@ abstract class ItemCollection extends ItemBaseAbstract
*/
protected $_bAllMode = false;
protected $_order;
protected string $lastSQL;
/**
* Constructor Function
@ -124,6 +125,16 @@ abstract class ItemCollection extends ItemBaseAbstract
);
}
public function getLastSQL(): string
{
return $this->lastSQL;
}
public function setLastSQL(string $lastSQL): void
{
$this->lastSQL = $lastSQL;
}
/**
* Defines the reverse links for this table.
*
@ -656,7 +667,7 @@ abstract class ItemCollection extends ItemBaseAbstract
$sql = implode(' ', $aStatement);
$result = $this->db->query($sql);
$this->_lastSQL = $sql;
$this->lastSQL = $sql;
// @todo disable all mode in this method for the moment. It has to be verified,
// if enabling will result in negative side effects.
$this->_bAllMode = false;
@ -796,7 +807,7 @@ abstract class ItemCollection extends ItemBaseAbstract
$sql = 'SELECT ' . $sFields . ' FROM `' . $this->table . '`' . $sWhere
. $sGroupBy . $sOrderBy . $sLimit;
$this->db->query($sql);
$this->_lastSQL = $sql;
$this->lastSQL = $sql;
$this->_bAllMode = $this->_settings['select_all_mode'];
if ($this->db->num_rows() == 0) {
@ -852,7 +863,7 @@ abstract class ItemCollection extends ItemBaseAbstract
. $sFrom . $sWhere . $sGroupBy . $sOrderBy . $sLimit;
$this->db->query($sql);
$this->_lastSQL = $sql;
$this->lastSQL = $sql;
// @todo disable all mode in this method
$this->_bAllMode = false;

Datei anzeigen

@ -12,31 +12,30 @@ if (!defined('CON_FRAMEWORK')) {
class pimPluginHandler {
protected $_iPluginId = 0;
protected $_oPlugin = NULL;
protected int $_iPluginId = 0;
protected ?pimPlugin $_oPlugin = NULL;
protected $_bIsLoaded = FALSE;
protected $_sPluginPath;
protected string $_sPluginPath;
/**
* holds the xml of plugin.xml
* @var SimpleXMLElement
*/
protected $_oPiXml = NULL;
protected ?SimpleXMLElement $_oPiXml = NULL;
/**
*
* @var DomDocument
*/
protected $_oDomDocument;
protected $_xsd = 'plugins/pluginmanager/xml/plugin_info.xsd';
protected $_bValid = FALSE;
protected DOMDocument $_oDomDocument;
protected string $_xsd = 'plugins/pluginmanager/xml/plugin_info.xsd';
protected bool $_bValid = false;
/**
* Constructor
*/
public function __construct() {
$this->_oDomDocument = new DOMDocument();
$this->_oDomDocument->preserveWhiteSpace = FALSE;
$this->_oDomDocument->preserveWhiteSpace = false;
}
/**
@ -44,7 +43,8 @@ class pimPluginHandler {
* @param int $iPluginId
* @return boolean
*/
public function loadPluginFromDb($iPluginId) {
public function loadPluginFromDb($iPluginId): bool
{
$this->_oPlugin = new pimPlugin($iPluginId);
if ($this->_oPlugin->isLoaded()) {
$this->_iPluginId = $this->_oPlugin->get('idplugin');
@ -63,8 +63,8 @@ class pimPluginHandler {
* @param string $sPluginFolderName
* @return boolean
*/
public function installPlugin($sPluginFolderName) {
$iNewPluginId = 0;
public function installPlugin(string $sPluginFolderName): bool
{
if (empty($sPluginFolderName)) {
return FALSE;
}
@ -98,7 +98,8 @@ class pimPluginHandler {
* @param string $sHandleSql
* @return boolean
*/
public function uninstallPlugin($sHandleSql) {
public function uninstallPlugin($sHandleSql): bool
{
$oPluginUninstall = new pimSetupPluginUninstall();
$oPluginUninstall->setPluginPath($this->_sPluginPath);
return $oPluginUninstall->uninstallPlugin($this->_iPluginId, $sHandleSql);
@ -108,7 +109,8 @@ class pimPluginHandler {
*
* @return int
*/
public function getPluginId() {
public function getPluginId(): int
{
return $this->_iPluginId;
}
@ -116,32 +118,29 @@ class pimPluginHandler {
*
* @param string $sFile
* @return boolean
* @throws pimXmlStructureException
*/
public function loadXmlFile($sFile) {
public function loadXmlFile(string $sFile): bool
{
$this->_oDomDocument->load($sFile);
if ($this->_validateXml()) {
$this->_oPiXml = simplexml_load_string($this->_oDomDocument->C14N());
}
return (is_a($this->_oPiXml, "SimpleXMLElement")) ? TRUE : FALSE;
return is_a($this->_oPiXml, "SimpleXMLElement");
}
/**
*
* @return object|null
*/
public function getCfgXmlObject() {
public function getCfgXmlObject(): ?SimpleXMLElement
{
if (is_object($this->_oPiXml)) {
return $this->_oPiXml;
}
return NULL;
}
/**
*
* @return array
*/
public function getPiGeneralArray() {
$aGeneral = array();
public function getPiGeneralArray(): array
{
$aGeneral = [];
if (is_object($this->_oPiXml)) {
$aGeneral = $this->_xml2Array($this->_oPiXml->general);
$aDependencies = $this->_xml2Array($this->_oPiXml->dependencies);
@ -157,7 +156,8 @@ class pimPluginHandler {
* @param int $iPluginId
* @return string
*/
public function getInfoInstalled($iPluginId) {
public function getInfoInstalled($iPluginId): string
{
$oPlugin = new pimPlugin($iPluginId);
if ($oPlugin->isLoaded()) {
$oView = new pimView();
@ -221,7 +221,8 @@ class pimPluginHandler {
return '';
}
protected function _getDepencyArray() {
protected function _getDepencyArray(): bool|array
{
$aDependencies = array();
$aAttributes = array();
$iCountDependencies = count($this->_oPiXml->dependencies);
@ -237,7 +238,7 @@ class pimPluginHandler {
return $aDependencies;
}
return FALSE;
return false;
}
/**
@ -245,24 +246,28 @@ class pimPluginHandler {
* @return boolean
* @throws pimXmlStructureException
*/
private function _validateXml() {
private function _validateXml(): bool
{
if ($this->_oDomDocument->schemaValidate($this->_xsd)) {
$this->_bValid = true;
return true;
} else {
return FALSE;
return false;
}
}
/**
*
* @param xml $xml
* @param ?SimpleXMLElement $xml
* @return array
*/
private function _xml2Array($xml) {
private function _xml2Array(?SimpleXMLElement $xml): array
{
if(empty($xml)) {
return [];
}
$string = json_encode($xml);
$array = json_decode($string, true);
return $array;
return json_decode($string, true);
}
}

Datei anzeigen

@ -15,6 +15,7 @@ class pimPluginCollection extends ItemCollection {
public function __construct() {
global $cfg;
//print_r($cfg['sql']);
parent::__construct($cfg['tab']['plugins'], 'idplugin');
$this->_setItemClass("pimPlugin");
}

Datei anzeigen

@ -15,10 +15,9 @@ class PluginmanagerAjax extends pimAjax {
* @param string $Request
* @return string
*/
public function handle($Request) {
$sString = '';
public function handle($Request): string
{
switch ($Request) {
// toggle active/inactive of plugins
case 'toggle_active':
if(!isset($_POST['plugin_id']) || empty($_POST['plugin_id'])) {
@ -60,8 +59,6 @@ class PluginmanagerAjax extends pimAjax {
// install plugin with existing source in plugin dir
case 'pim_install':
//sleep(3);
$iNewPluginId = 0;
$sPluginPath = cRegistry::getBackendPath()
.cRegistry::getConfigValue('path', 'plugins')
.Contenido_Security::escapeDB($_POST['plugin_folder']).DIRECTORY_SEPARATOR;
@ -100,5 +97,4 @@ class PluginmanagerAjax extends pimAjax {
}
return $sString;
}
}

Datei anzeigen

@ -67,13 +67,13 @@ class pimSetupBase {
* nav sub entries
* @var SimpleXMLElement
*/
public static $XmlNavSub;
public static SimpleXMLElement $XmlNavSub;
/**
* content type(s) for plugin
* @var SimpleXMLElement
*/
public static $XmlContentType;
public static SimpleXMLElement $XmlContentType;
/**
* whole xml object from info xml
@ -135,11 +135,10 @@ class pimSetupBase {
$this->_PimPluginCollection = new pimPluginCollection();
$this->_PimPluginRelationCollection = new pimPluginRelationCollection();
//print_r($this->_getAttrForTag("area"));
}
public function setPluginPath($sPath) {
public function setPluginPath($sPath): void
{
$this->_sPluginPath = $sPath;
}
@ -151,7 +150,8 @@ class pimSetupBase {
*
* @return boolean
*/
public function doQueries() {
public function doQueries(): bool
{
if (!is_array($this->_aSql) || count($this->_aSql) <= 0) {
return TRUE;
}
@ -177,7 +177,8 @@ class pimSetupBase {
}
public function setXmlObject($oXml, $bSplit = TRUE) {
public function setXmlObject($oXml, $bSplit = TRUE): void
{
if (is_object($oXml)) {
$this->_oXml = & $oXml;
}
@ -187,7 +188,8 @@ class pimSetupBase {
}
}
public function setXsdFile($sFile) {
public function setXsdFile($sFile): void
{
$this->_sXsdPath = $sFile;
}
@ -197,7 +199,8 @@ class pimSetupBase {
* @param string $sTable
* @return int the next usable table id
*/
protected function _getNextId($sTable) {
protected function _getNextId($sTable): int
{
cInclude("includes", "functions.database.php");
dbUpdateSequence(cRegistry::getConfigValue("tab", "sequence"), cRegistry::getConfigValue('tab', $sTable), cRegistry::getDb());
@ -219,7 +222,8 @@ class pimSetupBase {
return Contenido_Security::toInteger($iNextId . 0); // last number is always a zero
}
protected function _getAttrForTag($sTag) {
protected function _getAttrForTag($sTag): bool|array
{
foreach ($this->_aXmlDefaultValues as $Key => $aValue) {
if ($aValue['tag'] === strtoupper($sTag) && $aValue['type'] === "complete") {
if (isset($aValue['attributes']) && is_array($aValue['attributes'])) {
@ -292,7 +296,7 @@ class pimSetupBase {
$oPluginColl->setWhere("executionorder", (int) $_REQUEST['new_position'], ">=");
$oPluginColl->query();
if($oPluginColl->count() > 0) {
/* @var $oPlugin cApiPlugin */
/* @var $oPlugin pimPlugin */
while ($oPlugin = $oPluginColl->next()) {
$iOrder = $oPlugin->get("executionorder");
$oPlugin->set("executionorder", $iOrder++);

Datei anzeigen

@ -8,16 +8,11 @@ class pimSetupPluginInstall extends pimSetupBase {
const SQL_FILE = "plugin_install.sql";
/**
*
* @var pimPlugin
*/
private $_oPlugin;
//helper arrays
private $_aAreas = array();
private $_aInstalledAreas;
private $_aInstalledNavMain;
private $_aInstalledNavSub;
private array $_aAreas = [];
private array $_aInstalledAreas;
private array $_aInstalledNavMain;
private array $_aInstalledNavSub;
public function __construct() {
parent::__construct();
@ -33,29 +28,28 @@ class pimSetupPluginInstall extends pimSetupBase {
$this->_installCheckRequirements();
$oPiColl = new pimPluginCollection();
$this->_oPlugin = $oPiColl->createNewItem();
$_oPlugin = $oPiColl->createNewItem();
if ($this->_oPlugin->isLoaded()) {
$this->_iPiId = $this->_oPlugin->get('idplugin');
if ($_oPlugin->isLoaded()) {
$this->_iPiId = $_oPlugin->get('idplugin');
$this->_insertDbEntries();
$this->_getPluginSql();
if ($this->doQueries()) {
$this->_oPlugin->set('idclient', $this->_iClient, FALSE);
$this->_oPlugin->set('name', Contenido_Security::escapeDB(self::$XmlGeneral->plugin_name));
$this->_oPlugin->set('description', Contenido_Security::escapeDB(self::$XmlGeneral->description));
$this->_oPlugin->set('author', Contenido_Security::escapeDB(self::$XmlGeneral->author));
$this->_oPlugin->set('copyright', Contenido_Security::escapeDB(self::$XmlGeneral->copyright));
$this->_oPlugin->set('mail', Contenido_Security::escapeDB(self::$XmlGeneral->mail));
$this->_oPlugin->set('website', Contenido_Security::escapeDB(self::$XmlGeneral->website));
$this->_oPlugin->set('version', Contenido_Security::escapeDB(self::$XmlGeneral->version));
$this->_oPlugin->set('folder', Contenido_Security::escapeDB(self::$XmlGeneral->plugin_foldername));
$this->_oPlugin->set('uuid', Contenido_Security::escapeDB(self::$XmlGeneral->uuid));
$this->_oPlugin->set('executionorder', $this->_updateSortOrder(), FALSE);
$this->_oPlugin->set('installed', date('Y-m-d H:i:s'), FALSE);
$this->_oPlugin->set('active', (int) self::$XmlGeneral['active'], FALSE);
$_oPlugin->set('idclient', $this->_iClient, FALSE);
$_oPlugin->set('name', Contenido_Security::escapeDB(self::$XmlGeneral->plugin_name));
$_oPlugin->set('description', Contenido_Security::escapeDB(self::$XmlGeneral->description));
$_oPlugin->set('author', Contenido_Security::escapeDB(self::$XmlGeneral->author));
$_oPlugin->set('copyright', Contenido_Security::escapeDB(self::$XmlGeneral->copyright));
$_oPlugin->set('mail', Contenido_Security::escapeDB(self::$XmlGeneral->mail));
$_oPlugin->set('website', Contenido_Security::escapeDB(self::$XmlGeneral->website));
$_oPlugin->set('version', Contenido_Security::escapeDB(self::$XmlGeneral->version));
$_oPlugin->set('folder', Contenido_Security::escapeDB(self::$XmlGeneral->plugin_foldername));
$_oPlugin->set('uuid', Contenido_Security::escapeDB(self::$XmlGeneral->uuid));
$_oPlugin->set('executionorder', $this->_updateSortOrder(), FALSE);
$_oPlugin->set('installed', date('Y-m-d H:i:s'), FALSE);
$_oPlugin->set('active', (int) self::$XmlGeneral['active'], FALSE);
if ($this->_oPlugin->store()) {
//echo "stored: ".$this->_iPiId;
if ($_oPlugin->store()) {
return $this->_iPiId;
}
} else {
@ -245,7 +239,10 @@ class pimSetupPluginInstall extends pimSetupBase {
}
private function _addNavSub() {
$aAttributes = array();
$aDefaultAttr = array(
'online' => 1
);
$this->_initInstalledNavMainArray();
$iCountNavSub = (is_countable(self::$XmlNavSub->nav))?count(self::$XmlNavSub->nav):0;
@ -253,16 +250,21 @@ class pimSetupPluginInstall extends pimSetupBase {
$oNavSubColl = new cApiNavSubCollection();
for ($i = 0; $i < $iCountNavSub; $i++) {
$aAttributes = [];
$sLocation = cSecurity::escapeString(self::$XmlNavSub->nav[$i]);
if (empty($sLocation)) {
parent::error(i18n('There seem to be an empty sub navigation entry in plugin.xml. Please contact your plugin author.', 'pluginmanager'), $this->_iPiId);
}
// Build attributes with security checks
foreach (self::$XmlNavSub->nav[$i]->attributes() as $sKey => $sValue) {
$aAttributes[$sKey] = cSecurity::escapeString($sValue);
}
$aAttributes = array_merge($aDefaultAttr, array_filter($aAttributes, function($x) { return !(is_null($x) || $x === false); }));
/* @var $oNavSub cApiNavSub */
$oNavSub = $oNavSubColl->createNewItem($this->_getNextId("nav_sub"));
if ($oNavSub->isLoaded()) {
@ -272,7 +274,7 @@ class pimSetupPluginInstall extends pimSetupBase {
$oNavSub->set("idarea", $this->_getIdForArea($aAttributes['area']));
$oNavSub->set("level", (int) $aAttributes['level']);
$oNavSub->set("location", $sLocation, FALSE);
$oNavSub->set("online", 1, FALSE);
$oNavSub->set("online", (int) $aAttributes['online'], FALSE);
$oNavSub->store();
}
@ -361,7 +363,8 @@ class pimSetupPluginInstall extends pimSetupBase {
*/
}
private function _initInstalledAreasArray() {
private function _initInstalledAreasArray(): void
{
$this->_aInstalledAreas = array();
$oAreaColl = new cApiAreaCollection();
$oAreaColl->select();
@ -370,26 +373,25 @@ class pimSetupPluginInstall extends pimSetupBase {
while ($oArea = $oAreaColl->next()) {
$this->_aInstalledAreas[] = $oArea->get('name');
}
//print_r($this->_aInstalledAreas);
}
private function _initInstalledNavMainArray() {
private function _initInstalledNavMainArray(): void
{
$this->_aInstalledNavMain = array();
$oNavMainColl = new cApiNavMainCollection();
$oNavMainColl->select();
//$oNavMainColl->query();
/* @var $oArea cApiArea */
/* @var $oNavMain cApiNavMain */
while ($oNavMain = $oNavMainColl->next()) {
$this->_aInstalledNavMain[$oNavMain->get('name')] = $oNavMain->get('idnavm');
}
}
private function _initInstalledNavSubArray() {
private function _initInstalledNavSubArray(): void
{
$this->_aInstalledNavSub = array();
$oNavSubColl = new cApiNavSubCollection();
$oNavSubColl->select();
//$oNavSubColl->query();
/* @var $oArea cApiArea */
/* @var $oNavSub cApiNavSub */
while ($oNavSub = $oNavSubColl->next()) {
$this->_aInstalledNavMain[$oNavSub->get('idnavsub')] = $oNavSub->get('name');
}
@ -424,5 +426,4 @@ class pimSetupPluginInstall extends pimSetupBase {
//echo "<pre>";
//print_r($this->_aAreas);
}
}

Datei anzeigen

@ -23,6 +23,7 @@ $aMessages = [];
$oPage = new cPage();
$oPage->sendNoCacheHeaders();
$oPage->setEncoding('UTF-8');
$oPage->setHtml5();
$oPage->addCssFile("plugins/pluginmanager/css/pluginmanager.css");
$oPage->addJsFile("plugins/pluginmanager/scripts/jquery.plainoverlay.js");
@ -38,7 +39,7 @@ if (!$perm->isSysadmin()) {
}
// check disable plugin var
if ($cfg['debug']['disable_plugins'] === true) {
if (cRegistry::getConfigValue('debug', 'disable_plugins') === true) {
$oPage->setContent($Notification->returnNotification(Contenido_Notification::LEVEL_WARNING, i18n('Currently the plugin system is disabled via configuration', "pluginmanager")));
$oPage->render();
die();

Datei anzeigen

@ -162,6 +162,7 @@
<xsd:extension base="xsd:string">
<xsd:attribute name="area" type="xsd:string" use="required" />
<xsd:attribute name="level" type="xsd:integer" use="required" />
<xsd:attribute name="online" type="xsd:integer" default="1" />
<xsd:attribute name="navm" />
</xsd:extension>
</xsd:simpleContent>