Creates string condition from known data
@param string[] $condition
@param string $parentModel
@param string $fullName
@return string
188681
protected function getColumnEqualWithParent($condition, $parentModel, $fullName) {
        if (is_array($condition[1]) && is_array($condition[2])) {
            $conditions = [];
            foreach ($condition[1] as $c1) {
                $conditions[] = $this->getColumnEqualWithParent([$condition[0], $c1, $condition[2]], $parentModel, $fullName);
            }
            return "(" . implode(") OR (", $conditions) . ")";
        }
        if (is_array($condition[1])) {
            $c = $condition[1];
            $condition[1] = $condition[2];
            $condition[2] = $c;
        }
        if (is_string($condition[2])) {
            return $this->_column($condition[1], true, $fullName) . ' ' . $condition[0] . ' ' . $this->_column($condition[2], false, $fullName);//@TODO: parse columns name;
        } else {
            foreach ($condition[2] as $k => $v) {
                $condition[2][$k] = $this->_column($v, false, $fullName);
            }
            return $this->_column($condition[1], true, $fullName) . ($condition[0] == '=' ? ' IN (' : ' NOT IN (') . implode(", ", $condition[2]) . ')';
        }
    }
468756
protected function getConditionQuery( $conditions, $usePrimary = TRUE, $useForeign = TRUE )
	{
		$new = array();
		foreach( $this->fields as $field )									//  iterate all Fields
			if( isset( $conditions[$field] ) )								//  if Condition given
				$new[$field] = $conditions[$field];							//  note Condition Pair
		if( $useForeign && count( $this->foreignFocuses ) )					//  if using Foreign Keys
			foreach( $this->foreignFocuses as $key => $value )				//  iterate focused Foreign Keys & is focused Foreign
				$new[$key] = $value; 										//  note foreign Key Pair

		if( $usePrimary && $this->isFocused() == 'primary' )				//  if using foreign Keys & is focused primary
			$new[$this->focusKey] = $this->focus;							//  note primary Key Pair

		$pattern	= '/^(<=|>=|<|>|!=)(.+)/';
		$conditions = array();
		foreach( $new as $key => $value )									//  iterate all noted Pairs
		{
			$operation	= ' = ';
			if( preg_match( '/%/', $value ) )
				$operation	= ' LIKE ';
			else if( preg_match( $pattern, $value ) )
			{
				$matches	= array();
				preg_match_all( $pattern, $value, $matches );
				$operation	= ' '.$matches[1][0].' ';
				$value		= $matches[2][0];
			}
			if( !ini_get( 'magic_quotes_gpc' ) )
			{
				$key	= addslashes( $key );
				$value	= addslashes( $value );
			}
			$conditions[] = '`'.$key.'`'.$operation."'".$value."'";			//  create SQL WHERE Condition
		}
		$conditions = implode( ' AND ', $conditions );						//  combine Conditions with AND
		return $conditions;
	}
1079909
public function setCondition($condition)
    {
        if ($condition === null) {
            $this->condition = $condition;
            return $this;
        }

        if (!is_string($condition)) {
            throw new InvalidArgumentException(
                'Custom expression must be a string.'
            );
        }

        $condition = trim($condition);
        if ($condition === '') {
            $condition = null;
        }

        $this->condition = $condition;
        return $this;
    }
709071
public static function createFolder($fullPath, $makeParents = true) {
		if (file_exists($fullPath)) {
			return true;
		} else {
			$result = mkdir($fullPath, self::MKDIR_MODE, $makeParents);
			if(!$result) {
				return false;
			}
		}
		return true;
	}
186256
protected function makeWhere(Condition $condition, array $data = NULL)
    {
        $data = $data === NULL
            ? $this->data
            : $data;

        return array_filter($data, function ($row) use ($condition) {
            if ($condition->callback) {
                return call_user_func_array($condition->callback, [$condition->value, $row]);
            }

            $i = 0;
            $results = [];
            foreach ($condition->column as $column) {
                if (Condition::isOperator($column)) {
                    $results[] = " $column ";

                } else {
                    $i = count($condition->condition) > 1 ? $i : 0;
                    $results[] = (int) $this->compare(
                        $row[$column],
                        $condition->condition[$i],
                        isset($condition->value[$i]) ? $condition->value[$i] : NULL
                    );

                    $i++;
                }
            }

            $result = implode('', $results);
            return count($condition->column) === 1
                ? (bool) $result
                : eval("return $result;"); // QUESTION: How to remove this eval? hmmm?
        });
    }
1114685
private function className(string $fullname) : string
  {
    $m = explode( '_', $fullname);
    $date = $m[0] . '_' . $m[1] . '_' . $m[2] . '_' . $m[3] . '_' . $m[4] . '_' . $m[5] . '_';

    $class = str_replace($date, '', $fullname);
    $class = implode('', array_map('ucfirst', explode('_', $class)));
    return $class;
  }
133206
protected function parseCondition(string $condition): string
    {
        $conditions = $this->getConditions();

        foreach ($conditions as $signature => $conds) {
            $conds = is_array($conds) ? $conds : [$conds];

            if (in_array($condition, $conds, true)) {
                return $signature;
            }
        }

        return '';
    }
976702
public function generate(string $fullName, int $limit = 8): array
    {
        $original = str_replace(' ', '', $fullName);
        if ($limit > strlen($original)) {
            return array();
        }

        if (-1 === $index = $this->isReservedName($fullName)) {
            return array();
        }

        $temp = explode(' ', strtoupper($fullName));
        if (2 > count($temp)) {
            return array();
        }

        $temp[$index] = $this->reservedNames[$temp[$index]];
        $fullName = substr(implode('', $temp), 0, $limit);
        if ($limit > strlen($fullName)) {
            $fullName = $original;
        } else {
            $original = $temp[$index];
        }

        return $this->shift($fullName, $original);
    }
979522
public static function arrWhere(Array $conditions)
    {

        $model = static::class;
        $obj = new $model();

        foreach ($conditions as $condition) {
            if (count($condition) == 2) {
                $obj = $obj->where($condition[0], $condition[1]);
            } elseif (count($condition) == 3) {
                if (strtolower(trim($condition[1])) === 'between') {
                    $obj = $obj->whereBetween($condition[0], $condition[2]);
                } else {
                    $obj = $obj->where($condition[0], $condition[1], $condition[2]);
                }
            } elseif (count($condition) == 4) {
                if (strtolower(trim($condition[1])) === 'between') {
                    $obj = $obj->whereBetween($condition[0], $condition[2], $condition[3]);
                } else {
                    $obj = $obj->where($condition[0], $condition[1], $condition[2], $condition[3]);
                }
            } else {
                throw new \Exception("Invalid " . strtoupper($key) . " condition", 1);
            }
        }

        return $obj;
    }
1063111
public static function render(SQL\Condition $condition)
    {
        $content = $condition->getContent();
        $parameters = $condition->getParameters();

        if ($parameters and is_string($content)) {
            $content = self::expandParameterArrays($content, $parameters);
        }

        return Compiler::expression(array(
            Compiler::name($condition->getColumn()),
            $content
        ));
    }
140
final public String getFullName(final String parent) {
    if (isEmptyLocalName()) {
      return parent;
    }
    
    StringBuilder fullName = new StringBuilder(parent);
    if (!parent.endsWith(Path.SEPARATOR)) {
      fullName.append(Path.SEPARATOR);
    }
    fullName.append(getLocalName());
    return fullName.toString();
  }
1045442
public static function find($condition=array(), $limit=array(), $order_by=array()) {
		self::$db = MVC::$db;

		if (empty(static::$table)) 
			$table = strtolower(substr(static::class, strpos(static::class, '\\')+1));
		else
			$table = static::$table;

		
		if (is_array(static::relational()) && count(static::relational()) > 0) {
			$relational = static::relational();
			if (isset($relational[0]) && !is_array($relational[0])) {
				$model = '\Model\\'.$relational[0];

				if ($table == $model::$table || empty($model::$table)) 
					$join_table = strtolower($relational[0]);
				else
					$join_table = $model::$table;

				if (count($relational) == 1)
					$condition['join'][] = ['natural', $join_table];
				elseif (count($relational) == 2)
					$condition['join'][] = ['left', $join_table, $relational[1]];
				elseif (count($relational) == 3)
					$condition['join'][] = ['left', $join_table, [$relational[1], $relational[2]]];

				$modeljoin = $relational[0];
				self::__join($modeljoin, $condition);
			} else {
				while(list($id, $relation) = each($relational) ) {
					$model = '\Model\\'.$relation[0];
					
					if ($table == $model::$table || empty($model::$table)) 
						$join_table = strtolower($relation[0]);
					else
						$join_table = $model::$table;

					if (count($relation) == 1)
						$condition['join'][] = ['natural', $join_table];
					elseif (count($relation) == 2)
						$condition['join'][] = ['left', $join_table, $relation[1]];
					elseif (count($relation) == 3)
						$condition['join'][] = ['left', $join_table, [$relation[1], $relation[2]]];
				}

				reset($relational);
				while (list($id, $relation) = each($relational)) {
					$modeljoin = $relation[0];
					self::__join($modeljoin, $condition);
				}
			}
		}
		
		if (!isset(self::$pid[self::$currentId])) {
			if (!isset($condition['callback']) && is_array(static::callback()) && count(static::callback()))
				$condition['callback'] = static::callback();
		}

		$rows = self::$db->$table->find($condition, $limit, $order_by);
		return $rows;
	}
641871
public function createConditionGroup($conditionString): ConditionGroup {
        $mainConditionGroup = null;
        $conditionGroupStack = [];
        $currentBasicConditionElement = null;

        $pos = 0;
        while ($pos < strlen($conditionString)) {
            if ($conditionString[$pos] == self::CONDITION_ELEMENT_ARGUMENT_SEPARATOR) {
                if (empty($conditionGroupStack) && $mainConditionGroup != null && sizeof($mainConditionGroup->conditions()) > 1) {
                    $childConditionGroup = $mainConditionGroup;
                    $mainConditionGroup = new ConditionGroup();
                    $mainConditionGroup->onGroup($childConditionGroup);
                }
                $pos++;
                continue;
            }

            $nextEndPos = strpos($conditionString, self::CONDITION_ELEMENT_END, $pos);
            $nextStartPos = strpos($conditionString, self::CONDITION_ELEMENT_START, $pos);
            if ($nextStartPos !== false) {
                if ($nextEndPos === false || $nextStartPos < $nextEndPos) {
                    $type = substr($conditionString, $pos, $nextStartPos - $pos);
                    if (empty($type)) {
                        $type = self::CONDITION_TYPE_ON;
                    }

                    switch ($type) {
                        case self::CONDITION_TYPE_AND:
                        case self::CONDITION_TYPE_OR:
                            //Se esta comenzando una condicion de tipo grupo
                            $currentConditionGroup = new ConditionGroup();
                            $currentConditionGroup->connector(($type == self::CONDITION_TYPE_AND) ? ConditionGroup::CONNECTOR_AND : ConditionGroup::CONNECTOR_OR);
                            array_push($conditionGroupStack, $currentConditionGroup);
                            break;
                        default:
                            //Se esta comenzando una condicion básica
                            $currentBasicConditionElement = [];
                            $currentBasicConditionElement["type"] = $type;
                            $currentBasicConditionElement["start"] = $nextStartPos;
                            break;
                    }
                    $pos = $nextStartPos + 1;
                }
            }
            if ($nextEndPos !== false) {
                if ($nextStartPos === false || $nextEndPos < $nextStartPos) {
                    if (!empty($currentBasicConditionElement)) {
                        //Se esta finalizando una condición básica
                        $type = $currentBasicConditionElement["type"];
                        $startPos = $currentBasicConditionElement["start"];
                        $endPos = $nextEndPos;

                        $lastConditionGroup = end($conditionGroupStack);
                        if ($lastConditionGroup === false) {
                            if ($mainConditionGroup == null) {
                                $mainConditionGroup = new ConditionGroup();
                            }
                            $lastConditionGroup = $mainConditionGroup;
                        }

                        $arguments = explode(self::CONDITION_ELEMENT_ARGUMENT_SEPARATOR, substr($conditionString, $startPos+1, ($endPos - $startPos)-1));

                        switch ($type) {
                            case self::CONDITION_TYPE_ON:
                                call_user_func_array([$lastConditionGroup, "on"], $arguments);
                                break;
                            case self::CONDITION_TYPE_FIELD:
                                call_user_func_array([$lastConditionGroup, "onField"], $arguments);
                                break;
                            case self::CONDITION_TYPE_NULL:
                                call_user_func_array([$lastConditionGroup, "onNull"], $arguments);
                                break;
                            case self::CONDITION_TYPE_NOTNULL:
                                call_user_func_array([$lastConditionGroup, "onNotNull"], $arguments);
                                break;
                            default:
                                throw new RuntimeException("Unrecognized condition type \"$type\" !!");
                        }

                        $currentBasicConditionElement = null;
                    }
                    else {
                        //Se esta finalizando una condición de tipo grupo
                        $lastConditionGroup = array_pop($conditionGroupStack);
                        if ($lastConditionGroup === false) {
                            throw new RuntimeException("Syntax error while closing condition element");
                        }

                        if ($mainConditionGroup == null) {
                            $mainConditionGroup = $lastConditionGroup;
                        }
                        else if ($lastConditionGroup != $mainConditionGroup) {
                            $parentConditionGroup = end($conditionGroupStack);
                            if ($parentConditionGroup === false) {
                                if ($mainConditionGroup == null) {
                                    $mainConditionGroup = new ConditionGroup();
                                }
                                $parentConditionGroup = $mainConditionGroup;
                            }

                            $parentConditionGroup->onGroup($lastConditionGroup);
                        }
                    }
                    $pos = $nextEndPos + 1;
                }
            }
            else {
                $pos = strlen($conditionString);
            }
        }

        return $mainConditionGroup;
    }
