2019-11-04 15:57:28 +00:00
< ? php
/**
* AMR Content controller class
*
* @ package plugin
* @ subpackage Mod Rewrite
* @ version SVN Revision $Rev : 128 $
* @ id $Id : class . modrewrite_content_controller . php 128 2019 - 07 - 03 11 : 58 : 28 Z oldperl $ :
* @ author Murat Purc < murat @ purc . de >
* @ copyright four for business AG < www . 4 fb . de >
* @ license http :// www . contenido . org / license / LIZENZ . txt
* @ link http :// www . 4 fb . de
* @ link http :// www . contenido . org
*/
if ( ! defined ( 'CON_FRAMEWORK' )) {
die ( 'Illegal call' );
}
/**
* Content controller for general settings .
*
* @ author Murat Purc < murat @ purc . de >
* @ package plugin
* @ subpackage Mod Rewrite
*/
class ModRewrite_ContentController extends ModRewrite_ControllerAbstract {
2023-07-19 16:55:39 +00:00
public $_oView ;
public $_client ;
/**
* @ var array < string , mixed >
*/
public $_cfg ;
2019-11-04 15:57:28 +00:00
/**
* Index action
*/
public function indexAction () {
// donut
$this -> _doChecks ();
}
/**
* Save settings action
*/
public function saveAction () {
$bDebug = $this -> getProperty ( 'bDebug' );
$aSeparator = $this -> getProperty ( 'aSeparator' );
$routingSeparator = $this -> getProperty ( 'routingSeparator' );
$bError = false ;
2023-07-19 16:55:39 +00:00
$aMR = [];
2019-11-04 15:57:28 +00:00
2023-07-19 16:55:39 +00:00
$request = ( $_POST !== []) ? $_POST : $_GET ;
2019-11-04 15:57:28 +00:00
mr_requestCleanup ( $request );
2019-12-28 16:11:03 +00:00
// use cl-mod-rewrite
2019-11-04 15:57:28 +00:00
if ( mr_arrayValue ( $request , 'use' ) == 1 ) {
$this -> _oView -> use_chk = ' checked="checked"' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'use' ] = 1 ;
2019-11-04 15:57:28 +00:00
} else {
$this -> _oView -> use_chk = '' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'use' ] = 0 ;
2019-11-04 15:57:28 +00:00
}
// root dir
if ( mr_arrayValue ( $request , 'rootdir' , '' ) !== '' ) {
2023-05-12 17:13:50 +00:00
if ( ! preg_match ( '/^[a-zA-Z0-9\-_\/.]*$/' , $request [ 'rootdir' ])) {
2019-12-28 16:11:03 +00:00
$sMsg = i18n ( " The root directory has a invalid format, alowed are the chars [a-zA-Z0-9 \ -_ \ / \ .] " , " cl-mod-rewrite " );
2019-11-04 15:57:28 +00:00
$this -> _oView -> rootdir_error = $this -> _notifyBox ( 'error' , $sMsg );
$bError = true ;
} elseif ( ! is_dir ( $_SERVER [ 'DOCUMENT_ROOT' ] . $request [ 'rootdir' ])) {
if ( mr_arrayValue ( $request , 'checkrootdir' ) == 1 ) {
// root dir check is enabled, this results in error
2022-03-11 17:33:58 +00:00
$sMsgTpl = i18n ( " The specified directory '%s' does not exists " , " cl-mod-rewrite " );
$sMsg = sprintf ( $sMsgTpl , $_SERVER [ 'DOCUMENT_ROOT' ] . $request [ 'rootdir' ]);
2019-11-04 15:57:28 +00:00
$this -> _oView -> rootdir_error = $this -> _notifyBox ( 'error' , $sMsg );
$bError = true ;
} else {
// root dir check ist disabled, take over the setting and
// output a warning.
2022-03-11 17:33:58 +00:00
$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' ]);
2019-11-04 15:57:28 +00:00
$this -> _oView -> rootdir_error = $this -> _notifyBox ( 'warning' , $sMsg );
}
}
2023-02-10 09:54:09 +00:00
$this -> _oView -> rootdir = clHtmlEntities ( $request [ 'rootdir' ]);
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'rootdir' ] = $request [ 'rootdir' ];
2019-11-04 15:57:28 +00:00
}
// root dir check
if ( mr_arrayValue ( $request , 'checkrootdir' ) == 1 ) {
$this -> _oView -> checkrootdir_chk = ' checked="checked"' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'checkrootdir' ] = 1 ;
2019-11-04 15:57:28 +00:00
} else {
$this -> _oView -> checkrootdir_chk = '' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'checkrootdir' ] = 0 ;
2019-11-04 15:57:28 +00:00
}
// start from root
if ( mr_arrayValue ( $request , 'startfromroot' ) == 1 ) {
$this -> _oView -> startfromroot_chk = ' checked="checked"' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'startfromroot' ] = 1 ;
2019-11-04 15:57:28 +00:00
} else {
$this -> _oView -> startfromroot_chk = '' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'startfromroot' ] = 0 ;
2019-11-04 15:57:28 +00:00
}
// prevent duplicated content
if ( mr_arrayValue ( $request , 'prevent_duplicated_content' ) == 1 ) {
$this -> _oView -> prevent_duplicated_content_chk = ' checked="checked"' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'prevent_duplicated_content' ] = 1 ;
2019-11-04 15:57:28 +00:00
} else {
$this -> _oView -> prevent_duplicated_content_chk = '' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'prevent_duplicated_content' ] = 0 ;
2019-11-04 15:57:28 +00:00
}
// language settings
if ( mr_arrayValue ( $request , 'use_language' ) == 1 ) {
$this -> _oView -> use_language_chk = ' checked="checked"' ;
$this -> _oView -> use_language_name_disabled = '' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'use_language' ] = 1 ;
2019-11-04 15:57:28 +00:00
if ( mr_arrayValue ( $request , 'use_language_name' ) == 1 ) {
$this -> _oView -> use_language_name_chk = ' checked="checked"' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'use_language_name' ] = 1 ;
2019-11-04 15:57:28 +00:00
} else {
$this -> _oView -> use_language_name_chk = '' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'use_language_name' ] = 0 ;
2019-11-04 15:57:28 +00:00
}
} else {
$this -> _oView -> use_language_chk = '' ;
$this -> _oView -> use_language_name_chk = '' ;
$this -> _oView -> use_language_name_disabled = ' disabled="disabled"' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'use_language' ] = 0 ;
$aMR [ 'cl-mod-rewrite' ][ 'use_language_name' ] = 0 ;
2019-11-04 15:57:28 +00:00
}
// client settings
if ( mr_arrayValue ( $request , 'use_client' ) == 1 ) {
$this -> _oView -> use_client_chk = ' checked="checked"' ;
$this -> _oView -> use_client_name_disabled = '' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'use_client' ] = 1 ;
2019-11-04 15:57:28 +00:00
if ( mr_arrayValue ( $request , 'use_client_name' ) == 1 ) {
$this -> _oView -> use_client_name_chk = ' checked="checked"' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'use_client_name' ] = 1 ;
2019-11-04 15:57:28 +00:00
} else {
$this -> _oView -> use_client_name_chk = '' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'use_client_name' ] = 0 ;
2019-11-04 15:57:28 +00:00
}
} else {
$this -> _oView -> use_client_chk = '' ;
$this -> _oView -> use_client_name_chk = '' ;
$this -> _oView -> use_client_name_disabled = ' disabled="disabled"' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'use_client' ] = 0 ;
$aMR [ 'cl-mod-rewrite' ][ 'use_client_name' ] = 0 ;
2019-11-04 15:57:28 +00:00
}
// use lowercase uri
if ( mr_arrayValue ( $request , 'use_lowercase_uri' ) == 1 ) {
$this -> _oView -> use_lowercase_uri_chk = ' checked="checked"' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'use_lowercase_uri' ] = 1 ;
2019-11-04 15:57:28 +00:00
} else {
$this -> _oView -> use_lowercase_uri_chk = '' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'use_lowercase_uri' ] = 0 ;
2019-11-04 15:57:28 +00:00
}
$this -> _oView -> category_separator_attrib = '' ;
$this -> _oView -> category_word_separator_attrib = '' ;
$this -> _oView -> article_separator_attrib = '' ;
$this -> _oView -> article_word_separator_attrib = '' ;
$separatorPattern = $aSeparator [ 'pattern' ];
$separatorInfo = $aSeparator [ 'info' ];
$wordSeparatorPattern = $aSeparator [ 'pattern' ];
$wordSeparatorInfo = $aSeparator [ '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' , '' );
// category seperator
if ( $categorySeperator == '' ) {
2019-12-28 16:11:03 +00:00
$sMsg = i18n ( " Please specify separator (%s) for category " , " cl-mod-rewrite " );
2019-11-04 15:57:28 +00:00
$sMsg = sprintf ( $sMsg , $separatorInfo );
$this -> _oView -> category_separator_error = $this -> _notifyBox ( 'error' , $sMsg );
$bError = true ;
} elseif ( ! preg_match ( $separatorPattern , $categorySeperator )) {
2019-12-28 16:11:03 +00:00
$sMsg = i18n ( " Invalid separator for category, allowed one of following characters: %s " , " cl-mod-rewrite " );
2019-11-04 15:57:28 +00:00
$sMsg = sprintf ( $sMsg , $separatorInfo );
$this -> _oView -> category_separator_error = $this -> _notifyBox ( 'error' , $sMsg );
$bError = true ;
// category word seperator
} elseif ( $categoryWordSeperator == '' ) {
2019-12-28 16:11:03 +00:00
$sMsg = i18n ( " Please specify separator (%s) for category words " , " cl-mod-rewrite " );
2019-11-04 15:57:28 +00:00
$sMsg = sprintf ( $sMsg , $wordSeparatorInfo );
$this -> _oView -> category_word_separator_error = $this -> _notifyBox ( 'error' , $sMsg );
$bError = true ;
} elseif ( ! preg_match ( $wordSeparatorPattern , $categoryWordSeperator )) {
2019-12-28 16:11:03 +00:00
$sMsg = i18n ( " Invalid separator for category words, allowed one of following characters: %s " , " cl-mod-rewrite " );
2019-11-04 15:57:28 +00:00
$sMsg = sprintf ( $sMsg , $wordSeparatorInfo );
$this -> _oView -> category_word_separator_error = $this -> _notifyBox ( 'error' , $sMsg );
$bError = true ;
// article seperator
} elseif ( $articleSeperator == '' ) {
2019-12-28 16:11:03 +00:00
$sMsg = i18n ( " Please specify separator (%s) for article " , " cl-mod-rewrite " );
2019-11-04 15:57:28 +00:00
$sMsg = sprintf ( $sMsg , $separatorInfo );
$this -> _oView -> article_separator_error = $this -> _notifyBox ( 'error' , $sMsg );
$bError = true ;
} elseif ( ! preg_match ( $separatorPattern , $articleSeperator )) {
2019-12-28 16:11:03 +00:00
$sMsg = i18n ( " Invalid separator for article, allowed is one of following characters: %s " , " cl-mod-rewrite " );
2019-11-04 15:57:28 +00:00
$sMsg = sprintf ( $sMsg , $separatorInfo );
$this -> _oView -> article_separator_error = $this -> _notifyBox ( 'error' , $sMsg );
$bError = true ;
// article word seperator
} elseif ( $articleWordSeperator == '' ) {
2019-12-28 16:11:03 +00:00
$sMsg = i18n ( " Please specify separator (%s) for article words " , " cl-mod-rewrite " );
2019-11-04 15:57:28 +00:00
$sMsg = sprintf ( $sMsg , $wordSeparatorInfo );
$this -> _oView -> article_word_separator_error = $this -> _notifyBox ( 'error' , $sMsg );
$bError = true ;
} elseif ( ! preg_match ( $wordSeparatorPattern , $articleWordSeperator )) {
2019-12-28 16:11:03 +00:00
$sMsg = i18n ( " Invalid separator for article words, allowed is one of following characters: %s " , " cl-mod-rewrite " );
2019-11-04 15:57:28 +00:00
$sMsg = sprintf ( $sMsg , $wordSeparatorInfo );
$this -> _oView -> article_word_separator_error = $this -> _notifyBox ( 'error' , $sMsg );
$bError = true ;
// category_seperator - category_word_seperator
} elseif ( $categorySeperator == $categoryWordSeperator ) {
2019-12-28 16:11:03 +00:00
$sMsg = i18n ( " Separator for category and category words must not be identical " , " cl-mod-rewrite " );
2019-11-04 15:57:28 +00:00
$this -> _oView -> category_separator_error = $this -> _notifyBox ( 'error' , $sMsg );
$bError = true ;
// category_seperator - article_word_seperator
} elseif ( $categorySeperator == $articleWordSeperator ) {
2019-12-28 16:11:03 +00:00
$sMsg = i18n ( " Separator for category and article words must not be identical " , " cl-mod-rewrite " );
2019-11-04 15:57:28 +00:00
$this -> _oView -> category_separator_error = $this -> _notifyBox ( 'error' , $sMsg );
$bError = true ;
// article_seperator - article_word_seperator
} elseif ( $articleSeperator == $articleWordSeperator ) {
2019-12-28 16:11:03 +00:00
$sMsg = i18n ( " Separator for category-article and article words must not be identical " , " cl-mod-rewrite " );
2019-11-04 15:57:28 +00:00
$this -> _oView -> article_separator_error = $this -> _notifyBox ( 'error' , $sMsg );
$bError = true ;
}
2023-05-12 17:12:20 +00:00
$this -> _oView -> category_separator = clHtmlentities ( $categorySeperator );
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'category_seperator' ] = $categorySeperator ;
2023-05-12 17:12:20 +00:00
$this -> _oView -> category_word_separator = clHtmlentities ( $categoryWordSeperator );
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'category_word_seperator' ] = $categoryWordSeperator ;
2023-05-12 17:12:20 +00:00
$this -> _oView -> article_separator = clHtmlentities ( $articleSeperator );
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'article_seperator' ] = $articleSeperator ;
2023-05-12 17:12:20 +00:00
$this -> _oView -> article_word_separator = clHtmlentities ( $articleWordSeperator );
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'article_word_seperator' ] = $articleWordSeperator ;
2019-11-04 15:57:28 +00:00
// file extension
if ( mr_arrayValue ( $request , 'file_extension' , '' ) !== '' ) {
if ( ! preg_match ( '/^\.([a-zA-Z0-9\-_\/])*$/' , $request [ 'file_extension' ])) {
2019-12-28 16:11:03 +00:00
$sMsg = i18n ( " The file extension has a invalid format, allowed are the chars \ .([a-zA-Z0-9 \ -_ \ /]) " , " cl-mod-rewrite " );
2019-11-04 15:57:28 +00:00
$this -> _oView -> file_extension_error = $this -> _notifyBox ( 'error' , $sMsg );
$bError = true ;
}
2023-05-12 17:12:20 +00:00
$this -> _oView -> file_extension = clHtmlentities ( $request [ 'file_extension' ]);
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'file_extension' ] = $request [ 'file_extension' ];
2019-11-04 15:57:28 +00:00
} else {
$this -> _oView -> file_extension = '.html' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'file_extension' ] = '.html' ;
2019-11-04 15:57:28 +00:00
}
// category resolve min percentage
if ( isset ( $request [ 'category_resolve_min_percentage' ])) {
if ( ! is_numeric ( $request [ 'category_resolve_min_percentage' ])) {
2019-12-28 16:11:03 +00:00
$sMsg = i18n ( " Value has to be numeric. " , " cl-mod-rewrite " );
2019-11-04 15:57:28 +00:00
$this -> _oView -> category_resolve_min_percentage_error = $this -> _notifyBox ( 'error' , $sMsg );
$bError = true ;
} elseif ( $request [ 'category_resolve_min_percentage' ] < 0 || $request [ 'category_resolve_min_percentage' ] > 100 ) {
2019-12-28 16:11:03 +00:00
$sMsg = i18n ( " Value has to be between 0 an 100. " , " cl-mod-rewrite " );
2019-11-04 15:57:28 +00:00
$this -> _oView -> category_resolve_min_percentage_error = $this -> _notifyBox ( 'error' , $sMsg );
$bError = true ;
}
$this -> _oView -> category_resolve_min_percentage = $request [ 'category_resolve_min_percentage' ];
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'category_resolve_min_percentage' ] = $request [ 'category_resolve_min_percentage' ];
2019-11-04 15:57:28 +00:00
} else {
$this -> _oView -> category_resolve_min_percentage = '75' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'category_resolve_min_percentage' ] = '75' ;
2019-11-04 15:57:28 +00:00
}
// add start article name to url
if ( mr_arrayValue ( $request , 'add_startart_name_to_url' ) == 1 ) {
$this -> _oView -> add_startart_name_to_url_chk = ' checked="checked"' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'add_startart_name_to_url' ] = 1 ;
2019-11-04 15:57:28 +00:00
if ( mr_arrayValue ( $request , 'add_startart_name_to_url' , '' ) !== '' ) {
2023-05-12 17:13:50 +00:00
if ( ! preg_match ( '/^[a-zA-Z0-9\-_\/.]*$/' , $request [ 'default_startart_name' ])) {
2019-12-28 16:11:03 +00:00
$sMsg = i18n ( " The article name has a invalid format, allowed are the chars /^[a-zA-Z0-9 \ -_ \ / \ .]* $ / " , " cl-mod-rewrite " );
2019-11-04 15:57:28 +00:00
$this -> _oView -> add_startart_name_to_url_error = $this -> _notifyBox ( 'error' , $sMsg );
$bError = true ;
}
2023-05-12 17:12:20 +00:00
$this -> _oView -> default_startart_name = clHtmlentities ( $request [ 'default_startart_name' ]);
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'default_startart_name' ] = $request [ 'default_startart_name' ];
2019-11-04 15:57:28 +00:00
} else {
$this -> _oView -> default_startart_name = '' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'default_startart_name' ] = '' ;
2019-11-04 15:57:28 +00:00
}
} else {
$this -> _oView -> add_startart_name_to_url_chk = '' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'add_startart_name_to_url' ] = 0 ;
2019-11-04 15:57:28 +00:00
$this -> _oView -> default_startart_name = '' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'default_startart_name' ] = '' ;
2019-11-04 15:57:28 +00:00
}
// rewrite urls at
if ( mr_arrayValue ( $request , 'rewrite_urls_at' ) == 'congeneratecode' ) {
$this -> _oView -> rewrite_urls_at_congeneratecode_chk = ' checked="checked"' ;
$this -> _oView -> rewrite_urls_at_front_content_output_chk = '' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'rewrite_urls_at_congeneratecode' ] = 1 ;
$aMR [ 'cl-mod-rewrite' ][ 'rewrite_urls_at_front_content_output' ] = 0 ;
2019-11-04 15:57:28 +00:00
} else {
$this -> _oView -> rewrite_urls_at_congeneratecode_chk = '' ;
$this -> _oView -> rewrite_urls_at_front_content_output_chk = ' checked="checked"' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'rewrite_urls_at_congeneratecode' ] = 0 ;
$aMR [ 'cl-mod-rewrite' ][ 'rewrite_urls_at_front_content_output' ] = 1 ;
2019-11-04 15:57:28 +00:00
}
// routing
if ( isset ( $request [ 'rewrite_routing' ])) {
2023-07-19 16:55:39 +00:00
$aRouting = [];
2019-11-04 15:57:28 +00:00
$items = explode ( " \n " , $request [ 'rewrite_routing' ]);
2023-07-19 16:55:39 +00:00
foreach ( $items as $item ) {
$routingDef = explode ( $routingSeparator , $item );
2019-11-04 15:57:28 +00:00
if ( count ( $routingDef ) !== 2 ) {
continue ;
}
$routingDef [ 0 ] = trim ( $routingDef [ 0 ]);
$routingDef [ 1 ] = trim ( $routingDef [ 1 ]);
if ( $routingDef [ 0 ] == '' ) {
continue ;
}
$aRouting [ $routingDef [ 0 ]] = $routingDef [ 1 ];
}
2023-05-12 17:12:20 +00:00
$this -> _oView -> rewrite_routing = clHtmlentities ( $request [ 'rewrite_routing' ]);
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'routing' ] = $aRouting ;
2019-11-04 15:57:28 +00:00
} else {
$this -> _oView -> rewrite_routing = '' ;
2023-07-19 16:55:39 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'routing' ] = [];
2019-11-04 15:57:28 +00:00
}
// redirect invalid article to errorsite
if ( isset ( $request [ 'redirect_invalid_article_to_errorsite' ])) {
$this -> _oView -> redirect_invalid_article_to_errorsite_chk = ' checked="checked"' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'redirect_invalid_article_to_errorsite' ] = 1 ;
2019-11-04 15:57:28 +00:00
} else {
$this -> _oView -> redirect_invalid_article_to_errorsite_chk = '' ;
2019-12-28 16:11:03 +00:00
$aMR [ 'cl-mod-rewrite' ][ 'redirect_invalid_article_to_errorsite' ] = 0 ;
2019-11-04 15:57:28 +00:00
}
if ( $bError ) {
2019-12-28 16:11:03 +00:00
$sMsg = i18n ( " Please check your input " , " cl-mod-rewrite " );
2019-11-04 15:57:28 +00:00
$this -> _oView -> content_before .= $this -> _notifyBox ( 'error' , $sMsg );
return ;
}
if ( $bDebug == true ) {
echo $this -> _notifyBox ( 'info' , 'Debug' );
echo '<pre class="example">' ;
2019-12-28 16:11:03 +00:00
print_r ( $aMR [ 'cl-mod-rewrite' ]);
2019-11-04 15:57:28 +00:00
echo '</pre>' ;
2019-12-28 16:11:03 +00:00
$sMsg = i18n ( " Configuration has <b>not</b> been saved, because of enabled debugging " , " cl-mod-rewrite " );
2019-11-04 15:57:28 +00:00
echo $this -> _notifyBox ( 'info' , $sMsg );
return ;
}
2019-12-28 16:11:03 +00:00
$bSeparatorModified = $this -> _separatorModified ( $aMR [ 'cl-mod-rewrite' ]);
2019-11-04 15:57:28 +00:00
if ( mr_setConfiguration ( $this -> _client , $aMR )) {
2019-12-28 16:11:03 +00:00
$sMsg = i18n ( " Configuration has been saved " , " cl-mod-rewrite " );
2019-11-04 15:57:28 +00:00
if ( $bSeparatorModified ) {
mr_loadConfiguration ( $this -> _client , true );
}
$this -> _oView -> content_before .= $this -> _notifyBox ( 'info' , $sMsg );
} else {
2019-12-28 16:11:03 +00:00
$sMsg = i18n ( " Configuration could not saved. Please check write permissions for %s " , " cl-mod-rewrite " );
2022-03-11 17:33:58 +00:00
$sMsg = sprintf ( $sMsg , mr_getConfigurationFilePath ( $this -> _client ));
2019-11-04 15:57:28 +00:00
$this -> _oView -> content_before .= $this -> _notifyBox ( 'error' , $sMsg );
}
}
/**
* Checks , if any sseparators setting is modified or not
* @ param array $aNewCfg New configuration send by requests .
*/
2023-07-19 16:55:39 +00:00
protected function _separatorModified ( $aNewCfg ) : bool {
2019-11-04 15:57:28 +00:00
$aCfg = ModRewrite :: getConfig ();
if ( $aCfg [ 'category_seperator' ] != $aNewCfg [ 'category_seperator' ]) {
return true ;
} elseif ( $aCfg [ 'category_word_seperator' ] != $aNewCfg [ 'category_word_seperator' ]) {
return true ;
} elseif ( $aCfg [ 'article_seperator' ] != $aNewCfg [ 'article_seperator' ]) {
return true ;
} elseif ( $aCfg [ 'article_word_seperator' ] != $aNewCfg [ 'article_word_seperator' ]) {
return true ;
}
return false ;
}
/**
* Does some checks like 'is_start_compatible' check .
* Adds notifications , if something will went wrong ...
2023-07-19 16:55:39 +00:00
*
* @ todo review text and translations
2019-11-04 15:57:28 +00:00
*/
protected function _doChecks () {
if ( ! empty ( $this -> _cfg [ 'is_start_compatible' ]) && true === $this -> _cfg [ 'is_start_compatible' ]) {
2019-12-28 16:11:03 +00:00
$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 " );
2019-11-04 15:57:28 +00:00
$this -> _oView -> content_before .= $this -> _notifyBox ( 'warning' , $sMsg );
}
// Check for empty urlpath entries in cat_lang table
2023-07-19 16:55:39 +00:00
$dbConLite = new DB_ConLite ();
2019-11-04 15:57:28 +00:00
$sql = " SELECT idcatlang FROM " . $this -> _cfg [ 'tab' ][ 'cat_lang' ] . " WHERE urlpath = '' " ;
2023-07-19 16:55:39 +00:00
if ( $dbConLite -> query ( $sql ) && $dbConLite -> next_record ()) {
2019-12-28 16:11:03 +00:00
$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 " );
2019-11-04 15:57:28 +00:00
$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 );
}
}
}