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