Author: voxus
Date: 2005-06-13 20:26:54 +0400 (Mon, 13 Jun 2005)
New Revision: 469
Added:
src/classes/Expression/BetweenExpression.class.php
src/classes/Expression/EqLowerExpression.class.php
src/classes/Expression/InExpression.class.php
src/classes/Logic/
src/classes/Logic/LogicalBlock.class.php
src/classes/Logic/LogicalChain.class.php
src/classes/Logic/LogicalExpression.class.php
src/classes/Logic/LogicalObject.class.php
Removed:
src/classes/OSQL/BetweenExpression.class.php
src/classes/OSQL/EqLowerExpression.class.php
src/classes/OSQL/InExpression.class.php
src/classes/OSQL/LogicalBlock.class.php
src/classes/OSQL/LogicalChain.class.php
src/classes/OSQL/LogicalExpression.class.php
src/classes/OSQL/LogicalObject.class.php
Modified:
src/global.inc.php.tpl
Log:
* separation OSQL to Logic and Expression
Copied: src/classes/Expression/BetweenExpression.class.php (from rev 468, src/classes/OSQL/BetweenExpression.class.php)
Copied: src/classes/Expression/EqLowerExpression.class.php (from rev 468, src/classes/OSQL/EqLowerExpression.class.php)
Copied: src/classes/Expression/InExpression.class.php (from rev 468, src/classes/OSQL/InExpression.class.php)
Copied: src/classes/Logic/LogicalBlock.class.php (from rev 468, src/classes/OSQL/LogicalBlock.class.php)
Copied: src/classes/Logic/LogicalChain.class.php (from rev 468, src/classes/OSQL/LogicalChain.class.php)
Copied: src/classes/Logic/LogicalExpression.class.php (from rev 468, src/classes/OSQL/LogicalExpression.class.php)
Copied: src/classes/Logic/LogicalObject.class.php (from rev 468, src/classes/OSQL/LogicalObject.class.php)
Deleted: src/classes/OSQL/BetweenExpression.class.php
===================================================================
--- src/classes/OSQL/BetweenExpression.class.php 2005-06-13 16:17:33 UTC (rev 468)
+++ src/classes/OSQL/BetweenExpression.class.php 2005-06-13 16:26:54 UTC (rev 469)
@@ -1,56 +0,0 @@
-<?php
-/***************************************************************************
- * Copyright (C) 2004-2005 by Konstantin V. Arkhipov, Anton Lebedevich *
- * voxusAT@ATgentoo.org *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-/* $Id$ */
-
- class BetweenExpression implements LogicalObject
- {
- private $field = null;
- private $left = null;
- private $right = null;
-
- public function __construct($field, $left, $right)
- {
- $this->left = $left;
- $this->right = $right;
- $this->field = $field;
- }
-
- private function fieldOrValue(DB $db, $something)
- {
- if ($something instanceof DBField || $something instanceof DBValue)
- return $something->toString($db);
- else
- return $db->quoteField($something);
- }
-
- public function toString(DB $db)
- {
- return
- '('.
- $this->fieldOrValue($db, $this->field).
- ' BETWEEN '.
- $this->fieldOrValue($db, $this->left).
- ' AND '.
- $this->fieldOrValue($db, $this->right).
- ')';
- }
-
- public function toBoolean(Form $form)
- {
- $value = &$form->getValue($this->field);
-
- return
- ($form->getValue($this->left) <= $value) &&
- ($value >= $form->getValue($this->right));
- }
- }
-?>
\ No newline at end of file
Deleted: src/classes/OSQL/EqLowerExpression.class.php
===================================================================
--- src/classes/OSQL/EqLowerExpression.class.php 2005-06-13 16:17:33 UTC (rev 468)
+++ src/classes/OSQL/EqLowerExpression.class.php 2005-06-13 16:26:54 UTC (rev 469)
@@ -1,39 +0,0 @@
-<?php
-/***************************************************************************
- * Copyright (C) 2004-2005 by Konstantin V. Arkhipov, Anton Lebedevich *
- * voxusAT@ATgentoo.org *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-/* $Id$ */
-
- class EqLowerExpression implements LogicalObject
- {
- private $field = null;
- private $value = null;
-
- public function __construct($field, $value)
- {
- $this->field = $field;
- $this->value = $value;
- }
-
- public function toString(DB $db)
- {
- return
- "(lower({$db->fieldToString($this->field)}) = ".
- "lower({$db->quoteValue($this->value)}))";
- }
-
- public function toBoolean(Form $form)
- {
- return
- strtolower($form->getValue($this->field)) ===
- strtolower($this->value);
- }
- }
-?>
Deleted: src/classes/OSQL/InExpression.class.php
===================================================================
--- src/classes/OSQL/InExpression.class.php 2005-06-13 16:17:33 UTC (rev 468)
+++ src/classes/OSQL/InExpression.class.php 2005-06-13 16:26:54 UTC (rev 469)
@@ -1,71 +0,0 @@
-<?php
-/***************************************************************************
- * Copyright (C) 2004-2005 by Konstantin V. Arkhipov, Anton Lebedevich *
- * voxusAT@ATgentoo.org *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-/* $Id$ */
-
- class InExpression implements LogicalObject
- {
- const IN = 'in';
- const NOT_IN = 'not in';
-
- private $field = null;
- private $value = null;
- private $logic = null;
-
- public function __construct($field, $value, $logic)
- {
- $this->field = $field;
- $this->value = $value;
- $this->logic = $logic;
- }
-
- public function toString(DB $db)
- {
- if ($this->value instanceof SelectQuery)
- $value = $this->value->toString($db);
- elseif (is_array($this->value)) {
- $value = '';
-
- foreach ($this->value as $item)
- $item = $db->quoteValue($item);
-
- $value = implode(', ', $this->value);
-
- } else
- $value = $db->quoteValue($this->value);
-
- return
- $db->fieldToString($this->field).
- " {$this->logic} ({$value})";
- }
-
- public function toBoolean(Form $form)
- {
- if ($this->value instanceof SelectQuery)
- throw new UnsupportedMethodException();
- elseif (is_array($this->value)) {
- $out = in_array($form->getValue($this->field), $this->value);
-
- switch ($this->logic) {
- case self::IN:
- return $out;
-
- case self::NOT_IN:
- return !$out;
-
- default:
- throw new UnsupportedMethodException();
- }
- } else
- throw new UnsupportedMethodException();
- }
- }
-?>
\ No newline at end of file
Deleted: src/classes/OSQL/LogicalBlock.class.php
===================================================================
--- src/classes/OSQL/LogicalBlock.class.php 2005-06-13 16:17:33 UTC (rev 468)
+++ src/classes/OSQL/LogicalBlock.class.php 2005-06-13 16:26:54 UTC (rev 469)
@@ -1,63 +0,0 @@
-<?php
-/***************************************************************************
- * Copyright (C) 2004-2005 by Konstantin V. Arkhipov, Anton Lebedevich *
- * voxusAT@ATgentoo.org *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-/* $Id$ */
-
- class LogicalBlock implements LogicalObject
- {
- private $args = null;
- private $logic = null;
-
- public function __construct($args, $logic)
- {
- $this->args = $args;
- $this->logic = $logic;
- }
-
- public function toString(DB $db)
- {
- $quotedArgs = array();
-
- foreach ($this->args as $arg)
- $quotedArgs[] = $arg->toString($db);
-
- return '('.implode(' '.$this->logic.' ', $quotedArgs).')';
- }
-
- public function toBoolean(Form $form)
- {
- $out = null;
-
- switch ($this->logic) {
- case Expression::LOGIC_AND:
- for ($i = 0; $i < sizeof($args); $i++)
- if (isset($args[$i + 1]))
- $out =
- $args[$i]->toBoolean($form) &&
- $args[$i + 1]->toBoolean($form);
- else
- $out = $out && $args[$i]->toBoolean($form);
-
- return $out;
-
- case Expression::LOGIC_OR:
- for ($i = 0; $i < sizeof($args); $i++)
- if (isset($args[$i + 1]))
- $out =
- $args[$i]->toBoolean($form) ||
- $args[$i + 1]->toBoolean($form);
- else
- $out = $out || $args[$i]->toBoolean($form);
- return $out;
- }
- }
- }
-?>
\ No newline at end of file
Deleted: src/classes/OSQL/LogicalChain.class.php
===================================================================
--- src/classes/OSQL/LogicalChain.class.php 2005-06-13 16:17:33 UTC (rev 468)
+++ src/classes/OSQL/LogicalChain.class.php 2005-06-13 16:26:54 UTC (rev 469)
@@ -1,83 +0,0 @@
-<?php
-/***************************************************************************
- * Copyright (C) 2004-2005 by Konstantin V. Arkhipov *
- * voxusAT@ATgentoo.org *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-/* $Id$ */
-
- class LogicalChain implements LogicalObject
- {
- private $chain = array();
- private $logic = array();
-
- public function expAnd(LogicalObject $exp)
- {
- return $this->exp($exp, Expression::LOGIC_AND);
- }
-
- public function expOr(LogicalObject $exp)
- {
- return $this->exp($exp, Expression::LOGIC_OR);
- }
-
- private function exp(LogicalObject $exp, $logic)
- {
- $this->chain[] = $exp;
- $this->logic[] = $logic;
-
- return $this;
- }
-
- public function getSize()
- {
- return sizeof($this->chain);
- }
-
- public function toString(DB $db)
- {
- if ($this->chain) {
- $out = '(';
- $this->logic[0] = '';
-
- for ($i = 0; $i < sizeof($this->chain); $i++)
- $out .= "{$this->logic[$i]} {$this->chain[$i]->toString($db)} ";
-
- return $out.')';
- }
-
- return null;
- }
-
- public function toBoolean(Form $form)
- {
- $chain = &$this->chain;
-
- $out = null;
-
- for ($i = 0; $i < sizeof($chain); $i++) {
- if (isset($chain[$i + 1]))
- $out =
- Expression::toBoolean(
- $this->logic[$i + 1],
- $chain[$i]->toBoolean($form),
- $chain[$i + 1]->toBoolean($form)
- );
- else
- $out =
- Expression::toBoolean(
- $this->logic[$i],
- $out,
- $chain[$i]
- );
- }
-
- return $out;
- }
- }
-?>
\ No newline at end of file
Deleted: src/classes/OSQL/LogicalExpression.class.php
===================================================================
--- src/classes/OSQL/LogicalExpression.class.php 2005-06-13 16:17:33 UTC (rev 468)
+++ src/classes/OSQL/LogicalExpression.class.php 2005-06-13 16:26:54 UTC (rev 469)
@@ -1,147 +0,0 @@
-<?php
-/***************************************************************************
- * Copyright (C) 2004-2005 by Konstantin V. Arkhipov, Anton Lebedevich *
- * voxusAT@ATgentoo.org *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-/* $Id$ */
-
- class LogicalExpression implements LogicalObject
- {
- const EQUALS = '=';
- const NOT_EQUALS = '!';
-
- const IS_NULL = 'IS NULL';
- const IS_NOT_NULL = 'IS NOT NULL';
-
- const IS_TRUE = 'IS TRUE';
- const IS_FALSE = 'IS FALSE';
-
- const EXPRESSION_AND = 'AND';
- const EXPRESSION_OR = 'OR';
-
- const GREATER_THAN = '>';
- const GREATER_OR_EQUALS = '>=';
-
- const LOWER_THAN = '<';
- const LOWER_OR_EQUALS = '<=';
-
- const LIKE = 'LIKE';
- const NOT_LIKE = 'NOT LIKE';
-
- const SIMILAR_TO = 'SIMILAR TO';
- const NOT_SIMILAR_TO = 'NOT SIMILAR TO';
-
- private $left = null;
- private $right = null;
- private $logic = null;
-
- public function __construct($left, $right, $logic)
- {
- $this->left = $left;
- $this->right = $right;
- $this->logic = $logic;
- }
-
- public function getLeft()
- {
- return $this->left;
- }
-
- public function getRight()
- {
- return $this->right;
- }
-
- public function getLogic()
- {
- return $this->logic;
- }
-
- public function toString(DB $db)
- {
- $string = '(';
-
- if (null !== $left = $this->left) {
- if (is_object($left))
- $string .= $left->toString($db);
- else
- $string .= $db->quoteField($left);
- }
-
- $string .= " {$this->logic} ";
-
- if (null !== $right = $this->right) {
- if (is_object($right))
- $string .= $right->toString($db);
- else
- $string .= $db->quoteValue($this->right);
- }
-
- $string .= ')';
-
- return $string;
- }
-
- public function toBoolean(Form $form)
- {
- $left = &$form->getValue($this->left);
- $right = &$form->getValue($this->right);
-
- switch ($this->logic) {
- case self::EQUALS:
- return $left == $right;
-
- case self::NOT_EQUALS:
- return $left != $right;
-
- case self::IS_NULL:
- return null === $left;
-
- case self::IS_NOT_NULL:
- return null !== $left;
-
- case self::IS_TRUE:
- return true === $left;
-
- case self::IS_FALSE:
- return false === $left;
-
- case self::GREATER_THAN:
- return $left > $right;
-
- case self::GREATER_OR_EQUALS:
- return $left >= $right;
-
- case self::LOWER_THAN:
- return $left < $right;
-
- case self::LOWER_OR_EQUALS:
- return $left <= $right;
-
- case self::SIMILAR_TO:
- return soundex($left) == soundex($right);
-
- case self::NOT_SIMILAR_TO:
- return soundex($left) != soundex($right);
-
- case self::EXPRESSION_AND:
- return $left && $right->toBoolean($form);
-
- case self::EXPRESSION_OR:
- return $left && $right->toBoolean($form);
-
- case self::LIKE:
- case self::NOT_LIKE:
- default:
- throw new UnsupportedMethodException();
- break;
- }
- }
- }
-?>
\ No newline at end of file
Deleted: src/classes/OSQL/LogicalObject.class.php
===================================================================
--- src/classes/OSQL/LogicalObject.class.php 2005-06-13 16:17:33 UTC (rev 468)
+++ src/classes/OSQL/LogicalObject.class.php 2005-06-13 16:26:54 UTC (rev 469)
@@ -1,18 +0,0 @@
-<?php
-/***************************************************************************
- * Copyright (C) 2004-2005 by Konstantin V. Arkhipov *
- * voxusAT@ATgentoo.org *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-/* $Id$ */
-
- interface LogicalObject extends SQLExpression
- {
- public function toBoolean(Form $form);
- }
-?>
\ No newline at end of file
Modified: src/global.inc.php.tpl
===================================================================
--- src/global.inc.php.tpl 2005-06-13 16:17:33 UTC (rev 468)
+++ src/global.inc.php.tpl 2005-06-13 16:26:54 UTC (rev 469)
@@ -41,6 +41,7 @@
set_include_path(
ONPHP_CLASSES . 'Base' . PATH_SEPARATOR .
ONPHP_CLASSES . 'Expression' . PATH_SEPARATOR .
+ ONPHP_CLASSES . 'Logic' . PATH_SEPARATOR .
ONPHP_CLASSES . 'OSQL' . PATH_SEPARATOR .
ONPHP_CLASSES . 'DAOs' . PATH_SEPARATOR .
ONPHP_CLASSES . 'Form' . PATH_SEPARATOR .
@@ -56,4 +57,4 @@
define('EXT_TPL', '.tpl.html');
define('EXT_MOD', '.inc.php');
define('EXT_HTML', '.html');
-?>
+?>
\ No newline at end of file
Received on Mon Jun 13 2005 - 20:26:55 MSD
This archive was generated by hypermail 2.2.0 : Sat Oct 27 2007 - 19:26:26 MSD