TemplateConverterHelper::GetWithBodyField PHP Méthode

GetWithBodyField() public static méthode

public static GetWithBodyField ( )
    public static function GetWithBodyField()
    {
        return self::$m_withBodyField;
    }

Usage Example

    /**
     * @param array $p_optArray
     */
    private function parse($p_optArray)
    {
        if (isset($p_optArray[1]) && strtolower($p_optArray[1]) == 'not') {
            $condType = true;
            $idx = 2;
        } else {
            $condType = false;
            $idx = 1;
        }

        if (!isset($p_optArray[$idx])) {
            return;
        }

        $sentence = array_key_exists(strtolower($p_optArray[$idx]), $this->m_sentences) ? strtolower($p_optArray[$idx]) : '';
        $object = array_key_exists(strtolower($p_optArray[$idx]), $this->m_objects) ? strtolower($p_optArray[$idx]) : '';

        $ifBlockStr = '';
        $openBracket = false;
        if (strlen($sentence) > 0) {
            $this->m_ifBlock = $sentence;
            if ($sentence == 'nextsubtitles' || $sentence == 'prevsubtitles') {
                if (TemplateConverterHelper::GetWithArticleType() != '') {
                    $this->m_sentences[$sentence]['attribute'] = preg_replace('/#type_name#/', TemplateConverterHelper::GetWithArticleType(), $this->m_sentences[$sentence]['attribute']);
                }
            } elseif($sentence == 'currentsubtitle') {
                if (TemplateConverterHelper::GetWithBodyField() != '') {
                    $this->m_sentences[$sentence]['condition'] = preg_replace('/#field_name#/', TemplateConverterHelper::GetWithBodyField(), $this->m_sentences[$sentence]['condition']);
                }
            }

            $ifBlockStr.= '->'.$this->m_sentences[$sentence]['new_object'];
            $ifBlockStr.= '->'.$this->m_sentences[$sentence]['attribute'];
            if (isset($this->m_sentences[$sentence]['condition'])) {
                $ifBlockStr.= $this->m_sentences[$sentence]['condition'];
            }
            $idx++;
        }

        if (strlen($object) > 0) {
            $objectIdx = $idx;
            $idx++;
            $attribute = (isset($p_optArray[$idx])) ? strtolower($p_optArray[$idx]) : '';
            if ($attribute == 'fromstart') {
                $ifBlockStr.= '->default_'.$object.' == '.CS_OBJECT.'->'.$object;
            } else {
                if (array_key_exists($attribute, $this->m_objects[$object])) {
                    if (is_array($this->m_objects[$object][$attribute])) {
                        $ifBlockStr.= (isset($this->m_objects[$object][$attribute]['new_object'])) ? '->'.$this->m_objects[$object][$attribute]['new_object'] : '->'.$object;
                        $ifBlockStr.= (isset($this->m_objects[$object][$attribute]['attribute'])) ? '->'.$this->m_objects[$object][$attribute]['attribute'] : '->'.$attribute;
                    } else {
                        $ifBlockStr.= '->'.$object.'->'.$attribute;
                    }
                } else {
                    if ($object == 'image' && is_numeric($attribute)) {
                        $ifBlockStr.= '->article->has_image('.$attribute.')';
                    } else {
                        $numElements = sizeof($p_optArray);
                        if (isset($p_optArray[$numElements - 2]) && array_key_exists($p_optArray[$numElements - 2], $this->m_operators)) {
                            $operatorIdx = $numElements - 2;
                            if ($operatorIdx > $objectIdx) {
                                $numIdentifiers = $operatorIdx - $objectIdx;
                                if ($numIdentifiers == 3) {
                                    $type = $attribute;
                                    $attribute = $p_optArray[$idx+1];
                                    $ifBlockStr.= '->'.$object.'->type->'.$type.'->'.$attribute;
                                    $idx++;
                                } elseif ($numIdentifiers == 2) {
                                    $ifBlockStr.= '->'.$object.'->'.$attribute;
                                }
                            }

                        } else {
                            $ifBlockStr.= '->'.$object.'->'.$attribute;
                        }
                    }
                }
            }

            $idx++;
            //
            $operator = (isset($p_optArray[$idx]) && array_key_exists(strtolower($p_optArray[$idx]), $this->m_operators)) ? $this->m_operators[strtolower($p_optArray[$idx])] : '';
            if (strlen($operator) > 0) {
                $ifBlockStr.= ' '.$operator;
                $idx++;
            } elseif ($object == 'list' && ($attribute == 'row'
                                                || $attribute == 'column'
                                                || $attribute == 'index')) {
                $p_optArray[$idx] = isset($p_optArray[$idx]) ? strtolower($p_optArray[$idx]) : '';
                if (isset($p_optArray[$idx]) && ($p_optArray[$idx] == 'odd' || $p_optArray[$idx] == 'even')) {
                    $ifBlockStr.= ' is '.$p_optArray[$idx];
                    $idx++;
                } elseif(isset($p_optArray[$idx])) {
                    $ifBlockStr.= ' == '.$p_optArray[$idx++];
                    for ($i = $idx; $i < sizeof($p_optArray); $i++) {
                        $ifBlockStr.= ' || '.CS_OBJECT.'->current_list->'.$attribute.' == '.$p_optArray[$i];
                        $idx++;
                    }
                    if ($condType == true) {
                        $ifBlockStr.= ')';
                        $openBracket = true;
                    }
                }
            }

            //
            $value = (isset($p_optArray[$idx])) ? $p_optArray[$idx] : null;
            if (isset($p_optArray[$idx])) {
                if (!empty($p_optArray[$idx])) {
                    $value = $p_optArray[$idx];
                } else {
                    $value = '""';
                }
            }
            if (!is_null($value)) {
                if ($value == '""') $value = '';
                $value = (is_numeric($value)) ? $value : '"'.$value.'"';
                $ifBlockStr.= (strlen($operator) <= 0) ? ' == '.$value : ' '.$value;
                $idx++;
            }
        }

        for ($x = $idx; $x < sizeof($p_optArray); $x++) {
            $ifBlockStr.= ' '.$p_optArray[$x];
        }

        if (strlen($ifBlockStr) > 0) {
            $this->m_ifBlockStr = ($condType == true) ? 'if ! ' : 'if ';
            if ($openBracket == true) {
                $this->m_ifBlockStr.= '(';
            }
            $this->m_ifBlockStr.= CS_OBJECT . $ifBlockStr;
        }

        if (!empty($this->m_ifBlockStr)) {
            $this->m_endIfBlock = '/if';
        }
    } // fn parse