Commits vergleichen
22 Commits
Autor | SHA1 | Datum | |
---|---|---|---|
|
a00c8149f7 | ||
|
606b832ce8 | ||
|
e9d44453fb | ||
|
8e2fdca28b | ||
|
a89ee6a1f1 | ||
|
5f58aadcc4 | ||
|
4c3d78a044 | ||
|
91b0fd8c15 | ||
|
06cc337092 | ||
|
f523661e7a | ||
|
cc813c18d9 | ||
|
f0585f18c2 | ||
|
3ea22223d6 | ||
|
e282fbe015 | ||
|
38166a22fe | ||
|
6cfe4efa15 | ||
|
b8545396e3 | ||
|
3217b73d08 | ||
|
be253de493 | ||
|
8d7ba936a1 | ||
|
5ea089c877 | ||
|
d53c559871 |
18 geänderte Dateien mit 179 neuen und 196 gelöschten Zeilen
2
.gitignore
gevendort
Normale Datei
2
.gitignore
gevendort
Normale Datei
|
@ -0,0 +1,2 @@
|
||||||
|
/.project
|
||||||
|
/classes/class.modrewriteurlstack_1.php
|
|
@ -9,10 +9,10 @@
|
||||||
<copyright>ConLite Team</copyright>
|
<copyright>ConLite Team</copyright>
|
||||||
<mail>plugins@conlite.org</mail>
|
<mail>plugins@conlite.org</mail>
|
||||||
<website>https://conlite.org</website>
|
<website>https://conlite.org</website>
|
||||||
<version>1.0.0</version>
|
<version>1.0.2</version>
|
||||||
</general>
|
</general>
|
||||||
<requirements php="7.1">
|
<requirements php="7.4">
|
||||||
<conlite minversion="2.1.0" />
|
<conlite minversion="2.3.0" />
|
||||||
</requirements>
|
</requirements>
|
||||||
<conlite>
|
<conlite>
|
||||||
<areas>
|
<areas>
|
||||||
|
|
|
@ -53,6 +53,7 @@ class ModRewrite extends ModRewriteBase {
|
||||||
*/
|
*/
|
||||||
public static function initialize($clientId) {
|
public static function initialize($clientId) {
|
||||||
mr_loadConfiguration($clientId, true);
|
mr_loadConfiguration($clientId, true);
|
||||||
|
parent::initialize($clientId);
|
||||||
self::$_db = new DB_Contenido();
|
self::$_db = new DB_Contenido();
|
||||||
self::$_lookupTable = array();
|
self::$_lookupTable = array();
|
||||||
}
|
}
|
||||||
|
@ -154,7 +155,7 @@ class ModRewrite extends ModRewriteBase {
|
||||||
$iCatId = (int) $iCatId;
|
$iCatId = (int) $iCatId;
|
||||||
|
|
||||||
// get websafe name
|
// get websafe name
|
||||||
$sNewName = cApiStrCleanURLCharacters(conHtmlEntityDecode($sName));
|
$sNewName = cApiStrCleanURLCharacters(clHtmlEntityDecode($sName));
|
||||||
|
|
||||||
// remove double or more separators
|
// remove double or more separators
|
||||||
$sNewName = mr_removeMultipleChars('-', $sNewName);
|
$sNewName = mr_removeMultipleChars('-', $sNewName);
|
||||||
|
@ -195,7 +196,7 @@ class ModRewrite extends ModRewriteBase {
|
||||||
$iLangId = (int) $iLangId;
|
$iLangId = (int) $iLangId;
|
||||||
|
|
||||||
// create websafe name
|
// create websafe name
|
||||||
$sNewName = cApiStrCleanURLCharacters(conHtmlEntityDecode($sName));
|
$sNewName = cApiStrCleanURLCharacters(clHtmlEntityDecode($sName));
|
||||||
|
|
||||||
// remove double or more separators
|
// remove double or more separators
|
||||||
$sNewName = mr_removeMultipleChars('-', $sNewName);
|
$sNewName = mr_removeMultipleChars('-', $sNewName);
|
||||||
|
|
|
@ -494,8 +494,6 @@ class ModRewriteController extends ModRewriteBase {
|
||||||
// load_client is set in frontend/config.php
|
// load_client is set in frontend/config.php
|
||||||
$lang = (int) $load_lang;
|
$lang = (int) $load_lang;
|
||||||
} else {
|
} else {
|
||||||
// get client id from table
|
|
||||||
cInclude('classes', 'contenido/class.clientslang.php');
|
|
||||||
$clCol = new cApiClientLanguageCollection();
|
$clCol = new cApiClientLanguageCollection();
|
||||||
$clCol->setWhere('idclient', $client);
|
$clCol->setWhere('idclient', $client);
|
||||||
$clCol->query();
|
$clCol->query();
|
||||||
|
|
|
@ -1,54 +1,26 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* AMR url stack class
|
* File:
|
||||||
|
* class.modrewriteurlstack.php
|
||||||
*
|
*
|
||||||
* @package plugin
|
* ModRewrite url stack class
|
||||||
* @subpackage Mod Rewrite
|
*
|
||||||
* @version SVN Revision $Rev: 128 $
|
* @category ConLite
|
||||||
* @id $Id: class.modrewriteurlstack.php 128 2019-07-03 11:58:28Z oldperl $:
|
* @package Plugin
|
||||||
* @author Murat Purc <murat@purc.de>
|
* @subpackage ModRewrite
|
||||||
* @copyright four for business AG <www.4fb.de>
|
* @since 2.1.3
|
||||||
* @license http://www.contenido.org/license/LIZENZ.txt
|
* @author Ortwin Pinke <o.pinke@conlite.org>
|
||||||
* @link http://www.4fb.de
|
* @copyright (c) 2022, conlite.org
|
||||||
* @link http://www.contenido.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 <murat@purc.de> for CONTENIDO 4.8.x
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('CON_FRAMEWORK')) {
|
if (!defined('CON_FRAMEWORK')) {
|
||||||
die('Illegal call');
|
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:
|
|
||||||
* <code>
|
|
||||||
* // 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'
|
|
||||||
* </code>
|
|
||||||
*
|
|
||||||
* @author Murat Purc <murat@purc.de>
|
|
||||||
* @package plugin
|
|
||||||
* @subpackage Mod Rewrite
|
|
||||||
*/
|
|
||||||
class ModRewriteUrlStack {
|
class ModRewriteUrlStack {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,7 +28,7 @@ class ModRewriteUrlStack {
|
||||||
*
|
*
|
||||||
* @var ModRewriteUrlStack
|
* @var ModRewriteUrlStack
|
||||||
*/
|
*/
|
||||||
private static $_instance;
|
private static $_oInstance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database object
|
* Database object
|
||||||
|
@ -106,10 +78,9 @@ class ModRewriteUrlStack {
|
||||||
* Constructor, sets some properties.
|
* Constructor, sets some properties.
|
||||||
*/
|
*/
|
||||||
private function __construct() {
|
private function __construct() {
|
||||||
global $cfg, $lang;
|
$this->_oDb = cRegistry::getDb();
|
||||||
$this->_oDb = new DB_Contenido();
|
$this->_aTab = cRegistry::getConfigValue('tab');
|
||||||
$this->_aTab = $cfg['tab'];
|
$this->_idLang = cRegistry::getLanguageId();
|
||||||
$this->_idLang = $lang;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -118,10 +89,10 @@ class ModRewriteUrlStack {
|
||||||
* @return ModRewriteUrlStack
|
* @return ModRewriteUrlStack
|
||||||
*/
|
*/
|
||||||
public static function getInstance() {
|
public static function getInstance() {
|
||||||
if (self::$_instance == null) {
|
if (self::$_oInstance == null) {
|
||||||
self::$_instance = new ModRewriteUrlStack();
|
self::$_oInstance = new ModRewriteUrlStack();
|
||||||
}
|
}
|
||||||
return self::$_instance;
|
return self::$_oInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -175,11 +146,11 @@ class ModRewriteUrlStack {
|
||||||
|
|
||||||
$sStackId = $this->_aUrls[$url];
|
$sStackId = $this->_aUrls[$url];
|
||||||
if (!isset($this->_aStack[$sStackId]['urlpath'])) {
|
if (!isset($this->_aStack[$sStackId]['urlpath'])) {
|
||||||
$this->_chunkSetPrettyUrlParts();
|
$this->_chunkSetPrettyUrlParts($sStackId);
|
||||||
}
|
}
|
||||||
$aPretty = array(
|
$aPretty = array(
|
||||||
'urlpath' => $this->_aStack[$sStackId]['urlpath'],
|
'urlpath' => (empty($this->_aStack[$sStackId]['urlpath']))?'':$this->_aStack[$sStackId]['urlpath'],
|
||||||
'urlname' => $this->_aStack[$sStackId]['urlname']
|
'urlname' => (empty($this->_aStack[$sStackId]['urlname']))?'':$this->_aStack[$sStackId]['urlname']
|
||||||
);
|
);
|
||||||
return $aPretty;
|
return $aPretty;
|
||||||
}
|
}
|
||||||
|
@ -197,7 +168,7 @@ class ModRewriteUrlStack {
|
||||||
$aUrl['query'] = str_replace('&', '&', $aUrl['query']);
|
$aUrl['query'] = str_replace('&', '&', $aUrl['query']);
|
||||||
parse_str($aUrl['query'], $aUrl['params']);
|
parse_str($aUrl['query'], $aUrl['params']);
|
||||||
}
|
}
|
||||||
if (!isset($aUrl['params']) && !is_array($aUrl['params'])) {
|
if (empty($aUrl['params']) || !is_array($aUrl['params'])) {
|
||||||
$aUrl['params'] = array();
|
$aUrl['params'] = array();
|
||||||
}
|
}
|
||||||
return $aUrl;
|
return $aUrl;
|
||||||
|
@ -233,37 +204,36 @@ class ModRewriteUrlStack {
|
||||||
*
|
*
|
||||||
* Composes the query by looping thru stored but non processed urls, executes
|
* Composes the query by looping thru stored but non processed urls, executes
|
||||||
* the query and adds the (urlpath and urlname) result to the stack.
|
* 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
|
if (!isset($this->_aStack[$sStackId]) || isset($this->_aStack[$sStackId]['urlpath'])) {
|
||||||
$aStack = array();
|
return;
|
||||||
foreach ($this->_aStack as $stackId => $item) {
|
|
||||||
if (!isset($item['urlpath'])) {
|
|
||||||
// pretty url is to create
|
|
||||||
$aStack[$stackId] = $item;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$aStack = [];
|
||||||
|
$aStack[$sStackId] = $this->_aStack[$sStackId];
|
||||||
|
|
||||||
// now, it's time to compose the where clause of the query
|
// now, it's time to compose the where clause of the query
|
||||||
$sWhere = '';
|
$sWhere = '';
|
||||||
foreach ($aStack as $stackId => $item) {
|
$aP = $this->_aStack[$sStackId]['params'];
|
||||||
$aP = $item['params'];
|
if ((int) mr_arrayValue($aP, 'idart') > 0) {
|
||||||
if ((int) mr_arrayValue($aP, 'idart') > 0) {
|
$sWhere .= '(al.idart = ' . $aP['idart'] . ' AND al.idlang = ' . $aP['lang'] . ') OR ';
|
||||||
$sWhere .= '(al.idart = ' . $aP['idart'] . ' AND al.idlang = ' . $aP['lang'] . ') OR ';
|
} elseif ((int) mr_arrayValue($aP, 'idartlang') > 0) {
|
||||||
} elseif ((int) mr_arrayValue($aP, 'idartlang') > 0) {
|
$sWhere .= '(al.idartlang = ' . $aP['idartlang'] . ') OR ';
|
||||||
$sWhere .= '(al.idartlang = ' . $aP['idartlang'] . ') OR ';
|
} elseif ((int) mr_arrayValue($aP, 'idcat') > 0) {
|
||||||
} elseif ((int) mr_arrayValue($aP, 'idcat') > 0) {
|
$sWhere .= '(cl.idcat = ' . $aP['idcat'] . ' AND cl.idlang = ' . $aP['lang'] . ' AND cl.startidartlang = al.idartlang) OR ';
|
||||||
$sWhere .= '(cl.idcat = ' . $aP['idcat'] . ' AND cl.idlang = ' . $aP['lang'] . ' AND cl.startidartlang = al.idartlang) OR ';
|
} elseif ((int) mr_arrayValue($aP, 'idcatart') > 0) {
|
||||||
} elseif ((int) mr_arrayValue($aP, 'idcatart') > 0) {
|
$sWhere .= '(ca.idcatart = ' . $aP['idcatart'] . ' AND ca.idart = al.idart AND al.idlang = ' . $aP['lang'] . ') OR ';
|
||||||
$sWhere .= '(ca.idcatart = ' . $aP['idcatart'] . ' AND ca.idart = al.idart AND al.idlang = ' . $aP['lang'] . ') OR ';
|
} elseif ((int) mr_arrayValue($aP, 'idcatlang') > 0) {
|
||||||
} elseif ((int) mr_arrayValue($aP, 'idcatlang') > 0) {
|
$sWhere .= '(cl.idcatlang = ' . $aP['idcatlang'] . ' AND cl.startidartlang = al.idartlang) OR ';
|
||||||
$sWhere .= '(cl.idcatlang = ' . $aP['idcatlang'] . ' AND cl.startidartlang = al.idartlang) OR ';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ($sWhere == '') {
|
if ($sWhere == '') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$sWhere = substr($sWhere, 0, -4);
|
$sWhere = cString::getPartOfString($sWhere, 0, -4);
|
||||||
$sWhere = str_replace(' OR ', " OR \n", $sWhere);
|
$sWhere = str_replace(' OR ', " OR \n", $sWhere);
|
||||||
|
|
||||||
// compose query and execute it
|
// compose query and execute it
|
||||||
|
@ -281,7 +251,7 @@ WHERE
|
||||||
SQL;
|
SQL;
|
||||||
ModRewriteDebugger::add($sql, 'ModRewriteUrlStack->_chunkSetPrettyUrlParts() $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
|
// create array of fields, which are to reduce step by step from record set below
|
||||||
$aFields = array('', 'idart', 'idartlang', 'idcatart', 'idcat');
|
$aFields = array('', 'idart', 'idartlang', 'idcatart', 'idcat');
|
||||||
|
@ -296,19 +266,15 @@ SQL;
|
||||||
// reduce existing field
|
// reduce existing field
|
||||||
unset($aRS[$field]);
|
unset($aRS[$field]);
|
||||||
}
|
}
|
||||||
$rsStackID = $this->_makeStackId($aRS);
|
|
||||||
if (isset($aStack[$rsStackID])) {
|
// matching stack entry found, add urlpath and urlname to the new stack
|
||||||
// matching stack entry found, add urlpath and urlname to the new stack
|
$aNewStack[$sStackId]['urlpath'] = $aRS['urlpath'];
|
||||||
$aNewStack[$rsStackID]['urlpath'] = $aRS['urlpath'];
|
$aNewStack[$sStackId]['urlname'] = $aRS['urlname'];
|
||||||
$aNewStack[$rsStackID]['urlname'] = $aRS['urlname'];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ModRewriteDebugger::add($aNewStack, 'ModRewriteUrlStack->_chunkSetPrettyUrlParts() $aNewStack');
|
ModRewriteDebugger::add($aNewStack, 'ModRewriteUrlStack->_chunkSetPrettyUrlParts() $aNewStack');
|
||||||
|
ModRewriteDebugger::add($this->_aStack, 'ModRewriteUrlStack->_chunkSetPrettyUrlParts() $this->_aStack');
|
||||||
|
|
||||||
// merge stack data
|
|
||||||
$this->_aStack = array_merge($this->_aStack, $aNewStack);
|
$this->_aStack = array_merge($this->_aStack, $aNewStack);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
|
@ -27,6 +27,12 @@ if (!defined('CON_FRAMEWORK')) {
|
||||||
*/
|
*/
|
||||||
class ModRewrite_ContentController extends ModRewrite_ControllerAbstract {
|
class ModRewrite_ContentController extends ModRewrite_ControllerAbstract {
|
||||||
|
|
||||||
|
public $_oView;
|
||||||
|
public $_client;
|
||||||
|
/**
|
||||||
|
* @var array<string, mixed>
|
||||||
|
*/
|
||||||
|
public $_cfg;
|
||||||
/**
|
/**
|
||||||
* Index action
|
* Index action
|
||||||
*/
|
*/
|
||||||
|
@ -41,13 +47,12 @@ class ModRewrite_ContentController extends ModRewrite_ControllerAbstract {
|
||||||
public function saveAction() {
|
public function saveAction() {
|
||||||
$bDebug = $this->getProperty('bDebug');
|
$bDebug = $this->getProperty('bDebug');
|
||||||
$aSeparator = $this->getProperty('aSeparator');
|
$aSeparator = $this->getProperty('aSeparator');
|
||||||
$aWordSeparator = $this->getProperty('aWordSeparator');
|
|
||||||
$routingSeparator = $this->getProperty('routingSeparator');
|
$routingSeparator = $this->getProperty('routingSeparator');
|
||||||
|
|
||||||
$bError = false;
|
$bError = false;
|
||||||
$aMR = array();
|
$aMR = [];
|
||||||
|
|
||||||
$request = (count($_POST) > 0) ? $_POST : $_GET;
|
$request = ($_POST !== []) ? $_POST : $_GET;
|
||||||
mr_requestCleanup($request);
|
mr_requestCleanup($request);
|
||||||
|
|
||||||
// use cl-mod-rewrite
|
// use cl-mod-rewrite
|
||||||
|
@ -61,7 +66,7 @@ class ModRewrite_ContentController extends ModRewrite_ControllerAbstract {
|
||||||
|
|
||||||
// root dir
|
// root dir
|
||||||
if (mr_arrayValue($request, 'rootdir', '') !== '') {
|
if (mr_arrayValue($request, 'rootdir', '') !== '') {
|
||||||
if (!preg_match('/^[a-zA-Z0-9\-_\/\.]*$/', $request['rootdir'])) {
|
if (!preg_match('/^[a-zA-Z0-9\-_\/.]*$/', $request['rootdir'])) {
|
||||||
$sMsg = i18n("The root directory has a invalid format, alowed are the chars [a-zA-Z0-9\-_\/\.]", "cl-mod-rewrite");
|
$sMsg = i18n("The root directory has a invalid format, alowed are the chars [a-zA-Z0-9\-_\/\.]", "cl-mod-rewrite");
|
||||||
$this->_oView->rootdir_error = $this->_notifyBox('error', $sMsg);
|
$this->_oView->rootdir_error = $this->_notifyBox('error', $sMsg);
|
||||||
$bError = true;
|
$bError = true;
|
||||||
|
@ -69,19 +74,19 @@ class ModRewrite_ContentController extends ModRewrite_ControllerAbstract {
|
||||||
|
|
||||||
if (mr_arrayValue($request, 'checkrootdir') == 1) {
|
if (mr_arrayValue($request, 'checkrootdir') == 1) {
|
||||||
// root dir check is enabled, this results in error
|
// root dir check is enabled, this results in error
|
||||||
$sMsg = i18n("The specified directory '%s' does not exists", "cl-mod-rewrite");
|
$sMsgTpl = i18n("The specified directory '%s' does not exists", "cl-mod-rewrite");
|
||||||
$sMsg = sprintf($sMsg, $_SERVER['DOCUMENT_ROOT'] . $request['rootdir']);
|
$sMsg = sprintf($sMsgTpl, $_SERVER['DOCUMENT_ROOT'] . $request['rootdir']);
|
||||||
$this->_oView->rootdir_error = $this->_notifyBox('error', $sMsg);
|
$this->_oView->rootdir_error = $this->_notifyBox('error', $sMsg);
|
||||||
$bError = true;
|
$bError = true;
|
||||||
} else {
|
} else {
|
||||||
// root dir check ist disabled, take over the setting and
|
// root dir check ist disabled, take over the setting and
|
||||||
// output a warning.
|
// 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");
|
$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($sMsg, $request['rootdir'], $_SERVER['DOCUMENT_ROOT']);
|
$sMsg = sprintf($sMsgTpl, $request['rootdir'], $_SERVER['DOCUMENT_ROOT']);
|
||||||
$this->_oView->rootdir_error = $this->_notifyBox('warning', $sMsg);
|
$this->_oView->rootdir_error = $this->_notifyBox('warning', $sMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->_oView->rootdir = conHtmlentities($request['rootdir']);
|
$this->_oView->rootdir = clHtmlEntities($request['rootdir']);
|
||||||
$aMR['cl-mod-rewrite']['rootdir'] = $request['rootdir'];
|
$aMR['cl-mod-rewrite']['rootdir'] = $request['rootdir'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,13 +247,13 @@ class ModRewrite_ContentController extends ModRewrite_ControllerAbstract {
|
||||||
$bError = true;
|
$bError = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_oView->category_separator = conHtmlentities($categorySeperator);
|
$this->_oView->category_separator = clHtmlentities($categorySeperator);
|
||||||
$aMR['cl-mod-rewrite']['category_seperator'] = $categorySeperator;
|
$aMR['cl-mod-rewrite']['category_seperator'] = $categorySeperator;
|
||||||
$this->_oView->category_word_separator = conHtmlentities($categoryWordSeperator);
|
$this->_oView->category_word_separator = clHtmlentities($categoryWordSeperator);
|
||||||
$aMR['cl-mod-rewrite']['category_word_seperator'] = $categoryWordSeperator;
|
$aMR['cl-mod-rewrite']['category_word_seperator'] = $categoryWordSeperator;
|
||||||
$this->_oView->article_separator = conHtmlentities($articleSeperator);
|
$this->_oView->article_separator = clHtmlentities($articleSeperator);
|
||||||
$aMR['cl-mod-rewrite']['article_seperator'] = $articleSeperator;
|
$aMR['cl-mod-rewrite']['article_seperator'] = $articleSeperator;
|
||||||
$this->_oView->article_word_separator = conHtmlentities($articleWordSeperator);
|
$this->_oView->article_word_separator = clHtmlentities($articleWordSeperator);
|
||||||
$aMR['cl-mod-rewrite']['article_word_seperator'] = $articleWordSeperator;
|
$aMR['cl-mod-rewrite']['article_word_seperator'] = $articleWordSeperator;
|
||||||
|
|
||||||
// file extension
|
// file extension
|
||||||
|
@ -258,7 +263,7 @@ class ModRewrite_ContentController extends ModRewrite_ControllerAbstract {
|
||||||
$this->_oView->file_extension_error = $this->_notifyBox('error', $sMsg);
|
$this->_oView->file_extension_error = $this->_notifyBox('error', $sMsg);
|
||||||
$bError = true;
|
$bError = true;
|
||||||
}
|
}
|
||||||
$this->_oView->file_extension = conHtmlentities($request['file_extension']);
|
$this->_oView->file_extension = clHtmlentities($request['file_extension']);
|
||||||
$aMR['cl-mod-rewrite']['file_extension'] = $request['file_extension'];
|
$aMR['cl-mod-rewrite']['file_extension'] = $request['file_extension'];
|
||||||
} else {
|
} else {
|
||||||
$this->_oView->file_extension = '.html';
|
$this->_oView->file_extension = '.html';
|
||||||
|
@ -288,12 +293,12 @@ class ModRewrite_ContentController extends ModRewrite_ControllerAbstract {
|
||||||
$this->_oView->add_startart_name_to_url_chk = ' checked="checked"';
|
$this->_oView->add_startart_name_to_url_chk = ' checked="checked"';
|
||||||
$aMR['cl-mod-rewrite']['add_startart_name_to_url'] = 1;
|
$aMR['cl-mod-rewrite']['add_startart_name_to_url'] = 1;
|
||||||
if (mr_arrayValue($request, 'add_startart_name_to_url', '') !== '') {
|
if (mr_arrayValue($request, 'add_startart_name_to_url', '') !== '') {
|
||||||
if (!preg_match('/^[a-zA-Z0-9\-_\/\.]*$/', $request['default_startart_name'])) {
|
if (!preg_match('/^[a-zA-Z0-9\-_\/.]*$/', $request['default_startart_name'])) {
|
||||||
$sMsg = i18n("The article name has a invalid format, allowed are the chars /^[a-zA-Z0-9\-_\/\.]*$/", "cl-mod-rewrite");
|
$sMsg = i18n("The article name has a invalid format, allowed are the chars /^[a-zA-Z0-9\-_\/\.]*$/", "cl-mod-rewrite");
|
||||||
$this->_oView->add_startart_name_to_url_error = $this->_notifyBox('error', $sMsg);
|
$this->_oView->add_startart_name_to_url_error = $this->_notifyBox('error', $sMsg);
|
||||||
$bError = true;
|
$bError = true;
|
||||||
}
|
}
|
||||||
$this->_oView->default_startart_name = conHtmlentities($request['default_startart_name']);
|
$this->_oView->default_startart_name = clHtmlentities($request['default_startart_name']);
|
||||||
$aMR['cl-mod-rewrite']['default_startart_name'] = $request['default_startart_name'];
|
$aMR['cl-mod-rewrite']['default_startart_name'] = $request['default_startart_name'];
|
||||||
} else {
|
} else {
|
||||||
$this->_oView->default_startart_name = '';
|
$this->_oView->default_startart_name = '';
|
||||||
|
@ -321,10 +326,10 @@ class ModRewrite_ContentController extends ModRewrite_ControllerAbstract {
|
||||||
|
|
||||||
// routing
|
// routing
|
||||||
if (isset($request['rewrite_routing'])) {
|
if (isset($request['rewrite_routing'])) {
|
||||||
$aRouting = array();
|
$aRouting = [];
|
||||||
$items = explode("\n", $request['rewrite_routing']);
|
$items = explode("\n", $request['rewrite_routing']);
|
||||||
foreach ($items as $p => $v) {
|
foreach ($items as $item) {
|
||||||
$routingDef = explode($routingSeparator, $v);
|
$routingDef = explode($routingSeparator, $item);
|
||||||
if (count($routingDef) !== 2) {
|
if (count($routingDef) !== 2) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -335,11 +340,11 @@ class ModRewrite_ContentController extends ModRewrite_ControllerAbstract {
|
||||||
}
|
}
|
||||||
$aRouting[$routingDef[0]] = $routingDef[1];
|
$aRouting[$routingDef[0]] = $routingDef[1];
|
||||||
}
|
}
|
||||||
$this->_oView->rewrite_routing = conHtmlentities($request['rewrite_routing']);
|
$this->_oView->rewrite_routing = clHtmlentities($request['rewrite_routing']);
|
||||||
$aMR['cl-mod-rewrite']['routing'] = $aRouting;
|
$aMR['cl-mod-rewrite']['routing'] = $aRouting;
|
||||||
} else {
|
} else {
|
||||||
$this->_oView->rewrite_routing = '';
|
$this->_oView->rewrite_routing = '';
|
||||||
$aMR['cl-mod-rewrite']['routing'] = array();
|
$aMR['cl-mod-rewrite']['routing'] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// redirect invalid article to errorsite
|
// redirect invalid article to errorsite
|
||||||
|
@ -377,7 +382,7 @@ class ModRewrite_ContentController extends ModRewrite_ControllerAbstract {
|
||||||
$this->_oView->content_before .= $this->_notifyBox('info', $sMsg);
|
$this->_oView->content_before .= $this->_notifyBox('info', $sMsg);
|
||||||
} else {
|
} else {
|
||||||
$sMsg = i18n("Configuration could not saved. Please check write permissions for %s ", "cl-mod-rewrite");
|
$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);
|
$this->_oView->content_before .= $this->_notifyBox('error', $sMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -385,9 +390,8 @@ class ModRewrite_ContentController extends ModRewrite_ControllerAbstract {
|
||||||
/**
|
/**
|
||||||
* Checks, if any sseparators setting is modified or not
|
* Checks, if any sseparators setting is modified or not
|
||||||
* @param array $aNewCfg New configuration send by requests.
|
* @param array $aNewCfg New configuration send by requests.
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
protected function _separatorModified($aNewCfg) {
|
protected function _separatorModified($aNewCfg): bool {
|
||||||
$aCfg = ModRewrite::getConfig();
|
$aCfg = ModRewrite::getConfig();
|
||||||
|
|
||||||
if ($aCfg['category_seperator'] != $aNewCfg['category_seperator']) {
|
if ($aCfg['category_seperator'] != $aNewCfg['category_seperator']) {
|
||||||
|
@ -405,18 +409,19 @@ class ModRewrite_ContentController extends ModRewrite_ControllerAbstract {
|
||||||
/**
|
/**
|
||||||
* Does some checks like 'is_start_compatible' check.
|
* Does some checks like 'is_start_compatible' check.
|
||||||
* Adds notifications, if something will went wrong...
|
* Adds notifications, if something will went wrong...
|
||||||
|
*
|
||||||
|
* @todo review text and translations
|
||||||
*/
|
*/
|
||||||
protected function _doChecks() {
|
protected function _doChecks() {
|
||||||
// Check for not supported '$cfg["is_start_compatible"] = true;' mode
|
|
||||||
if (!empty($this->_cfg['is_start_compatible']) && true === $this->_cfg['is_start_compatible']) {
|
if (!empty($this->_cfg['is_start_compatible']) && true === $this->_cfg['is_start_compatible']) {
|
||||||
$sMsg = i18n("Your Contenido installation runs with the setting 'is_start_compatible'. This plugin will not work properly in this mode.<br />Please check following topic in Contenido forum to change this:<br /><br /><a href='http://forum.contenido.org/viewtopic.php?t=32530' class='blue' target='_blank'>is_start_compatible auf neue Version umstellen</a>", "cl-mod-rewrite");
|
$sMsg = i18n("Your Contenido installation runs with the setting 'is_start_compatible'. This plugin will not work properly in this mode.<br />Please check following topic in Contenido forum to change this:<br /><br /><a href='http://forum.contenido.org/viewtopic.php?t=32530' class='blue' target='_blank'>is_start_compatible auf neue Version umstellen</a>", "cl-mod-rewrite");
|
||||||
$this->_oView->content_before .= $this->_notifyBox('warning', $sMsg);
|
$this->_oView->content_before .= $this->_notifyBox('warning', $sMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for empty urlpath entries in cat_lang table
|
// Check for empty urlpath entries in cat_lang table
|
||||||
$db = new DB_Contenido();
|
$dbConLite = new DB_ConLite();
|
||||||
$sql = "SELECT idcatlang FROM " . $this->_cfg['tab']['cat_lang'] . " WHERE urlpath = ''";
|
$sql = "SELECT idcatlang FROM " . $this->_cfg['tab']['cat_lang'] . " WHERE urlpath = ''";
|
||||||
if ($db->query($sql) && $db->next_record()) {
|
if ($dbConLite->query($sql) && $dbConLite->next_record()) {
|
||||||
$sMsg = i18n("It seems as if some categories don't have a set 'urlpath' entry in the database. Please reset empty aliases in %sFunctions%s area.", "cl-mod-rewrite");
|
$sMsg = i18n("It seems as if some categories don't have a set 'urlpath' entry in the database. Please reset empty aliases in %sFunctions%s area.", "cl-mod-rewrite");
|
||||||
$sMsg = sprintf($sMsg, '<a href="main.php?area=mod_rewrite_expert&frame=4&contenido=' . $this->_oView->sessid . '&idclient=' . $this->_client . '" onclick="parent.right_top.sub.clicked(parent.right_top.document.getElementById(\'c_1\').firstChild);">', '</a>');
|
$sMsg = sprintf($sMsg, '<a href="main.php?area=mod_rewrite_expert&frame=4&contenido=' . $this->_oView->sessid . '&idclient=' . $this->_client . '" onclick="parent.right_top.sub.clicked(parent.right_top.document.getElementById(\'c_1\').firstChild);">', '</a>');
|
||||||
$this->_oView->content_before .= $this->_notifyBox('warning', $sMsg);
|
$this->_oView->content_before .= $this->_notifyBox('warning', $sMsg);
|
||||||
|
|
|
@ -77,17 +77,9 @@ class ModRewrite_ContentExpertController extends ModRewrite_ControllerAbstract {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type == 'restrictive') {
|
$source = $type == 'restrictive' ? $this->_htaccessRestrictive : $this->_htaccessSimple;
|
||||||
$source = $this->_htaccessRestrictive;
|
|
||||||
} else {
|
|
||||||
$source = $this->_htaccessSimple;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($copy == 'contenido') {
|
$dest = $copy == 'contenido' ? $aInfo['contenido_full_path'] . '.htaccess' : $aInfo['client_full_path'] . '.htaccess';
|
||||||
$dest = $aInfo['contenido_full_path'] . '.htaccess';
|
|
||||||
} else {
|
|
||||||
$dest = $aInfo['client_full_path'] . '.htaccess';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$result = @copy($source, $dest)) {
|
if (!$result = @copy($source, $dest)) {
|
||||||
$this->_oView->content_before = $this->_notifyBox('info', 'Die .htaccess konnte nicht von ' . $source . ' nach ' . $dest . ' kopiert werden!');
|
$this->_oView->content_before = $this->_notifyBox('info', 'Die .htaccess konnte nicht von ' . $source . ' nach ' . $dest . ' kopiert werden!');
|
||||||
|
@ -108,16 +100,12 @@ class ModRewrite_ContentExpertController extends ModRewrite_ControllerAbstract {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type == 'restrictive') {
|
$source = $type == 'restrictive' ? $this->_htaccessRestrictive : $this->_htaccessSimple;
|
||||||
$source = $this->_htaccessRestrictive;
|
|
||||||
} else {
|
|
||||||
$source = $this->_htaccessSimple;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->_oView->content = file_get_contents($source);
|
$this->_oView->content = file_get_contents($source);
|
||||||
|
|
||||||
header('Content-Type: text/plain');
|
header('Content-Type: text/plain');
|
||||||
header('Etag: ' . md5(mt_rand()));
|
header('Etag: ' . md5(random_int(0, mt_getrandmax())));
|
||||||
header('Content-Disposition: attachment; filename="' . $type . '.htaccess"');
|
header('Content-Disposition: attachment; filename="' . $type . '.htaccess"');
|
||||||
$this->render('{CONTENT}');
|
$this->render('{CONTENT}');
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,33 +60,25 @@ class ModRewrite_ContentTestController extends ModRewrite_ControllerAbstract {
|
||||||
$this->_oView->content = '';
|
$this->_oView->content = '';
|
||||||
|
|
||||||
// Array for testcases
|
// Array for testcases
|
||||||
$aTests = array();
|
$aTests = [];
|
||||||
|
|
||||||
// Instance of mr test
|
// Instance of mr test
|
||||||
$oMRTest = new ModRewriteTest($this->_iMaxItems);
|
$modRewriteTest = new ModRewriteTest($this->_iMaxItems);
|
||||||
|
|
||||||
$startTime = getmicrotime();
|
$startTime = getmicrotime();
|
||||||
|
|
||||||
// Fetch complete CONTENIDO page structure
|
// Fetch complete CONTENIDO page structure
|
||||||
$aStruct = $oMRTest->fetchFullStructure();
|
$aStruct = $modRewriteTest->fetchFullStructure();
|
||||||
ModRewriteDebugger::add($aStruct, 'mr_test.php $aStruct');
|
ModRewriteDebugger::add($aStruct, 'ModRewrite_ContentTestController::testAction() $aStruct');
|
||||||
|
|
||||||
// Loop through the structure and compose testcases
|
// Loop through the structure and compose testcases
|
||||||
foreach ($aStruct as $idcat => $aCat) {
|
foreach ($aStruct as $aCat) {
|
||||||
// category
|
// category
|
||||||
$aTests[] = array(
|
$aTests[] = ['url' => $modRewriteTest->composeURL($aCat, 'c'), 'level' => $aCat['level'], 'name' => $aCat['name']];
|
||||||
'url' => $oMRTest->composeURL($aCat, 'c'),
|
|
||||||
'level' => $aCat['level'],
|
|
||||||
'name' => $aCat['name']
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($aCat['articles'] as $idart => $aArt) {
|
foreach ($aCat['articles'] as $aArt) {
|
||||||
// articles
|
// articles
|
||||||
$aTests[] = array(
|
$aTests[] = ['url' => $modRewriteTest->composeURL($aArt, 'a'), 'level' => $aCat['level'], 'name' => $aCat['name'] . ' :: ' . $aArt['title']];
|
||||||
'url' => $oMRTest->composeURL($aArt, 'a'),
|
|
||||||
'level' => $aCat['level'],
|
|
||||||
'name' => $aCat['name'] . ' :: ' . $aArt['title']
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +88,7 @@ class ModRewrite_ContentTestController extends ModRewrite_ControllerAbstract {
|
||||||
$oMRUrlStack = ModRewriteUrlStack::getInstance();
|
$oMRUrlStack = ModRewriteUrlStack::getInstance();
|
||||||
|
|
||||||
// first loop to add urls to mr url stack
|
// first loop to add urls to mr url stack
|
||||||
foreach ($aTests as $p => $v) {
|
foreach ($aTests as $v) {
|
||||||
$oMRUrlStack->add($v['url']);
|
$oMRUrlStack->add($v['url']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,15 +96,15 @@ class ModRewrite_ContentTestController extends ModRewrite_ControllerAbstract {
|
||||||
$failCounter = 0;
|
$failCounter = 0;
|
||||||
|
|
||||||
// second loop to do the rest
|
// second loop to do the rest
|
||||||
foreach ($aTests as $p => $v) {
|
foreach ($aTests as $aTest) {
|
||||||
$url = mr_buildNewUrl($v['url']);
|
$url = mr_buildNewUrl($aTest['url']);
|
||||||
$arr = $oMRTest->resolveUrl($url);
|
$arr = $modRewriteTest->resolveUrl($url);
|
||||||
$error = '';
|
$error = '';
|
||||||
$resUrl = $oMRTest->getResolvedUrl();
|
$resUrl = $modRewriteTest->getResolvedUrl();
|
||||||
$color = 'green';
|
$color = 'green';
|
||||||
|
|
||||||
if ($url !== $resUrl) {
|
if ($url !== $resUrl) {
|
||||||
if ($oMRTest->getRoutingFoundState()) {
|
if ($modRewriteTest->getRoutingFoundState()) {
|
||||||
$successCounter++;
|
$successCounter++;
|
||||||
$resUrl = 'route to -> ' . $resUrl;
|
$resUrl = 'route to -> ' . $resUrl;
|
||||||
} else {
|
} else {
|
||||||
|
@ -144,18 +136,18 @@ class ModRewrite_ContentTestController extends ModRewrite_ControllerAbstract {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$pref = str_repeat(' ', $v['level']);
|
$pref = str_repeat(' ', $aTest['level']);
|
||||||
|
|
||||||
// render resolve information for current item
|
// render resolve information for current item
|
||||||
$itemTpl = $this->_oView->lng_result_item_tpl;
|
$itemTpl = $this->_oView->lng_result_item_tpl;
|
||||||
$itemTpl = str_replace('{pref}', $pref, $itemTpl);
|
$itemTpl = str_replace('{pref}', $pref, $itemTpl);
|
||||||
$itemTpl = str_replace('{name}', $v['name'], $itemTpl);
|
$itemTpl = str_replace('{name}', $aTest['name'], $itemTpl);
|
||||||
$itemTpl = str_replace('{url_in}', $v['url'], $itemTpl);
|
$itemTpl = str_replace('{url_in}', $aTest['url'], $itemTpl);
|
||||||
$itemTpl = str_replace('{url_out}', $url, $itemTpl);
|
$itemTpl = str_replace('{url_out}', $url, $itemTpl);
|
||||||
$itemTpl = str_replace('{color}', $color, $itemTpl);
|
$itemTpl = str_replace('{color}', $color, $itemTpl);
|
||||||
$itemTpl = str_replace('{url_res}', $resUrl, $itemTpl);
|
$itemTpl = str_replace('{url_res}', $resUrl, $itemTpl);
|
||||||
$itemTpl = str_replace('{err}', $error, $itemTpl);
|
$itemTpl = str_replace('{err}', $error, $itemTpl);
|
||||||
$itemTpl = str_replace('{data}', $oMRTest->getReadableResolvedData($arr), $itemTpl);
|
$itemTpl = str_replace('{data}', $modRewriteTest->getReadableResolvedData($arr), $itemTpl);
|
||||||
|
|
||||||
$this->_oView->content .= "\n" . $itemTpl . "\n";
|
$this->_oView->content .= "\n" . $itemTpl . "\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,13 +72,13 @@ abstract class ModRewrite_ControllerAbstract {
|
||||||
* Template file or template string to render
|
* Template file or template string to render
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $_template = null;
|
protected $_template;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Additional properties list
|
* Additional properties list
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $_properties = array();
|
protected $_properties = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Debug flag
|
* Debug flag
|
||||||
|
@ -138,20 +138,18 @@ abstract class ModRewrite_ControllerAbstract {
|
||||||
/**
|
/**
|
||||||
* Property setter.
|
* Property setter.
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param mixed $value
|
|
||||||
*/
|
*/
|
||||||
public function setProperty($key, $value) {
|
public function setProperty($key, mixed $value) {
|
||||||
$this->_properties[$key] = $value;
|
$this->_properties[$key] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property getter.
|
* Property getter.
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param mixed $default
|
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getProperty($key, $default = null) {
|
public function getProperty($key, mixed $default = null) {
|
||||||
return (isset($this->_properties[$key])) ? $this->_properties[$key] : $default;
|
return $this->_properties[$key] ?? $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -202,7 +200,7 @@ abstract class ModRewrite_ControllerAbstract {
|
||||||
* @param mixed $default The default value
|
* @param mixed $default The default value
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
protected function _getParam($key, $default = null) {
|
protected function _getParam($key, mixed $default = null) {
|
||||||
if (isset($_GET[$key])) {
|
if (isset($_GET[$key])) {
|
||||||
return $_GET[$key];
|
return $_GET[$key];
|
||||||
} elseif (isset($_POST[$key])) {
|
} elseif (isset($_POST[$key])) {
|
||||||
|
|
|
@ -23,11 +23,15 @@
|
||||||
* @link http://www.4fb.de
|
* @link http://www.4fb.de
|
||||||
* @link http://www.contenido.org
|
* @link http://www.contenido.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use ConLite\Log\LogWriter;
|
||||||
|
use ConLite\Log\Log;
|
||||||
|
|
||||||
if (!defined('CON_FRAMEWORK')) {
|
if (!defined('CON_FRAMEWORK')) {
|
||||||
die('Illegal call');
|
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.
|
* Processes cl-mod-rewrite related job for created new tree.
|
||||||
|
@ -485,10 +489,14 @@ function mr_buildGeneratedCode($code) {
|
||||||
|
|
||||||
// remove tinymce single quote entities:
|
// remove tinymce single quote entities:
|
||||||
$code = str_replace("'", "'", $code);
|
$code = str_replace("'", "'", $code);
|
||||||
|
|
||||||
|
$baseUri = cRegistry::getFrontendUrl();
|
||||||
|
$baseUri = CEC_Hook::execute("Contenido.Frontend.BaseHrefGeneration", $baseUri);
|
||||||
|
|
||||||
// get base uri
|
// CON-1389 modifier /e is deprecated as of PHP 5.5
|
||||||
$sBaseUri = $cfgClient[$client]['path']['htmlpath'];
|
$code = preg_replace_callback("/([\"|\'|=])upload\/(.?|.+?)([\"|\'|>])/i", function($match) use ($baseUri) {
|
||||||
$sBaseUri = CEC_Hook::execute("Contenido.Frontend.BaseHrefGeneration", $sBaseUri);
|
return stripslashes($match[1] . $baseUri . 'upload/' . $match[2] . $match[3]);
|
||||||
|
}, $code);
|
||||||
|
|
||||||
// define some preparations to replace /front_content.php & ./front_content.php
|
// define some preparations to replace /front_content.php & ./front_content.php
|
||||||
// against front_content.php, because urls should start with front_content.php
|
// against front_content.php, because urls should start with front_content.php
|
||||||
|
@ -514,12 +522,15 @@ function mr_buildGeneratedCode($code) {
|
||||||
foreach ($matches as $val) {
|
foreach ($matches as $val) {
|
||||||
$oMRUrlStack->add('front_content.php' . $val[2]);
|
$oMRUrlStack->add('front_content.php' . $val[2]);
|
||||||
}
|
}
|
||||||
|
ModRewriteDebugger::add($code, 'mr_buildGeneratedCode() before replace');
|
||||||
// ok let it beginn, build the clean urls
|
// 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);
|
||||||
$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) {
|
$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);
|
}, $code);
|
||||||
|
|
||||||
ModRewriteDebugger::add($code, 'mr_buildGeneratedCode() out');
|
ModRewriteDebugger::add($code, 'mr_buildGeneratedCode() out');
|
||||||
|
@ -608,8 +619,7 @@ function mr_loadConfiguration($clientId, $forceReload = false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function mr_getConfigurationFilePath($clientId) {
|
function mr_getConfigurationFilePath($clientId) {
|
||||||
$clientConfig = cRegistry::getClientConfig((int) $clientId);
|
$fePath = cRegistry::getFrontendPath();
|
||||||
$fePath = $clientConfig['path']['frontend'];
|
|
||||||
return $fePath . 'data/config/' . CL_ENVIRONMENT . '/config.mod_rewrite.php';
|
return $fePath . 'data/config/' . CL_ENVIRONMENT . '/config.mod_rewrite.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,11 +676,27 @@ function mr_getConfiguration($clientId) {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function mr_setConfiguration($clientId, array $config) {
|
function mr_setConfiguration($clientId, array $config) {
|
||||||
global $cfg;
|
$sClientPath = cRegistry::getClientConfig(cRegistry::getClientId())['path']['frontend'];
|
||||||
|
$sConfigClientPath = $sClientPath.'/data/config/'.CL_ENVIRONMENT.'/';
|
||||||
$file = $cfg['path']['contenido'] . $cfg['path']['plugins'] . 'cl-mod-rewrite/includes/config.mod_rewrite_' . $clientId . '.php';
|
|
||||||
|
if (is_writable($sClientPath) && !file_exists($sConfigClientPath)) {
|
||||||
|
try {
|
||||||
|
mkdir($sConfigClientPath, 0777, true);
|
||||||
|
} catch (Exception $ex) {
|
||||||
|
$writer = LogWriter::factory("File", array('destination' => 'contenido.log'));
|
||||||
|
$log = new Log($writer);
|
||||||
|
$log->log($ex->getFile() . " (" . $ex->getLine() . "): " . $ex->getMessage(), Log::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));
|
$result = file_put_contents($file, serialize($config));
|
||||||
return ($result) ? true : false;
|
return (empty($result)) ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,8 +23,10 @@ global $client, $cfg;
|
||||||
##### Initialization
|
##### Initialization
|
||||||
|
|
||||||
if ((int) $client <= 0) {
|
if ((int) $client <= 0) {
|
||||||
// if there is no client selected, display empty page
|
// if there is no client selected, display noti
|
||||||
$oPage = new cPage;
|
$oPage = new cPage;
|
||||||
|
$oNoti = new Contenido_Notification();
|
||||||
|
$oPage->setContent($oNoti->returnNotification("warning", i18n("No client set!")));
|
||||||
$oPage->render();
|
$oPage->render();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,10 @@ global $client, $cfg;
|
||||||
##### Initialization
|
##### Initialization
|
||||||
|
|
||||||
if ((int) $client <= 0) {
|
if ((int) $client <= 0) {
|
||||||
// if there is no client selected, display empty page
|
// if there is no client selected, display noti
|
||||||
$oPage = new cPage;
|
$oPage = new cPage;
|
||||||
|
$oNoti = new Contenido_Notification();
|
||||||
|
$oPage->setContent($oNoti->returnNotification("warning", i18n("No client set!")));
|
||||||
$oPage->render();
|
$oPage->render();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,10 @@ global $client, $cfg;
|
||||||
##### Initialization
|
##### Initialization
|
||||||
|
|
||||||
if ((int) $client <= 0) {
|
if ((int) $client <= 0) {
|
||||||
// if there is no client selected, display empty page
|
// if there is no client selected, display noti
|
||||||
$oPage = new cPage;
|
$oPage = new cPage;
|
||||||
|
$oNoti = new Contenido_Notification();
|
||||||
|
$oPage->setContent($oNoti->returnNotification("warning", i18n("No client set!")));
|
||||||
$oPage->render();
|
$oPage->render();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ var mrPlugin = {
|
||||||
initializeSettingsPage: function() {
|
initializeSettingsPage: function() {
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("#mr_use_language").change(function() {
|
$("#mr_use_language").change(function() {
|
||||||
if (true == $(this).attr("checked")) {
|
if (true == $(this).prop("checked")) {
|
||||||
$("#mr_use_language_name").removeAttr("disabled");
|
$("#mr_use_language_name").removeAttr("disabled");
|
||||||
} else {
|
} else {
|
||||||
$("#mr_use_language_name").attr("disabled", "disabled");
|
$("#mr_use_language_name").attr("disabled", "disabled");
|
||||||
|
@ -51,7 +51,7 @@ var mrPlugin = {
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#mr_use_client").change(function() {
|
$("#mr_use_client").change(function() {
|
||||||
if (true == $(this).attr("checked")) {
|
if (true == $(this).prop("checked")) {
|
||||||
$("#mr_use_client_name").removeAttr("disabled");
|
$("#mr_use_client_name").removeAttr("disabled");
|
||||||
} else {
|
} else {
|
||||||
$("#mr_use_client_name").attr("disabled", "disabled");
|
$("#mr_use_client_name").attr("disabled", "disabled");
|
||||||
|
@ -59,7 +59,7 @@ var mrPlugin = {
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#mr_add_startart_name_to_url").change(function() {
|
$("#mr_add_startart_name_to_url").change(function() {
|
||||||
if (true == $(this).attr("checked")) {
|
if (true == $(this).prop("checked")) {
|
||||||
$("#mr_default_startart_name").removeAttr("disabled")
|
$("#mr_default_startart_name").removeAttr("disabled")
|
||||||
.removeClass("disabled");
|
.removeClass("disabled");
|
||||||
} else {
|
} else {
|
||||||
|
|
1
scripts/mod_rewrite.min.js
gevendort
Normale Datei
1
scripts/mod_rewrite.min.js
gevendort
Normale Datei
|
@ -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()})})}};
|
|
@ -1,4 +1,4 @@
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
<!DOCTYPE HTML>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>mod_rewrite_content</title>
|
<title>mod_rewrite_content</title>
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
<meta http-equiv="pragma" content="no-cache">
|
<meta http-equiv="pragma" content="no-cache">
|
||||||
<script type="text/javascript" src="scripts/jquery/jquery.js"></script>
|
<script type="text/javascript" src="scripts/jquery/jquery.js"></script>
|
||||||
<script type="text/javascript" src="plugins/cl-mod-rewrite/external/aToolTip/js/atooltip.jquery.js"></script>
|
<script type="text/javascript" src="plugins/cl-mod-rewrite/external/aToolTip/js/atooltip.jquery.js"></script>
|
||||||
<script type="text/javascript" src="plugins/cl-mod-rewrite/scripts/mod_rewrite.js"></script>
|
<script type="text/javascript" src="plugins/cl-mod-rewrite/scripts/mod_rewrite.min.js?20220311"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="styles/contenido.css">
|
<link rel="stylesheet" type="text/css" href="styles/contenido.css">
|
||||||
<link rel="stylesheet" type="text/css" href="plugins/cl-mod-rewrite/external/aToolTip/css/atooltip.css">
|
<link rel="stylesheet" type="text/css" href="plugins/cl-mod-rewrite/external/aToolTip/css/atooltip.css">
|
||||||
<link rel="stylesheet" type="text/css" href="plugins/cl-mod-rewrite/styles/styles.css">
|
<link rel="stylesheet" type="text/css" href="plugins/cl-mod-rewrite/styles/styles.css">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
<!DOCTYPE HTML>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>mod_rewrite_content_expert</title>
|
<title>mod_rewrite_content_expert</title>
|
||||||
|
@ -6,7 +6,7 @@
|
||||||
<meta http-equiv="cache-control" content="no-cache">
|
<meta http-equiv="cache-control" content="no-cache">
|
||||||
<meta http-equiv="pragma" content="no-cache">
|
<meta http-equiv="pragma" content="no-cache">
|
||||||
<script type="text/javascript" src="scripts/jquery/jquery.js"></script>
|
<script type="text/javascript" src="scripts/jquery/jquery.js"></script>
|
||||||
<script type="text/javascript" src="plugins/cl-mod-rewrite/scripts/mod_rewrite.js"></script>
|
<script type="text/javascript" src="plugins/cl-mod-rewrite/scripts/mod_rewrite.min.js?20220311"></script>
|
||||||
<script type="text/javascript" src="plugins/cl-mod-rewrite/external/aToolTip/js/atooltip.jquery.js"></script>
|
<script type="text/javascript" src="plugins/cl-mod-rewrite/external/aToolTip/js/atooltip.jquery.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="styles/contenido.css">
|
<link rel="stylesheet" type="text/css" href="styles/contenido.css">
|
||||||
<link rel="stylesheet" type="text/css" href="plugins/cl-mod-rewrite/external/aToolTip/css/atooltip.css">
|
<link rel="stylesheet" type="text/css" href="plugins/cl-mod-rewrite/external/aToolTip/css/atooltip.css">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
<!DOCTYPE HTML>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>mod_rewrite_content_test</title>
|
<title>mod_rewrite_content_test</title>
|
||||||
|
@ -6,7 +6,7 @@
|
||||||
<meta http-equiv="cache-control" content="no-cache">
|
<meta http-equiv="cache-control" content="no-cache">
|
||||||
<meta http-equiv="pragma" content="no-cache">
|
<meta http-equiv="pragma" content="no-cache">
|
||||||
<script type="text/javascript" src="scripts/jquery/jquery.js"></script>
|
<script type="text/javascript" src="scripts/jquery/jquery.js"></script>
|
||||||
<script type="text/javascript" src="plugins/cl-mod-rewrite/scripts/mod_rewrite.js"></script>
|
<script type="text/javascript" src="plugins/cl-mod-rewrite/scripts/mod_rewrite.min.js?20220311"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="styles/contenido.css">
|
<link rel="stylesheet" type="text/css" href="styles/contenido.css">
|
||||||
<link rel="stylesheet" type="text/css" href="plugins/cl-mod-rewrite/styles/styles.css">
|
<link rel="stylesheet" type="text/css" href="plugins/cl-mod-rewrite/styles/styles.css">
|
||||||
<script type="text/javascript"><!--
|
<script type="text/javascript"><!--
|
||||||
|
|
Laden …
In neuem Issue referenzieren