1: <?php
2: /**
3: * AMR base Mod Rewrite class
4: *
5: * @package Plugin
6: * @subpackage ModRewrite
7: * @version SVN Revision $Rev:$
8: * @id $Id: class.modrewritebase.php 5599 2013-09-30 16:14:38Z marcus.gnass $:
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: * Abstract base mod rewrite class.
20: *
21: * Provides some common features such as common debugging, globals/configuration
22: * access for childs.
23: *
24: * @author Murat Purc <murat@purc.de>
25: * @package Plugin
26: * @subpackage ModRewrite
27: */
28: abstract class ModRewriteBase {
29:
30: /**
31: * Returns enabled state of mod rewrite plugin
32: *
33: * @return bool
34: */
35: public static function isEnabled() {
36: return (self::getConfig('use', 0) == 1) ? true : false;
37: }
38:
39: /**
40: * Sets the enabled state of mod rewrite plugin
41: *
42: * @param bool $bEnabled
43: */
44: public static function setEnabled($bEnabled) {
45: self::setConfig('use', (bool) $bEnabled);
46: }
47:
48: /**
49: * Returns configuration of mod rewrite, content of gobal $cfg['mod_rewrite']
50: *
51: * @param string $key Name of configuration key
52: * @param mixed $default Default value to return as a fallback
53: * @return mixed Desired value mr configuration, either the full configuration
54: * or one of the desired subpart
55: */
56: public static function getConfig($key = NULL, $default = NULL) {
57: global $cfg;
58: if ($key == NULL) {
59: return $cfg['mod_rewrite'];
60: } elseif ((string) $key !== '') {
61: return (isset($cfg['mod_rewrite'][$key])) ? $cfg['mod_rewrite'][$key] : $default;
62: } else {
63: return $default;
64: }
65: }
66:
67: /**
68: * Sets the configuration of mod rewrite, content of gobal $cfg['mod_rewrite']
69: *
70: * @param string $key Name of configuration key
71: * @param mixed $value The value to set
72: */
73: public static function setConfig($key, $value) {
74: global $cfg;
75: $cfg['mod_rewrite'][$key] = $value;
76: }
77:
78: }
79: