Render a full condition

@param \FreeFW\Model\Condition $p_condition

@throws \FreeFW\Core\FreeFWStorageException
509680
protected function renderCondition(\FreeFW\Model\Condition $p_condition)
    {
        $result = [];
        $left   = $p_condition->getLeftMember();
        $right  = $p_condition->getRightMember();
        $oper   = $p_condition->getOperator();
        switch ($oper) {
            case \FreeFW\Storage\Storage::COND_LOWER:
            case \FreeFW\Storage\Storage::COND_LOWER_EQUAL:
            case \FreeFW\Storage\Storage::COND_GREATER:
            case \FreeFW\Storage\Storage::COND_GREATER_EQUAL:
            case \FreeFW\Storage\Storage::COND_EQUAL:
                if ($left !== null && $right !== null) {
                    $leftDatas  = $this->renderConditionField($left);
                    $rightDatas = $this->renderConditionField($right);
                    $result = [
                        'sql'    => $leftDatas['id'] . ' ' . $oper . ' ' . $rightDatas['id'],
                        'values' => [],
                        'type'   => false
                    ];
                    if ($leftDatas['type'] === false) {
                        $result['values'][$leftDatas['id']] = $leftDatas['value'];
                    } else {
                        $result['type'] = $leftDatas['type'];
                    }
                    if ($rightDatas['type'] === false) {
                        $result['values'][$rightDatas['id']] = $rightDatas['value'];
                    } else {
                        $result['type'] = $rightDatas['type'];
                    }
                } else {
                    throw new \FreeFW\Core\FreeFWStorageException(
                        sprintf('Wrong fields for %s condition', $oper)
                    );
                }
                break;
            default:
                throw new \FreeFW\Core\FreeFWStorageException(
                    sprintf('Unknown condition : %s !', $oper)
                );
                break;
        }
        return $result;
    }
318073
protected function parseActionCondition($condition, $action = null, $renderer = null)
    {
        unset($action);

        if ($renderer === null) {
            $renderer = $this->getActionRenderer();
        }

        if (is_bool($condition)) {
            return $condition;
        } elseif (is_string($condition)) {
            $not = ($condition[0] === '!');
            if ($not) {
                $condition = ltrim($condition, '!');
            }

            $result = null;
            if ($renderer && is_callable([ $renderer, $condition ])) {
                $result = !!$renderer->{$condition}();
            } elseif (is_callable([ $this, $condition ])) {
                $result = !!$this->{$condition}();
            } elseif (is_callable($condition)) {
                $result = !!$condition();
            } elseif ($renderer) {
                $result = !!$renderer->renderTemplate($condition);
            }

            if ($result !== null) {
                return $not ? !$result : $result;
            }
        }

        return $condition;
    }
567555
private function _processConditionArray()
	{
		foreach($this->conditionArray as $conditions)
		{
			foreach($conditions as $operator => $condition)
			{
				if(!is_string($operator))
				{
					$this->conditionString .= $condition . ' ';
				}
				else
				{
					$this->conditionString .= strtoupper($operator) . ' ' . $condition . ' ';
				}
			}
		}
	}
232192
public function isTrue($condition, Blueprint $sourceBlueprint=null)
    {
        // resolve placeholders
        $condition = $this->valueResolver->resolvePlaceholders($condition, $sourceBlueprint, 'conditional_value', $condition);

        if ($condition == 'default') {
            return true;
        }
        if (strpos($condition, '==') !== false) {
            list($left, $right) = explode('==', $condition, 2);
            $left = trim($left);
            $right = trim($right);
            return ($left == $right);
        } elseif (strpos($condition, '!=') !== false) {
            list($left, $right) = explode('!=', $condition, 2);
            $left = trim($left);
            $right = trim($right);
            return ($left != $right);
        } elseif (strpos($condition, '~=') !== false) {
            list($subject, $pattern) = explode('~=', $condition, 2);
            $subject = trim($subject);
            $pattern = trim($pattern);
            return preg_match($pattern, $subject);
        }
        throw new \Exception('Invalid condition: ' . $condition);
    }
