Merge branch 'release/V1.0.1' into develop
Dieser Commit ist enthalten in:
Commit
06cc337092
14 geänderte Dateien mit 74 neuen und 105 gelöschten Zeilen
1
.gitignore
gevendort
1
.gitignore
gevendort
|
@ -1 +1,2 @@
|
|||
/.project
|
||||
/classes/class.modrewriteurlstack_1.php
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<website>https://conlite.org</website>
|
||||
<version>1.0.1</version>
|
||||
</general>
|
||||
<requirements php="7.1">
|
||||
<requirements php="7.4">
|
||||
<conlite minversion="2.1.0" />
|
||||
</requirements>
|
||||
<conlite>
|
||||
|
|
|
@ -1,54 +1,26 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* AMR url stack class
|
||||
* File:
|
||||
* class.modrewriteurlstack.php
|
||||
*
|
||||
* @package plugin
|
||||
* @subpackage Mod Rewrite
|
||||
* @version SVN Revision $Rev: 128 $
|
||||
* @id $Id: class.modrewriteurlstack.php 128 2019-07-03 11:58:28Z oldperl $:
|
||||
* @author Murat Purc <murat@purc.de>
|
||||
* @copyright four for business AG <www.4fb.de>
|
||||
* @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 <o.pinke@conlite.org>
|
||||
* @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 <murat@purc.de> 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:
|
||||
* <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 {
|
||||
|
||||
/**
|
||||
|
@ -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,21 +209,16 @@ 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'];
|
||||
$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) {
|
||||
|
@ -264,8 +230,6 @@ class ModRewriteUrlStack {
|
|||
} 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,13 +266,10 @@ 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;
|
||||
}
|
||||
$aNewStack[$sStackId]['urlpath'] = $aRS['urlpath'];
|
||||
$aNewStack[$sStackId]['urlname'] = $aRS['urlname'];
|
||||
}
|
||||
}
|
||||
ModRewriteDebugger::add($aNewStack, 'ModRewriteUrlStack->_chunkSetPrettyUrlParts() $aNewStack');
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
@ -693,7 +693,7 @@ function mr_setConfiguration($clientId, array $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
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
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>
|
||||
<head>
|
||||
<title>mod_rewrite_content</title>
|
||||
|
@ -7,7 +7,7 @@
|
|||
<meta http-equiv="pragma" content="no-cache">
|
||||
<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/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="plugins/cl-mod-rewrite/external/aToolTip/css/atooltip.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>
|
||||
<head>
|
||||
<title>mod_rewrite_content_expert</title>
|
||||
|
@ -6,7 +6,7 @@
|
|||
<meta http-equiv="cache-control" 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="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>
|
||||
<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">
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>mod_rewrite_content_test</title>
|
||||
|
@ -6,7 +6,7 @@
|
|||
<meta http-equiv="cache-control" 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="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="plugins/cl-mod-rewrite/styles/styles.css">
|
||||
<script type="text/javascript"><!--
|
||||
|
|
Laden …
In neuem Issue referenzieren