1 | <?php
|
---|
2 | function archives_block($options)
|
---|
3 | {
|
---|
4 | $mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
|
---|
5 | $type = empty( $options[1] ) ? false : true ;
|
---|
6 | $limit = empty( $options[2] ) ? '10' : $options[2] ;
|
---|
7 | $show_post_count = empty( $options[3] ) ? false : true ;
|
---|
8 | $drop_down = empty( $options[4] ) ? false : true ;
|
---|
9 | $this_template = empty( $options[5] ) ? 'db:'.$mydirname.'_archives_block.html' : trim( $options[3] );
|
---|
10 |
|
---|
11 | if ($type) {
|
---|
12 | $type_name = 'monthly';
|
---|
13 | } else {
|
---|
14 | $type_name = 'weekly';
|
---|
15 | }
|
---|
16 |
|
---|
17 | $drop_down_list = '<form id="archiveform" action="">';
|
---|
18 | $drop_down_list .= '<select name="archive_chrono" onchange="window.location = (document.forms.archiveform.archive_chrono[document.forms.archiveform.archive_chrono.selectedIndex].value);">';
|
---|
19 | $drop_down_list .= "<option value=''>";
|
---|
20 | if ($type) {
|
---|
21 | $drop_down_list .= __('Select Monthly', 'xpress');
|
---|
22 | } else {
|
---|
23 | $drop_down_list .= __('Select Weekly', 'xpress');
|
---|
24 | }
|
---|
25 | $drop_down_list .= '</option>';
|
---|
26 | ob_start();
|
---|
27 | get_archives($type_name,$limit,'option','','',$show_post_count);
|
---|
28 | $drop_down_list .= ob_get_contents();
|
---|
29 | ob_end_clean();
|
---|
30 | $drop_down_list .= '</select>';
|
---|
31 | $drop_down_list .= '</form>';
|
---|
32 |
|
---|
33 | ob_start();
|
---|
34 | get_archives($type_name,$limit,'custom','','|',$show_post_count);
|
---|
35 | $output = ob_get_contents();
|
---|
36 | ob_end_clean();
|
---|
37 | $output = preg_replace('/\|$/', '' ,$output); // "|" at the end of line is deleted.
|
---|
38 | $archives = explode('|',$output);
|
---|
39 | $item_no = 0;
|
---|
40 | foreach ($archives as $archive){
|
---|
41 | $row_data = array(
|
---|
42 | 'archive' => $archive
|
---|
43 | );
|
---|
44 | $block['contents']['item'.$item_no] = $row_data;
|
---|
45 | $item_no++;
|
---|
46 | }
|
---|
47 | $block['data_count'] = $item_no;
|
---|
48 | $block['config']['is_archive_doropdown'] = $drop_down;
|
---|
49 | $block['archive_dropdown'] = $drop_down_list;
|
---|
50 | return $block ;
|
---|
51 | }
|
---|
52 |
|
---|
53 | ?> |
---|