962251
public function render(): void
    {
        $useSession = $this->useSession && \session_status() === PHP_SESSION_ACTIVE;
        $redirectQueue = &$_SESSION['_tracy']['redirect'];

        foreach (['bar', 'redirect', 'bluescreen'] as $key) {
            $queue = &$_SESSION['_tracy'][$key];
            $queue = \array_slice((array) $queue, -10, null, true);
            $queue = \array_filter($queue, function ($item) {
                return isset($item['time']) && $item['time'] > \time() - 60;
            });
        }

        $rows = [];

        if (Helpers::isAjax()) {
			if ($useSession) {
				$rows[] = (object) ['type' => 'ajax', 'panels' => $this->renderPanels('-ajax')];
				$contentId = $_SERVER['HTTP_X_TRACY_AJAX'] . '-ajax';
				$_SESSION['_tracy']['bar'][$contentId] = ['content' => self::renderHtmlRows($rows), 'dumps' => Dumper::fetchLiveData(), 'time' => \time()];
			}
        } elseif (Helpers::isRedirect()) { // redirect
            if ($useSession) {
				Dumper::fetchLiveData();
				Dumper::$livePrefix = \count($redirectQueue) . 'p';
				$redirectQueue[] = [
					'panels' => $this->renderPanels('-r' . \count($redirectQueue)),
					'dumps' => Dumper::fetchLiveData(),
					'time' => \time(),
				];
			}
		} elseif (Helpers::isHtmlMode()) {
            $rows[] = (object) ['type' => 'main', 'panels' => $this->renderPanels()];
            $dumps = Dumper::fetchLiveData();
            foreach (\array_reverse((array) $redirectQueue) as $info) {
                $rows[] = (object) ['type' => 'redirect', 'panels' => $info['panels']];
                $dumps += $info['dumps'];
            }
            $redirectQueue = null;
            $content = self::renderHtmlRows($rows);

            if ($this->contentId) {
                $_SESSION['_tracy']['bar'][$this->contentId] = ['content' => $content, 'dumps' => $dumps, 'time' => time()];
			} else {
				$contentId = \substr(\md5(\uniqid('', true)), 0, 10);
				$nonce = Helpers::getNonce();
				$async = false;
				require __DIR__ . '/assets/Bar/loader.phtml';
			}
        }
    }
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
        ));
    }
911251
private function cleanCondition($condition)
    {
        if (is_array($condition)) {
            $condition = array_filter($condition);
            if (empty($condition)) {
                $condition = null;
            }
        }

        return $condition;
    }
308400
public void fillAllConditions(Condition condition) {
        if (_valueColumns != null) {
            final Condition[] conditions = new Condition[_valueColumns.length];
            Arrays.fill(conditions, condition);
            _conditions = conditions;
        }
    }
673745
private void paintCondition(final Condition condition, final XmlStringBuilder xml) {
		if (condition instanceof And) {
			xml.appendTag("ui:and");

			for (Condition operand : ((And) condition).getConditions()) {
				paintCondition(operand, xml);
			}

			xml.appendEndTag("ui:and");
		} else if (condition instanceof Or) {
			xml.appendTag("ui:or");

			for (Condition operand : ((Or) condition).getConditions()) {
				paintCondition(operand, xml);
			}

			xml.appendEndTag("ui:or");
		} else if (condition instanceof Not) {
			xml.appendTag("ui:not");
			paintCondition(((Not) condition).getCondition(), xml);
			xml.appendEndTag("ui:not");
		} else if (condition instanceof AbstractCompare) {
			AbstractCompare compare = (AbstractCompare) condition;
			xml.appendTagOpen("ui:condition");
			xml.appendAttribute("controller", compare.getTrigger().getId());
			xml.appendAttribute("value", compare.getComparePaintValue());
			xml.appendOptionalAttribute("operator", getCompareTypeName(compare.getCompareType()));
			xml.appendEnd();
		} else {
			throw new SystemException("Unknown condition: " + condition);
		}
	}
1210705
private function addCondition($key, $condition, $value)
    {
        if (!isset($this->where[$key]))
        {
            $this->where[$key] = array();
        }
        $this->where[$key][$condition] = AVClient::_encode($value, true);
    }
700818
public function endIf(bool $condition, ?callable $callback = null): void
    {
        if ((bool) $condition) {
            $this->end($callback);
        }
    }
141867
protected function get_qubaids_condition() {
        if (is_null($this->rawdata)) {
            throw new coding_exception(
                    'Cannot call get_qubaids_condition until the main data has been loaded.');
        }

        if ($this->is_downloading()) {
            // We want usages for all attempts.
            return new qubaid_join("(
                SELECT DISTINCT quiza.uniqueid
                  FROM " . $this->sql->from . "
                 WHERE " . $this->sql->where . "
                    ) quizasubquery", 'quizasubquery.uniqueid',
                    "1 = 1", $this->sql->params);
        }

        $qubaids = array();
        foreach ($this->rawdata as $attempt) {
            if ($attempt->usageid > 0) {
                $qubaids[] = $attempt->usageid;
            }
        }

        return new qubaid_list($qubaids);
    }
