-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththeme.php
134 lines (111 loc) · 4.04 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
128
129
130
131
132
133
134
<?php
/**
* MyTheme is a custom Theme class for the Simpler 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', 'F j, Y \a\t g:ia' );
Format::apply( 'nice_date', 'comment_date_out', 'F j, Y \a\t g:ia' );
//////////////////////Format::apply_with_hook_params( 'more', 'post_content_out', 'more', 100, 1 );
// We must tell Habari to use MyTheme as the custom theme class:
define( 'THEME_CLASS', 'MyTheme' );
/**
* A custom theme for Simpler output
*/
class MyTheme extends Theme
{
/**
* Add additional template variables to the template output.
*
* You can assign additional output values in the template here, instead of
* having the PHP execute directly in the template. The advantage is that
* you would easily be able to switch between template types (RawPHP/Smarty)
* without having to port code from one to the other.
*
* You could use this area to provide "recent comments" data to the template,
* for instance.
*
* Note that the variables added here should possibly *always* be added,
* especially 'user'.
*
* Also, this function gets executed *after* regular data is assigned to the
* template. So the values here, unless checked, will overwrite any existing
* values.
*/
public function add_template_vars()
{
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() );
}
if( !$this->template_engine->assigned( 'page' ) ) {
$page = Controller::get_var( 'page' );
$this->assign('page', isset( $page ) ? $page : 1 );
}
$copyright = Options::get( 'simpler__copyright_notice' );
if ( $copyright == null ) {
$copyright = '© Copyright ' . date('Y') . '. All Rights Reserved.';
}
else {
$copyright = str_replace( '%year', date('Y'), $copyright );
}
$this->assign( 'copyright', $copyright );
parent::add_template_vars();
}
public function action_update_check() {
Update::add( 'Simpler Theme', 'b903172d-caa2-487a-81ec-e7a41dd76c5e', $this->version );
}
public function filter_theme_config($configurable)
{
$configurable = true;
return $configurable;
}
/**
* Respond to the user selecting 'configure' on the themes page
*
*/
public function action_theme_ui()
{
$form = new FormUI( 'simpler_theme' );
$copyright_notice = $form->append('text', 'copyright_notice', 'simpler__copyright_notice', _t( 'Copyright Notice' ) );
$copyright_notice->template = 'optionscontrol_text';
$copyright_notice->class = 'clear';
$copyright_notice->raw = true;
$copyright_notice->helptext = _t( 'Use %year to substitute in the current year.' );
$form->append('submit', 'save', 'Save');
$form->on_success( array( $this, 'save_config' ) );
$form->out();
}
public function save_config( $form ){
Session::notice( _t( 'Theme Settings Updated' ) );
$form->save();
return true;
}
public function action_form_comment( $form ) {
$form->append( 'fieldset', 'cf_fieldset', _t( 'Leave a comment?' ) );
$form->cf_content->caption = _t( 'Comment:' );
$form->cf_content->move_into( $form->cf_fieldset );
$form->cf_content->rows = 5;
$form->cf_commenter->caption = _t( 'Name:' );
$form->cf_commenter->move_into( $form->cf_fieldset );
$form->cf_email->caption = _t( 'Email:' );
$form->cf_email->move_into( $form->cf_fieldset );
$form->cf_url->caption = _t( 'Website:.' );
$form->cf_url->move_into( $form->cf_fieldset );
$form->cf_submit->caption = _t( 'Submit Comment' );
$form->cf_submit->move_into( $form->cf_fieldset );
}
}
?>