Changeset 16333


Ignore:
Timestamp:
2007/10/08 22:49:32 (16 years ago)
Author:
adachi
Message:

テンプレート切り替え処理の修正
*site_frame.tplの切り替えに対応
*モバイルテンプレートの切り替えに対応
*メールテンプレートの切り替えに対応

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/feature-templates/data/class/SC_View.php

    r16325 r16333  
    2020    /** »ÈÍѤ·¤Æ¤¤¤ë¥Æ¥ó¥×¥ì¡¼¥È¥Ñ¥Ã¥±¡¼¥¸Ì¾ */ 
    2121    var $tplName; 
     22    /** display¤¹¤ëtpl¥Õ¥¡¥¤¥ë̾ */ 
     23    var $template; 
    2224 
    2325    /** 
     
    7779        $this->_smarty->register_function("sfIsHTTPS","sfIsHTTPS"); 
    7880        $this->_smarty->default_modifiers = array('script_escape'); 
    79         $this->_smarty->force_compile = true; 
     81        $this->_smarty->force_compile = DEBUG_MODE; 
    8082    } 
    8183 
     
    154156     */ 
    155157    function display($template, $display = false) { 
     158        $this->template = $template; 
     159 
    156160        // ¥Æ¥ó¥×¥ì¡¼¥ÈÀÚ¤êÂؤ¨½èÍý 
    157         $this->initDisplay($template); 
     161        $this->initTemplate(); 
    158162 
    159163        // ¥°¥í¡¼¥Ð¥ë¥¨¥é¡¼¤Îɽ¼¨ 
     
    161165 
    162166        // ²èÌÌɽ¼¨ 
    163         $this->_smarty->display($template); 
     167        $this->_smarty->display($this->template); 
    164168 
    165169        // ¥Ù¥ó¥Á¥Þ¡¼¥¯·ë²Ì¤Îɽ¼¨ 
     
    171175     *  ¼ÂÁõ¤Ï»Ò¥¯¥é¥¹¤Ç¹Ô¤¦. 
    172176     */ 
    173     function initDisplay($template) {} 
     177    function initTemplate() {} 
    174178 
    175179    /** 
     
    276280    } 
    277281 
    278     function initDisplay($template) { 
     282    function initTemplate() { 
    279283        // ¥Æ¥ó¥×¥ì¡¼¥È¤ò»ÈÍѤ·¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ïreturn 
    280284        if (empty($this->tplName)) return; 
    281285 
     286        // ¸½ºß»ÈÍѤ·¤Æ¤¤¤ë¥Æ¥ó¥×¥ì¡¼¥È¥Ñ¥Ã¥±¡¼¥¸¤Î¥Ñ¥¹ 
     287        // ***/html/user_data/tpl_packages/***/templates/ 
     288        $template_dir = TPL_PKG_PATH . $this->tplName . '/templates/'; 
     289        // FIXME ¤³¤³¤Ë¥â¥Ð¥¤¥ëÍѽèÍý¤ò¶´¤ß¤¿¤¯¤Ê¤¤... 
     290        if ($this->_smarty->template_dir == MOBILE_TEMPLATE_DIR) { 
     291            $template_dir .= 'mobile/'; 
     292        } 
     293 
    282294        /** 
     295         * tpl_mainpage¤Î¥Æ¥ó¥×¥ì¡¼¥ÈŬ±þ½èÍý 
     296         * 
    283297         * tpl_mainpage¤¬ÁêÂХѥ¹¤Ç¤¢¤ì¤Ð 
    284298         * ¥æ¡¼¥¶¡¼¥Æ¥ó¥×¥ì¡¼¥È¤Ø¤ÎÀäÂХѥ¹¤ËÊѹ¹¤· 
     
    286300         */ 
    287301        $tpl_mainpage  = $this->_smarty->get_template_vars('tpl_mainpage'); 
    288         $template_dir = TPL_PKG_PATH . $this->tplName . '/templates/'; 
    289302 
    290303        $win = "^[a-zA-Z]{1}:"; 
    291304        $other = "^\/"; 
    292305        $pattern = "/($win)|($other)/"; 
    293         if (!preg_match($pattern, $tpl_mainpage)) { 
     306 
     307        if (!is_null($tpl_mainpage) && !preg_match($pattern, $tpl_mainpage)) { 
    294308            $tpl_pkg_mainpage = $template_dir . $tpl_mainpage; 
    295309            if (file_exists($tpl_pkg_mainpage)) { 
     
    297311            } 
    298312        } 
     313 
     314        // site_frame.tpl¤Î¥Æ¥ó¥×¥ì¡¼¥ÈŬÍѽèÍý 
     315        if ($this->template == SITE_FRAME) { 
     316            if(file_exists($template_dir . SITE_FRAME)) { 
     317                $this->template = $template_dir . SITE_FRAME; 
     318            } 
     319        // $this->template¤¬SITE_FRAME¤Ç¤Ê¤¤¾ì¹ç 
     320        // $objView->display($objPage->tpl_mainpage)¤Ê¤É 
     321        } else { 
     322            if(file_exists($template_dir . $this->template)) { 
     323                $this->template = $template_dir . $this->template; 
     324            } 
     325        } 
     326 
     327        // site_main.tpl¤Î¥Æ¥ó¥×¥ì¡¼¥ÈŬ±þ½èÍý 
    299328        $tpl_site_main = $template_dir . 'site_main.tpl'; 
    300329        if (file_exists($tpl_site_main)) { 
     
    302331        } 
    303332    } 
    304 } 
     333 
     334    function fetch($template) { 
     335        $this->template = $template; 
     336        $this->initTemplate(); 
     337        return $this->_smarty->fetch($this->template); 
     338    } 
     339} 
     340 
    305341class SC_UserView extends SC_SiteView{ 
    306342    function SC_UserView($template_dir, $compile_dir = COMPILE_DIR) { 
     
    321357        $this->_smarty->compile_dir = $compile_dir; 
    322358    } 
     359    // SC_View::getTemplateName()¤ÎDB¥¢¥¯¥»¥¹½èÍý¤ò¹Ô¤ï¤Ê¤¤¤è¤¦¤Ë¥ª¡¼¥Ð¡¼¥é¥¤¥É 
    323360    function getTemplateName() {} 
    324361} 
     
    331368    } 
    332369} 
    333  
    334370?> 
Note: See TracChangeset for help on using the changeset viewer.