Overview

Packages

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