From d53c559871796a0d5703f7b37dd0d945996670f3 Mon Sep 17 00:00:00 2001 From: "o.pinke" Date: Mon, 8 Jun 2020 16:09:59 +0200 Subject: [PATCH 01/21] fixed rewriting, added further debug infos --- classes/class.modrewrite.php | 1 + classes/class.modrewritecontroller.php | 2 -- classes/class.modrewriteurlstack.php | 36 +++++++++++++++----------- includes/functions.mod_rewrite.php | 12 ++++++--- 4 files changed, 30 insertions(+), 21 deletions(-) diff --git a/classes/class.modrewrite.php b/classes/class.modrewrite.php index faa259a..fdab44a 100644 --- a/classes/class.modrewrite.php +++ b/classes/class.modrewrite.php @@ -53,6 +53,7 @@ class ModRewrite extends ModRewriteBase { */ public static function initialize($clientId) { mr_loadConfiguration($clientId, true); + parent::initialize(); self::$_db = new DB_Contenido(); self::$_lookupTable = array(); } diff --git a/classes/class.modrewritecontroller.php b/classes/class.modrewritecontroller.php index aa59e24..3fb2611 100644 --- a/classes/class.modrewritecontroller.php +++ b/classes/class.modrewritecontroller.php @@ -494,8 +494,6 @@ class ModRewriteController extends ModRewriteBase { // load_client is set in frontend/config.php $lang = (int) $load_lang; } else { - // get client id from table - cInclude('classes', 'contenido/class.clientslang.php'); $clCol = new cApiClientLanguageCollection(); $clCol->setWhere('idclient', $client); $clCol->query(); diff --git a/classes/class.modrewriteurlstack.php b/classes/class.modrewriteurlstack.php index 99713fd..f7cdc59 100644 --- a/classes/class.modrewriteurlstack.php +++ b/classes/class.modrewriteurlstack.php @@ -1,4 +1,5 @@ _aUrls[$url]; if (!isset($this->_aStack[$sStackId]['urlpath'])) { - $this->_chunkSetPrettyUrlParts(); + $this->_chunkSetPrettyUrlParts($sStackId); } $aPretty = array( 'urlpath' => $this->_aStack[$sStackId]['urlpath'], @@ -233,8 +233,11 @@ class ModRewriteUrlStack { * * Composes the query by looping thru stored but non processed urls, executes * the query and adds the (urlpath and urlname) result to the stack. + * + * @param type $sStackId + * @return type */ - private function _chunkSetPrettyUrlParts() { + private function _chunkSetPrettyUrlParts($sStackId) { // collect stack parameter to get urlpath and urlname $aStack = array(); foreach ($this->_aStack as $stackId => $item) { @@ -247,23 +250,26 @@ class ModRewriteUrlStack { // now, it's time to compose the where clause of the query $sWhere = ''; foreach ($aStack as $stackId => $item) { - $aP = $item['params']; - if ((int) mr_arrayValue($aP, 'idart') > 0) { - $sWhere .= '(al.idart = ' . $aP['idart'] . ' AND al.idlang = ' . $aP['lang'] . ') OR '; - } elseif ((int) mr_arrayValue($aP, 'idartlang') > 0) { - $sWhere .= '(al.idartlang = ' . $aP['idartlang'] . ') OR '; - } elseif ((int) mr_arrayValue($aP, 'idcat') > 0) { - $sWhere .= '(cl.idcat = ' . $aP['idcat'] . ' AND cl.idlang = ' . $aP['lang'] . ' AND cl.startidartlang = al.idartlang) OR '; - } elseif ((int) mr_arrayValue($aP, 'idcatart') > 0) { - $sWhere .= '(ca.idcatart = ' . $aP['idcatart'] . ' AND ca.idart = al.idart AND al.idlang = ' . $aP['lang'] . ') OR '; - } elseif ((int) mr_arrayValue($aP, 'idcatlang') > 0) { - $sWhere .= '(cl.idcatlang = ' . $aP['idcatlang'] . ' AND cl.startidartlang = al.idartlang) OR '; + + if ($stackId == $sStackId) { + $aP = $item['params']; + if ((int) mr_arrayValue($aP, 'idart') > 0) { + $sWhere .= '(al.idart = ' . $aP['idart'] . ' AND al.idlang = ' . $aP['lang'] . ') OR '; + } elseif ((int) mr_arrayValue($aP, 'idartlang') > 0) { + $sWhere .= '(al.idartlang = ' . $aP['idartlang'] . ') OR '; + } elseif ((int) mr_arrayValue($aP, 'idcat') > 0) { + $sWhere .= '(cl.idcat = ' . $aP['idcat'] . ' AND cl.idlang = ' . $aP['lang'] . ' AND cl.startidartlang = al.idartlang) OR '; + } elseif ((int) mr_arrayValue($aP, 'idcatart') > 0) { + $sWhere .= '(ca.idcatart = ' . $aP['idcatart'] . ' AND ca.idart = al.idart AND al.idlang = ' . $aP['lang'] . ') OR '; + } elseif ((int) mr_arrayValue($aP, 'idcatlang') > 0) { + $sWhere .= '(cl.idcatlang = ' . $aP['idcatlang'] . ' AND cl.startidartlang = al.idartlang) OR '; + } } } if ($sWhere == '') { return; } - $sWhere = substr($sWhere, 0, -4); + $sWhere = cString::getPartOfString($sWhere, 0, -4); $sWhere = str_replace(' OR ', " OR \n", $sWhere); // compose query and execute it diff --git a/includes/functions.mod_rewrite.php b/includes/functions.mod_rewrite.php index 658c81e..d3fdcb0 100644 --- a/includes/functions.mod_rewrite.php +++ b/includes/functions.mod_rewrite.php @@ -27,7 +27,7 @@ if (!defined('CON_FRAMEWORK')) { die('Illegal call'); } -cInclude('classes', 'contenido/class.articlelanguage.php'); +global $_cecRegistry, $cfg, $contenido, $area, $client, $load_client; /** * Processes cl-mod-rewrite related job for created new tree. @@ -485,10 +485,14 @@ function mr_buildGeneratedCode($code) { // remove tinymce single quote entities: $code = str_replace("'", "'", $code); + + $baseUri = cRegistry::getFrontendUrl(); + $baseUri = CEC_Hook::execute("Contenido.Frontend.BaseHrefGeneration", $baseUri); - // get base uri - $sBaseUri = $cfgClient[$client]['path']['htmlpath']; - $sBaseUri = CEC_Hook::execute("Contenido.Frontend.BaseHrefGeneration", $sBaseUri); + // CON-1389 modifier /e is deprecated as of PHP 5.5 + $code = preg_replace_callback("/([\"|\'|=])upload\/(.?|.+?)([\"|\'|>])/i", function($match) use ($baseUri) { + return stripslashes($match[1] . $baseUri . 'upload/' . $match[2] . $match[3]); + }, $code); // define some preparations to replace /front_content.php & ./front_content.php // against front_content.php, because urls should start with front_content.php From 5ea089c8779b4eef52e183796ab99d27735c33ac Mon Sep 17 00:00:00 2001 From: "o.pinke" Date: Mon, 8 Jun 2020 16:11:29 +0200 Subject: [PATCH 02/21] add ignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d8fe4fa --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.project From 8d7ba936a1530338390500fd8b3c69e2d25694a3 Mon Sep 17 00:00:00 2001 From: "o.pinke" Date: Thu, 25 Jun 2020 15:31:00 +0200 Subject: [PATCH 03/21] bugfix url creation --- classes/class.modrewrite.php | 2 +- classes/class.modrewriteurlstack.php | 7 +++---- includes/functions.mod_rewrite.php | 5 ++++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/classes/class.modrewrite.php b/classes/class.modrewrite.php index fdab44a..971bc16 100644 --- a/classes/class.modrewrite.php +++ b/classes/class.modrewrite.php @@ -53,7 +53,7 @@ class ModRewrite extends ModRewriteBase { */ public static function initialize($clientId) { mr_loadConfiguration($clientId, true); - parent::initialize(); + parent::initialize($clientId); self::$_db = new DB_Contenido(); self::$_lookupTable = array(); } diff --git a/classes/class.modrewriteurlstack.php b/classes/class.modrewriteurlstack.php index f7cdc59..dbfd893 100644 --- a/classes/class.modrewriteurlstack.php +++ b/classes/class.modrewriteurlstack.php @@ -312,9 +312,8 @@ SQL; } } ModRewriteDebugger::add($aNewStack, 'ModRewriteUrlStack->_chunkSetPrettyUrlParts() $aNewStack'); - - // merge stack data + ModRewriteDebugger::add($this->_aStack, 'ModRewriteUrlStack->_chunkSetPrettyUrlParts() $this->_aStack'); + $this->_aStack = array_merge($this->_aStack, $aNewStack); } - -} +} \ No newline at end of file diff --git a/includes/functions.mod_rewrite.php b/includes/functions.mod_rewrite.php index d3fdcb0..42c645f 100644 --- a/includes/functions.mod_rewrite.php +++ b/includes/functions.mod_rewrite.php @@ -523,7 +523,10 @@ function mr_buildGeneratedCode($code) { $code = str_replace('"front_content.php"', '"' . mr_buildNewUrl('front_content.php') . '"', $code); $code = str_replace("'front_content.php'", "'" . mr_buildNewUrl('front_content.php') . "'", $code); $code = preg_replace_callback("/([\"|\'|=])front_content\.php(.?|.+?)([\"|\'|>])/i", function($match) { - return $match[1] . mr_buildNewUrl('front_content.php' . $match[2]) . $match[3]; + ModRewriteDebugger::add($match, 'mr_buildGeneratedCode() matches'); + $sHref = $match[1] . mr_buildNewUrl('front_content.php' . $match[2]) . $match[3]; + ModRewriteDebugger::add($sHref, 'mr_buildGeneratedCode() matches -> href'); + return $sHref; }, $code); ModRewriteDebugger::add($code, 'mr_buildGeneratedCode() out'); From be253de493f1596e7e0673f8fd08d0c4dda0a04b Mon Sep 17 00:00:00 2001 From: "o.pinke" Date: Thu, 25 Jun 2020 15:37:12 +0200 Subject: [PATCH 04/21] increase version --- cl_plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cl_plugin.xml b/cl_plugin.xml index 6d088e7..242cd1d 100644 --- a/cl_plugin.xml +++ b/cl_plugin.xml @@ -9,7 +9,7 @@ ConLite Team plugins@conlite.org https://conlite.org - 1.0.0 + 1.0.1 From 3217b73d08e1b76193f02d2d912134320ef40bfe Mon Sep 17 00:00:00 2001 From: "o.pinke" Date: Thu, 22 Apr 2021 11:15:21 +0200 Subject: [PATCH 05/21] add client path for configuration --- includes/functions.mod_rewrite.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/includes/functions.mod_rewrite.php b/includes/functions.mod_rewrite.php index 42c645f..d93dd73 100644 --- a/includes/functions.mod_rewrite.php +++ b/includes/functions.mod_rewrite.php @@ -673,9 +673,25 @@ function mr_getConfiguration($clientId) { * @return bool */ function mr_setConfiguration($clientId, array $config) { - global $cfg; - - $file = $cfg['path']['contenido'] . $cfg['path']['plugins'] . 'cl-mod-rewrite/includes/config.mod_rewrite_' . $clientId . '.php'; + $sClientPath = cRegistry::getClientConfig(cRegistry::getClientId())['path']['frontend']; + $sConfigClientPath = $sClientPath.'/data/config/'.CL_ENVIRONMENT.'/'; + + if (is_writable($sClientPath) && !file_exists($sConfigClientPath)) { + try { + mkdir($sConfigClientPath, 0777, true); + } catch (Exception $ex) { + $oWriter = cLogWriter::factory("File", array('destination' => 'contenido.log')); + $oLog = new cLog($oWriter); + $oLog->log($ex->getFile() . " (" . $ex->getLine() . "): " . $ex->getMessage(), cLog::WARN); + } + } + + if(file_exists($sConfigClientPath) && is_writable($sConfigClientPath)) { + $file = $sConfigClientPath. 'config.mod_rewrite.php'; + } else { + $file = cRegistry::getConfigValue('path', 'contenido') . cRegistry::getConfigValue('path', 'plugins') . 'cl-mod-rewrite/includes/config.mod_rewrite_' . cRegistry::getClientId() . '.php'; + } + $result = file_put_contents($file, serialize($config)); return ($result) ? true : false; } From b8545396e3c319391b39c3b6d73800c61021701b Mon Sep 17 00:00:00 2001 From: "o.pinke" Date: Fri, 4 Mar 2022 20:16:33 +0100 Subject: [PATCH 06/21] show noti if client missing --- includes/include.mod_rewrite_content.php | 4 +++- includes/include.mod_rewrite_contentexpert.php | 4 +++- includes/include.mod_rewrite_contenttest.php | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/includes/include.mod_rewrite_content.php b/includes/include.mod_rewrite_content.php index 05227e0..fecd30c 100644 --- a/includes/include.mod_rewrite_content.php +++ b/includes/include.mod_rewrite_content.php @@ -23,8 +23,10 @@ global $client, $cfg; ##### Initialization if ((int) $client <= 0) { - // if there is no client selected, display empty page + // if there is no client selected, display noti $oPage = new cPage; + $oNoti = new Contenido_Notification(); + $oPage->setContent($oNoti->returnNotification("warning", i18n("No client set!"))); $oPage->render(); return; } diff --git a/includes/include.mod_rewrite_contentexpert.php b/includes/include.mod_rewrite_contentexpert.php index f6581bc..cfd0b18 100644 --- a/includes/include.mod_rewrite_contentexpert.php +++ b/includes/include.mod_rewrite_contentexpert.php @@ -23,8 +23,10 @@ global $client, $cfg; ##### Initialization if ((int) $client <= 0) { - // if there is no client selected, display empty page + // if there is no client selected, display noti $oPage = new cPage; + $oNoti = new Contenido_Notification(); + $oPage->setContent($oNoti->returnNotification("warning", i18n("No client set!"))); $oPage->render(); return; } diff --git a/includes/include.mod_rewrite_contenttest.php b/includes/include.mod_rewrite_contenttest.php index 90a1032..52c3d09 100644 --- a/includes/include.mod_rewrite_contenttest.php +++ b/includes/include.mod_rewrite_contenttest.php @@ -31,8 +31,10 @@ global $client, $cfg; ##### Initialization if ((int) $client <= 0) { - // if there is no client selected, display empty page + // if there is no client selected, display noti $oPage = new cPage; + $oNoti = new Contenido_Notification(); + $oPage->setContent($oNoti->returnNotification("warning", i18n("No client set!"))); $oPage->render(); return; } From 6cfe4efa1582950ebe6d3580f61619e3491ae48d Mon Sep 17 00:00:00 2001 From: "o.pinke" Date: Thu, 10 Mar 2022 16:12:50 +0100 Subject: [PATCH 07/21] enhance php and plugin version --- cl_plugin.xml | 6 +++--- includes/functions.mod_rewrite.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cl_plugin.xml b/cl_plugin.xml index 242cd1d..61b788e 100644 --- a/cl_plugin.xml +++ b/cl_plugin.xml @@ -9,10 +9,10 @@ ConLite Team plugins@conlite.org https://conlite.org - 1.0.1 + 1.0.2 - - + + diff --git a/includes/functions.mod_rewrite.php b/includes/functions.mod_rewrite.php index d93dd73..274f85b 100644 --- a/includes/functions.mod_rewrite.php +++ b/includes/functions.mod_rewrite.php @@ -518,7 +518,7 @@ function mr_buildGeneratedCode($code) { foreach ($matches as $val) { $oMRUrlStack->add('front_content.php' . $val[2]); } - + ModRewriteDebugger::add($code, 'mr_buildGeneratedCode() before replace'); // ok let it beginn, build the clean urls $code = str_replace('"front_content.php"', '"' . mr_buildNewUrl('front_content.php') . '"', $code); $code = str_replace("'front_content.php'", "'" . mr_buildNewUrl('front_content.php') . "'", $code); From 38166a22fedcbe697edaa5d22a0a8d5c343ab279 Mon Sep 17 00:00:00 2001 From: "o.pinke" Date: Fri, 11 Mar 2022 10:03:13 +0100 Subject: [PATCH 08/21] set release version to 1.0.1 --- cl_plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cl_plugin.xml b/cl_plugin.xml index 61b788e..34a529e 100644 --- a/cl_plugin.xml +++ b/cl_plugin.xml @@ -9,7 +9,7 @@ ConLite Team plugins@conlite.org https://conlite.org - 1.0.2 + 1.0.1 From e282fbe01502914a197d7e97a56738810748388b Mon Sep 17 00:00:00 2001 From: "o.pinke" Date: Fri, 11 Mar 2022 10:03:45 +0100 Subject: [PATCH 09/21] recode mr urlstack class --- classes/class.modrewriteurlstack.php | 127 ++++++++++----------------- 1 file changed, 44 insertions(+), 83 deletions(-) diff --git a/classes/class.modrewriteurlstack.php b/classes/class.modrewriteurlstack.php index dbfd893..014f583 100644 --- a/classes/class.modrewriteurlstack.php +++ b/classes/class.modrewriteurlstack.php @@ -1,54 +1,26 @@ - * @copyright four for business AG - * @license http://www.contenido.org/license/LIZENZ.txt - * @link http://www.4fb.de - * @link http://www.contenido.org + * ModRewrite url stack class + * + * @category ConLite + * @package Plugin + * @subpackage ModRewrite + * @since 2.1.3 + * @author Ortwin Pinke + * @copyright (c) 2022, conlite.org + * @license http://www.gnu.de/documents/gpl.en.html GPL v3 (english version) + * @license http://www.gnu.de/documents/gpl.de.html GPL v3 (deutsche Version) + * @link http://www.conlite.org ConLite.org + * + * based on former AMR class by Murat Purc for CONTENIDO 4.8.x */ if (!defined('CON_FRAMEWORK')) { die('Illegal call'); } -/** - * Mod rewrite url stack class. Provides features to collect urls and to get the - * pretty path and names of categories/articles at one go. - * - * Main goal of this class is to collect urls and to get the urlpath and urlname - * of the related categories/articles at one go. This will reduce the queries - * against the database. - * Therefore the full advantage will be taken by rewriting the urls at codeoutput - * in front_content.php, where you will be able to collect all urls at once... - * - * Usage: - * - * // get the instance - * $oMRUrlStack = ModRewriteUrlStack::getInstance(); - * - * // add several urls to fill the stack - * $oMRUrlStack->add('front_content.php?idcat=123'); - * $oMRUrlStack->add('front_content.php?idart=321'); - * $oMRUrlStack->add('front_content.php?idcatart=213'); - * $oMRUrlStack->add('front_content.php?idcatlang=213'); - * $oMRUrlStack->add('front_content.php?idartlang=312'); - * - * // now the first call will get the pretty path and names from database at one go - * $aPrettyParts = $oMRUrlStack->getPrettyUrlParts('front_content.php?idcat=123'); - * echo $aPrettyParts['urlpath']; // something like 'Main-category-name/Category-name/Another-category-name/' - * echo $aPrettyParts['urlname']; // something like 'Name-of-an-article' - * - * - * @author Murat Purc - * @package plugin - * @subpackage Mod Rewrite - */ class ModRewriteUrlStack { /** @@ -56,7 +28,7 @@ class ModRewriteUrlStack { * * @var ModRewriteUrlStack */ - private static $_instance; + private static $_oInstance; /** * Database object @@ -106,10 +78,9 @@ class ModRewriteUrlStack { * Constructor, sets some properties. */ private function __construct() { - global $cfg, $lang; - $this->_oDb = new DB_Contenido(); - $this->_aTab = $cfg['tab']; - $this->_idLang = $lang; + $this->_oDb = cRegistry::getDb(); + $this->_aTab = cRegistry::getConfigValue('tab'); + $this->_idLang = cRegistry::getLanguageId(); } /** @@ -118,10 +89,10 @@ class ModRewriteUrlStack { * @return ModRewriteUrlStack */ public static function getInstance() { - if (self::$_instance == null) { - self::$_instance = new ModRewriteUrlStack(); + if (self::$_oInstance == null) { + self::$_oInstance = new ModRewriteUrlStack(); } - return self::$_instance; + return self::$_oInstance; } /** @@ -238,33 +209,26 @@ class ModRewriteUrlStack { * @return type */ private function _chunkSetPrettyUrlParts($sStackId) { - // collect stack parameter to get urlpath and urlname - $aStack = array(); - foreach ($this->_aStack as $stackId => $item) { - if (!isset($item['urlpath'])) { - // pretty url is to create - $aStack[$stackId] = $item; - } + if (!isset($this->_aStack[$sStackId]) || isset($this->_aStack[$sStackId]['urlpath'])) { + return; } + $aStack = []; + $aStack[$sStackId] = $this->_aStack[$sStackId]; + // now, it's time to compose the where clause of the query $sWhere = ''; - foreach ($aStack as $stackId => $item) { - - if ($stackId == $sStackId) { - $aP = $item['params']; - if ((int) mr_arrayValue($aP, 'idart') > 0) { - $sWhere .= '(al.idart = ' . $aP['idart'] . ' AND al.idlang = ' . $aP['lang'] . ') OR '; - } elseif ((int) mr_arrayValue($aP, 'idartlang') > 0) { - $sWhere .= '(al.idartlang = ' . $aP['idartlang'] . ') OR '; - } elseif ((int) mr_arrayValue($aP, 'idcat') > 0) { - $sWhere .= '(cl.idcat = ' . $aP['idcat'] . ' AND cl.idlang = ' . $aP['lang'] . ' AND cl.startidartlang = al.idartlang) OR '; - } elseif ((int) mr_arrayValue($aP, 'idcatart') > 0) { - $sWhere .= '(ca.idcatart = ' . $aP['idcatart'] . ' AND ca.idart = al.idart AND al.idlang = ' . $aP['lang'] . ') OR '; - } elseif ((int) mr_arrayValue($aP, 'idcatlang') > 0) { - $sWhere .= '(cl.idcatlang = ' . $aP['idcatlang'] . ' AND cl.startidartlang = al.idartlang) OR '; - } - } + $aP = $this->_aStack[$sStackId]['params']; + if ((int) mr_arrayValue($aP, 'idart') > 0) { + $sWhere .= '(al.idart = ' . $aP['idart'] . ' AND al.idlang = ' . $aP['lang'] . ') OR '; + } elseif ((int) mr_arrayValue($aP, 'idartlang') > 0) { + $sWhere .= '(al.idartlang = ' . $aP['idartlang'] . ') OR '; + } elseif ((int) mr_arrayValue($aP, 'idcat') > 0) { + $sWhere .= '(cl.idcat = ' . $aP['idcat'] . ' AND cl.idlang = ' . $aP['lang'] . ' AND cl.startidartlang = al.idartlang) OR '; + } elseif ((int) mr_arrayValue($aP, 'idcatart') > 0) { + $sWhere .= '(ca.idcatart = ' . $aP['idcatart'] . ' AND ca.idart = al.idart AND al.idlang = ' . $aP['lang'] . ') OR '; + } elseif ((int) mr_arrayValue($aP, 'idcatlang') > 0) { + $sWhere .= '(cl.idcatlang = ' . $aP['idcatlang'] . ' AND cl.startidartlang = al.idartlang) OR '; } if ($sWhere == '') { return; @@ -287,7 +251,7 @@ WHERE SQL; ModRewriteDebugger::add($sql, 'ModRewriteUrlStack->_chunkSetPrettyUrlParts() $sql'); - $aNewStack = array(); + $aNewStack = []; // create array of fields, which are to reduce step by step from record set below $aFields = array('', 'idart', 'idartlang', 'idcatart', 'idcat'); @@ -302,18 +266,15 @@ SQL; // reduce existing field unset($aRS[$field]); } - $rsStackID = $this->_makeStackId($aRS); - if (isset($aStack[$rsStackID])) { - // matching stack entry found, add urlpath and urlname to the new stack - $aNewStack[$rsStackID]['urlpath'] = $aRS['urlpath']; - $aNewStack[$rsStackID]['urlname'] = $aRS['urlname']; - break; - } + + // matching stack entry found, add urlpath and urlname to the new stack + $aNewStack[$sStackId]['urlpath'] = $aRS['urlpath']; + $aNewStack[$sStackId]['urlname'] = $aRS['urlname']; } } ModRewriteDebugger::add($aNewStack, 'ModRewriteUrlStack->_chunkSetPrettyUrlParts() $aNewStack'); ModRewriteDebugger::add($this->_aStack, 'ModRewriteUrlStack->_chunkSetPrettyUrlParts() $this->_aStack'); - + $this->_aStack = array_merge($this->_aStack, $aNewStack); } } \ No newline at end of file From 3ea22223d679762cf2d29873462128d2955fbb08 Mon Sep 17 00:00:00 2001 From: "o.pinke" Date: Fri, 11 Mar 2022 10:04:26 +0100 Subject: [PATCH 10/21] add debug vars for mr; gitadmin --- .gitignore | 1 + classes/controller/class.modrewrite_contenttest_controller.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d8fe4fa..84c62c8 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /.project +/classes/class.modrewriteurlstack_1.php diff --git a/classes/controller/class.modrewrite_contenttest_controller.php b/classes/controller/class.modrewrite_contenttest_controller.php index 067e3f3..1f095ee 100644 --- a/classes/controller/class.modrewrite_contenttest_controller.php +++ b/classes/controller/class.modrewrite_contenttest_controller.php @@ -69,7 +69,7 @@ class ModRewrite_ContentTestController extends ModRewrite_ControllerAbstract { // Fetch complete CONTENIDO page structure $aStruct = $oMRTest->fetchFullStructure(); - ModRewriteDebugger::add($aStruct, 'mr_test.php $aStruct'); + ModRewriteDebugger::add($aStruct, 'ModRewrite_ContentTestController::testAction() $aStruct'); // Loop through the structure and compose testcases foreach ($aStruct as $idcat => $aCat) { From f0585f18c2050ea255fe292055d2a49dbbef2be1 Mon Sep 17 00:00:00 2001 From: "o.pinke" Date: Fri, 11 Mar 2022 18:33:58 +0100 Subject: [PATCH 11/21] fix #1 - saving of config files --- .../controller/class.modrewrite_content_controller.php | 10 +++++----- includes/functions.mod_rewrite.php | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/classes/controller/class.modrewrite_content_controller.php b/classes/controller/class.modrewrite_content_controller.php index 9aeaefb..a26b415 100644 --- a/classes/controller/class.modrewrite_content_controller.php +++ b/classes/controller/class.modrewrite_content_controller.php @@ -69,15 +69,15 @@ class ModRewrite_ContentController extends ModRewrite_ControllerAbstract { if (mr_arrayValue($request, 'checkrootdir') == 1) { // root dir check is enabled, this results in error - $sMsg = i18n("The specified directory '%s' does not exists", "cl-mod-rewrite"); - $sMsg = sprintf($sMsg, $_SERVER['DOCUMENT_ROOT'] . $request['rootdir']); + $sMsgTpl = i18n("The specified directory '%s' does not exists", "cl-mod-rewrite"); + $sMsg = sprintf($sMsgTpl, $_SERVER['DOCUMENT_ROOT'] . $request['rootdir']); $this->_oView->rootdir_error = $this->_notifyBox('error', $sMsg); $bError = true; } else { // root dir check ist disabled, take over the setting and // output a warning. - $sMsg = i18n("The specified directory '%s' does not exists in DOCUMENT_ROOT '%s'. This could happen, if clients DOCUMENT_ROOT differs from CONTENIDO backends DOCUMENT_ROOT. However, the setting will be taken over because of disabled check.", "cl-mod-rewrite"); - $sMsg = sprintf($sMsg, $request['rootdir'], $_SERVER['DOCUMENT_ROOT']); + $sMsgTpl = i18n("The specified directory '%s' does not exists in DOCUMENT_ROOT '%s'. This could happen, if clients DOCUMENT_ROOT differs from CONTENIDO backends DOCUMENT_ROOT. However, the setting will be taken over because of disabled check.", "cl-mod-rewrite"); + $sMsg = sprintf($sMsgTpl, $request['rootdir'], $_SERVER['DOCUMENT_ROOT']); $this->_oView->rootdir_error = $this->_notifyBox('warning', $sMsg); } } @@ -377,7 +377,7 @@ class ModRewrite_ContentController extends ModRewrite_ControllerAbstract { $this->_oView->content_before .= $this->_notifyBox('info', $sMsg); } else { $sMsg = i18n("Configuration could not saved. Please check write permissions for %s ", "cl-mod-rewrite"); - $sMsg = sprintf($sMsg, $options['key']); + $sMsg = sprintf($sMsg, mr_getConfigurationFilePath($this->_client)); $this->_oView->content_before .= $this->_notifyBox('error', $sMsg); } } diff --git a/includes/functions.mod_rewrite.php b/includes/functions.mod_rewrite.php index 274f85b..e007994 100644 --- a/includes/functions.mod_rewrite.php +++ b/includes/functions.mod_rewrite.php @@ -688,12 +688,12 @@ function mr_setConfiguration($clientId, array $config) { if(file_exists($sConfigClientPath) && is_writable($sConfigClientPath)) { $file = $sConfigClientPath. 'config.mod_rewrite.php'; - } else { + } else { $file = cRegistry::getConfigValue('path', 'contenido') . cRegistry::getConfigValue('path', 'plugins') . 'cl-mod-rewrite/includes/config.mod_rewrite_' . cRegistry::getClientId() . '.php'; } $result = file_put_contents($file, serialize($config)); - return ($result) ? true : false; + return (empty($result)) ? false : true; } /** From cc813c18d96a99443b84329c8d446ce74c29ae29 Mon Sep 17 00:00:00 2001 From: "o.pinke" Date: Fri, 11 Mar 2022 19:05:02 +0100 Subject: [PATCH 12/21] Fix #3 - js toggle of editfields on config page --- scripts/mod_rewrite.js | 6 +++--- scripts/mod_rewrite.min.js | 1 + templates/content.html | 4 ++-- templates/contentexpert.html | 4 ++-- templates/contenttest.html | 4 ++-- 5 files changed, 10 insertions(+), 9 deletions(-) create mode 100644 scripts/mod_rewrite.min.js diff --git a/scripts/mod_rewrite.js b/scripts/mod_rewrite.js index 521a65f..15230a9 100644 --- a/scripts/mod_rewrite.js +++ b/scripts/mod_rewrite.js @@ -43,7 +43,7 @@ var mrPlugin = { initializeSettingsPage: function() { $(document).ready(function() { $("#mr_use_language").change(function() { - if (true == $(this).attr("checked")) { + if (true == $(this).prop("checked")) { $("#mr_use_language_name").removeAttr("disabled"); } else { $("#mr_use_language_name").attr("disabled", "disabled"); @@ -51,7 +51,7 @@ var mrPlugin = { }); $("#mr_use_client").change(function() { - if (true == $(this).attr("checked")) { + if (true == $(this).prop("checked")) { $("#mr_use_client_name").removeAttr("disabled"); } else { $("#mr_use_client_name").attr("disabled", "disabled"); @@ -59,7 +59,7 @@ var mrPlugin = { }); $("#mr_add_startart_name_to_url").change(function() { - if (true == $(this).attr("checked")) { + if (true == $(this).prop("checked")) { $("#mr_default_startart_name").removeAttr("disabled") .removeClass("disabled"); } else { diff --git a/scripts/mod_rewrite.min.js b/scripts/mod_rewrite.min.js new file mode 100644 index 0000000..70a6846 --- /dev/null +++ b/scripts/mod_rewrite.min.js @@ -0,0 +1 @@ +var mrPlugin={lng:{more_informations:"More informations"},toggle:function(a){$("#"+a).slideToggle("slow")},showReadme:function(){},initializeSettingsPage:function(){$(document).ready(function(){$("#mr_use_language").change(function(){if(true==$(this).prop("checked")){$("#mr_use_language_name").removeAttr("disabled")}else{$("#mr_use_language_name").attr("disabled","disabled")}});$("#mr_use_client").change(function(){if(true==$(this).prop("checked")){$("#mr_use_client_name").removeAttr("disabled")}else{$("#mr_use_client_name").attr("disabled","disabled")}});$("#mr_add_startart_name_to_url").change(function(){if(true==$(this).prop("checked")){$("#mr_default_startart_name").removeAttr("disabled").removeClass("disabled")}else{$("#mr_default_startart_name").attr("disabled","disabled").addClass("disabled")}});mrPlugin._initializeTooltip()})},initializeExterpPage:function(){$(document).ready(function(){mrPlugin._initializeTooltip()})},_initializeTooltip:function(){$(".mrPlugin a.i-link").each(function(){$(this).attr("href","javascript:void(0);");$(this).attr("title",mrPlugin.lng.more_informations);var a=$(this).attr("id").substring(0,$(this).attr("id").indexOf("-link"));$(this).aToolTip({clickIt:true,xOffset:-20,yOffset:4,outSpeed:250,tipContent:$("#"+a).html()})})}}; \ No newline at end of file diff --git a/templates/content.html b/templates/content.html index 87de490..0b8f148 100644 --- a/templates/content.html +++ b/templates/content.html @@ -1,4 +1,4 @@ - + mod_rewrite_content @@ -7,7 +7,7 @@ - + diff --git a/templates/contentexpert.html b/templates/contentexpert.html index f672bbb..e19e0a7 100644 --- a/templates/contentexpert.html +++ b/templates/contentexpert.html @@ -1,4 +1,4 @@ - + mod_rewrite_content_expert @@ -6,7 +6,7 @@ - + diff --git a/templates/contenttest.html b/templates/contenttest.html index a0b3af2..8ac4506 100644 --- a/templates/contenttest.html +++ b/templates/contenttest.html @@ -1,4 +1,4 @@ - + mod_rewrite_content_test @@ -6,7 +6,7 @@ - +