TemplateConverterHelper::GetNewTagContent PHP Méthode

GetNewTagContent() public static méthode

public static GetNewTagContent ( array $p_optArray, $p_tplPath = null )
$p_optArray array
    public static function GetNewTagContent($p_optArray, $p_tplPath = null)
    {
        if (!is_array($p_optArray) || sizeof($p_optArray) < 1) {
            continue;
        }
        $newTag = '';
        $p_optArray[0] = strtolower($p_optArray[0]);
        // <!** Print statement ... > to {{ $campsite->statement ... }}
        if ($p_optArray[0] == 'print') {
            return self::BuildPrintStatement($p_optArray);
        }
        // Environmental Objects
        // <!** Publication name ... > to {{ set_publication name= ... }}
        // <!** Issue off ... > to {{ unset_issue }}
        if (in_array($p_optArray[0], self::$m_envObjects)) {
            return self::BuildEnvironmentalStatement($p_optArray);
        }
        // URI and URL Functions
        // <!** URI> to {{ uri }}
        // <!** URLParameters section> to {{ urlparameters options="section" }}
        if (in_array($p_optArray[0], self::$m_urXFuncs)) {
            return self::BuildUrxStatement($p_optArray);
        }
        // User, Search and Login Forms
        // <!** Search do-search.tpl Go>
        // to
        // {{ search_form template="do-search.tpl" submit_button="Go" }}
        if (in_array($p_optArray[0], self::$m_simpleForms)) {
            return self::BuildSimpleFormStatement($p_optArray);
        }
        // Article Comment Form
        // <!** ArticleCommentForm ArtCommForm.tpl Send Preview>
        // to
        // {{ article_comment_form template="ArtCommForm.tpl"
        //    submit_button="Send" preview_button="Preview" }}
        if ($p_optArray[0] == 'articlecommentform') {
            return self::BuildArticleCommentFormStatement($p_optArray);
        }
        // Subscription Comment Form
        // <!** Subscription by_section do-subsc.tpl Subscribe>
        // to
        // {{ subscription_form type="by_section" template="do-subsc.tpl"
        //    submit_button="Subscribe" }}
        if ($p_optArray[0] == 'subscription') {
            return self::BuildSubscriptionFormStatement($p_optArray);
        }
        // End forms
        // <!** EndSearch> to {{ /search_form }}
        if (in_array($p_optArray[0], self::$m_endForms)) {
            return self::BuildEndFormStatement($p_optArray);
        }
        // Edit form fields
        // <!** Edit Login uname>
        // <!** Edit Search keywords>
        if ($p_optArray[0] == 'edit') {
            return self::BuildEditStatement($p_optArray);
        }
        // Select form fields
        // <!** Select Login RememberLogin>
        // to
        // {{ camp_select object="login" attribute="rememberlogin" }}
        //
        // <!** Select User gender male female>
        // to
        // {{ camp_select object="user" attribute="gender" male_name="M" female_name="M" }}
        if ($p_optArray[0] == 'select') {
            return self::BuildSelectStatement($p_optArray);
        }
        // HTML Encoding
        // <!** HTMLEncoding> to {{ enable_html_encoding }}
        // <!** HTMLEncoding off> to {{ disable_html_encoding }}
        if ($p_optArray[0] == 'htmlencoding') {
            return self::BuildHTMLEncodingStatement($p_optArray);
        }
        if ($p_optArray[0] == 'with' || $p_optArray[0] == 'endwith') {
            return self::BuildWithStatement($p_optArray);
        }
        switch ($p_optArray[0]) {
            // <!** Date ... > to {{ $smarty.now|camp_date_format:" ... " }}
            case 'date':
                $newTag = '$smarty.now|camp_date_format:"' . $p_optArray[1] . '"';
                break;
                // <!** include header.tpl> to {{ include file="header.tpl" }}
                // <!** include article.tpl> to {{ include file="news/article.tpl" }}
            // <!** include header.tpl> to {{ include file="header.tpl" }}
            // <!** include article.tpl> to {{ include file="news/article.tpl" }}
            case 'include':
                $filePath = !is_null($p_tplPath) ? $p_tplPath . '/' . $p_optArray[1] : $p_optArray[1];
                $newTag = 'include file="' . $filePath . '"';
                break;
                // <!** local> to {{ local }}
            // <!** local> to {{ local }}
            case 'local':
                $newTag = 'local';
                break;
                // <!** endLocal> to {{ /local }}
            // <!** endLocal> to {{ /local }}
            case 'endlocal':
                $newTag = '/local';
                break;
                // <!** else> to {{ /else }}
            // <!** else> to {{ /else }}
            case 'else':
                $newTag = 'else';
                break;
        }
        return $newTag;
    }

Usage Example

    /**
     * @param array $p_optArray
     */
    private function getNewTagContent($p_optArray, $p_oldTagContent = null)
    {
        if (!is_array($p_optArray) || sizeof($p_optArray) < 1) {
            return;
        }

        $newTag = '';
        $p_optArray[0] = strtolower($p_optArray[0]);

        if ($p_optArray[0] == 'list'|| $p_optArray[0] == 'foremptylist'
                || strpos($p_optArray[0], 'endlist') !== false) {
            $newTag = TemplateConverterListObject::GetNewTagContent($p_optArray);
        } elseif ($p_optArray[0] == 'if' || $p_optArray[0] == 'endif') {
            $newTag = TemplateConverterIfBlock::GetNewTagContent($p_optArray);
        } else {
            if (in_array($p_optArray[0], array('uri','uripath','url','urlparameters'))) {
                $newTag = TemplateConverterHelper::GetNewTagContent($p_optArray);
            } else {
                return TemplateConverterHelper::GetNewTagContent($p_optArray, $this->m_templateDirectory);
            }
        }

        if (strlen($newTag) > 0) {
            $pattern = '/<!\*\*\s*'.@preg_quote($p_oldTagContent).'\s*>/';
            $replacement = CS_OPEN_TAG.' '.$newTag.' '.CS_CLOSE_TAG;
            $this->m_templateOriginalContent = @preg_replace($pattern,
                                                             $replacement,
                                                             $this->m_templateOriginalContent,
                                                             1);
            return null;
        }

        return false;
    } // fn getNewTagContent