PluginProbe
wpForo Forum / 1.1.2
wpForo Forum v1.1.2
3.1.5 3.1.4 3.1.2 3.1.1 3.1.0 3.0.9 3.0.8 3.0.7 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.2 All 137 releases
wpforo / wpf-includes / class-template.php

class-template.php in wpForo Forum 1.1.2, at wpf-includes/class-template.php

1,251 lines 57.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // Exit if accessed directly
3 if( !defined( 'ABSPATH' ) ) exit;
4
5
6 class wpForoTemplate{
7
8 private $wpforo;
9
10 function __construct( $wpForo ){
11 if(!isset($this->wpforo)) $this->wpforo = $wpForo;
12 if( is_wpforo_page() ){
13 add_filter("mce_external_plugins", array(&$this, 'add_tinymce_buttons'), 15);
14 add_filter("tiny_mce_plugins", array(&$this, 'filter_tinymce_plugins'), 15);
15 add_filter("wp_mce_translation", array(&$this, 'add_tinymce_translations'));
16 }
17 }
18
19 function add_tinymce_buttons($plugin_array) {
20 $plugin_array = array();
21 $plugin_array['wpforo_pre_button'] = WPFORO_URL . '/wpf-assets/js/tinymce-pre.js';
22 $plugin_array['wpforo_link_button'] = WPFORO_URL . '/wpf-assets/js/tinymce-link.js';
23 $plugin_array['wpforo_source_code_button'] = WPFORO_URL . '/wpf-assets/js/tinymce-code.js';
24 return $plugin_array;
25 }
26
27 function filter_tinymce_plugins($plugins){
28 return array('hr','lists','textcolor');
29 }
30
31 function add_tinymce_translations($mce_translation){
32 $mce_translation['Insert link'] = __( 'Insert link' );
33 $mce_translation['Link Text'] = __( 'Link Text' );
34 $mce_translation['Open link in a new tab'] = __( 'Open link in a new tab' );
35 return $mce_translation;
36 }
37
38 function topic_form($forumid){
39 if(!isset($this->wpforo->post_options['max_upload_size']) || !$this->wpforo->post_options['max_upload_size']){ $server_mus = wpforo_human_size_to_bytes(ini_get('upload_max_filesize')); if( !$server_mus || $server_mus > 10485760 ) $server_mus = 10485760; $this->wpforo->post_options['max_upload_size'] = $server_mus;}
40 ?>
41 <div id="wpf-topic-create" class="wpf-topic-create">
42 <form name="topic" action="" enctype="multipart/form-data" method="POST">
43 <?php wp_nonce_field( 'wpforo_verify_form', 'wpforo_form' ); ?>
44 <input type="hidden" name="topic[action]" value="add"/>
45 <input type="hidden" id="parent" name="topic[forumid]" value="<?php echo intval($forumid) ?>" />
46
47 <label style="padding-left: 8px;"> <?php wpforo_phrase('Topic Title') ?>:&nbsp; </label>
48 <input required="true" autofocus type="text" name="topic[title]" class="wpf-subject" value="" id="title" autocomplete="off" placeholder="<?php wpforo_phrase('Enter title here') ?>">
49 <?php
50 $content = '';
51 $editor_id = 'postbody';
52 $settings = array(
53 'wpautop' => true,// use wpautop?
54 'media_buttons'=> FALSE,// show insert / upload button(s)
55 'textarea_name'=> $editor_id,// set the textarea name to something different, square brackets [] can be used here
56 'textarea_rows'=> get_option('default_post_edit_rows', 20),// rows = "..."
57 'tabindex'=> '',
58 'editor_height' => '180',
59 'editor_css' => '', // intended for extra styles for both visual and HTML editors buttons, needs to include the < style > tags, can use "scoped".
60 'editor_class'=> '', // add extra class(es) to the editor textarea
61 'teeny'=> FALSE, // output the minimal editor config used in Press This
62 'dfw'=> false, // replace the default fullscreen with DFW (supported on the front - end in WordPress 3.4)
63 'tinymce'=> array(
64 'toolbar1' => 'bold,italic,underline,strikethrough,forecolor,bullist,numlist,hr,alignleft,aligncenter,alignright,alignjustify,link,unlink,blockquote,pre,undo,redo,source_code',
65 'toolbar2' => '',
66 'toolbar3' => '',
67 'toolbar4' => ''
68 ), // load TinyMCE, can be used to pass settings directly to TinyMCE using an array()
69 'quicktags'=> true, // load Quicktags, can be used to pass settings directly to Quicktags using an array()
70 'default_editor' => 'tinymce'
71 );
72 wp_editor( $content, $editor_id, $settings );
73 ?>
74 <div class="wpf-extra-fields">
75 <?php if($this->wpforo->perm->forum_can('s', $forumid)) : ?>
76 <input id="t_sticky" name="topic[type]" type="checkbox" value="0">&nbsp;&nbsp;
77 <i class="fa fa-exclamation fa-0x"></i>&nbsp;&nbsp;<label for="t_sticky" style="padding-bottom:2px; cursor: pointer;"><?php wpforo_phrase('Set Topic Sticky'); ?>&nbsp;</label>
78 <span class="wpfbs">&nbsp;&nbsp;|&nbsp;&nbsp;</span>
79 <?php endif ?>
80 <?php if($this->wpforo->perm->forum_can('p', $forumid) || $this->wpforo->perm->forum_can('op', $forumid)) : ?>
81 <input id="t_private" name="topic[private]" type="checkbox" value="0">&nbsp;&nbsp;
82 <i class="fa fa-eye-slash fa-0x"></i>&nbsp;&nbsp;<label for="t_private" style="padding-bottom:2px; cursor: pointer;" title="<?php wpforo_phrase('Only Admins and Moderators can see your private topics.'); ?>"><?php wpforo_phrase('Private Topic'); ?>&nbsp;</label>
83 <span class="wpfbs">&nbsp;&nbsp;|&nbsp;&nbsp;</span>
84 <?php endif ?>
85 <?php do_action('wpforo_topic_form_buttons_hook'); ?>&nbsp;&nbsp;
86 <?php if(!defined('WPFOROATTACH_BASENAME') && $this->wpforo->perm->forum_can('a', $forumid)): ?>
87 <div class="wpf-default-attachment" style="padding-top:5px;">
88 <label for="file"><?php wpforo_phrase('Attach file:') ?> </label> <input id="file" type="file" name="attachfile" />
89 <p><?php wpforo_phrase('Maximum allowed file size is'); echo ' ' . wpforo_print_size($this->wpforo->post_options['max_upload_size']); ?></p>
90 </div>
91 <?php endif; ?>
92 </div>
93 <?php if( wpforo_feature('subscribe_checkbox_on_post_editor', $this->wpforo) ) : ?>
94 <div class="wpf-topic-sbs" style="float:left;"><input id="wpf-topic-sbs" type="checkbox" name="wpforo_topic_subs" value="1" <?php echo ( wpforo_feature('subscribe_checkbox_default_status', $this->wpforo) ) ? 'checked="true" ' : ''; ?>/>&nbsp;<label for="wpf-topic-sbs"><?php wpforo_phrase('Subscribe to this topic') ?></label></div>
95 <?php endif; ?>
96 <input id="formbutton" type="submit" name="topic[save]" class="button button-primary forum_submit" value="<?php wpforo_phrase('Save') ?>">
97 <div class="wpf-clear"></div>
98 </form>
99 </div>
100
101 <?php
102 }
103
104 /**
105 *
106 * @param array $args
107 *
108 * Please note that all array elements are required!
109 * example of args
110 * $default = array(
111 * "topic_closed" => $topic['closed'], // is topic closed or opened (values 1 or 0)
112 * "topicid" => $topic['topicid'], // the id of topic
113 * "forumid" => $forum_data['forumid'],
114 * "layout" => $cat_layout,
115 * "topic_title" => $topic['title'] // the title of topic
116 * );
117 *
118 * @return html form
119 */
120
121 function reply_form($args){
122 extract($args, EXTR_OVERWRITE); ?>
123 <!-- Report Dialog -->
124
125 <div id="reportdialog" title="<?php esc_attr( wpforo_phrase('Report to Administration') ) ?>" style="display: none">
126 <form id="reportform">
127 <input type="hidden" id="reportpostid" value=""/>
128 <textarea required style="width:100%; height:105px;" id="reportmessagecontent" placeholder="<?php wpforo_phrase('Write message') ?>"></textarea>
129 </form>
130 <input style="float: right;" id="sendreport" type="submit" value="<?php wpforo_phrase('Send Report') ?>"/>
131 </div>
132
133 <!-- Report Dialog end -->
134
135 <!-- Move Dialog -->
136
137 <div id="movedialog" title="<?php esc_attr( wpforo_phrase('Move topic') ) ?>" style="display: none">
138 <div class="form-field">
139 <label for="parent"><?php wpforo_phrase('Choose target forum') ?></label>
140 <form id="topicmoveform" method="POST">
141 <?php wp_nonce_field( 'wpforo_verify_form', 'wpforo_form' ); ?>
142 <input type="hidden" name="movetopicid" value="<?php echo intval($topicid) ?>"/>
143 <input type="hidden" name="post[save]" value="move"/>
144 <select id="parent" name="topic[forumid]" class="postform">
145 <?php $this->wpforo->forum->tree('select_box', FALSE, $topicid ); ?>
146 </select>
147 <input type="submit" value="<?php wpforo_phrase('Move') ?>"/>
148 </form>
149 </div>
150 </div>
151
152 <!-- move Dialog end -->
153 <?php
154 if( $topic_closed ) return;
155
156 $head_html = '<p id="wpf-reply-form-title">'.wpforo_phrase('Leave a reply', false).'</p>';
157 $head_html = apply_filters( 'wpforo_reply_form_head', $head_html, $args );
158 if(!isset($this->wpforo->post_options['max_upload_size']) || !$this->wpforo->post_options['max_upload_size']){$server_mus = wpforo_human_size_to_bytes(ini_get('upload_max_filesize')); if( !$server_mus || $server_mus > 10485760 ) $server_mus = 10485760; $this->wpforo->post_options['max_upload_size'] = $server_mus;}
159 ?>
160 <div id="wpf-form-wrapper">
161 <?php echo $head_html; //this is a HTML content ?>
162 <div id="wpf-post-create" class="wpf-post-create">
163 <form name="post" action="" enctype="multipart/form-data" method="POST" class="editor">
164 <?php wp_nonce_field( 'wpforo_verify_form', 'wpforo_form' ); ?>
165 <input type="hidden" id="formaction" name="post[action]" value="add"/>
166 <input type="hidden" id="formtopicid" name="post[topicid]" value="<?php echo intval($topicid) ?>"/>
167 <input type="hidden" id="postparentid" name="post[parentid]" value="0"/>
168 <input type="hidden" id="formpostid" name="post[postid]" value=""/>
169 <input type="hidden" id="parent" name="post[forumid]" value="<?php echo intval($forumid) ?>" />
170 <?php
171 $reply_title = wpforo_phrase('RE', false) . ': '. $topic_title;
172 $reply_title = apply_filters( 'wpforo_reply_form_field_title', $reply_title, $args );
173 $reply_title = esc_attr($reply_title);
174 ?>
175 <input id="title" required="true" type="text" name="post[title]" class="wpf-subject" value="<?php if($reply_title) echo esc_attr($reply_title); ?>" autocomplete="off" placeholder="<?php if($reply_title) echo esc_attr($reply_title); ?>"><br/>
176 <?php
177 $content = '';
178 $editor_id = 'postbody';
179 $settings = array(
180 'wpautop' => true,// use wpautop?
181 'media_buttons'=> FALSE,// show insert / upload button(s)
182 'textarea_name'=> $editor_id,// set the textarea name to something different, square brackets [] can be used here
183 'textarea_rows'=> get_option('default_post_edit_rows', 5),// rows = "..."
184 'editor_class'=> 'wpeditor', // add extra class(es) to the editor textarea
185 'teeny'=> false, // output the minimal editor config used in Press This
186 'dfw'=> false, // replace the default fullscreen with DFW (supported on the front - end in WordPress 3.4)
187 'editor_height' => '180',
188 'tinymce'=> array(
189 'toolbar1' => 'bold,italic,underline,strikethrough,forecolor,bullist,numlist,hr,alignleft,aligncenter,alignright,alignjustify,link,unlink,blockquote,pre,undo,redo,source_code',
190 'toolbar2' => '',
191 'toolbar3' => '',
192 'toolbar4' => ''
193 ), // load TinyMCE, can be used to pass settings directly to TinyMCE using an array()
194 'quicktags'=> true, // load Quicktags, can be used to pass settings directly to Quicktags using an array()
195 'default_editor' => 'tinymce' // load Quicktags, can be used to pass settings directly to Quicktags using an array()
196 );
197 wp_editor( $content, $editor_id, $settings );
198 ?>
199 <div class="wpf-extra-fields">
200 <?php do_action('wpforo_reply_form_buttons_hook'); ?>&nbsp;&nbsp;
201 <?php if(!defined('WPFOROATTACH_BASENAME') && $this->wpforo->perm->forum_can('a', $forumid)): ?>
202 <div class="wpf-default-attachment">
203 <label for="file"><?php wpforo_phrase('Attach file:') ?> </label> <input id="file" type="file" name="attachfile" />
204 <p><?php wpforo_phrase('Maximum allowed file size is'); echo ' ' . wpforo_print_size($this->wpforo->post_options['max_upload_size']); ?></p>
205 </div>
206 <?php endif; ?>
207 </div>
208 <?php if( wpforo_feature('subscribe_checkbox_on_post_editor', $this->wpforo) ) :
209 $args = array( "userid" => $this->wpforo->current_userid , "itemid" => intval($topicid), "type" => "topic" );
210 $subscribe = $this->wpforo->sbscrb->get_subscribe( $args );
211 if( !isset($subscribe['subid']) ) : ?>
212 <div class="wpf-topic-sbs"><input id="wpf-topic-sbs" type="checkbox" name="wpforo_topic_subs" value="1" <?php echo ( wpforo_feature('subscribe_checkbox_default_status', $this->wpforo) ) ? 'checked="true" ' : ''; ?> />&nbsp;<label for="wpf-topic-sbs"><?php wpforo_phrase('Subscribe to this topic') ?></label></div>
213 <?php endif;
214 endif; ?>
215 <input id="formbutton" type="submit" name="post[save]" class="button button-primary forum_submit" value="<?php wpforo_phrase('Save') ?>">
216 <div class="wpf-clear"></div>
217 </form>
218 </div>
219 </div>
220 <?php
221 }
222
223 function pagenavi($paged, $items_count, $permalink = TRUE){
224 $items_per_page = ( $this->wpforo->current_object['template'] == 'topic' ? $this->wpforo->post_options['topics_per_page'] : $this->wpforo->post_options['posts_per_page'] );
225 if($items_count <= $items_per_page) return;
226
227 $pages_count = ceil($items_count/$items_per_page);
228
229 if($permalink){
230 $url = trim( preg_replace('#\/paged\/[\d]+\/*.*$#is', '', wpforo_get_request_uri()), '/' ) . '/paged/';
231 }else{
232 $url = trim( preg_replace('#[\&\?]wpfpaged=[\d]*.*$#is', '', wpforo_get_request_uri()), '/' );
233 $url .= (strpos($url, '?') === FALSE ? '?' : '&') . 'wpfpaged=';
234 }
235 ?>
236
237 <div class="wpf-navi">
238 <div class="wpf-navi-wrap">
239 <span class="wpf-page-info"><?php wpforo_phrase('Page') ?> <?php echo intval($paged) ?> / <?php echo intval($pages_count) ?></span>
240 <?php if( $paged - 1 > 0 ): ?><a href="<?php echo esc_url($url) . ($paged - 1) ?>" class="wpf-prev-button"><i class="fa fa-chevron-left fa-sx"></i> <?php wpforo_phrase('prev') ?></a><?php endif ?>
241 <select class="wpf-navi-dropdown" onchange="if (this.value) window.location.href=this.value" title="<?php esc_attr( wpforo_phrase('Select Page') ) ?>">
242 <?php for($i = 1; $i <= $pages_count; $i++) : ?>
243 <option value="<?php echo esc_url($url) . $i ?>" <?php echo $paged == $i ? ' selected="selected"' : '' ?>><?php echo intval($i); ?></option>
244 <?php endfor; ?>
245 </select>
246 <?php if( $paged + 1 <= $pages_count ): ?><a href="<?php echo esc_url($url) . ($paged + 1) ?>" class="wpf-prev-button"><?php wpforo_phrase('next') ?> <i class="fa fa-chevron-right fa-sx"></i></a><?php endif ?>
247 </div>
248 </div>
249
250 <?php
251 }
252
253 function likers($postid){
254 if(!$postid) return '';
255
256 $return = '';
257 if( $l_count = $this->wpforo->post->get_post_likes_count($postid) ){
258 $l_usernames = $this->wpforo->post->get_likers_usernames($postid);
259 if($l_usernames[0]['ID'] == $this->wpforo->current_userid) $l_usernames[0]['display_name'] = wpforo_phrase('You', FALSE);
260 if($l_count == 1){
261 $return = sprintf( wpforo_phrase('%s liked', FALSE), '<a href="' . esc_url($this->wpforo->member->get_profile_url($l_usernames[0]['ID'])) . '">'.esc_html($l_usernames[0]['display_name']).'</a>' );
262 }elseif($l_count == 2){
263 $return = sprintf( wpforo_phrase('%s and %s liked', FALSE), '<a href="' . esc_url($this->wpforo->member->get_profile_url($l_usernames[0]['ID'])) . '">'.esc_html($l_usernames[0]['display_name']).'</a>', '<a href="'.esc_url($this->wpforo->member->get_profile_url($l_usernames[1]['ID'])).'">'.esc_html($l_usernames[1]['display_name']).'</a>' );
264 }elseif($l_count == 3){
265 $return = sprintf( wpforo_phrase('%s, %s and %s liked', FALSE), '<a href="' . esc_url($this->wpforo->member->get_profile_url($l_usernames[0]['ID'])) .'">'.esc_html($l_usernames[0]['display_name']).'</a>', '<a href="'.esc_url($this->wpforo->member->get_profile_url($l_usernames[1]['ID'])).'">'.esc_html($l_usernames[1]['display_name']).'</a>', '<a href="'.esc_url($this->wpforo->member->get_profile_url($l_usernames[2]['ID'])).'">'.esc_html($l_usernames[2]['display_name']).'</a>' );
266 }elseif($l_count >= 4){
267 $l_count = $l_count - 3;
268 $return = sprintf( wpforo_phrase('%s, %s, %s and %d people liked', FALSE), '<a href="' . esc_url($this->wpforo->member->get_profile_url($l_usernames[0]['ID'])) .'">'.esc_html($l_usernames[0]['display_name']).'</a>', '<a href="'.esc_url($this->wpforo->member->get_profile_url($l_usernames[1]['ID'])).'">'.esc_html($l_usernames[1]['display_name']).'</a>', '<a href="'.esc_url($this->wpforo->member->get_profile_url($l_usernames[2]['ID'])).'">'.esc_html($l_usernames[2]['display_name']).'</a>', $l_count );
269 }
270 }
271 return $return;
272 }
273
274
275 /**
276 * Get actions buttons
277 *
278 * @since 1.0.0
279 *
280 * @param array buttons names function will return buttons by this array
281 *
282 * @param array $forum required
283 *
284 * @param array $topic required
285 *
286 * @param array $post required
287 *
288 * @param int $is_topic required this is a first post in the loop
289 *
290 * $buttons = array( 'reply', 'answer', 'comment', 'quote', 'like', 'report', 'sticky', 'close', 'move', 'edit', 'delete', 'link' );
291 *
292 * @return html ( buttons )
293 */
294
295 function buttons( $buttons, $forum = array(), $topic = array(), $post = array(), $is_topic = FALSE ){
296
297 $button_html = array();
298
299 $forumid = (isset($forum['forumid'])) ? $forum['forumid'] : 0;
300 $topicid = (isset($topic['topicid'])) ? $topic['topicid'] : 0;
301 $postid = (isset($post['postid'])) ? $post['postid'] : 0;
302
303 $is_sticky = (isset($topic['type'])) ? $topic['type'] : 0;
304 $is_closed = (isset($topic['closed'])) ? $topic['closed'] : 0;
305 $is_private = (isset($topic['private'])) ? $topic['private'] : 0;
306 $is_solved = (isset($post['is_answer'])) ? $post['is_answer'] : 0;
307
308 foreach($buttons as $button){
309
310 switch($button){
311
312 case 'reply':
313 if($is_closed) break;
314 if( $this->wpforo->perm->forum_can('cr', $forumid) ){
315 $button_html[] = '<span id="parentpostid'.intval($postid).'" class="wpforo-reply wpf-action add_post_button"><i class="fa fa-reply fa-rotate-180"></i>' . wpforo_phrase('Reply', false).'</span>';
316 }else{
317 $button_html[] = '<span class="wpf-action not_reg_user"><i class="fa fa-reply fa-rotate-180"></i> ' . wpforo_phrase('Reply', false).'</span>';
318 }
319 break;
320 case 'answer':
321 if( $this->wpforo->perm->forum_can('cr', $forumid) ){
322 $button_html[] = '<span class="wpforo-answer wpf-button add_post_button"><i class="fa fa-pencil"></i> ' . wpforo_phrase('Answer', false).'</span>';
323 }else{
324 $button_html[] = '<span class="wpf-button not_reg_user"><i class="fa fa-pencil"></i> ' . wpforo_phrase('Answer', false).'</span>';
325 }
326 break;
327 case 'comment':
328 if($is_closed) break;
329 $title = wpforo_phrase('Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.', false);
330 if( $this->wpforo->perm->forum_can('cr', $forumid) ) {
331 $button_html[] = '<span id="parentpostid'.intval($postid).'" class="wpforo-childreply wpf-button add_post_button" title="'.esc_attr($title).'"><i class="fa fa-comment"></i> ' . wpforo_phrase('Add a comment', false).'</span>';
332 }else{
333 $button_html[] = '<span class="not_reg_user wpf-button add_post_button" title="'.esc_attr($title).'"><i class="fa fa-comment"></i> ' . wpforo_phrase('Add a comment', false).'</span>';
334 }
335 break;
336 case 'quote':
337 if($is_closed) break;
338 if( $this->wpforo->perm->forum_can('cr', $forumid) ) {
339 $button_html[] = '<span id="wpfquotepost'.intval($postid).'" class="wpforo-quote wpf-action"><i class="fa fa-quote-left fa-0x"></i>' . wpforo_phrase('Quote', false).'</span>';
340 }else{
341 $button_html[] = '<span class="wpf-action not_reg_user"><i class="fa fa-quote-left fa-0x"></i>' . wpforo_phrase('Quote', false).'</span>';
342 }
343 break;
344 case 'like':
345 if( $this->wpforo->perm->forum_can('l', $forumid) ) {
346 $like_status = ( $this->wpforo->post->is_liked( $postid, $this->wpforo->current_userid ) === FALSE ? 'wpforo-like' : 'wpforo-unlike' );
347 $like_icode = ( $like_status == 'wpforo-like') ? 'up' : 'down';
348 $button_html[] = '<span id="wpflike'. intval($postid) .'" class="wpf-action '. sanitize_html_class($like_status) .'"><i id="likeicon'. intval($postid) .'" class="fa fa-thumbs-o-'. esc_attr($like_icode) .' fa-0x"></i><span id="liketext'. intval($postid) .'">' . wpforo_phrase( str_replace('wpforo-', '', $like_status), false) . '</span></span>';
349 }
350 break;
351 case 'report':
352 if( $this->wpforo->perm->forum_can('r', $forumid) ) {
353 $button_html[] = '<span id="wpfreport'. intval($postid) .'" class="wpf-action wpforo-report"><i class="fa fa-exclamation-triangle"></i>' . wpforo_phrase('Report', false).'</span>';
354 }
355 break;
356 case 'sticky':
357 if( $this->wpforo->perm->forum_can('s', $forumid) ) {
358 $sticky_status = ( $is_sticky ? 'wpforo-unsticky' : 'wpforo-sticky');
359 $button_html[] = '<span id="wpfsticky'. intval($topicid) .'" class="wpf-action '. sanitize_html_class($sticky_status) .'"><i class="fa fa-exclamation fa-0x"></i><span id="stickytext'. intval($topicid) .'">' . wpforo_phrase( str_replace('wpforo-', '', $sticky_status), false).'</span></span>';
360 }
361 break;
362 case 'private':
363 if( $this->wpforo->perm->forum_can('p', $forumid) || ($this->wpforo->current_userid == $post['userid'] && $this->wpforo->perm->forum_can('op', $forumid)) ) {
364 $private_status = ( $is_private ? 'wpforo-public' : 'wpforo-private');
365 $private_icon = ( $private_status == 'wpforo-public') ? 'eye' : 'eye-slash';
366 $button_html[] = '<span id="wpfprivate'. intval($topicid) .'" class="wpf-action '. sanitize_html_class($private_status) .'"><i id="privateicon'. intval($topicid) .'" class="fa fa-'. esc_attr($private_icon) .' fa-0x"></i><span id="privatetext'. intval($topicid) .'">' . wpforo_phrase( str_replace('wpforo-', '', $private_status), false).'</span></span>';
367 }
368 break;
369 case 'solved':
370 if( $this->wpforo->perm->forum_can('sv', $forumid) || ($this->wpforo->current_userid == $post['userid'] && $this->wpforo->perm->forum_can('osv', $forumid)) ) {
371 $solved_status = ( $is_solved ? 'wpforo-unsolved' : 'wpforo-solved');
372 $button_html[] = '<span id="wpfsolved'. intval($postid) .'" class="wpf-action '. sanitize_html_class($solved_status) .'"><i class="fa fa-check-circle fa-0x"></i><span id="solvedtext'. intval($postid) .'">' . wpforo_phrase( str_replace('wpforo-', '', $solved_status), false).'</span></span>';
373 }
374 break;
375 case 'close':
376 if( $this->wpforo->perm->forum_can('cot', $forumid) ) {
377 $open_status = ( $is_closed ? 'wpforo-open' : 'wpforo-close' );
378 $open_icon = ($open_status == 'wpforo-open') ? 'unlock' : 'lock';
379 $button_html[] = '<span id="wpfclose'. intval($topicid) .'" class="wpf-action '. sanitize_html_class($open_status) .'"><i id="closeicon'. intval($topicid) .'" class="fa fa-'. esc_attr($open_icon) .' fa-0x"></i><span id="closetext'. intval($topicid) .'">' . wpforo_phrase( str_replace('wpforo-', '', $open_status), false).'</span></span>';
380 }
381 break;
382 case 'move':
383 if( $this->wpforo->perm->forum_can('mt', $forumid) ) {
384 $button_html[] = '<span class="wpf-action wpforo-move"><i class="fa fa-share-square-o fa-0x"></i>' . wpforo_phrase('Move', false).'</span>';
385 }
386 break;
387 case 'edit':
388 if($is_closed) break;
389 $diff = current_time( 'timestamp', 1 ) - strtotime($post['created']);
390 if( $this->wpforo->perm->forum_can( ($is_topic ? 'et' : 'er'), $forumid ) || ($this->wpforo->current_userid == $post['userid'] && $this->wpforo->perm->forum_can( ($is_topic ? 'eot' : 'eor' ), $forumid ) && $diff < $this->wpforo->post_options[($is_topic ? 'eot' : 'eor' ).'_durr'] ) ) {
391 $a = ( $is_topic ) ? 'wpfedittopicpid' : '';
392 $b = ( $is_topic ) ? $postid : $postid;
393 $button_html[] = '<span id="'. esc_attr( $a . $b ) .'" class="wpforo-edit wpf-action"><i class="fa fa-edit fa-0x"></i>' . wpforo_phrase('Edit', false).'</span>';
394 }
395 break;
396 case 'delete':
397 $diff = current_time( 'timestamp', 1 ) - strtotime($post['created']);
398 if( $this->wpforo->perm->forum_can( ($is_topic ? 'dt' : 'dr' ), $forumid ) || ($this->wpforo->current_userid == $post['userid'] && $this->wpforo->perm->forum_can( ($is_topic ? 'dot' : 'dor' ), $forumid ) && $diff < $this->wpforo->post_options[($is_topic ? 'dot' : 'dor' ).'_durr']) ){
399 $a = ( $is_topic ) ? 'wpftopicdelete' : 'wpfreplydelete';
400 $b = ( $is_topic ) ? $topicid : $postid;
401 $button_html[] = '<span id="'. esc_attr( $a . $b ) .'" class="wpf-action wpforo-delete"><i class="fa fa-times fa-0x"></i>' . wpforo_phrase('Delete', false).'</span>';
402 }
403 break;
404 case 'link':
405 $url = ( $is_topic ) ? $this->wpforo->topic->get_topic_url( $topic ) : $this->wpforo->post->get_post_url( $post );
406 $button_html[] = '<a href="'. esc_url($url) .'"><i class="fa fa-link fa-0x"></i></a>';
407 break;
408 case 'positivevote':
409 if( $this->wpforo->perm->forum_can('v', $forumid) ) {
410 $button_html[] = '<i itemtype="' . ( $is_topic ? 'topic' : 'reply' ) . '" id="wpfvote-up-'. intval($postid) .'" class="voteup fa fa-play fa-rotate-270 wpfcl-0"></i>';
411 }else{
412 $button_html[] = '<i class="not_reg_user fa fa-play fa-rotate-270 wpfcl-0"></i>';
413 }
414 break;
415 case 'negativevote':
416 if( $this->wpforo->perm->forum_can('v', $forumid) ) {
417 $button_html[] = '<i itemtype="' . ( $is_topic ? 'topic' : 'reply' ) . '" id="wpfvote-down-'. intval($postid) .'" class="votedown fa fa-play fa-rotate-90 wpfcl-0"></i>';
418 }else{
419 $button_html[] = '<i class="not_reg_user fa fa-play fa-rotate-90 wpfcl-0"></i>';
420 }
421 break;
422 case 'isanswer':
423 $is_answer = $this->wpforo->post->is_answered( $postid );
424 $is_answer = ( $is_answer == 0 ) ? '-not' : '';
425 if( is_user_logged_in() ){
426 $button_html[] = '<div id="wpf-answer-'. intval($postid) .'" class="wpf-toggle'. esc_attr($is_answer) .'-answer"><i class="fa fa-check"></i></div>';
427 }else{
428 $button_html[] = '<div class="wpf-toggle'. esc_attr($is_answer) .'-answer not_reg_user"><i class="fa fa-check"></i></div>';
429 }
430 break;
431 } //switch
432 } //foreach
433
434 echo implode('', $button_html);
435
436 }
437
438 function breadcrumb($url_data){
439 extract($url_data, EXTR_OVERWRITE);
440
441 switch($template) :
442 case 'search': ?>
443
444 <div class="wpf-breadcrumb">
445 <a href="<?php echo WPFORO_BASE_URL ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i></a>
446
447 <a href="#" class="active"><?php wpforo_phrase('Search') ?></a>
448
449 <a href="#" class="wpf-end">&nbsp;</a>
450 </div>
451
452 <?php break;
453 case 'signup': ?>
454
455 <div class="wpf-breadcrumb">
456 <a href="<?php echo WPFORO_BASE_URL ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i></a>
457
458 <a href="#" class="active"><?php wpforo_phrase('Register') ?></a>
459
460 <a href="#" class="wpf-end">&nbsp;</a>
461 </div>
462
463 <?php break;
464 case 'signin': ?>
465
466 <div class="wpf-breadcrumb">
467 <a href="<?php echo WPFORO_BASE_URL ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i></a>
468
469 <a href="#" class="active"><?php wpforo_phrase('Login') ?></a>
470
471 <a href="#" class="wpf-end">&nbsp;</a>
472 </div>
473
474 <?php break;
475 case 'members': ?>
476
477 <div class="wpf-breadcrumb">
478 <a href="<?php echo WPFORO_BASE_URL ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i></a>
479
480 <?php if(isset($_GET['wpfms'])) : ?>
481
482 <a href="<?php echo WPFORO_BASE_URL ?>members/"><?php wpforo_phrase('Members') ?></a>
483 <a href="#" class="active"><?php wpforo_phrase('Search') ?></a>
484
485 <?php else : ?>
486
487 <a href="#" class="active"><?php wpforo_phrase('Members') ?></a>
488
489 <?php endif ?>
490
491 <a href="#" class="wpf-end">&nbsp;</a>
492 </div>
493
494 <?php break;
495 case 'profile': ?>
496
497 <div class="wpf-breadcrumb">
498 <a href="<?php echo WPFORO_BASE_URL ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i></a>
499
500 <a href="<?php echo WPFORO_BASE_URL ?>members/"><?php wpforo_phrase('Members') ?></a>
501 <a href="#" class="active"><?php wpforo_text( !empty($user['display_name']) ? esc_html($user['display_name']) : !empty($user['user_nicename']) ? esc_html(urldecode($user['user_nicename'])) : '', 19 ) ?></a>
502
503 <a href="#" class="wpf-end">&nbsp;</a>
504 </div>
505
506 <?php break;
507 case 'account': ?>
508
509 <div class="wpf-breadcrumb">
510 <a href="<?php echo WPFORO_BASE_URL ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i>
511
512 <a href="<?php echo WPFORO_BASE_URL ?>members/"><?php wpforo_phrase('Members') ?></a>
513 <a href="<?php echo esc_url($user['profile_url']) ?>"><?php wpforo_text( !empty($user['display_name']) ? esc_html($user['display_name']) : !empty($user['user_nicename']) ? esc_html(urldecode($user['user_nicename'])) : '', 19 ) ?></a>
514 <a href="#" class="active"><?php wpforo_phrase('Account') ?></a>
515
516 <a href="#" class="wpf-end">&nbsp;</a>
517 </div>
518
519 <?php break;
520 case 'activity': ?>
521
522 <div class="wpf-breadcrumb">
523 <a href="<?php echo WPFORO_BASE_URL ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i>
524
525 <a href="<?php echo WPFORO_BASE_URL ?>members/"><?php wpforo_phrase('Members') ?></a>
526 <a href="<?php echo esc_url($user['profile_url']) ?>"><?php wpforo_text( !empty($user['display_name']) ? esc_html($user['display_name']) : !empty($user['user_nicename']) ? esc_html(urldecode($user['user_nicename'])) : '', 19 ) ?></a>
527 <a href="#" class="active"><?php wpforo_phrase('Activity') ?></a>
528
529 <a href="#" class="wpf-end">&nbsp;</a>
530 </div>
531
532 <?php break;
533 case 'subscriptions': ?>
534
535 <div class="wpf-breadcrumb">
536 <a href="<?php echo WPFORO_BASE_URL ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i>
537
538 <a href="<?php echo WPFORO_BASE_URL ?>members/"><?php wpforo_phrase('Members') ?></a>
539 <a href="<?php echo esc_url($user['profile_url']) ?>"><?php wpforo_text( !empty($user['display_name']) ? esc_html($user['display_name']) : !empty($user['user_nicename']) ? esc_html(urldecode($user['user_nicename'])) : '', 19 ) ?></a>
540 <a href="#" class="active"><?php wpforo_phrase('Subscriptions') ?></a>
541
542 <a href="#" class="wpf-end">&nbsp;</a>
543 </div>
544
545 <?php break;
546 // TODO: move code to pm plugin
547 case 'messages': ?>
548
549 <div class="wpf-breadcrumb">
550 <a href="<?php echo WPFORO_BASE_URL ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i>
551
552 <a href="<?php echo WPFORO_BASE_URL ?>members/"><?php wpforo_phrase('Members') ?></a>
553
554 <?php if(!empty($user)) : ?>
555
556 <a href="<?php echo esc_url($user['profile_url']) ?>"><?php wpforo_text( !empty($user['display_name']) ? esc_html($user['display_name']) : !empty($user['user_nicename']) ? esc_html(urldecode($user['user_nicename'])) : '', 19 ) ?></a>
557
558 <?php endif ?>
559
560 <a href="#" class="active"><?php wpforo_phrase('Messages') ?></a>
561
562 <a href="#" class="wpf-end">&nbsp;</a>
563 </div>
564
565 <?php break;
566 case 'topic': ?>
567
568 <div class="wpf-breadcrumb">
569 <a href="<?php echo ( !isset($forumid) ? '#' : WPFORO_BASE_URL ) ?>" class="wpf-root<?php echo ( !isset($forumid) ? ' active' : '' ) ?>" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i></a>
570
571 <?php if(isset($forumid)) : ?>
572 <?php $relative_ids = array();
573 $this->wpforo->forum->get_all_relative_ids($forumid, $relative_ids);
574 foreach( $relative_ids as $key => $rel_forumid ) : ?>
575 <?php $forum = $this->wpforo->forum->get_forum($rel_forumid) ?>
576 <?php if( $key != ( count($relative_ids) - 1 ) ) : ?>
577
578 <a href="<?php echo esc_url($this->wpforo->forum->get_forum_url($rel_forumid)) ?>" title="<?php echo esc_attr($forum['title']) ?>"><?php wpforo_text($forum['title'], 19) ?></a>
579
580 <?php else : ?>
581
582 <a href="#" class="active" title="<?php echo esc_attr($forum['title']) ?>"><?php wpforo_text($forum['title'], 19) ?></a>
583
584 <?php endif ?>
585 <?php endforeach ?>
586 <?php endif ?>
587
588 <a href="#" class="wpf-end">&nbsp;</a>
589 </div>
590
591 <?php break;
592 case 'post': ?>
593
594 <div class="wpf-breadcrumb">
595 <a href="<?php echo ( !isset($forumid) ? '#' : WPFORO_BASE_URL ) ?>" class="wpf-root<?php echo ( !isset($forumid) ? ' active' : '' ) ?>" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i></a>
596
597 <?php if(isset($forumid)) : ?>
598 <?php $relative_ids = array();
599 $this->wpforo->forum->get_all_relative_ids($forumid, $relative_ids);
600 foreach( $relative_ids as $key => $rel_forumid ) : ?>
601 <?php $forum = $this->wpforo->forum->get_forum($rel_forumid) ?>
602
603 <a href="<?php echo esc_url($this->wpforo->forum->get_forum_url($rel_forumid)) ?>" title="<?php echo esc_attr($forum['title']) ?>"><?php wpforo_text($forum['title'], 19) ?></a>
604
605 <?php endforeach ?>
606 <?php endif ?>
607 <?php if(!empty($topic)) : ?>
608
609 <a href="#" class="active" title="<?php echo esc_attr($topic['title']) ?>"><?php wpforo_text($topic['title'], 19) ?></a>
610
611 <?php endif ?>
612 <a href="#" class="wpf-end">&nbsp;</a>
613 </div>
614
615 <?php break;
616 default: ?>
617
618 <div class="wpf-breadcrumb">
619 <a href="#" class="wpf-root active"><?php wpforo_phrase('Forums') ?></a>
620 <a href="#" class="wpf-end">&nbsp;</a>
621 </div>
622
623 <?php
624 endswitch;
625
626 }
627
628 function icon($type, $item = array(), $echo = true, $data = 'icon' ){
629
630 $icon = array();
631 $status = false;
632 if(isset($item['type'])){
633
634 if( $type == 'topic' ){
635 if($this->wpforo->topic->is_private($item['topicid'])){
636 $icon['class'] = 'fa-eye-slash';
637 $icon['color'] = 'wpfcl-1';
638 $icon['title'] = wpforo_phrase('Private', false);
639 if($echo) {
640 $status = true; echo ($data == 'icon') ? implode(' ', $icon) : $icon['title'];
641 }
642 else{
643 return ($data == 'icon') ? implode(' ', $icon) : $icon['title'];
644 }
645 }
646 if($this->wpforo->topic->is_solved($item['topicid'])){
647 $icon['class'] = 'fa-check-circle';
648 $icon['color'] = 'wpfcl-8';
649 $icon['title'] = wpforo_phrase('Solved', false);
650 if($echo) {
651 $status = true; echo ($data == 'icon') ? implode(' ', $icon) : $icon['title'];
652 }
653 else{
654 return ($data == 'icon') ? implode(' ', $icon) : $icon['title'];
655 }
656 }
657 }
658
659 if( $item['closed'] && $item['type'] == 1 ){
660 $icon['class'] = 'fa-lock';
661 $icon['color'] = 'wpfcl-1';
662 $icon['title'] = wpforo_phrase('Closed', false);
663 if($echo) { $status = true; echo ($data == 'icon') ? implode(' ', $icon) : $icon['title']; } else{ return ($data == 'icon') ? implode(' ', $icon) : $icon['title']; }
664 }
665 elseif( $item['closed'] && $item['type'] != 1 ){
666 $icon['class'] = 'fa-lock';
667 $icon['color'] = 'wpfcl-1';
668 $icon['title'] = wpforo_phrase('Closed', false);
669 if($echo) { $status = true; echo ($data == 'icon') ? implode(' ', $icon) : $icon['title']; } else{ return ($data == 'icon') ? implode(' ', $icon) : $icon['title']; }
670 }
671 elseif( !$item['closed'] && $item['type'] == 1 ){
672 $icon['class'] = 'fa-thumb-tack';
673 $icon['color'] = 'wpfcl-5';
674 $icon['title'] = wpforo_phrase('Sticky', false);
675 if($echo) { $status = true; echo ($data == 'icon') ? implode(' ', $icon) : $icon['title']; } else{ return ($data == 'icon') ? implode(' ', $icon) : $icon['title']; }
676 }
677
678 if( $status ){
679 //do nothing
680 }
681 else{
682 if( $type == 'forum' ){
683 $icon['class'] = 'fa-comments';
684 $icon['color'] = 'wpfcl-2';
685 }
686 elseif( $type == 'topic' ){
687 if( $item['posts'] == 1 ){
688 $icon['class'] = 'fa-file-o';
689 $icon['color'] = 'wpfcl-2';
690 $icon['title'] = '';
691 }
692 elseif( $item['posts'] > 1 && $item['posts'] <= 5 ){
693 $icon['class'] = 'fa-file-text-o';
694 $icon['color'] = 'wpfcl-2';
695 $icon['title'] = '';
696 }
697 elseif( $item['posts'] > 5 && $item['posts'] <= 20 ){
698 $icon['class'] = 'fa-file-text';
699 $icon['color'] = 'wpfcl-2';
700 $icon['title'] = '';
701 }
702 elseif( $item['posts'] > 20 ){
703 $icon['class'] = 'fa-file-text';
704 $icon['color'] = 'wpfcl-5';
705 $icon['title'] = '';
706 }
707 else{
708 $icon['class'] = 'fa-file-o';
709 $icon['color'] = 'wpfcl-2';
710 $icon['title'] = '';
711 }
712 }
713 if($echo) { echo ($data == 'icon') ? implode(' ', $icon) : $icon['title']; } else{ return ($data == 'icon') ? implode(' ', $icon) : $icon['title']; }
714 }
715
716 }
717 else{
718 return false;
719 }
720
721 }
722
723 public function member_buttons( $member ){
724
725 if(empty($member)) return false;
726 $profile_access = ( $this->wpforo->perm->usergroup_can('vprf') ? true : false );
727
728 if( $profile_access ){
729 ?>
730 <a class="wpf-member-profile-button" title="<?php wpforo_phrase('Profile') ?>" href="<?php echo esc_url($this->wpforo->member->profile_url($member)) ?>">
731 <i class="fa fa-user"></i>
732 </a>
733 <a class="wpf-member-profile-button" title="<?php wpforo_phrase('Activity') ?>" href="<?php echo esc_url($this->wpforo->member->profile_url($member, 'activity')) ?>">
734 <i class="fa fa-comments-o"></i>
735 </a>
736 <a class="wpf-member-profile-button" title="<?php wpforo_phrase('Subscriptions') ?>" href="<?php echo esc_url($this->wpforo->member->profile_url($member, 'subscriptions')) ?>">
737 <i class="fa fa-rss"></i>
738 </a>
739 <?php do_action( 'wpforo_member_info_buttons', $member ); ?>
740 <?php
741 }
742 }
743
744 public function member_social_buttons( $member ){
745
746 $socnets = array();
747 if(empty($member)) return false;
748 $social_access = ( $this->wpforo->perm->usergroup_can('vmsn') ? true : false );
749
750 if( $social_access ){
751
752 if( isset($member['facebook']) && $member['facebook'] ){
753 $socnets['facebook']['set'] = $member['facebook'];
754 $member['facebook'] = ( strpos($member['facebook'], 'facebook.com') === FALSE ) ? 'https://www.facebook.com/' . trim($member['facebook'], '/') : $member['facebook'] ;
755 $socnets['facebook']['value'] = $member['facebook'];
756 $socnets['facebook']['protocol'] = 'https://';
757 $socnets['facebook']['title'] = wpforo_phrase('Facebook', false);
758 }
759
760 if( isset($member['twitter']) && $member['twitter'] ){
761 $socnets['twitter']['set'] = $member['twitter'];
762 $member['twitter'] = ( strpos($member['twitter'], 'twitter.com') === FALSE ) ? 'http://twitter.com/' . trim($member['twitter'], '/') : $member['twitter'] ;
763 $socnets['twitter']['value'] = $member['twitter'];
764 $socnets['twitter']['protocol'] = 'https://';
765 $socnets['twitter']['title'] = wpforo_phrase('Twitter', false);
766 }
767
768 if( isset($member['gtalk']) && $member['gtalk'] ){
769 $socnets['gtalk']['set'] = $member['gtalk'];
770 $socnets['gtalk']['value'] = $member['gtalk'];
771 $socnets['gtalk']['protocol'] = 'https://';
772 $socnets['gtalk']['title'] = wpforo_phrase('Google+', false);
773 }
774
775 if( isset($member['yahoo']) && $member['yahoo'] ){
776 $socnets['yahoo']['set'] = $member['yahoo'];
777 $socnets['yahoo']['value'] = $member['yahoo'];
778 $socnets['yahoo']['protocol'] = 'mailto:';
779 $socnets['yahoo']['title'] = wpforo_phrase('Yahoo', false);
780 }
781
782 if( isset($member['aim']) && $member['aim'] ){
783 $socnets['aim']['set'] = $member['aim'];
784 $socnets['aim']['value'] = $member['aim'];
785 $socnets['aim']['protocol'] = 'mailto:';
786 $socnets['aim']['title'] = wpforo_phrase('AOL IM', false);
787 }
788
789 if( isset($member['icq']) && $member['icq'] ){
790 $socnets['icq']['set'] = $member['icq'];
791 $socnets['icq']['value'] = 'www.icq.com/whitepages/cmd.php?uin=' . $member['icq'] . '&action=message';
792 $socnets['icq']['protocol'] = 'https://';
793 $socnets['icq']['title'] = wpforo_phrase('ICQ', false);
794 }
795
796 if( isset($member['msn']) && $member['msn'] ){
797 $socnets['msn']['set'] = $member['msn'];
798 $socnets['msn']['value'] = $member['msn'];
799 $socnets['msn']['protocol'] = 'mailto:';
800 $socnets['msn']['title'] = wpforo_phrase('MSN', false);
801 }
802
803 if( isset($member['skype']) && $member['skype'] ){
804 $socnets['skype']['set'] = $member['skype'];
805 $socnets['skype']['value'] = $member['skype'];
806 $socnets['skype']['protocol'] = 'skype:';
807 $socnets['skype']['title'] = wpforo_phrase('Skype', false);
808 }
809
810 ?>
811 <div class="wpf-member-socnet-wrap">
812 <?php if(!empty($socnets)): ?>
813 <?php foreach( $socnets as $key => $socnet ): ?>
814 <?php if( !$socnet['set'] ) continue; ?>
815 <?php $title = $member['display_name'] . ' - ' . $socnet['title']; ?>
816 <?php $url = ($key == 'skype') ? 'skype:' . esc_attr($socnet['value']) : esc_url($socnet['protocol'] . str_replace( array('https://', 'http://', 'skype:', 'mailto:'), '', $socnet['value'])); ?>
817 <a href="<?php echo $url ?>" class="wpf-member-socnet-button" title="<?php echo esc_attr($title) ?>">
818 <img src="<?php echo esc_url(WPFORO_URL) ?>/wpf-assets/images/sn/<?php echo $key ?>.png" alt="<?php echo esc_attr($title) ?>" title="<?php echo esc_attr($title) ?>" />
819 </a>
820 <?php endforeach; ?>
821 <?php endif; ?>
822 <?php do_action( 'wpforo_member_socnet_buttons', $member ); ?>
823 </div>
824 <?php
825 }
826 }
827
828 public function init_member_templates(){
829 $this->wpforo->member_tpls = array(
830 'account' => wpftpl('profile-account.php'),
831 'activity' => wpftpl('profile-activity.php'),
832 'subscriptions' => wpftpl('profile-subscriptions.php')
833 );
834 $this->wpforo->member_tpls = apply_filters('wpforo_member_templates_filter', $this->wpforo->member_tpls);
835 $this->wpforo->member_tpls['profile'] = wpftpl('profile-home.php');
836 }
837
838 function has_menu(){
839 return has_nav_menu( 'wpforo-menu' );
840 }
841
842 function nav_menu(){
843 if ( has_nav_menu( 'wpforo-menu' ) ){
844 $defaults = array(
845 'theme_location' => 'wpforo-menu',
846 'menu' => '',
847 'container' => '',
848 'container_class' => '',
849 'container_id' => '',
850 'menu_class' => 'wpf-menu',
851 'menu_id' => 'wpf-menu',
852 'echo' => true,
853 'fallback_cb' => 'wp_page_menu',
854 'before' => '',
855 'after' => '',
856 'link_before' => '',
857 'link_after' => '',
858 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>',
859 'depth' => 0,
860 'walker' => ''
861 );
862 wp_nav_menu( $defaults );
863 }
864 }
865
866 function init_nav_menu(){
867
868 if(isset($this->wpforo->current_object) && !empty($this->wpforo->current_object)){
869
870 extract($this->wpforo->current_object, EXTR_OVERWRITE);
871
872 $this->wpforo->menu['wpforo-home'] = array(
873 'href' => WPFORO_BASE_URL,
874 'label' => wpforo_phrase('forums', FALSE),
875 'attr' => ((($template == 'forum' || $template == 'topic' || $template == 'post') && !isset($_GET['wpforo'])) ? ' class="wpforo-active"' : '' ),
876 'submenues' => array()
877 );
878
879 if($this->wpforo->perm->usergroup_can('vmem')){
880 $this->wpforo->menu['wpforo-members'] = array(
881 'href' => WPFORO_BASE_URL . 'members/',
882 'label' => wpforo_phrase('members', FALSE),
883 'attr' => ( $template == 'members' ? ' class="wpforo-active"' : '' ),
884 'submenues' => array()
885 );
886 }
887
888 if( is_user_logged_in() ){
889
890 $this->wpforo->menu['wpforo-profile-home'] = array(
891 'href' => $this->wpforo->member->get_profile_url($this->wpforo->current_userid),
892 'label' => wpforo_phrase('my profile', FALSE),
893 'attr' => ( isset($this->wpforo->member_tpls[$template]) && $this->wpforo->member_tpls[$template] ? ' class="wpforo-active"' : '' ),
894 'submenues' => array()
895 );
896 $this->wpforo->menu['wpforo-profile-account'] = array(
897 'href' => $this->wpforo->member->get_profile_url($this->wpforo->current_userid, 'account'),
898 'label' => wpforo_phrase('account', FALSE),
899 'attr' => ( $template == 'account' ? ' class="wpforo-active"' : '' ),
900 'submenues' => array()
901 );
902 $this->wpforo->menu['wpforo-profile-activity'] = array(
903 'href' => $this->wpforo->member->get_profile_url($this->wpforo->current_userid, 'activity'),
904 'label' => wpforo_phrase('activity', FALSE),
905 'attr' => ( $template == 'activity' ? ' class="wpforo-active"' : '' ),
906 'submenues' => array()
907 );
908 $this->wpforo->menu['wpforo-profile-subscriptions'] = array(
909 'href' => $this->wpforo->member->get_profile_url($this->wpforo->current_userid, 'subscriptions'),
910 'label' => wpforo_phrase('subscriptions', FALSE),
911 'attr' => ( $template == 'subscriptions' ? ' class="wpforo-active"' : '' ),
912 'submenues' => array()
913 );
914 $this->wpforo->menu['wpforo-logout'] = array(
915 'href' => WPFORO_BASE_URL . '?wpforo=logout',
916 'label' => wpforo_phrase('logout', FALSE),
917 'attr' => '',
918 'submenues' => array()
919 );
920
921 }else{
922
923 if( wpforo_feature('user-register', $this->wpforo) ){
924 $this->wpforo->menu['wpforo-register'] = array(
925 'href' => wpforo_register_url(),
926 'label' => wpforo_phrase('register', FALSE),
927 'attr' => ( isset($_GET['wpforo']) && $_GET['wpforo'] == 'signup' ? ' class="wpforo-active"' : '' ),
928 'submenues' => array()
929 );
930 }
931 $this->wpforo->menu['wpforo-login'] = array(
932 'href' => wpforo_login_url(),
933 'label' => wpforo_phrase('login', FALSE),
934 'attr' => ( isset($_GET['wpforo']) && $_GET['wpforo'] == 'signin' ? ' class="wpforo-active"' : '' ),
935 'submenues' => array()
936 );
937 }
938
939 $this->wpforo->menu = apply_filters('wpforo_menu_array_filter', $this->wpforo->menu);
940 }
941 }
942
943 /**
944 *
945 * Checks in current active theme options if certain layout exists.
946 *
947 * @since 1.0.0
948 *
949 * @param mixed $identifier Layout id (folder name) OR @layout variable in header ( 1 or Extended )
950 * @param string $identifier_type The type of first parameter 'id' OR 'name' (@layout)
951 *
952 * @return boolean true/false
953 *
954 **/
955 function layout_exists( $identifier, $identifier_type = 'id' ){
956
957 $layouts = $this->wpforo->theme_options['layouts'];
958
959 if( $identifier_type == 'id' ){
960 if( isset($layouts[$identifier]) && !empty($layouts[$identifier])){
961 return true;
962 }
963 else{
964 return false;
965 }
966 }
967 elseif( $identifier_type = 'name' ){
968 foreach( $layouts as $id => $layout ){
969 if( !isset($layout['name']) && $layout['name'] == $identifier ){
970 return true;
971 }
972 }
973 return false;
974 }
975 }
976
977 /**
978 *
979 * Finds and returns all layouts information in array from theme's /layouts/ folder
980 *
981 * @since 1.0.0
982 *
983 * @param string $theme Theme id ( folder name ) e.g. 'classic'
984 *
985 * @return array
986 *
987 **/
988 function find_layouts( $theme ){
989 $layout_data = array();
990 $layouts = $this->find_themes('/'.$theme.'/layouts', 'php', 'layout');
991 if(!empty($layouts)){
992 foreach( $layouts as $layout ){
993 $lid = trim(basename(dirname( $layout['file']['value'] )), '/');
994 $layout_data[$lid]['id'] = $lid;
995 $layout_data[$lid]['name'] = $layout['name']['value'];
996 $layout_data[$lid]['version'] = $layout['version']['value'];
997 $layout_data[$lid]['description'] = $layout['description']['value'];
998 $layout_data[$lid]['author'] = $layout['author']['value'];
999 $layout_data[$lid]['url'] = $layout['layout_url']['value'];
1000 $layout_data[$lid]['file'] = $layout['file']['value'];
1001 }
1002 }
1003 return $layout_data;
1004 }
1005
1006 function show_layout_selectbox($layoutid = 0){
1007 $layouts = $this->find_layouts( WPFORO_THEME );
1008 if( !empty($layouts) ){
1009 foreach( $layouts as $layout ) : ?>
1010 <option value="<?php echo esc_attr(trim($layout['id'])) ?>" <?php echo ( $layoutid == $layout['id'] ? 'selected' : '' ); ?> ><?php echo esc_html($layout['name']) ?></option>
1011 <?php
1012 endforeach;
1013 }
1014 }
1015
1016 /**
1017 *
1018 * Finds and returns styles array from theme's /styles/colors.php file
1019 *
1020 * @since 1.0.0
1021 *
1022 * @param string $theme Theme id ( folder name ) e.g. 'classic'
1023 *
1024 * @return array
1025 *
1026 **/
1027 function find_styles( $theme ){
1028 $colors = array();
1029 $color_file = WPFORO_THEME_DIR . '/' . $theme . '/styles/colors.php';
1030 if( file_exists($color_file) ){
1031 include( $color_file );
1032 }
1033 return $colors;
1034 }
1035
1036 /**
1037 *
1038 * Scans certain theme directory and returns all information in array ( theme header, layouts, styles ).
1039 *
1040 * @since 1.0.0
1041 *
1042 * @param string $theme_file Theme folder name or main css file base path ( 'classic' OR classic/style.css' )
1043 *
1044 * @return array
1045 *
1046 **/
1047 function find_theme( $theme_file ){
1048 $theme = array();
1049 $theme_file = trim(trim($theme_file, '/'));
1050
1051 if( preg_match('|\.[\w\d]{2,4}$|is', $theme_file) ){
1052 $theme_folder = trim(basename(dirname($theme_file)), '/');
1053 }
1054 else{
1055 $theme_folder = $theme_file;
1056 $theme_file = $theme_file . '/style.css';
1057 }
1058
1059 if( !is_readable( WPFORO_THEME_DIR . '/' . $theme_file ) ){
1060 return $theme['error'] = __('Theme file not readable', 'wpforo') .' ('.$theme_file.')';
1061 }
1062 else{
1063 $theme_data = $this->find_theme_headers( WPFORO_THEME_DIR . '/' . $theme_file );
1064 $theme['id'] = $theme_folder;
1065 $theme['name'] = $theme_data['name']['value'];
1066 $theme['version'] = $theme_data['version']['value'];
1067 $theme['description'] = $theme_data['description']['value'];
1068 $theme['author'] = $theme_data['author']['value'];
1069 $theme['url'] = $theme_data['theme_url']['value'];
1070 $theme['file'] = $theme_file;
1071 $theme['folder'] = $theme_folder;
1072 $theme['layouts'] = $this->find_layouts( $theme_folder );
1073 $styles = $this->find_styles( $theme_folder );
1074 if(!empty($styles)){
1075 reset($styles);
1076 $theme['style'] = key($styles);
1077 $theme['styles'] = $styles;
1078 }
1079 return $theme;
1080 }
1081
1082 }
1083
1084 /**
1085 *
1086 * Scans wpForo themes (wpf-themes) folder, reads main files' headers and returns information about all themes in array.
1087 * This function can also be used to scan and get information about layouts in each theme /layouts/ folder.
1088 *
1089 * @since 1.0.0
1090 *
1091 * @param string $base_dir Absolute path to scan directory (e.g. /home/public_html/wp-content/plugins/wpforo/wpf-themes/)
1092 * @param string $ext File extension which may contain header information
1093 * @param string $mode 'theme' or 'layout'
1094 *
1095 * @return array
1096 *
1097 **/
1098 function find_themes( $base_dir = '', $ext = 'css', $mode = 'theme' ){
1099 $themes = array ();
1100 $themes_dir = @opendir( WPFORO_THEME_DIR . $base_dir );
1101 $theme_files = array();
1102 if( $themes_dir ){
1103 while( ($file = readdir( $themes_dir )) !== false ){
1104 if( substr($file, 0, 1) == '.' ) continue;
1105 if( is_dir( WPFORO_THEME_DIR . $base_dir .'/'.$file ) ){
1106 $themes_subdir = @opendir( WPFORO_THEME_DIR . $base_dir .'/'.$file );
1107 if( $themes_subdir ){
1108 while(($subfile = readdir( $themes_subdir ) ) !== false ){
1109 if( substr($subfile, 0, 1) == '.' ) continue;
1110 if( substr($subfile, -4) == '.' . $ext ) $theme_files[] = "$file/$subfile";
1111 }
1112 closedir( $themes_subdir );
1113 }
1114 }
1115 else{
1116 if( substr($file, -4) == '.' . $ext ) $theme_files[] = $file;
1117 }
1118 }
1119 closedir( $themes_dir );
1120 }
1121 if( empty($theme_files) ) return $themes;
1122 foreach( $theme_files as $theme_file ){
1123 if( !is_readable( WPFORO_THEME_DIR . $base_dir . '/' . $theme_file ) ) continue;
1124 if( $mode == 'theme' ){
1125 $theme_data = $this->find_theme_headers( WPFORO_THEME_DIR . $base_dir . '/' . $theme_file );
1126 }
1127 elseif( $mode == 'layout' ){
1128 $theme_data = $this->find_layout_headers( WPFORO_THEME_DIR . $base_dir . '/' . $theme_file );
1129 }
1130 if( empty($theme_data['name']['value']) ) continue;
1131 $themes[wpforo_clear_basename($theme_file)] = $theme_data;
1132 }
1133 return $themes;
1134 }
1135
1136 /**
1137 *
1138 * Reads theme main file's header variables and returns information in array.
1139 *
1140 * @since 1.0.0
1141 *
1142 * @param string $file Absolute path to file (e.g. /home/public_html/wp-content/plugins/wpforo/wpf-themes/style.css)
1143 *
1144 * @return array
1145 *
1146 **/
1147 function find_theme_headers( $file ){
1148 $theme_headers = array();
1149 $headers = array(
1150 'name' => 'Theme Name',
1151 'version' => 'Version',
1152 'description' => 'Description',
1153 'author' => 'Author',
1154 'theme_url' => 'Theme URI',
1155 );
1156 $fp = fopen( $file, 'r' );
1157 $data = fread( $fp, 8192 );
1158 fclose( $fp );
1159 $data = str_replace( "\r", "\n", $data );
1160 foreach ( $headers as $header_key => $header_name ){
1161 if ( preg_match( '|^[\s\t\/*#@]*' . preg_quote( $header_name, '|' ) . ':(.*)$|mi', $data, $match ) && $match[1] ){
1162 $theme_headers[$header_key]['name'] = $header_name;
1163 $theme_headers[$header_key]['value'] = trim(preg_replace("/\s*(?:\*\/|\?>).*/", '', $match[1]));
1164 }
1165 else{
1166 $theme_headers[$header_key]['name'] = $header_name;
1167 $theme_headers[$header_key]['value'] = '';
1168 }
1169 }
1170 $theme_headers['file']['name'] = 'file';
1171 $theme_headers['file']['value'] = $file;
1172 return $theme_headers;
1173 }
1174
1175 /**
1176 *
1177 * Reads layout main file's header variables and returns information in array.
1178 *
1179 * @since 1.0.0
1180 *
1181 * @param string $file Absolute path to file (e.g. /home/public_html/wp-content/plugins/wpforo/wpf-themes/layouts/1/forum.php)
1182 *
1183 * @return array
1184 *
1185 **/
1186 function find_layout_headers( $file ){
1187 $theme_headers = array();
1188 $headers = array(
1189 'name' => 'layout',
1190 'version' => 'version',
1191 'description' => 'description',
1192 'author' => 'author',
1193 'layout_url' => 'url',
1194 );
1195 $fp = fopen( $file, 'r' );
1196 $data = fread( $fp, 8192 );
1197 fclose( $fp );
1198 $data = str_replace( "\r", "\n", $data );
1199 foreach ( $headers as $header_key => $header_name ){
1200 if ( preg_match( '|^[\s\t\/*#@]*' . preg_quote( $header_name, '|' ) . ':(.*)$|mi', $data, $match ) && $match[1] ){
1201 $theme_headers[$header_key]['name'] = $header_name;
1202 $theme_headers[$header_key]['value'] = trim(preg_replace("/\s*(?:\*\/|\?>).*/", '', $match[1]));
1203 }
1204 else{
1205 $theme_headers[$header_key]['name'] = $header_name;
1206 $theme_headers[$header_key]['value'] = '';
1207 }
1208 }
1209 $theme_headers['file']['name'] = 'file';
1210 $theme_headers['file']['value'] = trim(str_replace( WPFORO_THEME_DIR, '', $file), '/');
1211 return $theme_headers;
1212 }
1213
1214 public function copyright(){
1215 if( wpforo_feature('copyright', $this->wpforo) ): ?>
1216 <div id="wpforo-poweredby">
1217 <p class="wpf-by">
1218 <span onclick='javascript:document.getElementById("bywpforo").style.display = "inline";document.getElementById("awpforo").style.display = "none";' id="awpforo"> <img align="absmiddle" title="<?php esc_attr( wpforo_phrase('Powered by') ) ?> wpForo version <?php echo esc_html(WPFORO_VERSION) ?>" alt="Powered by wpForo" class="wpdimg" src="<?php echo WPFORO_URL ?>/wpf-assets/images/wpforo-info.png" alt="wpForo"> </span><a id="bywpforo" target="_blank" href="http://wpforo.com/">&nbsp;<?php wpforo_phrase('Powered by') ?> wpForo version <?php echo esc_html(WPFORO_VERSION) ?></a>
1219 </p>
1220 </div>
1221 <?php
1222 endif;
1223 }
1224
1225 public function member_menu( $userid, $menu = array() ){
1226 if( empty($menu) ) $menu = array('profile' => 'fa-user', 'account' => 'fa-cog', 'activity' => 'fa-comments-o', 'subscriptions' => 'fa-rss');
1227 $menu = apply_filters('wpforo_member_menu_filter', $menu, $userid);
1228 if( !($userid == $this->wpforo->current_userid || $this->wpforo->perm->usergroup_can('em')) ) unset($menu['account']);
1229 foreach( $menu as $key => $value ) : ?>
1230 <a class="wpf-profile-menu <?php echo ( $this->wpforo->current_object['template'] == $key ? ' wpforo-active' : '' ) ?>" href="<?php echo esc_url($this->wpforo->member->get_profile_url($userid, $key)) ?>">
1231 <i style="font-size:14px; padding-right:3px;" class="fa <?php echo sanitize_html_class($value) ?>"></i> <?php wpforo_phrase($key) ?>
1232 </a>
1233 <?php
1234 endforeach;
1235 }
1236
1237 public function member_template(){
1238 global $wpforo;
1239 extract($this->wpforo->current_object, EXTR_OVERWRITE);
1240 extract($user, EXTR_OVERWRITE);
1241
1242 include( (isset($this->wpforo->member_tpls[$template]) && $this->wpforo->member_tpls[$template] ? $this->wpforo->member_tpls[$template] : $this->wpforo->member_tpls['profile']) );
1243 }
1244
1245 public function member_error(){
1246 echo apply_filters('wpforo_member_error_filter', wpforo_phrase('Members not found', FALSE));
1247 }
1248
1249 }
1250
1251 ?>