XPressME Integration Kit

Trac

source: tags/Ver2.2.0RC1/xpressme_integration_kit/wp-content/themes/xpress_default/blocks/archives_block_theme.php @ 450

Last change on this file since 450 was 450, checked in by toemon, 14 years ago

Ver2.2.0RC1 リリース

File size: 2.2 KB
Line 
1<?php
2// Block Version: 1.0
3function archives_block($options)
4{
5        $mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
6        $this_template = empty( $options[1] ) ? 'db:'.$mydirname.'_archives_block.html' : trim( $options[1] );
7        $type = empty( $options[2] ) ? 'monthly' : $options[2] ;
8        $limit  = !is_numeric( $options[3] ) ? 0 : $options[3] ;
9        $show_post_count = empty( $options[4] ) ? false : true ;               
10        $drop_down = empty( $options[5] ) ? false : true ;     
11       
12        switch($type){
13                case 'yearly':
14                        $select_str = __('Select Yearly', 'xpress');
15                        break;
16                case 'monthly':
17                        $select_str = __('Select Monthly', 'xpress');
18                        break;
19                case 'weekly':
20                        $select_str = __('Select Weekly', 'xpress');
21                        break;
22                case 'daily':
23                        $select_str = __('Select Daily', 'xpress');
24                        break;
25                case 'postbypost':
26                        $select_str = __('Select Post', 'xpress');
27                        break;
28                default:
29                        $select_str = __('Select Monthly', 'xpress');
30        }
31       
32        if ($drop_down) $format = 'option'; else $format = 'html';
33        if ($limit == 0 ) $limit_str = ''; else $limit_str = $limit;
34       
35        $param = array(
36                'type' => $type,
37                'limit' => $limit_str,
38                'format' => $format,
39                'before' => '',
40                'after' => '',
41                'show_post_count' => $show_post_count
42        );
43       
44        ob_start();
45                wp_get_archives($param);
46                $get_archives_output = ob_get_contents();
47        ob_end_clean();
48       
49
50        if($drop_down){
51               
52
53                $output = '<form id="archiveform" action="">';
54                $output .= '<select name="archive_chrono" onchange="window.location = (document.forms.archiveform.archive_chrono[document.forms.archiveform.archive_chrono.selectedIndex].value);">';
55                $output .= "<option value=''>" . $select_str . "</option>\n";
56                $output .=  $get_archives_output;
57                $output .= '</select>';
58                $output .= '</form>';
59               
60                $output  = '<select name="archive-dropdown"' . "onChange='document.location.href=this.options[this.selectedIndex].value;'>\n";
61                $output .= '<option value="">'.attribute_escape($select_str) . "</option>\n";
62                $output .=      $get_archives_output;
63                $output .=      "</select>\n";
64               
65        } else {
66                $output  = "<ul>\n";
67                $output .=  $get_archives_output;
68                $output  .= "</ul>\n";
69        }
70        $block['archive'] = $output;
71        return $block ;
72}
73
74?>
Note: See TracBrowser for help on using the repository browser.