1: <?php
2:
3: /**
4: * This file contains the base class for content search.
5: *
6: * @package Core
7: * @subpackage Frontend_Search
8: * @author Willi Man
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: cInclude('includes', 'functions.encoding.php');
18:
19: /**
20: * Abstract base search class.
21: *
22: * Provides general properties and functions for child implementations.
23: *
24: * @author Murat Purc <murat@purc.de>
25: * @package Core
26: * @subpackage Frontend_Search
27: */
28: abstract class cSearchBaseAbstract {
29:
30: /**
31: * CONTENIDO database object.
32: *
33: * @var cDb
34: */
35: protected $oDB;
36:
37: /**
38: * CONTENIDO configuration data.
39: *
40: * @var array
41: */
42: protected $cfg;
43:
44: /**
45: * Language id of a client.
46: *
47: * @var int
48: */
49: protected $lang;
50:
51: /**
52: * Client id.
53: *
54: * @var int
55: */
56: protected $client;
57:
58: /**
59: * Constructor to create an instance of this class.
60: *
61: * Initialises some properties.
62: *
63: * @param cDb $oDB [optional]
64: * CONTENIDO database object
65: * @param bool $bDebug [optional]
66: * Optional, flag to enable debugging (no longer needed)
67: */
68: protected function __construct($oDB = NULL, $bDebug = false) {
69: global $cfg, $lang, $client;
70:
71: $this->cfg = $cfg;
72: $this->lang = $lang;
73: $this->client = $client;
74:
75: $this->bDebug = $bDebug;
76:
77: if ($oDB == NULL || !is_object($oDB)) {
78: $this->db = cRegistry::getDb();
79: } else {
80: $this->db = $oDB;
81: }
82: }
83:
84: /**
85: * Main debug function, prints dumps parameter if debugging is
86: * enabled.
87: *
88: * @param string $msg
89: * Some text
90: * @param mixed $var
91: * The variable to dump
92: *
93: * @throws cInvalidArgumentException
94: */
95: protected function _debug($msg, $var) {
96: $dump = $msg . ': ';
97: if (is_array($var) || is_object($var)) {
98: $dump .= print_r($var, true);
99: } else {
100: $dump .= $var;
101: }
102: cDebug::out($dump);
103: }
104: }
105: