PluginProbe
wpForo Forum / 1.3.0
wpForo Forum v1.3.0
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.3.0, at wpf-includes/class-template.php

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