/
theme.php
127 lines (107 loc) · 4.53 KB
/
theme.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
/**
* MyTheme is a custom Theme class for the K2 theme.
*
* @package Habari
*/
/**
* @todo This stuff needs to move into the custom theme class:
*/
// Apply Format::autop() to post content...
Format::apply( 'autop', 'post_content_out' );
// Apply Format::autop() to comment content...
Format::apply( 'autop', 'comment_content_out' );
// Apply Format::tag_and_list() to post tags...
Format::apply( 'tag_and_list', 'post_tags_out' );
// Apply Format::nice_date() to post date...
Format::apply( 'nice_date', 'post_pubdate_out', 'l, d F Y' );
// Apply Format::nice_date() to comment date...
Format::apply( 'nice_date', 'comment_date_out', 'l, d F Y' );
$header_text = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt.';
// Remove the comment on the following line to limit post length on the home page to 2 paragraphs or 150 characters
//Format::apply_with_hook_params( 'more', 'post_content_out', 'Continue Reading »', 150, 2 );
// We must tell Habari to use MyTheme as the custom theme class:
define( 'THEME_CLASS', 'MyTheme' );
/**
* A custom theme for K2 output
*/
class MyTheme extends Theme
{
public function add_template_vars()
{
//Theme Options
$this->assign('header_text','Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt.');
if( !$this->template_engine->assigned( 'pages' ) ) {
$this->assign('pages', Posts::get( array( 'content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1 ) ) );
}
if( !$this->template_engine->assigned( 'user' ) ) {
$this->assign('user', User::identify()->loggedin );
}
/* if( !$this->template_engine->assigned( 'page' ) ) {
$this->assign('page', isset( $page ) ? $page : 1 );
}*/
if( !$this->template_engine->assigned( 'all_tags' ) ) {
// List of all the tags
$tags = Tags::get();
$this->assign('all_tags', $tags);}
//visiting page/2, /3 will offset to the next page of posts in the sidebar
$page=Controller::get_var( 'page' );
$pagination=Options::get('pagination');
if ( $page == '' ) { $page= 1; }
$this->assign( 'more_posts', Posts::get(array ( 'status' => 'published','content_type' => 'entry','offset' => ($pagination)*($page), 'limit' => 5, ) ) );
parent::add_template_vars();
$this->add_template('formcontrol_text', dirname(__FILE__).'/forms/formcontrol_text.php', true);
$this->add_template('formcontrol_textarea', dirname(__FILE__).'/forms/formcontrol_textarea.php', true);
}
// called in theme template like so: $theme->monthly_archives_links_list();
public function theme_monthly_archives_links_list( $theme, $full_names = TRUE, $show_counts = TRUE, $type = 'entry', $status = 'published' )
{
$results = Posts::get( array( 'content_type' => $type, 'status' => $status, 'month_cts' => 1 ) );
$archives[] = '';
foreach ( $results as $result ) {
// add leading zeros
$result->month= str_pad( $result->month, 2, 0, STR_PAD_LEFT );
// what format do we want to show the month in?
if( $full_names ) {
$display_month = HabariDateTime::date_create()->set_date( $result->year, $result->month, 1)->get( 'F' );
}
else {
$display_month = HabariDateTime::date_create()->set_date( $result->year, $result->month, 1)->get( 'M' );
}
// do we want to show the count of posts?
if ( $show_counts ) {
$count = ' (' . $result->ct . ')';
}
else {
$count = '';
}
$archives[] = '<li>';
$archives[] = '<a href="' . URL::get( 'display_entries_by_date', array( 'year' => $result->year, 'month' => $result->month ) ) . '" title="View entries in ' . $display_month . '/' . $result->year . '">' . $display_month . ' ' . $result->year . ' ' . $count . '</a>';
$archives[] = '</li>';
}
$archives[] = '';
return implode( "\n", $archives );
}
public function action_form_comment( $form ) {
$form->cf_commenter->caption = 'Username :';
$form->cf_email->caption = 'Email :';
$form->cf_url->caption = 'Web Site :';
$form->cf_content->caption = 'Comment :';
$form->cf_content->cols = 50;
$form->cf_content->rows = 8;
}
/*public function gravatar($rating = false, $size = false, $default = false, $border = false)
{
$out = "http://www.gravatar.com/avatar.php?gravatar_id=".md5( $posts->comments->moderated->email );
if($rating && $rating != '')
$out .= "&rating=".$rating;
if($size && $size != '')
$out .="&size=".$size;
if($default && $default != '')
$out .= "&default=".urlencode($default);
if($border && $border != '')
$out .= "&border=".$border;
echo $out;
}*/
}
?>