00001 <?php 00002 /**************************************************************************** 00003 * Copyright (C) 2004-2007 by Konstantin V. Arkhipov, Anton E. Lebedevich * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU Lesser General Public License as * 00007 * published by the Free Software Foundation; either version 3 of the * 00008 * License, or (at your option) any later version. * 00009 * * 00010 ****************************************************************************/ 00011 /* $Id: EqualsLowerExpression.class.php 4687 2007-12-09 18:57:18Z voxus $ */ 00012 00016 final class EqualsLowerExpression implements LogicalObject, MappableObject 00017 { 00018 private $left = null; 00019 private $right = null; 00020 00021 public function __construct($left, $right) 00022 { 00023 $this->left = $left; 00024 $this->right = $right; 00025 } 00026 00027 public function toDialectString(Dialect $dialect) 00028 { 00029 return 00030 '(' 00031 .$dialect->toFieldString( 00032 SQLFunction::create('lower', $this->left) 00033 ) 00034 .' = ' 00035 .$dialect->toValueString( 00036 SQLFunction::create('lower', $this->right) 00037 ) 00038 .')'; 00039 } 00040 00044 public function toMapped(StorableDAO $dao, JoinCapableQuery $query) 00045 { 00046 return new self( 00047 $dao->guessAtom($this->left, $query), 00048 $dao->guessAtom($this->right, $query) 00049 ); 00050 } 00051 00052 public function toBoolean(Form $form) 00053 { 00054 $left = $form->toFormValue($this->left); 00055 $right = $form->toFormValue($this->right); 00056 00057 $both = 00058 (null !== $left) 00059 && (null !== $right); 00060 00061 return $both && (mb_strtolower($left) === mb_strtolower($right)); 00062 } 00063 } 00064 ?>