XPressME Integration Kit

Trac

Changeset 463


Ignore:
Timestamp:
Nov 27, 2009, 3:27:01 PM (14 years ago)
Author:
toemon
Message:

ブロックオプションでテンプレートの指定が行えるようにし、ブロック複製時別テンプレートが使えるようにする。 Fixes #247

Location:
trunk
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/extras/for_wordpressme2011/ja_EUC/language/japanese/blocks.php

    r429 r463  
    2626        define("_MB_XP2_LIST","¥ê¥¹¥È"); 
    2727        define("_MB_XP2_FILE_NAME","¥Õ¥¡¥¤¥ë̾"); 
     28        define("_MB_XP2_THISTEMPLATE","¤³¤Î¥Ö¥í¥Ã¥¯¤Î¥Æ¥ó¥×¥ì¡¼¥È"); 
    2829         
    2930// recent comment block  
  • trunk/extras/for_wordpressme2011/ja_UTF/language/ja_utf8/blocks.php

    r429 r463  
    2626        define("_MB_XP2_LIST","リスト"); 
    2727        define("_MB_XP2_FILE_NAME","ファイル名"); 
     28        define("_MB_XP2_THISTEMPLATE","このブロックのテンプレート"); 
    2829         
    2930// recent comment block  
  • trunk/extras/xpress_i18n/portuguese-br/xpressme_modules_root/language/pt-br_utf8/blocks.php

    r429 r463  
    2626        define("_MB_XP2_LIST","Lista"); 
    2727        define("_MB_XP2_FILE_NAME","Nome do arquivo"); 
     28        define("_MB_XP2_THISTEMPLATE","Modelo"); 
    2829         
    2930// recent comment block  
  • trunk/xpressme_integration_kit/blocks/archives_block.php

    r232 r463  
    2828 
    2929                $form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />"; 
    30             $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />"; 
     30            $form .= _MB_XP2_THISTEMPLATE . "<input type='text' size='50' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />"; 
    3131                $form .= "<br />"; 
    3232                $a_month = _MB_XP2_ARC_MONTH ; 
     
    6262                $form .=  "</select><br/>"; 
    6363                 
    64                 $form .= "<br />" . _MB_XP2_COUNT_ZERO_ALL . "  <input type='text' name='options[3]' value='" . $limit . "' />"; 
     64                $form .= "<br />" . _MB_XP2_COUNT_ZERO_ALL . "  <input type='text' size='3' name='options[3]' value='" . $limit . "' />"; 
    6565                $form .= "<br />" . yes_no_radio_option('options[4]', _MB_XP2_SHOW_NUM_OF_POST , $show_post_count); 
    6666                $form .= "<br />" . yes_no_radio_option('options[5]', _MB_XP2_SHOW_DROP_DOWN , $drop_down); 
  • trunk/xpressme_integration_kit/blocks/authors_block.php

    r232 r463  
    2828                         
    2929                $form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />"; 
    30             $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />"; 
     30            $form .= _MB_XP2_THISTEMPLATE . "<input type='text' size='50' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />"; 
    3131                $form .= "<br />"; 
    3232                $form .= yes_no_radio_option('options[2]', _MB_XP2_SHOW_NUM_OF_POST , $optioncount); 
  • trunk/xpressme_integration_kit/blocks/calender_block.php

    r232 r463  
    2626 
    2727                $form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />\n"; 
    28             $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />"; 
     28            $form .= _MB_XP2_THISTEMPLATE . "<input type='text' size='50' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />"; 
    2929                $form .= "<br />"; 
    3030                $form .= _MB_XP2_SUN_COLOR .": <input type='text' name='options[2]' value='" . $sun_color . "' /><br />\n"; 
  • trunk/xpressme_integration_kit/blocks/category_block.php

    r232 r463  
    3535 
    3636                $form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' />"; 
    37             $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />"; 
     37            $form .= _MB_XP2_THISTEMPLATE . "<input type='text' size='50' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />"; 
    3838                $form .= "<br />"; 
    3939                $form .= _MB_XP2_CAT_ALL_STR . "  <input type='text' name='options[2]' value='" . $show_option_all . "' /><br />"; 
  • trunk/xpressme_integration_kit/blocks/enhanced_block.php

    r232 r463  
    1919                $mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ; 
    2020                $this_template = empty( $options[1] ) ? 'db:'.$mydirname.'_enhanced_block.html' : trim( $options[1] ); 
     21            $form .= _MB_XP2_THISTEMPLATE . "<input type='text' size='50' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />"; 
    2122                $include_file = empty( $options[2] ) ? '' : $options[2] ; 
    2223                 
  • trunk/xpressme_integration_kit/blocks/meta_block.php

    r232 r463  
    3131 
    3232                $form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />"; 
    33             $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />"; 
     33            $form .= _MB_XP2_THISTEMPLATE . "<input type='text' size='50' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />"; 
    3434                $form .= "<br />"; 
    3535                $form .= yes_no_radio_option('options[2]', _MB_XP2_META_WP_LINK , $wp_link) . "<br />\n"; 
  • trunk/xpressme_integration_kit/blocks/page_block.php

    r386 r463  
    3535 
    3636                $form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />"; 
    37             $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />"; 
     37            $form .= _MB_XP2_THISTEMPLATE . "<input type='text' size='50' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />"; 
    3838                $form .= "<br />"; 
    3939                $form .= _MB_XP2_PAGE_ORDERBY .": "; 
  • trunk/xpressme_integration_kit/blocks/popular_posts_block.php

    r435 r463  
    3030 
    3131                $form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />\n"; 
    32             $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />\n"; 
     32            $form .= _MB_XP2_THISTEMPLATE . "<input type='text' size='50' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />"; 
    3333                $form .= "<br />\n"; 
    3434                $form .= _MB_XP2_COUNT .": <input type='text' name='options[2]' value='" . $disp_count . "' /><br />\n"; 
  • trunk/xpressme_integration_kit/blocks/recent_comments_block.php

    r436 r463  
    3030                 
    3131                $form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />\n"; 
    32             $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />\n"; 
     32            $form .= _MB_XP2_THISTEMPLATE . "<input type='text' size='50' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />"; 
    3333                $form .= "<br />"; 
    34                 $form .= _MB_XP2_COUNT .": <input type='text' name='options[2]' value='" . $disp_count . "' /><br />\n"; 
    35                 $form .= _MB_XP2_LENGTH .": <input type='text' name='options[3]' value='" . $disp_length . "' /><br />\n"; 
     34                $form .= _MB_XP2_COUNT .": <input type='text' size='3' name='options[2]' value='" . $disp_count . "' /><br />\n"; 
     35                $form .= _MB_XP2_LENGTH .": <input type='text' size='3' name='options[3]' value='" . $disp_length . "' /><br />\n"; 
    3636                $form .= _MB_XP2_DATE_FORMAT .": <input type='text' name='options[4]' value='" . $date_format . "' /><br />\n"; 
    3737                $form .= _MB_XP2_TIME_FORMAT .": <input type='text' name='options[5]' value='" . $time_format . "' /><br />\n"; 
  • trunk/xpressme_integration_kit/blocks/recent_posts_content_block.php

    r435 r463  
    3434                 
    3535                $form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />\n"; 
    36             $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />"; 
    37                 $form .= _MB_XP2_COUNT .": <input type='text' name='options[2]' value='" . $disp_count . "' /><br />\n"; 
     36            $form .= _MB_XP2_THISTEMPLATE . "<input type='text' size='50' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />"; 
     37                $form .= _MB_XP2_COUNT .": <input type='text' size='3' name='options[2]' value='" . $disp_count . "' /><br />\n"; 
    3838                $form .= yes_no_radio_option('options[3]', _MB_XP2_P_EXCERPT , $excerpt) . "<br />\n"; 
    3939                $form .= _MB_XP2_P_EXCERPT_SIZE .": <input type='text' name='options[4]' value='" . $excerpt_size . "' /><br />\n"; 
  • trunk/xpressme_integration_kit/blocks/recent_posts_list_block.php

    r435 r463  
    3131 
    3232                $form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />\n"; 
    33             $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />\n"; 
     33            $form .= _MB_XP2_THISTEMPLATE . "<input type='text' size='50' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />"; 
    3434                $form .= "<br />\n";     
    35                 $form .= _MB_XP2_COUNT .": <input type='text' name='options[2]' value='" . $disp_count . "' /><br />\n"; 
    36                 $form .= _MB_XP2_REDNEW_DAYS .": <input type='text' name='options[3]' value='" . $disp_red . "' /><br />\n"; 
    37                 $form .= _MB_XP2_GREENNEW_DAYS .": <input type='text' name='options[4]' value='" . $disp_green . "' /><br />\n"; 
     35                $form .= _MB_XP2_COUNT .": <input type='text' size='3' name='options[2]' value='" . $disp_count . "' /><br />\n"; 
     36                $form .= _MB_XP2_REDNEW_DAYS .": <input type='text' size='3' name='options[3]' value='" . $disp_red . "' /><br />\n"; 
     37                $form .= _MB_XP2_GREENNEW_DAYS .": <input type='text' size='3' name='options[4]' value='" . $disp_green . "' /><br />\n"; 
    3838                $form .= _MB_XP2_DATE_FORMAT .": <input type='text' name='options[5]' value='" . $date_format . "' /><br />\n"; 
    3939                $form .= _MB_XP2_TIME_FORMAT .": <input type='text' name='options[6]' value='" . $time_format . "' /><br />\n"; 
  • trunk/xpressme_integration_kit/blocks/search_block.php

    r232 r463  
    2525                 
    2626                $form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />"; 
    27             $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />"; 
     27            $form .= _MB_XP2_THISTEMPLATE . "<input type='text' size='50' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />"; 
    2828                $form .= "<br />";               
    29                 $form .= _MB_XP2_SEARCH_LENGTH .": <input type='text' name='options[2]' value='" . $disp_count . "' /><br />"; 
     29                $form .= _MB_XP2_SEARCH_LENGTH .": <input type='text' size='3' name='options[2]' value='" . $disp_count . "' /><br />"; 
    3030//          $form .="<br /><input type='text' size='60' name='options[2]' value='".htmlspecialchars($this_template,ENT_QUOTES)."' />"; 
    3131 
  • trunk/xpressme_integration_kit/blocks/tag_cloud_block.php

    r232 r463  
    3232 
    3333                $form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />"; 
    34             $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />"; 
     34            $form .= _MB_XP2_THISTEMPLATE . "<input type='text' size='50' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />"; 
    3535                $form .= "<br />"; 
    3636                $form .= _MB_XP2_CLOUD_SMALLEST .": <input type='text' size='4' name='options[2]' value='" . $smallest . "' /><br />"; 
  • trunk/xpressme_integration_kit/blocks/widget_block.php

    r437 r463  
    4646 
    4747                $form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />"; 
    48             $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />"; 
     48            $form .= _MB_XP2_THISTEMPLATE . "<input type='text' size='50' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />"; 
    4949                $form .= "<br />" . yes_no_radio_option('options[2]', _MB_XP2_WIDGET_TITLE_SHOW , $title_show); 
    5050                $form .= "<br />"; 
  • trunk/xpressme_integration_kit/include/xpress_block_render.php

    r456 r463  
    5252                        } 
    5353                        return $block_id; 
     54        } 
     55 
     56        function get_block_mid($mydirname) 
     57        { 
     58                        $xoopsDB =& Database::getInstance(); 
     59                        $modules_tbl = $xoopsDB->prefix('modules');      
     60 
     61                        $sql = "SELECT mid FROM $modules_tbl WHERE dirname = '$mydirname'"; 
     62                        $result =  $xoopsDB->query($sql, 0, 0); 
     63                        if ($xoopsDB->getRowsNum($result)  > 0){ 
     64                                $row = $xoopsDB->fetchArray($result); 
     65                                $mid = $row['mid']; 
     66                        } 
     67                        return $mid; 
    5468        } 
    5569 
     
    190204                $option = explode('|' , $block['options']); 
    191205                 
    192                 if (isset($option[1])) 
     206                if (isset($option[1])) { 
    193207                        $templates_file = $option[1]; 
    194                 else 
     208                } else { 
    195209                        $templates_file = 'db:'.$mydirname. '_' . str_replace(".php", ".html", $block_function_name); 
     210                } 
     211                 
    196212                $tpl =& new XoopsTpl() ; 
     213                $tpl->template_dir = $xoops_config->module_path . '/templates'; 
     214                if (!$tpl->template_exists($templates_file)){ 
     215                        $src_file_path = $xoops_config->module_path . '/templates/' .$mydirname. '_' . str_replace(".php", ".html", $block_function_name); 
     216                        add_xpress_tpl($mydirname,$templates_file,$src_file_path); 
     217                } 
    197218                $tpl->assign( 'block' , $block ) ; 
    198219                $ret['content'] = $tpl->fetch( $templates_file ) ; 
    199220                return $ret ; 
     221        } 
     222         
     223        function add_xpress_tpl($mydirname,$templates='',$src_file_path){ 
     224                global $wpdb,$xoops_config , $xoops_db; 
     225                 
     226                $mid = get_block_mid($mydirname); 
     227 
     228                $temp_parm = explode(':' , $templates); 
     229                if (empty($temp_parm[1])) { 
     230                        $filename=$temp_parm[0]; 
     231                        $type = 'db'; 
     232                } else  { 
     233                        $filename=$temp_parm[1]; 
     234                        $type = $temp_parm[0]; 
     235                } 
     236                $temp_file_path = $xoops_config->module_path . '/templates/'. $filename; 
     237                $pattern = '^' . $mydirname . '_'; 
     238                if (preg_match('/' . $pattern . '/' , $filename, $match)){ // file prefix check 
     239                        if (!file_exists($temp_file_path)){             // Repetition check 
     240                                if (file_exists($src_file_path)){       // source file check 
     241                                        $rcd = copy($src_file_path, $temp_file_path); 
     242                                } 
     243                        } 
     244                } 
    200245        } 
    201246         
     
    250295        { 
    251296                global $xoops_db,$xoops_config; 
     297                 
    252298                $mid = get_xpress_modid(); 
    253299                $sql = "SELECT bid,options,func_file FROM " . get_xoops_prefix() . "newblocks WHERE mid = $mid AND visible = 1"; 
     
    294340                        return $xu_row['conf_value']; 
    295341                } 
    296         } 
    297          
     342        }        
    298343}        
    299344?> 
  • trunk/xpressme_integration_kit/language/english/blocks.php

    r429 r463  
    2626        define("_MB_XP2_LIST","List"); 
    2727        define("_MB_XP2_FILE_NAME","Files Name"); 
     28        define("_MB_XP2_THISTEMPLATE","Template"); 
    2829         
    2930// recent comment block  
  • trunk/xpressme_integration_kit/language/ja_utf8/blocks.php

    r429 r463  
    2626        define("_MB_XP2_LIST","リスト"); 
    2727        define("_MB_XP2_FILE_NAME","ファイル名"); 
     28        define("_MB_XP2_THISTEMPLATE","このブロックのテンプレート"); 
    2829         
    2930// recent comment block  
Note: See TracChangeset for help on using the changeset viewer.