Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationMain
    • NavigationTop
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cUriBuilderMR
  • ModRewrite
  • ModRewrite_ContentController
  • ModRewrite_ContentExpertController
  • ModRewrite_ContentTestController
  • ModRewrite_ControllerAbstract
  • ModRewriteBase
  • ModRewriteController
  • ModRewriteDebugger
  • ModRewriteTest
  • ModRewriteUrlStack
  • ModRewriteUrlUtil

Functions

  • mr_arrayValue
  • mr_buildGeneratedCode
  • mr_buildNewUrl
  • mr_conCopyArtLang
  • mr_conMoveArticles
  • mr_conSaveArticle
  • mr_conSyncArticle
  • mr_debugOutput
  • mr_getConfiguration
  • mr_getRequest
  • mr_header
  • mr_i18n
  • mr_loadConfiguration
  • mr_queryAndNextRecord
  • mr_removeMultipleChars
  • mr_requestCleanup
  • mr_runFrontendController
  • mr_setClientLanguageId
  • mr_setConfiguration
  • mr_strCopyCategory
  • mr_strMovedownCategory
  • mr_strMoveSubtree
  • mr_strMoveUpCategory
  • mr_strNewCategory
  • mr_strNewTree
  • mr_strRenameCategory
  • mr_strSyncCategory
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * AMR Content controller class
  4:  *
  5:  * @package     Plugin
  6:  * @subpackage  ModRewrite
  7:  * @version     SVN Revision $Rev:$
  8:  * @id          $Id: class.modrewrite_content_controller.php 4548 2013-04-14 17:15:42Z dominik.ziegler $:
  9:  * @author      Murat Purc <murat@purc.de>
 10:  * @copyright   four for business AG <www.4fb.de>
 11:  * @license     http://www.contenido.org/license/LIZENZ.txt
 12:  * @link        http://www.4fb.de
 13:  * @link        http://www.contenido.org
 14:  */
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: 
 19: /**
 20:  * Content controller for general settings.
 21:  *
 22:  * @author      Murat Purc <murat@purc.de>
 23:  * @package     Plugin
 24:  * @subpackage  ModRewrite
 25:  */
 26: class ModRewrite_ContentController extends ModRewrite_ControllerAbstract {
 27: 
 28:     /**
 29:      * Index action
 30:      */
 31:     public function indexAction() {
 32:         // donut
 33:     }
 34: 
 35:     /**
 36:      * Save settings action
 37:      */
 38:     public function saveAction() {
 39:         $bDebug = $this->getProperty('bDebug');
 40:         $aSeparator = $this->getProperty('aSeparator');
 41:         $aWordSeparator = $this->getProperty('aWordSeparator');
 42:         $routingSeparator = $this->getProperty('routingSeparator');
 43: 
 44:         $bError = false;
 45:         $aMR = array();
 46: 
 47:         $request = (count($_POST) > 0) ? $_POST : $_GET;
 48:         mr_requestCleanup($request);
 49: 
 50:         // use mod_rewrite
 51:         if (mr_arrayValue($request, 'use') == 1) {
 52:             $this->_oView->use_chk = ' checked="checked"';
 53:             $aMR['mod_rewrite']['use'] = 1;
 54:         } else {
 55:             $this->_oView->use_chk = '';
 56:             $aMR['mod_rewrite']['use'] = 0;
 57:         }
 58: 
 59:         // root dir
 60:         if (mr_arrayValue($request, 'rootdir', '') !== '') {
 61:             if (!preg_match('/^[a-zA-Z0-9\-_\/\.]*$/', $request['rootdir'])) {
 62:                 $sMsg = i18n('The root directory has a invalid format, alowed are the chars [a-zA-Z0-9\-_\/\.]', 'mod_rewrite');
 63:                 $this->_oView->rootdir_error = $this->_notifyBox('error', $sMsg);
 64:                 $bError = true;
 65:             } elseif (!is_dir($_SERVER['DOCUMENT_ROOT'] . $request['rootdir'])) {
 66: 
 67:                 if (mr_arrayValue($request, 'checkrootdir') == 1) {
 68:                     // root dir check is enabled, this results in error
 69:                     $sMsg = i18n('The specified directory "%s" does not exists', 'mod_rewrite');
 70:                     $sMsg = sprintf($sMsg, $_SERVER['DOCUMENT_ROOT'] . $request['rootdir']);
 71:                     $this->_oView->rootdir_error = $this->_notifyBox('error', $sMsg);
 72:                     $bError = true;
 73:                 } else {
 74:                     // root dir check ist disabled, take over the setting and
 75:                     // output a warning.
 76:                     $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.', 'mod_rewrite');
 77:                     $sMsg = sprintf($sMsg, $request['rootdir'], $_SERVER['DOCUMENT_ROOT']);
 78:                     $this->_oView->rootdir_error = $this->_notifyBox('warning', $sMsg);
 79:                 }
 80:             }
 81:             $this->_oView->rootdir = conHtmlentities($request['rootdir']);
 82:             $aMR['mod_rewrite']['rootdir'] = $request['rootdir'];
 83:         }
 84: 
 85:         // root dir check
 86:         if (mr_arrayValue($request, 'checkrootdir') == 1) {
 87:             $this->_oView->checkrootdir_chk = ' checked="checked"';
 88:             $aMR['mod_rewrite']['checkrootdir'] = 1;
 89:         } else {
 90:             $this->_oView->checkrootdir_chk = '';
 91:             $aMR['mod_rewrite']['checkrootdir'] = 0;
 92:         }
 93: 
 94:         // start from root
 95:         if (mr_arrayValue($request, 'startfromroot') == 1) {
 96:             $this->_oView->startfromroot_chk = ' checked="checked"';
 97:             $aMR['mod_rewrite']['startfromroot'] = 1;
 98:         } else {
 99:             $this->_oView->startfromroot_chk = '';
100:             $aMR['mod_rewrite']['startfromroot'] = 0;
101:         }
102: 
103:         // prevent duplicated content
104:         if (mr_arrayValue($request, 'prevent_duplicated_content') == 1) {
105:             $this->_oView->prevent_duplicated_content_chk = ' checked="checked"';
106:             $aMR['mod_rewrite']['prevent_duplicated_content'] = 1;
107:         } else {
108:             $this->_oView->prevent_duplicated_content_chk = '';
109:             $aMR['mod_rewrite']['prevent_duplicated_content'] = 0;
110:         }
111: 
112:         // language settings
113:         if (mr_arrayValue($request, 'use_language') == 1) {
114:             $this->_oView->use_language_chk = ' checked="checked"';
115:             $this->_oView->use_language_name_disabled = '';
116:             $aMR['mod_rewrite']['use_language'] = 1;
117:             if (mr_arrayValue($request, 'use_language_name') == 1) {
118:                 $this->_oView->use_language_name_chk = ' checked="checked"';
119:                 $aMR['mod_rewrite']['use_language_name'] = 1;
120:             } else {
121:                 $this->_oView->use_language_name_chk = '';
122:                 $aMR['mod_rewrite']['use_language_name'] = 0;
123:             }
124:         } else {
125:             $this->_oView->use_language_chk = '';
126:             $this->_oView->use_language_name_chk = '';
127:             $this->_oView->use_language_name_disabled = ' disabled="disabled"';
128:             $aMR['mod_rewrite']['use_language'] = 0;
129:             $aMR['mod_rewrite']['use_language_name'] = 0;
130:         }
131: 
132:         // client settings
133:         if (mr_arrayValue($request, 'use_client') == 1) {
134:             $this->_oView->use_client_chk = ' checked="checked"';
135:             $this->_oView->use_client_name_disabled = '';
136:             $aMR['mod_rewrite']['use_client'] = 1;
137:             if (mr_arrayValue($request, 'use_client_name') == 1) {
138:                 $this->_oView->use_client_name_chk = ' checked="checked"';
139:                 $aMR['mod_rewrite']['use_client_name'] = 1;
140:             } else {
141:                 $this->_oView->use_client_name_chk = '';
142:                 $aMR['mod_rewrite']['use_client_name'] = 0;
143:             }
144:         } else {
145:             $this->_oView->use_client_chk = '';
146:             $this->_oView->use_client_name_chk = '';
147:             $this->_oView->use_client_name_disabled = ' disabled="disabled"';
148:             $aMR['mod_rewrite']['use_client'] = 0;
149:             $aMR['mod_rewrite']['use_client_name'] = 0;
150:         }
151: 
152:         // use lowercase uri
153:         if (mr_arrayValue($request, 'use_lowercase_uri') == 1) {
154:             $this->_oView->use_lowercase_uri_chk = ' checked="checked"';
155:             $aMR['mod_rewrite']['use_lowercase_uri'] = 1;
156:         } else {
157:             $this->_oView->use_lowercase_uri_chk = '';
158:             $aMR['mod_rewrite']['use_lowercase_uri'] = 0;
159:         }
160: 
161:         $this->_oView->category_separator_attrib = '';
162:         $this->_oView->category_word_separator_attrib = '';
163:         $this->_oView->article_separator_attrib = '';
164:         $this->_oView->article_word_separator_attrib = '';
165: 
166:         $separatorPattern = $aSeparator['pattern'];
167:         $separatorInfo = $aSeparator['info'];
168: 
169:         $wordSeparatorPattern = $aSeparator['pattern'];
170:         $wordSeparatorInfo = $aSeparator['info'];
171: 
172:         $categorySeperator = mr_arrayValue($request, 'category_seperator', '');
173:         $categoryWordSeperator = mr_arrayValue($request, 'category_word_seperator', '');
174:         $articleSeperator = mr_arrayValue($request, 'article_seperator', '');
175:         $articleWordSeperator = mr_arrayValue($request, 'article_word_seperator', '');
176: 
177:         // category seperator
178:         if ($categorySeperator == '') {
179:             $sMsg = i18n('Please specify separator (%s) for category', 'mod_rewrite');
180:             $sMsg = sprintf($sMsg, $separatorInfo);
181:             $this->_oView->category_separator_error = $this->_notifyBox('error', $sMsg);
182:             $bError = true;
183:         } elseif (!preg_match($separatorPattern, $categorySeperator)) {
184:             $sMsg = i18n('Invalid separator for category, allowed one of following characters: %s', 'mod_rewrite');
185:             $sMsg = sprintf($sMsg, $separatorInfo);
186:             $this->_oView->category_separator_error = $this->_notifyBox('error', $sMsg);
187:             $bError = true;
188: 
189:             // category word seperator
190:         } elseif ($categoryWordSeperator == '') {
191:             $sMsg = i18n('Please specify separator (%s) for category words', 'mod_rewrite');
192:             $sMsg = sprintf($sMsg, $wordSeparatorInfo);
193:             $this->_oView->category_word_separator_error = $this->_notifyBox('error', $sMsg);
194:             $bError = true;
195:         } elseif (!preg_match($wordSeparatorPattern, $categoryWordSeperator)) {
196:             $sMsg = i18n('Invalid separator for category words, allowed one of following characters: %s', 'mod_rewrite');
197:             $sMsg = sprintf($sMsg, $wordSeparatorInfo);
198:             $this->_oView->category_word_separator_error = $this->_notifyBox('error', $sMsg);
199:             $bError = true;
200: 
201:             // article seperator
202:         } elseif ($articleSeperator == '') {
203:             $sMsg = i18n('Please specify separator (%s) for article', 'mod_rewrite');
204:             $sMsg = sprintf($sMsg, $separatorInfo);
205:             $this->_oView->article_separator_error = $this->_notifyBox('error', $sMsg);
206:             $bError = true;
207:         } elseif (!preg_match($separatorPattern, $articleSeperator)) {
208:             $sMsg = i18n('Invalid separator for article, allowed is one of following characters: %s', 'mod_rewrite');
209:             $sMsg = sprintf($sMsg, $separatorInfo);
210:             $this->_oView->article_separator_error = $this->_notifyBox('error', $sMsg);
211:             $bError = true;
212: 
213:             // article word seperator
214:         } elseif ($articleWordSeperator == '') {
215:             $sMsg = i18n('Please specify separator (%s) for article words', 'mod_rewrite');
216:             $sMsg = sprintf($sMsg, $wordSeparatorInfo);
217:             $this->_oView->article_word_separator_error = $this->_notifyBox('error', $sMsg);
218:             $bError = true;
219:         } elseif (!preg_match($wordSeparatorPattern, $articleWordSeperator)) {
220:             $sMsg = i18n('Invalid separator for article words, allowed is one of following characters: %s', 'mod_rewrite');
221:             $sMsg = sprintf($sMsg, $wordSeparatorInfo);
222:             $this->_oView->article_word_separator_error = $this->_notifyBox('error', $sMsg);
223:             $bError = true;
224: 
225:             // category_seperator - category_word_seperator
226:         } elseif ($categorySeperator == $categoryWordSeperator) {
227:             $sMsg = i18n('Separator for category and category words must not be identical', 'mod_rewrite');
228:             $this->_oView->category_separator_error = $this->_notifyBox('error', $sMsg);
229:             $bError = true;
230:             // category_seperator - article_word_seperator
231:         } elseif ($categorySeperator == $articleWordSeperator) {
232:             $sMsg = i18n('Separator for category and article words must not be identical', 'mod_rewrite');
233:             $this->_oView->category_separator_error = $this->_notifyBox('error', $sMsg);
234:             $bError = true;
235:             // article_seperator - article_word_seperator
236:         } elseif ($articleSeperator == $articleWordSeperator) {
237:             $sMsg = i18n('Separator for category-article and article words must not be identical', 'mod_rewrite');
238:             $this->_oView->article_separator_error = $this->_notifyBox('error', $sMsg);
239:             $bError = true;
240:         }
241: 
242:         $this->_oView->category_separator = conHtmlentities($categorySeperator);
243:         $aMR['mod_rewrite']['category_seperator'] = $categorySeperator;
244:         $this->_oView->category_word_separator = conHtmlentities($categoryWordSeperator);
245:         $aMR['mod_rewrite']['category_word_seperator'] = $categoryWordSeperator;
246:         $this->_oView->article_separator = conHtmlentities($articleSeperator);
247:         $aMR['mod_rewrite']['article_seperator'] = $articleSeperator;
248:         $this->_oView->article_word_separator = conHtmlentities($articleWordSeperator);
249:         $aMR['mod_rewrite']['article_word_seperator'] = $articleWordSeperator;
250: 
251:         // file extension
252:         if (mr_arrayValue($request, 'file_extension', '') !== '') {
253:             if (!preg_match('/^\.([a-zA-Z0-9\-_\/])*$/', $request['file_extension'])) {
254:                 $sMsg = i18n('The file extension has a invalid format, allowed are the chars \.([a-zA-Z0-9\-_\/])', 'mod_rewrite');
255:                 $this->_oView->file_extension_error = $this->_notifyBox('error', $sMsg);
256:                 $bError = true;
257:             }
258:             $this->_oView->file_extension = conHtmlentities($request['file_extension']);
259:             $aMR['mod_rewrite']['file_extension'] = $request['file_extension'];
260:         } else {
261:             $this->_oView->file_extension = '.html';
262:             $aMR['mod_rewrite']['file_extension'] = '.html';
263:         }
264: 
265:         // category resolve min percentage
266:         if (isset($request['category_resolve_min_percentage'])) {
267:             if (!is_numeric($request['category_resolve_min_percentage'])) {
268:                 $sMsg = i18n('Value has to be numeric.', 'mod_rewrite');
269:                 $this->_oView->category_resolve_min_percentage_error = $this->_notifyBox('error', $sMsg);
270:                 $bError = true;
271:             } elseif ($request['category_resolve_min_percentage'] < 0 || $request['category_resolve_min_percentage'] > 100) {
272:                 $sMsg = i18n('Value has to be between 0 an 100.', 'mod_rewrite');
273:                 $this->_oView->category_resolve_min_percentage_error = $this->_notifyBox('error', $sMsg);
274:                 $bError = true;
275:             }
276:             $this->_oView->category_resolve_min_percentage = $request['category_resolve_min_percentage'];
277:             $aMR['mod_rewrite']['category_resolve_min_percentage'] = $request['category_resolve_min_percentage'];
278:         } else {
279:             $this->_oView->category_resolve_min_percentage = '75';
280:             $aMR['mod_rewrite']['category_resolve_min_percentage'] = '75';
281:         }
282: 
283:         // add start article name to url
284:         if (mr_arrayValue($request, 'add_startart_name_to_url') == 1) {
285:             $this->_oView->add_startart_name_to_url_chk = ' checked="checked"';
286:             $aMR['mod_rewrite']['add_startart_name_to_url'] = 1;
287:             if (mr_arrayValue($request, 'add_startart_name_to_url', '') !== '') {
288:                 if (!preg_match('/^[a-zA-Z0-9\-_\/\.]*$/', $request['default_startart_name'])) {
289:                     $sMsg = i18n('The article name has a invalid format, allowed are the chars /^[a-zA-Z0-9\-_\/\.]*$/', 'mod_rewrite');
290:                     $this->_oView->add_startart_name_to_url_error = $this->_notifyBox('error', $sMsg);
291:                     $bError = true;
292:                 }
293:                 $this->_oView->default_startart_name = conHtmlentities($request['default_startart_name']);
294:                 $aMR['mod_rewrite']['default_startart_name'] = $request['default_startart_name'];
295:             } else {
296:                 $this->_oView->default_startart_name = '';
297:                 $aMR['mod_rewrite']['default_startart_name'] = '';
298:             }
299:         } else {
300:             $this->_oView->add_startart_name_to_url_chk = '';
301:             $aMR['mod_rewrite']['add_startart_name_to_url'] = 0;
302:             $this->_oView->default_startart_name = '';
303:             $aMR['mod_rewrite']['default_startart_name'] = '';
304:         }
305: 
306:         // rewrite urls at
307:         if (mr_arrayValue($request, 'rewrite_urls_at') == 'congeneratecode') {
308:             $this->_oView->rewrite_urls_at_congeneratecode_chk = ' checked="checked"';
309:             $this->_oView->rewrite_urls_at_front_content_output_chk = '';
310:             $aMR['mod_rewrite']['rewrite_urls_at_congeneratecode'] = 1;
311:             $aMR['mod_rewrite']['rewrite_urls_at_front_content_output'] = 0;
312:         } else {
313:             $this->_oView->rewrite_urls_at_congeneratecode_chk = '';
314:             $this->_oView->rewrite_urls_at_front_content_output_chk = ' checked="checked"';
315:             $aMR['mod_rewrite']['rewrite_urls_at_congeneratecode'] = 0;
316:             $aMR['mod_rewrite']['rewrite_urls_at_front_content_output'] = 1;
317:         }
318: 
319:         // routing
320:         if (isset($request['rewrite_routing'])) {
321:             $aRouting = array();
322:             $items = explode("\n", $request['rewrite_routing']);
323:             foreach ($items as $p => $v) {
324:                 $routingDef = explode($routingSeparator, $v);
325:                 if (count($routingDef) !== 2) {
326:                     continue;
327:                 }
328:                 $routingDef[0] = trim($routingDef[0]);
329:                 $routingDef[1] = trim($routingDef[1]);
330:                 if ($routingDef[0] == '') {
331:                     continue;
332:                 }
333:                 $aRouting[$routingDef[0]] = $routingDef[1];
334:             }
335:             $this->_oView->rewrite_routing = conHtmlentities($request['rewrite_routing']);
336:             $aMR['mod_rewrite']['routing'] = $aRouting;
337:         } else {
338:             $this->_oView->rewrite_routing = '';
339:             $aMR['mod_rewrite']['routing'] = array();
340:         }
341: 
342:         // redirect invalid article to errorsite
343:         if (isset($request['redirect_invalid_article_to_errorsite'])) {
344:             $this->_oView->redirect_invalid_article_to_errorsite_chk = ' checked="checked"';
345:             $aMR['mod_rewrite']['redirect_invalid_article_to_errorsite'] = 1;
346:         } else {
347:             $this->_oView->redirect_invalid_article_to_errorsite_chk = '';
348:             $aMR['mod_rewrite']['redirect_invalid_article_to_errorsite'] = 0;
349:         }
350: 
351:         if ($bError) {
352:             $sMsg = i18n('Please check your input', 'mod_rewrite');
353:             $this->_oView->content_before = $this->_notifyBox('error', $sMsg);
354:             return;
355:         }
356: 
357:         if ($bDebug == true) {
358:             echo $this->_notifyBox('info', 'Debug');
359:             echo '<pre class="example">';
360:             print_r($aMR['mod_rewrite']);
361:             echo '</pre>';
362:             $sMsg = i18n('Configuration has <b>not</b> been saved, because of enabled debugging', 'mod_rewrite');
363:             echo $this->_notifyBox('info', $sMsg);
364:             return;
365:         }
366: 
367:         $bSeparatorModified = $this->_separatorModified($aMR['mod_rewrite']);
368: 
369:         if (mr_setConfiguration($this->_client, $aMR)) {
370:             $sMsg = i18n('Configuration has been saved', 'mod_rewrite');
371:             if ($bSeparatorModified) {
372:                 mr_loadConfiguration($this->_client, true);
373:             }
374:             $this->_oView->content_before = $this->_notifyBox('info', $sMsg);
375:         } else {
376:             $sMsg = i18n('Configuration could not saved. Please check write permissions for %s ', 'mod_rewrite');
377:             $sMsg = sprintf($sMsg, $options['key']); // TODO: from where does $options come?
378:             $this->_oView->content_before = $this->_notifyBox('error', $sMsg);
379:         }
380:     }
381: 
382:     /**
383:      * Checks, if any sseparators setting is modified or not
384:      * @param   array  $aNewCfg  New configuration send by requests.
385:      * @return  bool
386:      */
387:     protected function _separatorModified($aNewCfg) {
388:         $aCfg = ModRewrite::getConfig();
389: 
390:         if ($aCfg['category_seperator'] != $aNewCfg['category_seperator']) {
391:             return true;
392:         } elseif ($aCfg['category_word_seperator'] != $aNewCfg['category_word_seperator']) {
393:             return true;
394:         } elseif ($aCfg['article_seperator'] != $aNewCfg['article_seperator']) {
395:             return true;
396:         } elseif ($aCfg['article_word_seperator'] != $aNewCfg['article_word_seperator']) {
397:             return true;
398:         }
399:         return false;
400:     }
401: 
402: }
403: 
CMS CONTENIDO 4.9.0 API documentation generated by ApiGen 2.8.0