1
0
Fork 0

Release version 1.0.0

Dieser Commit ist enthalten in:
o.pinke 2019-12-28 17:11:03 +01:00
Ursprung 7d1f043bed
Commit d098573903
18 geänderte Dateien mit 312 neuen und 287 gelöschten Zeilen

Datei anzeigen

@ -1,4 +1,5 @@
<?php
/**
* Mod Rewrite front_content.php controller. Does some preprocessing jobs, tries
* to set following variables, depending on mod rewrite configuration and if
@ -13,7 +14,7 @@
* @package plugin
* @subpackage Mod Rewrite
* @version SVN Revision $Rev: 128 $
* @id $Id: functions.mod_rewrite.php 128 2019-07-03 11:58:28Z oldperl $:
* @id $Id: functions.cl-mod-rewrite.php 128 2019-07-03 11:58:28Z oldperl $:
* @author Stefan Seifarth / stese
* @author Murat Purc <murat@purc.de>
* @copyright www.polycoder.de
@ -22,16 +23,14 @@
* @link http://www.4fb.de
* @link http://www.contenido.org
*/
if (!defined('CON_FRAMEWORK')) {
die('Illegal call');
}
cInclude('classes', 'contenido/class.articlelanguage.php');
/**
* Processes mod_rewrite related job for created new tree.
* Processes cl-mod-rewrite related job for created new tree.
*
* Will be called by chain 'Contenido.Action.str_newtree.AfterCall'.
*
@ -54,7 +53,7 @@ function mr_strNewTree(array $data) {
}
/**
* Processes mod_rewrite related job for created new category.
* Processes cl-mod-rewrite related job for created new category.
*
* Will be called by chain 'Contenido.Action.str_newcat.AfterCall'.
*
@ -77,7 +76,7 @@ function mr_strNewCategory(array $data) {
}
/**
* Processes mod_rewrite related job for renamed category
* Processes cl-mod-rewrite related job for renamed category
* 2010-02-01: and now all existing subcategories and modify their paths too...
* 2010-02-01: max 50 recursion level
*
@ -130,7 +129,7 @@ function mr_strRenameCategory(array $data) {
}
/**
* Processes mod_rewrite related job after moving a category up.
* Processes cl-mod-rewrite related job after moving a category up.
*
* Will be called by chain 'Contenido.Action.str_moveupcat.AfterCall'.
*
@ -164,7 +163,7 @@ function mr_strMoveUpCategory($idcat) {
}
/**
* Processes mod_rewrite related job after moving a category down.
* Processes cl-mod-rewrite related job after moving a category down.
*
* Will be called by chain 'Contenido.Action.str_movedowncat.AfterCall'.
*
@ -197,7 +196,7 @@ function mr_strMovedownCategory($idcat) {
}
/**
* Processes mod_rewrite related job after moving a category subtree.
* Processes cl-mod-rewrite related job after moving a category subtree.
*
* Will be called by chain 'Contenido.Action.str_movesubtree.AfterCall'.
*
@ -239,7 +238,7 @@ function mr_strMoveSubtree(array $data) {
}
/**
* Processes mod_rewrite related job after copying a category subtree.
* Processes cl-mod-rewrite related job after copying a category subtree.
*
* Will be called by chain 'Contenido.Category.strCopyCategory'.
*
@ -267,7 +266,7 @@ function mr_strCopyCategory(array $data) {
}
/**
* Processes mod_rewrite related job during structure synchronisation process,
* Processes cl-mod-rewrite related job during structure synchronisation process,
* sets the urlpath of current category.
*
* Will be called by chain 'Contenido.Category.strSyncCategory_Loop'.
@ -282,7 +281,7 @@ function mr_strSyncCategory(array $data) {
}
/**
* Processes mod_rewrite related job for saved articles (new or modified article).
* Processes cl-mod-rewrite related job for saved articles (new or modified article).
*
* Will be called by chain 'Contenido.Action.con_saveart.AfterCall'.
*
@ -322,7 +321,7 @@ function mr_conSaveArticle(array $data) {
}
/**
* Processes mod_rewrite related job for articles beeing moved.
* Processes cl-mod-rewrite related job for articles beeing moved.
*
* Will be called by chain 'Contenido.Article.conMoveArticles_Loop'.
*
@ -350,7 +349,7 @@ function mr_conMoveArticles($data) {
}
/**
* Processes mod_rewrite related job for duplicated articles.
* Processes cl-mod-rewrite related job for duplicated articles.
*
* Will be called by chain 'Contenido.Article.conCopyArtLang_AfterInsert'.
*
@ -377,7 +376,7 @@ function mr_conCopyArtLang($data) {
}
/**
* Processes mod_rewrite related job for synchronized articles.
* Processes cl-mod-rewrite related job for synchronized articles.
*
* Will be called by chain 'Contenido.Article.conSyncArticle_AfterInsert'.
*
@ -465,7 +464,7 @@ function mr_buildNewUrl($url) {
* Replaces existing ancors inside passed code, while rebuilding the urls.
*
* Will be called by chain 'Contenido.Content.conGenerateCode' or
* 'Contenido.Frontend.HTMLCodeOutput' depening on mod_rewrite settings.
* 'Contenido.Frontend.HTMLCodeOutput' depening on cl-mod-rewrite settings.
*
* @param string $code Code to prepare
* @return string New code
@ -481,9 +480,9 @@ function mr_buildGeneratedCode($code) {
// anchor hack
$code = preg_replace_callback(
"/<a([^>]*)href\s*=\s*[\"|\'][\/]#(.?|.+?)[\"|\']([^>]*)>/i",
create_function('$matches', 'return ModRewrite::rewriteHtmlAnchor($matches);'),
$code
"/<a([^>]*)href\s*=\s*[\"|\'][\/]#(.?|.+?)[\"|\']([^>]*)>/i",
create_function('$matches', 'return ModRewrite::rewriteHtmlAnchor($matches);'),
$code
);
// remove tinymce single quote entities:
@ -495,9 +494,9 @@ function mr_buildGeneratedCode($code) {
// IE hack with wrong base href interpretation
$code = preg_replace_callback(
"/([\"|\'|=])upload\/(.?|.+?)([\"|\'|>])/i",
create_function('$matches', 'return stripslashes($matches[1]' . $sBaseUri . ' . "upload/" . $matches[2] . $matches[3]);'),
$code
"/([\"|\'|=])upload\/(.?|.+?)([\"|\'|>])/i",
create_function('$matches', 'return stripslashes($matches[1]' . $sBaseUri . ' . "upload/" . $matches[2] . $matches[3]);'),
$code
);
// define some preparations to replace /front_content.php & ./front_content.php
@ -529,9 +528,9 @@ 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",
create_function('$aMatches', 'return $aMatches[1] . mr_buildNewUrl("front_content.php" . $aMatches[2]) . $aMatches[3];'),
$code
"/([\"|\'|=])front_content\.php(.?|.+?)([\"|\'|>])/i",
create_function('$aMatches', 'return $aMatches[1] . mr_buildNewUrl("front_content.php" . $aMatches[2]) . $aMatches[3];'),
$code
);
ModRewriteDebugger::add($code, 'mr_buildGeneratedCode() out');
@ -540,9 +539,9 @@ function mr_buildGeneratedCode($code) {
} else {
// anchor hack for non modrewrite websites
$code = preg_replace_callback(
"/<a([^>]*)href\s*=\s*[\"|\'][\/]#(.?|.+?)[\"|\']([^>]*)>/i",
create_function('$matches', 'return ModRewrite::contenidoHtmlAnchor($matches, $GLOBALS["is_XHTML"]);'),
$code
"/<a([^>]*)href\s*=\s*[\"|\'][\/]#(.?|.+?)[\"|\']([^>]*)>/i",
create_function('$matches', 'return ModRewrite::contenidoHtmlAnchor($matches, $GLOBALS["is_XHTML"]);'),
$code
);
}
@ -590,7 +589,7 @@ function mr_setClientLanguageId($client) {
* Loads Advanced Mod Rewrite configuration for passed client using serialized
* file containing the settings.
*
* File is placed in /contenido/mod_rewrite/includes/and is named like
* File is placed in /contenido/cl-mod-rewrite/includes/and is named like
* config.mod_rewrite_{client_id}.php.
*
* @param int $clientId Id of client
@ -615,16 +614,22 @@ function mr_loadConfiguration($clientId, $forceReload = false) {
$cfg = array_merge($cfg, $mrConfig);
} else {
// couldn't load configuration, set defaults
include_once($cfg['path']['contenido'] . $cfg['path']['plugins'] . 'mod_rewrite/includes/config.mod_rewrite_default.php');
include_once($cfg['path']['contenido'] . $cfg['path']['plugins'] . 'cl-mod-rewrite/includes/config.mod_rewrite_default.php');
}
$aLoaded[$clientId] = true;
}
function mr_getConfigurationFilePath($clientId) {
$clientConfig = cRegistry::getClientConfig((int) $clientId);
$fePath = $clientConfig['path']['frontend'];
return $fePath . 'data/config/' . CON_ENVIRONMENT . '/config.mod_rewrite.php';
}
/**
* Returns the mod rewrite configuration array of an client.
*
* File is placed in /contenido/mod_rewrite/includes/and is named like
* File is placed in /contenido/cl-mod-rewrite/includes/and is named like
* config.mod_rewrite_{client_id}.php.
*
* @param int $clientId Id of client
@ -633,12 +638,31 @@ function mr_loadConfiguration($clientId, $forceReload = false) {
function mr_getConfiguration($clientId) {
global $cfg;
$file = $cfg['path']['contenido'] . $cfg['path']['plugins'] . 'mod_rewrite/includes/config.mod_rewrite_' . $clientId . '.php';
$clientId = (int) $clientId;
$file = mr_getConfigurationFilePath($clientId);
if (!is_file($file) || !is_readable($file)) {
$backendPath = cRegistry::getBackendPath();
$file = $cfg['path']['config'] . 'config.mod_rewrite_' . $clientId . '.php';
}
if (!is_file($file) || !is_readable($file)) {
$backendPath = cRegistry::getBackendPath();
$file = $backendPath . $cfg['path']['plugins'] . 'cl-mod-rewrite/includes/config.mod_rewrite_' . $clientId . '.php';
}
if (!is_file($file) || !is_readable($file)) {
return null;
}
if ($content = file_get_contents($file)) {
return unserialize($content);
$content = unserialize($content);
if (array_key_exists("mod_rewrite", $content)) {
$content['cl-mod-rewrite'] = $content['mod_rewrite'];
unset($content['mod_rewrite']);
}
return $content;
} else {
return null;
}
@ -647,7 +671,7 @@ function mr_getConfiguration($clientId) {
/**
* Saves the mod rewrite configuration array of an client.
*
* File is placed in /contenido/mod_rewrite/includes/and is named like
* File is placed in /contenido/cl-mod-rewrite/includes/and is named like
* config.mod_rewrite_{client_id}.php.
*
* @param int $clientId Id of client
@ -657,7 +681,7 @@ function mr_getConfiguration($clientId) {
function mr_setConfiguration($clientId, array $config) {
global $cfg;
$file = $cfg['path']['contenido'] . $cfg['path']['plugins'] . 'mod_rewrite/includes/config.mod_rewrite_' . $clientId . '.php';
$file = $cfg['path']['contenido'] . $cfg['path']['plugins'] . 'cl-mod-rewrite/includes/config.mod_rewrite_' . $clientId . '.php';
$result = file_put_contents($file, serialize($config));
return ($result) ? true : false;
}
@ -673,10 +697,10 @@ function mr_setConfiguration($clientId, array $config) {
function mr_runFrontendController() {
$iStartTime = getmicrotime();
plugin_include('mod_rewrite', 'includes/config.plugin.php');
plugin_include('cl-mod-rewrite', 'includes/config.plugin.php');
if (ModRewrite::isEnabled() == true) {
plugin_include('mod_rewrite', 'includes/front_content_controller.php');
plugin_include('cl-mod-rewrite', 'includes/front_content_controller.php');
$totalTime = sprintf('%.4f', (getmicrotime() - $iStartTime));
ModRewriteDebugger::add($totalTime, 'mr_runFrontendController() total time');
@ -891,8 +915,7 @@ function mr_header($header) {
*/
function mr_debugOutput($print = true) {
global $DB_Contenido_QueryCache;
if (isset($DB_Contenido_QueryCache) && is_array($DB_Contenido_QueryCache) &&
count($DB_Contenido_QueryCache) > 0) {
if (isset($DB_Contenido_QueryCache) && is_array($DB_Contenido_QueryCache) && count($DB_Contenido_QueryCache) > 0) {
ModRewriteDebugger::add($DB_Contenido_QueryCache, 'sql statements');
// calculate total time consumption of queries