612789
public function addCondition(Condition $condition): Condition
    {
        $query = $this->connection->createQueryBuilder()
            ->insert('ngbm_rule_condition')
            ->values(
                [
                    'id' => ':id',
                    'status' => ':status',
                    'rule_id' => ':rule_id',
                    'type' => ':type',
                    'value' => ':value',
                ]
            )
            ->setValue(
                'id',
                $condition->id !== null ?
                    (int) $condition->id :
                    $this->connectionHelper->getAutoIncrementValue('ngbm_rule_condition')
            )
            ->setParameter('status', $condition->status, Type::INTEGER)
            ->setParameter('rule_id', $condition->ruleId, Type::INTEGER)
            ->setParameter('type', $condition->type, Type::STRING)
            ->setParameter('value', json_encode($condition->value), Type::STRING);

        $query->execute();

        $condition->id = $condition->id ?? (int) $this->connectionHelper->lastInsertId('ngbm_rule_condition');

        return $condition;
    }
1017545
function remove( $conditions = null, $extraConditions = null )
    {
        if ( $this->attribute( 'version' ) == eZPDFExport::VERSION_VALID &&
             $this->attribute( 'status' ) != eZPDFExport::CREATE_ONFLY )
        {
            $sys = eZSys::instance();
            $storage_dir = $sys->storageDirectory();

            $filename = $storage_dir . '/pdf/' . $this->attribute( 'pdf_filename' );
            if ( file_exists( $filename ) )
            {
                unlink( $filename );
            }
        }
        parent::remove( $conditions, $extraConditions);
    }
189698
public void addCondition(final Condition condition) {
        if (conditions_ == null) {
            conditions_ = new ArrayList<>();
        }
        conditions_.add(condition);
    }
1306736
protected function processTokenCondition($condition)
    {
        if (false === $this->condition->hasCondition($condition)) {
            $this->addError('The condition "' . $condition . '" does not exist.', self::ERROR_CODE_CONDITION_NOT_FOUND);
        } else {
            $node = new ConditionNode($condition, $this->condition->getCondition($condition));
            $this->scope
                ->setNode($node)
                ->shiftExpression();
        }
    }
952988
public function _render_where($kind)
    {
        $ret = array();
        foreach ($this->args[$kind] as $row) {
            list($field, $cond, $value) = $row;

            if (is_object($field)) {
                // if first argument is object, condition must be explicitly
                // specified
                $field = $this->consume($field);
            } else {
                list($table, $field) = explode('.', $field, 2);
                if ($field) {
                    if ($this->mode == 'delete') {
                        $field = $this->bt($field);
                    } else {
                        $field = $this->bt($table).'.'.$this->bt($field);
                    }
                } else {
                    $field = $this->bt($table);
                }
            }

            // no value or condition passed, so this should be SQL chunk itself
            if ($value === UNDEFINED && $cond === UNDEFINED) {
                $r = $field;
                $ret[] = $r;
                continue;
            }

            // if no condition defined - set default condition
            if ($value === UNDEFINED) {
                $value = $cond;
                if (is_array($value)) {
                    $cond = 'in';
                } elseif (is_object($value) && @$value->mode === 'select') {
                    $cond = 'in';
                } else {
                    $cond = '=';
                }
            } else {
                $cond = trim(strtolower($cond));
            }

            // special conditions if value is null
            if ($value === null) {
                if ($cond === '=') {
                    $cond = 'is';
                } elseif (in_array($cond, array('!=', '<>', 'not'))) {
                    $cond = 'is not';
                }
            }

            // value should be array for such conditions
            if (($cond === 'in' || $cond === 'not in') && is_string($value)) {
                $value = explode(',', $value);
            }

            // if value is array, then use IN or NOT IN as condition
            if (is_array($value)) {
                $v = array();
                foreach ($value as $vv) {
                    $v[] = $this->escape($vv);
                }
                $value = '('.implode(',', $v).')';
                $cond = in_array($cond, array('!=', '<>', 'not', 'not in')) ? 'not in' : 'in';
                $r = $this->consume($field).' '.$cond.' '.$value;
                $ret[] = $r;
                continue;
            }

            // if value is object, then it should be DSQL itself
            // otherwise just escape value
            if (is_object($value)) {
                $value = $this->consume($value);
            } else {
                $value = $this->escape($value);
            }

            $r = $field.' '.$cond.' '.$value;
            $ret[] = $r;
        }

        return $ret;
    }