Source for file include.mod_rewrite_content.php
Documentation is available at include.mod_rewrite_content.php
* Plugin mod_rewrite backend include file to administer settings (in content frame)
* @copyright © Murat Purc 2008
defined('CON_FRAMEWORK') or die('Illegal call');
$action =
(isset
($_REQUEST['mr_action'])) ?
$_REQUEST['mr_action'] :
'index';
//var_dump($cfg['templates']['mod_rewrite_content']);
####################################################################################################
// downwards compatibility to previous plugin versions
$aMrCfg['category_seperator'] =
'/';
if (mr_arrayValue($aMrCfg, 'category_word_seperator', '') ==
'') {
$aMrCfg['category_word_seperator'] =
'-';
$aMrCfg['article_seperator'] =
'/';
if (mr_arrayValue($aMrCfg, 'article_word_seperator', '') ==
'') {
$aMrCfg['article_word_seperator'] =
'-';
'pattern' =>
'/^[\/\-_\.\$~]{1}$/',
'info' =>
'<span style="font-family:courier;font-weight:bold;">/ - . _ ~</span>'
'pattern' =>
'/^[\-_\.\$~]{1}$/',
'info' =>
'<span style="font-family:courier;font-weight:bold;">- . _ ~</span>'
$routingSeparator =
'>>>';
// define basic data contents (used for template)
$aData['CONTENT.BEFORE'] =
'';
$aData['SESSID'] =
$sess->id;
$aData['ACTION'] =
$action;
$aData['IDCLIENT'] =
$client;
$aData['USE_CHK'] =
(ModRewrite::isEnabled()) ?
' checked="checked"' :
'';
$aData['BGCOLOR_ENABLED'] =
$aBgColor['enabled'];
$aData['BGCOLOR_DISABLED'] =
$aBgColor['disabled'];
$aData['ROOTDIR'] =
$aMrCfg['rootdir'];
$aData['ROOTDIR_ERROR'] =
'';
$aData['CHECKROOTDIR_CHK'] =
($aMrCfg['checkrootdir'] ==
1) ?
' checked="checked"' :
'';
$aData['STARTFROMROOT_CHK'] =
($aMrCfg['startfromroot'] ==
1) ?
' checked="checked"' :
'';
// mr prevent duplicated content
$aData['PREVENT_DUPLICATED_CONTENT_CHK'] =
($aMrCfg['prevent_duplicated_content'] ==
1) ?
' checked="checked"' :
'';
$aData['USE_LANGUAGE_CHK'] =
($aMrCfg['use_language'] ==
1) ?
' checked="checked"' :
'';
$aData['USE_LANGUAGE_NAME_CHK'] =
($aMrCfg['use_language_name'] ==
1) ?
' checked="checked"' :
'';
$aData['USE_LANGUAGE_NAME_DISABLED'] =
($aMrCfg['use_language'] ==
1) ?
'' :
' disabled="disabled"';
$aData['USE_CLIENT_CHK'] =
($aMrCfg['use_client'] ==
1) ?
' checked="checked"' :
'';
$aData['USE_CLIENT_NAME_CHK'] =
($aMrCfg['use_client_name'] ==
1) ?
' checked="checked"' :
'';
$aData['USE_CLIENT_NAME_DISABLED'] =
($aMrCfg['use_client'] ==
1) ?
'' :
' disabled="disabled"';
$aData['USE_LOWERCASE_URI_CHK'] =
($aMrCfg['use_lowercase_uri'] ==
1) ?
' checked="checked"' :
'';
// mr category/category word separator
$aData['CATEGORY_SEPARATOR'] =
$aMrCfg['category_seperator'];
$aData['CATEGORY_SEPARATOR_ATTRIB'] =
'';
$aData['CATEGORY_WORD_SEPARATOR'] =
$aMrCfg['category_word_seperator'];
$aData['CATEGORY_WORD_SEPARATOR_ATTRIB'] =
'';
$aData['CATEGORY_SEPARATOR_ERROR'] =
'';
$aData['CATEGORY_WORD_SEPARATOR_ERROR'] =
'';
// mr article/article word separator
$aData['ARTICLE_SEPARATOR'] =
$aMrCfg['article_seperator'];
$aData['ARTICLE_SEPARATOR_ATTRIB'] =
'';
$aData['ARTICLE_WORD_SEPARATOR'] =
$aMrCfg['article_word_seperator'];
$aData['ARTICLE_WORD_SEPARATOR_ATTRIB'] =
'';
$aData['ARTICLE_SEPARATOR_ERROR'] =
'';
$aData['ARTICLE_WORD_SEPARATOR_ERROR'] =
'';
$aData['CAT_ART_SEP_MSG'] =
'(Mögliche Werte: ' .
$aSeparator['info'] .
')';
$aData['WORD_SEPARATOR_MSG'] =
'(Mögliche Werte: ' .
$aWordSeparator['info'] .
')';
$aData['FILE_EXTENSION'] =
$aMrCfg['file_extension'];
$aData['FILE_EXTENSION_ERROR'] =
'';
// mr category name resolve percentage
$aData['CATEGORY_RESOLVE_MIN_PERCENTAGE'] =
$aMrCfg['category_resolve_min_percentage'];
$aData['CATEGORY_RESOLVE_MIN_PERCENTAGE_ERROR'] =
'';
// mr add start article name to url
$aData['ADD_STARTART_NAME_TO_URL_CHK'] =
($aMrCfg['add_startart_name_to_url'] ==
1) ?
' checked="checked"' :
'';
$aData['ADD_STARTART_NAME_TO_URL_ERROR'] =
'';
$aData['DEFAULT_STARTART_NAME'] =
$aMrCfg['default_startart_name'];
$aData['REWRITE_URLS_AT_CONGENERATECODE_CHK'] =
($aMrCfg['rewrite_urls_at_congeneratecode'] ==
1) ?
' checked="checked"' :
'';
$aData['REWRITE_URLS_AT_FRONT_CONTENT_OUTPUT_CHK'] =
($aMrCfg['rewrite_urls_at_front_content_output'] ==
1) ?
' checked="checked"' :
'';
$aData['CONTENT.AFTER'] =
'';
foreach ($aMrCfg['routing'] as $uri =>
$route){
$data .=
$uri .
$routingSeparator .
$route .
"\n";
$aData['REWRITE_ROUTING'] =
$data;
// mr redirect invalid article
$aData['REDIRECT_INVALID_ARTICLE_TO_ERRORSITE_CHK'] =
($aMrCfg['redirect_invalid_article_to_errorsite'] ==
1) ?
' checked="checked"' :
'';
####################################################################################################
if ($action ==
'index') {
} elseif ($action ==
'save') {
} elseif ($action ==
'reset') {
// Loop data array, fill'n output template
foreach ($aData as $p =>
$v) {
$oGlob->get('cfg/path/contenido') .
$oGlob->get('cfg/path/plugins') .
'mod_rewrite/templates/content.html', 0, 0
####################################################################################################
$cfg =
$oGlob->get('cfg');
$aData =
$oGlob->get('aData');
$request =
(count($_POST) >
0) ?
$_POST :
$_GET;
$aData['USE_CHK'] =
' checked="checked"';
$aMR['mod_rewrite']['use'] =
1;
$aMR['mod_rewrite']['use'] =
0;
if (!preg_match('/^[a-zA-Z0-9\-_\/\.]*$/', $request['rootdir'])) {
$aData['ROOTDIR_ERROR'] =
_notifyBox('error', 'Das Rootverzeichnis hat ein ungültiges Format, erlaubt sind die Zeichen [a-zA-Z0-9\-_\/\.]');
} elseif (!is_dir($_SERVER['DOCUMENT_ROOT'] .
$request['rootdir'])) {
// root dir check is enabled, this results in error
$aData['ROOTDIR_ERROR'] =
_notifyBox('error', 'Das angegebene Verzeichnis "' .
$_SERVER['DOCUMENT_ROOT'] .
$request['rootdir'] .
'" existiert nicht');
// root dir check ist disabled, take over the setting and output a warning.
$aData['ROOTDIR_ERROR'] =
_notifyBox('warning', 'Das angegebene Verzeichnis "' .
$request['rootdir'] .
'" existiert nicht im aktuellen DOCUMENT_ROOT "' .
$_SERVER['DOCUMENT_ROOT'] .
'". Das kann vorkommen, wenn das DOCUMENT_ROOT des Clients vom Contenido Backend DOCUMENT_ROOT abweicht. Die Einstellung wird dennoch übernommen, da die Überprüfung abgeschaltet wurde');
$aMR['mod_rewrite']['rootdir'] =
$request['rootdir'];
$aData['CHECKROOTDIR_CHK'] =
' checked="checked"';
$aMR['mod_rewrite']['checkrootdir'] =
1;
$aData['CHECKROOTDIR_CHK'] =
'';
$aMR['mod_rewrite']['checkrootdir'] =
0;
$aData['STARTFROMROOT_CHK'] =
' checked="checked"';
$aMR['mod_rewrite']['startfromroot'] =
1;
$aData['STARTFROMROOT_CHK'] =
'';
$aMR['mod_rewrite']['startfromroot'] =
0;
// prevent duplicated content
if (mr_arrayValue($request, 'prevent_duplicated_content') ==
1) {
$aData['PREVENT_DUPLICATED_CONTENT_CHK'] =
' checked="checked"';
$aMR['mod_rewrite']['prevent_duplicated_content'] =
1;
$aData['PREVENT_DUPLICATED_CONTENT_CHK'] =
'';
$aMR['mod_rewrite']['prevent_duplicated_content'] =
0;
$aData['USE_LANGUAGE_CHK'] =
' checked="checked"';
$aData['USE_LANGUAGE_NAME_DISABLED'] =
'';
$aMR['mod_rewrite']['use_language'] =
1;
$aData['USE_LANGUAGE_NAME_CHK'] =
' checked="checked"';
$aMR['mod_rewrite']['use_language_name'] =
1;
$aData['USE_LANGUAGE_NAME_CHK'] =
'';
$aMR['mod_rewrite']['use_language_name'] =
0;
$aData['USE_LANGUAGE_CHK'] =
'';
$aData['USE_LANGUAGE_NAME_DISABLED'] =
' disabled="disabled"';
$aMR['mod_rewrite']['use_language'] =
0;
$aData['USE_LANGUAGE_NAME_CHK'] =
'';
$aMR['mod_rewrite']['use_language_name'] =
0;
$aData['USE_CLIENT_CHK'] =
' checked="checked"';
$aData['USE_CLIENT_NAME_DISABLED'] =
'';
$aMR['mod_rewrite']['use_client'] =
1;
$aData['USE_CLIENT_NAME_CHK'] =
' checked="checked"';
$aMR['mod_rewrite']['use_client_name'] =
1;
$aData['USE_CLIENT_NAME_CHK'] =
'';
$aMR['mod_rewrite']['use_client_name'] =
0;
$aData['USE_CLIENT_CHK'] =
'';
$aData['USE_CLIENT_NAME_DISABLED'] =
' disabled="disabled"';
$aMR['mod_rewrite']['use_client'] =
0;
$aData['USE_CLIENT_NAME_CHK'] =
'';
$aMR['mod_rewrite']['use_client_name'] =
0;
$aData['USE_LOWERCASE_URI_CHK'] =
' checked="checked"';
$aMR['mod_rewrite']['use_lowercase_uri'] =
1;
$aData['USE_LOWERCASE_URI_CHK'] =
'';
$aMR['mod_rewrite']['use_lowercase_uri'] =
0;
$aData['CATEGORY_SEPARATOR_ATTRIB'] =
'';
$aData['CATEGORY_WORD_SEPARATOR_ATTRIB'] =
'';
$aData['ARTICLE_SEPARATOR_ATTRIB'] =
'';
$aData['ARTICLE_WORD_SEPARATOR_ATTRIB'] =
'';
$separatorPattern =
$oGlob->get('aSeparator/pattern');
$separatorInfo =
$oGlob->get('aSeparator/info');
$wordSeparatorPattern =
$oGlob->get('aWordSeparator/pattern');
$wordSeparatorInfo =
$oGlob->get('aWordSeparator/info');
$categorySeperator =
mr_arrayValue($request, 'category_seperator', '');
$categoryWordSeperator =
mr_arrayValue($request, 'category_word_seperator', '');
$articleSeperator =
mr_arrayValue($request, 'article_seperator', '');
$articleWordSeperator =
mr_arrayValue($request, 'article_word_seperator', '');
if ($categorySeperator ==
'') {
$aData['CATEGORY_SEPARATOR_ERROR'] =
_notifyBox('error', 'Bitte Trenner (' .
$separatorInfo .
') für Kategorie angeben');
} elseif (!preg_match($separatorPattern, $categorySeperator)) {
$aData['CATEGORY_SEPARATOR_ERROR'] =
_notifyBox('error', 'Trenner für Kategorie ist ungültig, erlaubt ist eines der Zeichen: ' .
$separatorInfo);
// category word seperator
} elseif ($categoryWordSeperator ==
'') {
$aData['CATEGORY_WORD_SEPARATOR_ERROR'] =
_notifyBox('error', 'Bitte Trenner (' .
$wordSeparatorInfo .
') für Kategoriewörter angeben');
} elseif (!preg_match($wordSeparatorPattern, $categoryWordSeperator)) {
$aData['CATEGORY_WORD_SEPARATOR_ERROR'] =
_notifyBox('error', 'Trenner für Kategoriewörter ist ungültig, erlaubt ist eines der Zeichen: ' .
$wordSeparatorInfo);
} elseif ($articleSeperator ==
'') {
$aData['ARTICLE_SEPARATOR_ERROR'] =
_notifyBox('error', 'Bitte Trenner (' .
$separatorInfo .
') für Artikel angeben') .
'<br>';
} elseif (!preg_match($separatorPattern, $articleSeperator)) {
$aData['ARTICLE_SEPARATOR_ERROR'] =
_notifyBox('error', 'Trenner für Artikel ist ungültig, erlaubt ist eines der Zeichen: ' .
$separatorInfo);
// article word seperator
} elseif ($articleWordSeperator ==
'') {
$aData['ARTICLE_WORD_SEPARATOR_ERROR'] =
_notifyBox('error', 'Bitte Trenner (' .
$wordSeparatorInfo .
') für Artikelwörter angeben');
} elseif (!preg_match($wordSeparatorPattern, $articleWordSeperator)) {
$aData['ARTICLE_WORD_SEPARATOR_ERROR'] =
_notifyBox('error', 'Trenner für Artikelwörter ist ungültig, erlaubt ist eines der Zeichen: ' .
$wordSeparatorInfo);
// category_seperator - category_word_seperator
} elseif ($categorySeperator ==
$categoryWordSeperator) {
$aData['CATEGORY_SEPARATOR_ERROR'] =
_notifyBox('error', 'Trenner für Kategorie und Kategoriewörter dürfen nicht identisch sein');
// category_seperator - article_word_seperator
} elseif ($categorySeperator ==
$articleWordSeperator) {
$aData['CATEGORY_SEPARATOR_ERROR'] =
_notifyBox('error', 'Trenner für Kategorie und Artikelwörter dürfen nicht identisch sein');
// article_seperator - article_word_seperator
} elseif ($articleSeperator ==
$articleWordSeperator) {
$aData['ARTICLE_SEPARATOR_ERROR'] =
_notifyBox('error', 'Trenner für Kategorie-Artikel und Artikelwörter dürfen nicht identisch sein');
$aData['CATEGORY_SEPARATOR'] =
htmlentities($categorySeperator);
$aMR['mod_rewrite']['category_seperator'] =
$categorySeperator;
$aData['CATEGORY_WORD_SEPARATOR'] =
htmlentities($categoryWordSeperator);
$aMR['mod_rewrite']['category_word_seperator'] =
$categoryWordSeperator;
$aData['ARTICLE_SEPARATOR'] =
htmlentities($articleSeperator);
$aMR['mod_rewrite']['article_seperator'] =
$articleSeperator;
$aData['ARTICLE_WORD_SEPARATOR'] =
htmlentities($articleWordSeperator);
$aMR['mod_rewrite']['article_word_seperator'] =
$articleWordSeperator;
if (!preg_match('/^\.([a-zA-Z0-9\-_\/])*$/', $request['file_extension'])) {
$aData['FILE_EXTENSION_ERROR'] =
_notifyBox('error', 'Die Dateiendung hat ein ungültiges Format, erlaubt sind die Zeichen \.([a-zA-Z0-9\-_\/])');
$aData['FILE_EXTENSION'] =
htmlentities($request['file_extension']);
$aMR['mod_rewrite']['file_extension'] =
$request['file_extension'];
$aData['FILE_EXTENSION'] =
'.html';
$aMR['mod_rewrite']['file_extension'] =
'.html';
// category resolve min percentage
if (isset
($request['category_resolve_min_percentage'])) {
if (!is_numeric($request['category_resolve_min_percentage'])) {
$aData['CATEGORY_RESOLVE_MIN_PERCENTAGE_ERROR'] =
_notifyBox('error', 'Wert muss numerisch sein.');
} elseif ($request['category_resolve_min_percentage'] <
0 ||
$request['category_resolve_min_percentage'] >
100) {
$aData['CATEGORY_RESOLVE_MIN_PERCENTAGE_ERROR'] =
_notifyBox('error', 'Wert muss zwischen 0 und 100 sein.');
$aData['CATEGORY_RESOLVE_MIN_PERCENTAGE'] =
$request['category_resolve_min_percentage'];
$aMR['mod_rewrite']['category_resolve_min_percentage'] =
$request['category_resolve_min_percentage'];
$aData['CATEGORY_RESOLVE_MIN_PERCENTAGE'] =
'75';
$aMR['mod_rewrite']['category_resolve_min_percentage'] =
'75';
// add start article name to url
$aData['ADD_STARTART_NAME_TO_URL_CHK'] =
' checked="checked"';
$aMR['mod_rewrite']['add_startart_name_to_url'] =
1;
if (mr_arrayValue($request, 'add_startart_name_to_url', '') !==
'') {
if (!preg_match('/^[a-zA-Z0-9\-_\/\.]*$/', $request['default_startart_name'])) {
$aData['ADD_STARTART_NAME_TO_URL_ERROR'] =
_notifyBox('error', 'Der Artikelname hat ein ungültiges Format, erlaubt sind die Zeichen /^[a-zA-Z0-9\-_\/\.]*$/');
$aData['DEFAULT_STARTART_NAME'] =
htmlentities($request['default_startart_name']);
$aMR['mod_rewrite']['default_startart_name'] =
$request['default_startart_name'];
$aData['DEFAULT_STARTART_NAME'] =
'';
$aMR['mod_rewrite']['default_startart_name'] =
'';
$aData['ADD_STARTART_NAME_TO_URL_CHK'] =
'';
$aMR['mod_rewrite']['add_startart_name_to_url'] =
0;
$aData['DEFAULT_STARTART_NAME'] =
'';
$aMR['mod_rewrite']['default_startart_name'] =
'';
if (mr_arrayValue($request, 'rewrite_urls_at') ==
'congeneratecode') {
$aData['REWRITE_URLS_AT_CONGENERATECODE_CHK'] =
' checked="checked"';
$aData['REWRITE_URLS_AT_FRONT_CONTENT_OUTPUT_CHK'] =
'';
$aMR['mod_rewrite']['rewrite_urls_at_congeneratecode'] =
1;
$aMR['mod_rewrite']['rewrite_urls_at_front_content_output'] =
0;
$aData['REWRITE_URLS_AT_CONGENERATECODE_CHK'] =
'';
$aData['REWRITE_URLS_AT_FRONT_CONTENT_OUTPUT_CHK'] =
' checked="checked"';
$aMR['mod_rewrite']['rewrite_urls_at_congeneratecode'] =
0;
$aMR['mod_rewrite']['rewrite_urls_at_front_content_output'] =
1;
if (isset
($request['rewrite_routing'])) {
$items =
explode("\n", $request['rewrite_routing']);
foreach ($items as $p =>
$v) {
$routingDef =
explode($oGlob->get('routingSeparator'), $v);
if (count($routingDef) !==
2) {
$routingDef[0] =
trim($routingDef[0]);
$routingDef[1] =
trim($routingDef[1]);
if ($routingDef[0] ==
'') {
$aRouting[$routingDef[0]] =
$routingDef[1];
$aData['REWRITE_ROUTING'] =
htmlentities($request['rewrite_routing']);
$aMR['mod_rewrite']['routing'] =
$aRouting;
$aData['REWRITE_ROUTING'] =
'';
$aMR['mod_rewrite']['routing'] =
array();
// redirect invalid article to errorsite
if (isset
($request['redirect_invalid_article_to_errorsite'])) {
$aData['REDIRECT_INVALID_ARTICLE_TO_ERRORSITE_CHK'] =
' checked="checked"';
$aMR['mod_rewrite']['redirect_invalid_article_to_errorsite'] =
1;
$aData['REDIRECT_INVALID_ARTICLE_TO_ERRORSITE_CHK'] =
'';
$aMR['mod_rewrite']['redirect_invalid_article_to_errorsite'] =
0;
$aData['CONTENT.BEFORE'] =
_notifyBox('error', 'Bitte überprüfen Sie ihre Eingaben');
$oGlob->set('aData', $aData);
if ($oGlob->get('debug') ==
true) {
echo
'<pre class="example">';print_r($aMR['mod_rewrite']);echo
'</pre>';
echo
_notifyBox('info', 'Konfiguration wurde <b>nicht</b> gespeichert, weil debugging aktiv ist');
$options['key'] =
$cfg['path']['contenido'] .
$cfg['path']['plugins'] .
'mod_rewrite/includes/config.mod_rewrite_' .
$oGlob->get('client') .
'.php';
if ($config->set($aMR)) {
$sMsg =
'Konfiguration wurde gespeichert';
if ($bSeparatorModified) {
$aData['CONTENT.BEFORE'] =
_notifyBox('info', $sMsg);
$aData['CONTENT.BEFORE'] =
_notifyBox('error', 'Konfiguration konnte nicht gespeichert werden. Überprüfen Sie bitte die Schreibrechte für ' .
$options['key']);
$oGlob->set('aData', $aData);
$oGlob->set('aData/CONTENT.BEFORE', _notifyBox('info', 'Aliase wurden zurückgesetzt'));
if ($aCfg['category_seperator'] !=
$aNewCfg['category_seperator']) {
} elseif ($aCfg['category_word_seperator'] !=
$aNewCfg['category_word_seperator']) {
} elseif ($aCfg['article_seperator'] !=
$aNewCfg['article_seperator']) {
} elseif ($aCfg['article_word_seperator'] !=
$aNewCfg['article_word_seperator']) {
return $oNotification->returnNotification($type, $msg) .
'<br>';
Documentation generated on Sun, 08 Feb 2009 22:01:02 +0100 by phpDocumentor 1.4.1