Ignore:
Timestamp:
2012/01/23 04:49:37 (12 years ago)
Author:
Seasoft
Message:

#1613 (ソース整形・ソースコメントの改善)

  • Zend Framework PHP 標準コーディング規約への準拠を高めた
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_12-dev/data/class/plugin/SC_Plugin_Template_Transformer.php

    r21416 r21420  
    6161        $html = file_get_contents(SMARTY_TEMPLATES_REALDIR . $tmpl); 
    6262        $err_msg = null; 
    63          
     63 
    6464        // 対象のパスが存在するかを検証する, 
    6565        if ($html === false) { 
     
    6868            $err_msg = $tmpl. "の文字コードがUTF-8ではありません"; 
    6969        } 
    70          
     70 
    7171        if (!is_null($err_msg)) { 
    7272            // TODO エラー処理 
     
    7474 
    7575        // JavaScript内にSmartyのタグが存在するものを、コメント形式に置換 
    76         $html = preg_replace_callback( 
    77             '/<script.+?\/script>/s', 
    78             array($this, 'captureSmartyTags2Comment'), 
    79             $html 
    80         ); 
     76    $html = preg_replace_callback( 
     77    '/<script.+?\/script>/s', 
     78    array($this, 'captureSmartyTags2Comment'), 
     79    $html 
     80    ); 
    8181 
    8282        // HTMLタグ内にSmartyのタグが存在するものを、いったんダミーのタグに置換する 
     
    9393            $html 
    9494        ); 
    95          
     95 
    9696        $html = '<meta http-equiv="content-type" content="text/html; charset=UTF-8" /><html><body><!--TemplateTransformer start-->'.$html.'<!--TemplateTransformer end--></body></html>'; 
    9797        // TODO エラー処理 
     
    213213    function scanChild(DOMNode $objDOMElement, $parent_selector = '') { 
    214214        $objNodeList = $objDOMElement->childNodes; 
    215          
     215 
    216216        if (is_null($objNodeList)) return; 
    217217        foreach ($objNodeList as $element) { 
    218              
     218 
    219219            $arrAttr = array(); 
    220220            // エレメントの場合、tag名を配列に入れる. 
     
    222222                $arrAttr[] = $element->tagName; 
    223223            } 
    224              
     224 
    225225            // getAttributeメソッドを持つかを検証 
    226226            if (method_exists($element, 'getAttribute')) { 
     
    266266 
    267267        if (is_null($objSelector)) $objSelector = new SC_Plugin_Template_Selector($this, $this->current_plugin); 
    268          
     268 
    269269        // jQueryライクなセレクタを正規表現に 
    270270        $selector = preg_replace('/ *> */', ' >', $selector); 
     
    274274        // セレクターを配列にします. 
    275275        $arrSelectors = explode(' ', $selector);         
    276          
     276 
    277277        // セレクタから正規表現を生成. 
    278278        foreach ($arrSelectors as $sub_selector) { 
     
    296296        // エレメントツリーのセレクタを先ほど作成した正規表現で順に検索. 
    297297        for($iLoop=$startIndex; $iLoop < count($this->arrElementTree); $iLoop++){ 
    298              
     298 
    299299            if (preg_match($regex, $this->arrElementTree[$iLoop][0])) { 
    300300                if (is_null($index) || $cur_idx == $index) { 
     
    314314            ); 
    315315        } 
    316          
     316 
    317317        return $objSelector; 
    318318    } 
    319      
     319 
    320320    /** 
    321321     * DOMを用いた変形を実行する 
     
    327327     */ 
    328328    function setTransform($mode, $target_key, $html_snip) { 
    329          
     329 
    330330        $substitute_tag = sprintf('<!--###%08d###-->', $this->smarty_tags_idx); 
    331331 
     
    333333        $this->arrSmartyTagsSub[$this->smarty_tags_idx] = $substitute_tag; 
    334334        $this->smarty_tags_idx++; 
    335          
     335 
    336336        $objSnip = $this->objDOM->createDocumentFragment(); 
    337337        $objSnip->appendXML($substitute_tag); 
    338          
     338 
    339339        $objElement = false; 
    340340        if(isset($this->arrElementTree[$target_key]) && $this->arrElementTree[$target_key][0]){ 
     
    343343 
    344344        if (!$objElement) return false; 
    345          
     345 
    346346        try { 
    347347            if ($mode == 'appendChild') { 
     
    351351                $objElement->parentNode->insertBefore($objSnip, $objElement); 
    352352            } elseif ($mode == 'insertAfter') { 
    353                 if ($objElement->nextSibling) { 
    354                      $objElement->parentNode->insertBefore($objSnip, $objElement->nextSibling); 
    355                 } else { 
    356                      $objElement->parentNode->appendChild($objSnip); 
    357                 } 
     353                if ($objElement->nextSibling) { 
     354                     $objElement->parentNode->insertBefore($objSnip, $objElement->nextSibling); 
     355                } else { 
     356                     $objElement->parentNode->appendChild($objSnip); 
     357                } 
    358358            } elseif ($mode == 'replaceChild') { 
    359359                if (!is_object($objElement->parentNode)) return false; 
     
    366366        return true; 
    367367    } 
    368      
     368 
    369369    /** 
    370370     * セレクタエラーを記録する 
     
    384384        ); 
    385385    } 
    386      
     386 
    387387    /** 
    388388     * HTMLに戻して、Transform用に付けたマーカーを削除し、Smartyのタグを復元する 
     
    407407            // TODO エラー処理 
    408408            // ECC_Plugin_Engine::dispError(FREE_ERROR_MSG, "テンプレートの操作に失敗しました。".$err_msg); 
    409          
     409 
    410410        } elseif ($this->snip_count) { 
    411411            $html = $this->objDOM->saveHTML(); 
     
    415415            $html = preg_replace('/<\!--TemplateTransformer end-->.*$/s', '', $html); 
    416416            return $html; 
    417          
     417 
    418418        } else { 
    419419            return false; 
     
    434434            $filepath = PLUGIN_TMPL_CACHE_REALDIR . $filename; 
    435435            $dir = dirname($filepath); 
    436              
     436 
    437437            if (!file_exists($dir)) mkdir($dir, PLUGIN_DIR_PERMISSION, true); 
    438438            if (!file_put_contents($filepath, $html)) return false; 
     
    444444 
    445445} 
    446  
    447  
    448 ?> 
Note: See TracChangeset for help on using the changeset viewer.