160818
protected function splitFullPropName($fullPropName)
    {
        $propInfo = explode(ILocalizedProperty::LOCALE_SEPARATOR, $fullPropName);
        $propName = $propInfo[0];
        $localeId = isset($propInfo[1]) ? $propInfo[1] : null;

        return [$propName, $localeId];
    }
184746
public function getSearchCondition(): SearchCondition
    {
        if ($this->parent) {
            return $this->parent->getSearchCondition();
        }

        // This the root of the condition so now traverse back up the hierarchy.
        // We need to re-create the condition using actual objects.
        $rootValuesGroup = new ValuesGroup($this->valuesGroup->getGroupLogical());
        $this->normalizeValueGroup($this->valuesGroup, $rootValuesGroup);

        return new SearchCondition($this->fieldSet, $rootValuesGroup);
    }
44494
protected function parseCondition($condition)
    {
        $tableAlias = $this->getAlias();
        $parts = [];

        if ($condition instanceof QueryBuilderAwareInterface) {
            $condition->setQueryBuilder($this);
        }

        if ($condition instanceof Expression) {
            $parts[] = $this->getAdapter()->quoteSql($condition->toSQL());
        } elseif ($condition instanceof Q) {
            $condition->setLookupBuilder($this->getLookupBuilder());
            $condition->setAdapter($this->getAdapter());
            $condition->setTableAlias($tableAlias);
            $parts[] = $condition->toSQL();
        } elseif ($condition instanceof ToSqlInterface) {
            $parts[] = $condition->toSQL();
        } elseif (is_array($condition)) {
            foreach ($condition as $key => $value) {
                if ($value instanceof Q) {
                    $parts[] = $this->parseCondition($value);
                } else {
                    list($lookup, $column, $lookupValue) = $this->lookupBuilder->parseLookup($this, $key, $value);
                    $column = $this->getLookupBuilder()->fetchColumnName($column);
                    if (false === empty($tableAlias) && false === strpos($column, '.')) {
                        $column = $tableAlias.'.'.$column;
                    }
                    $parts[] = $this->lookupBuilder->runLookup($this->getAdapter(), $lookup, $column, $lookupValue);
                }
            }
        } elseif (is_string($condition)) {
            $parts[] = $condition;
        } elseif ($condition instanceof Expression) {
            $parts[] = $condition->toSQL();
        }

        if (1 === count($parts)) {
            return $parts[0];
        }

        return '('.implode(') AND (', $parts).')';
    }
1016789
public function buildSelectString($whereCondition = null)
    {
        $database = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();

        $get = $this->getSelectFields();
        $query = "select $get from " . $this->getViewName() . ' where 1 ';

        if ($whereCondition) {
            reset($whereCondition);
            foreach ($whereCondition as $name => $value) {
                $query .= ' and ' . $name . ' = ' . $database->quote($value);
            }
        }

        return $query;
    }