diff --git a/conlite/classes/drivers/class.gdb.driver.php b/conlite/classes/drivers/class.gdb.driver.php deleted file mode 100644 index 4bc38ec..0000000 --- a/conlite/classes/drivers/class.gdb.driver.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @license http://www.contenido.org/license/LIZENZ.txt - * @link http://www.4fb.de - * @link http://www.contenido.org - * - * $Id$ - */ -if (!defined('CON_FRAMEWORK')) { - die('Illegal call'); -} - -class gdbDriver { - - var $_sEncoding; - var $_oItemClassInstance; - - public function __construct() { - - } - - public function setEncoding($sEncoding) { - $this->_sEncoding = $sEncoding; - } - - public function setItemClassInstance($oInstance) { - $this->_oItemClassInstance = $oInstance; - } - - public function buildJoinQuery($destinationTable, $destinationClass, $destinationPrimaryKey, $sourceClass, $primaryKey) { - - } - - public function buildOperator($sField, $sOperator, $sRestriction) { - - } -} -?> diff --git a/conlite/classes/drivers/mysql/class.gdb.mysql.php b/conlite/classes/drivers/mysql/class.gdb.mysql.php deleted file mode 100644 index 1ccb0f5..0000000 --- a/conlite/classes/drivers/mysql/class.gdb.mysql.php +++ /dev/null @@ -1,194 +0,0 @@ - - * @license http://www.contenido.org/license/LIZENZ.txt - * @link http://www.4fb.de - * @link http://www.contenido.org - * - * {@internal - * created 2006-05-10 - * modified 2008-05-23 Added Debug_DevNull and Debug_VisibleAdv - * - * $Id$ - * }} - * - */ -if (!defined('CON_FRAMEWORK')) { - die('Illegal call'); -} - -class gdbMySQL extends gdbDriver { - - function buildJoinQuery($destinationTable, $destinationClass, $destinationPrimaryKey, $sourceClass, $primaryKey) { - // Build a regular LEFT JOIN - $field = "$destinationClass.$destinationPrimaryKey"; - $tables = ""; - $join = "LEFT JOIN $destinationTable AS $destinationClass ON " . - Contenido_Security::toString($sourceClass . "." . $primaryKey) . " = " . - Contenido_Security::toString($destinationClass . "." . $primaryKey); - $where = ""; - - return array("field" => $field, "table" => $tables, "join" => $join, "where" => $where); - } - - function buildOperator($sField, $sOperator, $sRestriction) { - $sOperator = strtolower($sOperator); - - $sWhereStatement = ""; - - switch ($sOperator) { - case "matchbool": - $sqlStatement = "MATCH (%s) AGAINST ('%s' IN BOOLEAN MODE)"; - $sWhereStatement = sprintf($sqlStatement, $sField, $this->_oItemClassInstance->_inFilter($sRestriction)); - break; - case "match": - $sqlStatement = "MATCH (%s) AGAINST ('%s')"; - $sWhereStatement = sprintf($sqlStatement, $sField, $this->_oItemClassInstance->_inFilter($sRestriction)); - break; - case "like": - $sqlStatement = "%s LIKE '%%%s%%'"; - $sWhereStatement = sprintf($sqlStatement, Contenido_Security::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction)); - break; - case "likeleft": - $sqlStatement = "%s LIKE '%s%%'"; - $sWhereStatement = sprintf($sqlStatement, Contenido_Security::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction)); - break; - case "likeright": - $sqlStatement = "%s LIKE '%%%s'"; - $sWhereStatement = sprintf($sqlStatement, Contenido_Security::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction)); - break; - case "notlike": - $sqlStatement = "%s NOT LIKE '%%%s%%'"; - $sWhereStatement = sprintf($sqlStatement, Contenido_Security::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction)); - break; - case "notlikeleft": - $sqlStatement = "%s NOT LIKE '%s%%'"; - $sWhereStatement = sprintf($sqlStatement, Contenido_Security::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction)); - break; - case "notlikeright": - $sqlStatement = "%s NOT LIKE '%%%s'"; - $sWhereStatement = sprintf($sqlStatement, Contenido_Security::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction)); - break; - case "diacritics": - if (!is_object($GLOBALS["_cCharTable"])) { - $GLOBALS["_cCharTable"] = new cCharacterConverter; - } - - $aliasSearch = array(); - - $metaCharacters = array("*", "[", "]", "^", '$', "\\", "*", "'", '"', '+'); - - for ($i = 0; $i < strlen($sRestriction); $i ++) { - $char = substr($sRestriction, $i, 1); - - $aliases = array(); - - $aliases = array_merge($aliases, $GLOBALS["_cCharTable"]->fetchDiacriticCharactersForNormalizedChar($this->_sEncoding, $char)); - $normalizedChars = $GLOBALS["_cCharTable"]->fetchNormalizedCharsForDiacriticCharacter($this->_sEncoding, $char); - - foreach ($normalizedChars as $normalizedChar) { - $aliases = array_merge($aliases, $GLOBALS["_cCharTable"]->fetchDiacriticCharactersForNormalizedChar($this->_sEncoding, $normalizedChar)); - } - - $aliases = array_merge($aliases, $normalizedChars); - - if (count($aliases) > 0) { - $aliases[] = $char; - $allAliases = array(); - - foreach ($aliases as $alias) { - $alias1 = $this->_oItemClassInstance->_inFilter($alias); - $allAliases[] = $alias1; - $allAliases[] = $alias; - } - - $allAliases = array_unique($allAliases); - $aliasSearch[] = "(" . implode("|", $allAliases) . ")"; - } else { - $addChars = array(); - - - - if (in_array($char, $metaCharacters)) { - $addChars[] = "\\\\" . $char; - } else { - $addChars[] = $char; - - $vChar = $this->_oItemClassInstance->_inFilter($char); - - if ($char != $vChar) { - if (in_array($vChar, $metaCharacters)) { - $addChars[] = "\\\\" . $vChar; - } else { - $addChars[] = $vChar; - } - } - } - - $aliasSearch[] = "(" . implode("|", $addChars) . ")"; - } - } - - $restriction = "'" . implode("", $aliasSearch) . "'"; - $sWhereStatement = implode(" ", array($sField, "REGEXP", $restriction)); - - break; - case "fulltext": - - break; - case "in": - if (is_array($sRestriction)) { - $items = array(); - - foreach ($sRestriction as $key => $sRestrictionItem) { - $items[] = "'" . $this->_oItemClassInstance->_inFilter($sRestrictionItem) . "'"; - } - - $sRestriction = implode(", ", $items); - } else { - $sRestriction = "'" . $sRestriction . "'"; - } - - $sWhereStatement = implode(" ", array($sField, "IN (", $sRestriction, ")")); - break; - case "notin": - if (is_array($sRestriction)) { - $items = array(); - - foreach ($sRestriction as $key => $sRestrictionItem) { - $items[] = "'" . $this->_oItemClassInstance->_inFilter($sRestrictionItem) . "'"; - } - - $sRestriction = implode(", ", $items); - } else { - $sRestriction = "'" . $sRestriction . "'"; - } - - $sWhereStatement = implode(" ", array($sField, "NOT IN (", $sRestriction, ")")); - break; - default : - $sRestriction = "'" . $this->_oItemClassInstance->_inFilter($sRestriction) . "'"; - - $sWhereStatement = implode(" ", array($sField, $sOperator, $sRestriction)); - } - - return $sWhereStatement; - } - -} - -?> \ No newline at end of file diff --git a/conlite/classes/genericdb/class.item.base.abstract.php b/conlite/classes/genericdb/class.item.base.abstract.php deleted file mode 100644 index c167cbb..0000000 --- a/conlite/classes/genericdb/class.item.base.abstract.php +++ /dev/null @@ -1,164 +0,0 @@ -db = new DB_ConLite(); - - if ($sTable == '') { - $sMsg = "$sClassName: No table specified. Inherited classes *need* to set a table"; - throw new Contenido_ItemException($sMsg); - } elseif ($sPrimaryKey == '') { - $sMsg = "No primary key specified. Inherited classes *need* to set a primary key"; - throw new Contenido_ItemException($sMsg); - } - - $this->_settings = $cfg['sql']; - - // instanciate caching - $aCacheOpt = (isset($this->_settings['cache'])) ? $this->_settings['cache'] : array(); - self::$_oCache = cItemCache::getInstance($sTable, $aCacheOpt); - - $this->table = $sTable; - $this->primaryKey = $sPrimaryKey; - $this->virgin = true; - $this->lifetime = $iLifetime; - $this->_className = $sClassName; - } - - /** - * Escape string for using in SQL-Statement. - * - * @param string $sString The string to escape - * @return string Escaped string - */ - public function escape($sString) { - return $this->db->escape($sString); - } - - /** - * Returns the second database instance, usable to run additional statements - * without losing current query results. - * - * @return DB_ConLite - */ - protected function _getSecondDBInstance() { - if (!isset($this->secondDb) || !($this->secondDb instanceof DB_ConLite)) { - $this->secondDb = new DB_ConLite(); - } - return $this->secondDb; - } - - /** - * Returns properties instance, instantiates it if not done before. - * - * @return PropertyCollection - */ - protected function _getPropertiesCollectionInstance() { - // Runtime on-demand allocation of the properties object - if (!isset($this->properties) || !($this->properties instanceof PropertyCollection)) { - $this->properties = new PropertyCollection(); - } - return $this->properties; - } - -} - -?> \ No newline at end of file diff --git a/conlite/classes/genericdb/class.item.cache.php b/conlite/classes/genericdb/class.item.cache.php deleted file mode 100644 index b6ea912..0000000 --- a/conlite/classes/genericdb/class.item.cache.php +++ /dev/null @@ -1,214 +0,0 @@ -_sTable = $sTable; - if (isset($aOptions['max_items_to_cache']) && (int) $aOptions['max_items_to_cache'] > 0) { - $this->_iMaxItemsToCache = (int) $aOptions['max_items_to_cache']; - } - if (isset($aOptions['enable']) && is_bool($aOptions['enable'])) { - $this->_bEnable = (bool) $aOptions['enable']; - } - - if (isset($_GET['frame']) && is_numeric($_GET['frame'])) { - $this->_iFrame = (int) $_GET['frame']; - } else { - $this->_bEnable = false; - } - } - - /** - * Prevent cloning - */ - protected function __clone() { - - } - - /** - * Returns item cache instance, creates it, if not done before. - * Works as a singleton for one specific table. - * - * @param string $sTable Table name - * @param array $aOptions Options array as follows: - * - $aOptions['max_items_to_cache'] = (int) Number of items to cache - * - $aOptions['enable'] = (bool) Flag to enable caching - */ - public static function getInstance($sTable, array $aOptions = array()) { - if (!isset(self::$_oInstances[$sTable])) { - self::$_oInstances[$sTable] = new self($sTable, $aOptions); - } - return self::$_oInstances[$sTable]; - } - - /** - * Returns items cache list. - * - * @return array - */ - public function getItemsCache() { - return $this->_aItemsCache[$this->_iFrame]; - } - - /** - * Returns existing entry from cache by it's id. - * - * @param mixed $mId - * @return array|null - */ - public function getItem($mId) { - if (!$this->_bEnable) { - return null; - } - - if (isset($this->_aItemsCache[$this->_iFrame][$mId])) { - return $this->_aItemsCache[$this->_iFrame][$mId]; - } else { - return null; - } - } - - /** - * Returns existing entry from cache by matching propery value. - * - * @param mixed $mProperty - * @param mixed $mValue - * @return array|null - */ - public function getItemByProperty($mProperty, $mValue) { - if (!$this->_bEnable) { - return null; - } - - // loop thru all cached entries and try to find a entry by it's property - if (is_array($this->_aItemsCache[$this->_iFrame]) && count($this->_aItemsCache[$this->_iFrame]) > 0) { - foreach ($this->_aItemsCache[$this->_iFrame] as $id => $aEntry) { - if (isset($aEntry[$mProperty]) && $aEntry[$mProperty] == $mValue) { - return $aEntry; - } - } - } - return null; - } - - /** - * Returns existing entry from cache by matching properties and their values. - * - * @param array $aProperties Assoziative key value pairs - * @return array|null - */ - public function getItemByProperties(array $aProperties) { - if (!$this->_bEnable) { - return null; - } - - // loop thru all cached entries and try to find a entry by it's property - foreach ($this->_aItemsCache as $id => $aEntry) { - $mFound = null; - foreach ($aProperties as $key => $value) { - if (isset($aEntry[$key]) && $aEntry[$key] == $value) { - if (null === $mFound) { - $mFound = true; - } - } else { - $mFound = false; - break; - } - if (true === $mFound) { - return $aEntry; - } - } - } - return null; - } - - /** - * Adds passed item data to internal cache - * - * @param mixed $mId - * @param array $aData Usually the recordset - * @return void - */ - public function addItem($mId, array $aData) { - if (!$this->_bEnable) { - return null; - } - - if (isset($this->_aItemsCache[$this->_iFrame])) { - $aTmpItemsArray = $this->_aItemsCache[$this->_iFrame]; - - if ($this->_iMaxItemsToCache == count($aTmpItemsArray)) { - // we have reached the maximum number of cached items, remove first entry - $firstEntryKey = array_shift($aTmpItemsArray); - if (is_array($firstEntryKey)) - return null; - unset($this->_aItemsCache[$this->_iFrame][$firstEntryKey]); - } - } - - // add entry - $this->_aItemsCache[$this->_iFrame][$mId] = $aData; - } - - /** - * Removes existing cache entry by it's key - * - * @param mixed $mId - * @return void - */ - public function removeItem($mId) { - if (!$this->_bEnable) { - return null; - } - - // remove entry - if (isset($this->_aItemsCache[$this->_iFrame][$mId])) { - unset($this->_aItemsCache[$this->_iFrame][$mId]); - } - } - -}