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

1,282 lines 58.4 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 = wpforo_post($postid, 'likes_count');
265 $l_usernames = wpforo_post($postid, '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() && $post['status'] ){
400 //New registered user's unapproved topic/post | No Edit button.
401 }
402 else{
403 $diff = current_time( 'timestamp', 1 ) - strtotime($post['created']);
404 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'] ) ) {
405 $a = ( $is_topic ) ? 'wpfedittopicpid' : '';
406 $b = ( $is_topic ) ? $postid : $postid;
407 $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>';
408 }
409 }
410 break;
411 case 'delete':
412 if( $this->wpforo->member->current_user_is_new() && $post['status'] ){
413 //New registered user's unapproved topic/post | No Delete button.
414 }
415 else{
416 $diff = current_time( 'timestamp', 1 ) - strtotime($post['created']);
417 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']) ){
418 $a = ( $is_topic ) ? 'wpftopicdelete' : 'wpfreplydelete';
419 $b = ( $is_topic ) ? $topicid : $postid;
420 $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>';
421 }
422 }
423 break;
424 case 'link':
425 $url = ( $is_topic ) ? $this->wpforo->topic->get_topic_url( $topic ) : wpforo_post( $postid, 'url' );
426 $button_html[] = '<a href="'. esc_url($url) .'"><i class="fa fa-link fa-0x"></i></a>';
427 break;
428 case 'positivevote':
429 if( $this->wpforo->perm->forum_can('v', $forumid) ) {
430 $button_html[] = '<i itemtype="' . ( $is_topic ? 'topic' : 'reply' ) . '" id="wpfvote-up-'. intval($postid) .'" class="voteup fa fa-play fa-rotate-270 wpfcl-0"></i>';
431 }else{
432 $button_html[] = '<i class="not_reg_user fa fa-play fa-rotate-270 wpfcl-0"></i>';
433 }
434 break;
435 case 'negativevote':
436 if( $this->wpforo->perm->forum_can('v', $forumid) ) {
437 $button_html[] = '<i itemtype="' . ( $is_topic ? 'topic' : 'reply' ) . '" id="wpfvote-down-'. intval($postid) .'" class="votedown fa fa-play fa-rotate-90 wpfcl-0"></i>';
438 }else{
439 $button_html[] = '<i class="not_reg_user fa fa-play fa-rotate-90 wpfcl-0"></i>';
440 }
441 break;
442 case 'isanswer':
443 $is_answer = $this->wpforo->post->is_answered( $postid );
444 $is_answer = ( $is_answer == 0 ) ? '-not' : '';
445 if( is_user_logged_in() ){
446 $button_html[] = '<div id="wpf-answer-'. intval($postid) .'" class="wpf-toggle'. esc_attr($is_answer) .'-answer"><i class="fa fa-check"></i></div>';
447 }else{
448 $button_html[] = '<div class="wpf-toggle'. esc_attr($is_answer) .'-answer not_reg_user"><i class="fa fa-check"></i></div>';
449 }
450 break;
451 } //switch
452 } //foreach
453
454 echo implode('', $button_html);
455
456 }
457
458 function breadcrumb($url_data){
459 extract($url_data, EXTR_OVERWRITE);
460
461 switch($template) :
462 case 'search': ?>
463
464 <div class="wpf-breadcrumb">
465 <a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i></a>
466
467 <a href="#" class="active"><?php wpforo_phrase('Search') ?></a>
468
469 <a href="#" class="wpf-end">&nbsp;</a>
470 </div>
471
472 <?php break;
473 case 'signup': ?>
474
475 <div class="wpf-breadcrumb">
476 <a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i></a>
477
478 <a href="#" class="active"><?php wpforo_phrase('Register') ?></a>
479
480 <a href="#" class="wpf-end">&nbsp;</a>
481 </div>
482
483 <?php break;
484 case 'signin': ?>
485
486 <div class="wpf-breadcrumb">
487 <a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i></a>
488
489 <a href="#" class="active"><?php wpforo_phrase('Login') ?></a>
490
491 <a href="#" class="wpf-end">&nbsp;</a>
492 </div>
493
494 <?php break;
495 case 'members': ?>
496
497 <div class="wpf-breadcrumb">
498 <a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i></a>
499
500 <?php if(isset($_GET['wpfms'])) : ?>
501
502 <a href="<?php echo wpforo_home_url('members') ?>"><?php wpforo_phrase('Members') ?></a>
503 <a href="#" class="active"><?php wpforo_phrase('Search') ?></a>
504
505 <?php else : ?>
506
507 <a href="#" class="active"><?php wpforo_phrase('Members') ?></a>
508
509 <?php endif ?>
510
511 <a href="#" class="wpf-end">&nbsp;</a>
512 </div>
513
514 <?php break;
515 case 'profile': ?>
516
517 <div class="wpf-breadcrumb">
518 <a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i></a>
519
520 <a href="<?php echo wpforo_home_url('members') ?>"><?php wpforo_phrase('Members') ?></a>
521 <a href="#" class="active"><?php wpforo_text( wpforo_make_dname($user['display_name'], $user['user_nicename']), 19 ) ?></a>
522
523 <a href="#" class="wpf-end">&nbsp;</a>
524 </div>
525
526 <?php break;
527 case 'account': ?>
528
529 <div class="wpf-breadcrumb">
530 <a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i>
531
532 <a href="<?php echo wpforo_home_url('members') ?>"><?php wpforo_phrase('Members') ?></a>
533 <a href="<?php echo esc_url($user['profile_url']) ?>"><?php wpforo_text( wpforo_make_dname($user['display_name'], $user['user_nicename']), 19 ) ?></a>
534 <a href="#" class="active"><?php wpforo_phrase('Account') ?></a>
535
536 <a href="#" class="wpf-end">&nbsp;</a>
537 </div>
538
539 <?php break;
540 case 'activity': ?>
541
542 <div class="wpf-breadcrumb">
543 <a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i>
544
545 <a href="<?php echo wpforo_home_url('members') ?>"><?php wpforo_phrase('Members') ?></a>
546 <a href="<?php echo esc_url($user['profile_url']) ?>"><?php wpforo_text( wpforo_make_dname($user['display_name'], $user['user_nicename']), 19 ) ?></a>
547 <a href="#" class="active"><?php wpforo_phrase('Activity') ?></a>
548
549 <a href="#" class="wpf-end">&nbsp;</a>
550 </div>
551
552 <?php break;
553 case 'subscriptions': ?>
554
555 <div class="wpf-breadcrumb">
556 <a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i>
557
558 <a href="<?php echo wpforo_home_url('members') ?>"><?php wpforo_phrase('Members') ?></a>
559 <a href="<?php echo esc_url($user['profile_url']) ?>"><?php wpforo_text( wpforo_make_dname($user['display_name'], $user['user_nicename']), 19 ) ?></a>
560 <a href="#" class="active"><?php wpforo_phrase('Subscriptions') ?></a>
561
562 <a href="#" class="wpf-end">&nbsp;</a>
563 </div>
564
565 <?php break;
566 // TODO: move code to pm plugin
567 case 'messages': ?>
568
569 <div class="wpf-breadcrumb">
570 <a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fa fa-home"></i>
571
572 <a href="<?php echo wpforo_home_url('members') ?>"><?php wpforo_phrase('Members') ?></a>
573
574 <?php if(!empty($user)) : ?>
575
576 <a href="<?php echo esc_url($user['profile_url']) ?>"><?php wpforo_text( wpforo_make_dname($user['display_name'], $user['user_nicename']), 19 ) ?></a>
577
578 <?php endif ?>
579
580 <a href="#" class="active"><?php wpforo_phrase('Messages') ?></a>
581
582 <a href="#" class="wpf-end">&nbsp;</a>
583 </div>
584
585 <?php break;
586 case 'topic': ?>
587
588 <div class="wpf-breadcrumb">
589 <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>
590
591 <?php if(isset($forumid)) : ?>
592 <?php $relative_ids = array();
593 $this->wpforo->forum->get_all_relative_ids($forumid, $relative_ids);
594 foreach( $relative_ids as $key => $rel_forumid ) : ?>
595 <?php $forum = wpforo_forum($rel_forumid) ?>
596 <?php if(!empty($forum)): ?>
597 <?php if( $key != ( count($relative_ids) - 1 ) ) : ?>
598 <a href="<?php echo esc_url( $forum['url'] ) ?>" title="<?php echo esc_attr($forum['title']) ?>"><?php wpforo_text($forum['title'], 19) ?></a>
599 <?php else : ?>
600 <a href="#" class="active" title="<?php echo esc_attr($forum['title']) ?>"><?php wpforo_text($forum['title'], 19) ?></a>
601 <?php endif ?>
602 <?php endif ?>
603 <?php endforeach ?>
604 <?php endif ?>
605
606 <a href="#" class="wpf-end">&nbsp;</a>
607 </div>
608
609 <?php break;
610 case 'post': ?>
611
612 <div class="wpf-breadcrumb">
613 <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>
614
615 <?php if(isset($forumid)) : ?>
616 <?php $relative_ids = array();
617 $this->wpforo->forum->get_all_relative_ids($forumid, $relative_ids);
618 foreach( $relative_ids as $key => $rel_forumid ) : ?>
619 <?php $forum = wpforo_forum($rel_forumid) ?>
620 <?php if(!empty($forum)): ?>
621 <a href="<?php echo esc_url( $forum['url'] ) ?>" title="<?php echo esc_attr($forum['title']) ?>"><?php wpforo_text($forum['title'], 19) ?></a>
622 <?php endif ?>
623 <?php endforeach ?>
624 <?php endif ?>
625 <?php if(!empty($topic)) : ?>
626
627 <a href="#" class="active" title="<?php echo esc_attr($topic['title']) ?>"><?php wpforo_text($topic['title'], 19) ?></a>
628
629 <?php endif ?>
630 <a href="#" class="wpf-end">&nbsp;</a>
631 </div>
632
633 <?php break;
634 default: ?>
635
636 <div class="wpf-breadcrumb">
637 <a href="#" class="wpf-root active"><?php wpforo_phrase('Forums') ?></a>
638 <a href="#" class="wpf-end">&nbsp;</a>
639 </div>
640
641 <?php
642 endswitch;
643
644 }
645
646 function icon($type, $item = array(), $echo = true, $data = 'icon' ){
647
648 $icon = array();
649 $status = false;
650
651 if( isset($item['status']) && $item['status'] ){
652 $icon['class'] = 'fa-exclamation-circle';
653 $icon['color'] = 'wpfcl-5';
654 $icon['title'] = wpforo_phrase('Unapproved', false);
655 if($echo) {
656 $status = true; echo ($data == 'icon') ? implode(' ', $icon) : $icon['title'];
657 }
658 else{
659 return ($data == 'icon') ? implode(' ', $icon) : $icon['title'];
660 }
661 }
662
663 if(isset($item['type'])){
664
665 if( $type == 'topic' ){
666 if($this->wpforo->topic->is_private($item['topicid'])){
667 $icon['class'] = 'fa-eye-slash';
668 $icon['color'] = 'wpfcl-1';
669 $icon['title'] = wpforo_phrase('Private', false);
670 if($echo) {
671 $status = true; echo ($data == 'icon') ? implode(' ', $icon) : $icon['title'];
672 }
673 else{
674 return ($data == 'icon') ? implode(' ', $icon) : $icon['title'];
675 }
676 }
677 if( wpforo_topic($item['topicid'], 'is_answer') ){
678 $icon['class'] = 'fa-check-circle';
679 $icon['color'] = 'wpfcl-8';
680 $icon['title'] = wpforo_phrase('Solved', false);
681 if($echo) {
682 $status = true; echo ($data == 'icon') ? implode(' ', $icon) : $icon['title'];
683 }
684 else{
685 return ($data == 'icon') ? implode(' ', $icon) : $icon['title'];
686 }
687 }
688 }
689
690 if( $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-lock';
698 $icon['color'] = 'wpfcl-1';
699 $icon['title'] = wpforo_phrase('Closed', false);
700 if($echo) { $status = true; echo ($data == 'icon') ? implode(' ', $icon) : $icon['title']; } else{ return ($data == 'icon') ? implode(' ', $icon) : $icon['title']; }
701 }
702 elseif( !$item['closed'] && $item['type'] == 1 ){
703 $icon['class'] = 'fa-thumb-tack';
704 $icon['color'] = 'wpfcl-5';
705 $icon['title'] = wpforo_phrase('Sticky', false);
706 if($echo) { $status = true; echo ($data == 'icon') ? implode(' ', $icon) : $icon['title']; } else{ return ($data == 'icon') ? implode(' ', $icon) : $icon['title']; }
707 }
708
709 if( $status ){
710 //do nothing
711 }
712 else{
713 if( $type == 'forum' ){
714 $icon['class'] = 'fa-comments';
715 $icon['color'] = 'wpfcl-2';
716 }
717 elseif( $type == 'topic' ){
718 if( $item['posts'] == 1 ){
719 $icon['class'] = 'fa-file-o';
720 $icon['color'] = 'wpfcl-2';
721 $icon['title'] = '';
722 }
723 elseif( $item['posts'] > 1 && $item['posts'] <= 5 ){
724 $icon['class'] = 'fa-file-text-o';
725 $icon['color'] = 'wpfcl-2';
726 $icon['title'] = '';
727 }
728 elseif( $item['posts'] > 5 && $item['posts'] <= 20 ){
729 $icon['class'] = 'fa-file-text';
730 $icon['color'] = 'wpfcl-2';
731 $icon['title'] = '';
732 }
733 elseif( $item['posts'] > 20 ){
734 $icon['class'] = 'fa-file-text';
735 $icon['color'] = 'wpfcl-5';
736 $icon['title'] = '';
737 }
738 else{
739 $icon['class'] = 'fa-file-o';
740 $icon['color'] = 'wpfcl-2';
741 $icon['title'] = '';
742 }
743 }
744 if($echo) { echo ($data == 'icon') ? implode(' ', $icon) : $icon['title']; } else{ return ($data == 'icon') ? implode(' ', $icon) : $icon['title']; }
745 }
746
747 }
748 else{
749 return false;
750 }
751
752 }
753
754 public function member_buttons( $member ){
755
756 if(empty($member)) return false;
757 $profile_access = ( $this->wpforo->perm->usergroup_can('vprf') ? true : false );
758
759 if( $profile_access ){
760 ?>
761 <a class="wpf-member-profile-button" title="<?php wpforo_phrase('Profile') ?>" href="<?php echo esc_url($this->wpforo->member->profile_url($member)) ?>">
762 <i class="fa fa-user"></i>
763 </a>
764 <a class="wpf-member-profile-button" title="<?php wpforo_phrase('Activity') ?>" href="<?php echo esc_url($this->wpforo->member->profile_url($member, 'activity')) ?>">
765 <i class="fa fa-comments-o"></i>
766 </a>
767 <a class="wpf-member-profile-button" title="<?php wpforo_phrase('Subscriptions') ?>" href="<?php echo esc_url($this->wpforo->member->profile_url($member, 'subscriptions')) ?>">
768 <i class="fa fa-rss"></i>
769 </a>
770 <?php do_action( 'wpforo_member_info_buttons', $member ); ?>
771 <?php
772 }
773 }
774
775 public function member_social_buttons( $member ){
776
777 $socnets = array();
778 if(empty($member)) return false;
779 $social_access = ( $this->wpforo->perm->usergroup_can('vmsn') ? true : false );
780
781 if( $social_access ){
782
783 if( isset($member['facebook']) && $member['facebook'] ){
784 $socnets['facebook']['set'] = $member['facebook'];
785 $member['facebook'] = ( strpos($member['facebook'], 'facebook.com') === FALSE ) ? 'https://www.facebook.com/' . trim($member['facebook'], '/') : $member['facebook'] ;
786 $socnets['facebook']['value'] = $member['facebook'];
787 $socnets['facebook']['protocol'] = 'https://';
788 $socnets['facebook']['title'] = wpforo_phrase('Facebook', false);
789 }
790
791 if( isset($member['twitter']) && $member['twitter'] ){
792 $socnets['twitter']['set'] = $member['twitter'];
793 $member['twitter'] = ( strpos($member['twitter'], 'twitter.com') === FALSE ) ? 'http://twitter.com/' . trim($member['twitter'], '/') : $member['twitter'] ;
794 $socnets['twitter']['value'] = $member['twitter'];
795 $socnets['twitter']['protocol'] = 'https://';
796 $socnets['twitter']['title'] = wpforo_phrase('Twitter', false);
797 }
798
799 if( isset($member['gtalk']) && $member['gtalk'] ){
800 $socnets['gtalk']['set'] = $member['gtalk'];
801 $socnets['gtalk']['value'] = $member['gtalk'];
802 $socnets['gtalk']['protocol'] = 'https://';
803 $socnets['gtalk']['title'] = wpforo_phrase('Google+', false);
804 }
805
806 if( isset($member['yahoo']) && $member['yahoo'] ){
807 $socnets['yahoo']['set'] = $member['yahoo'];
808 $socnets['yahoo']['value'] = $member['yahoo'];
809 $socnets['yahoo']['protocol'] = 'mailto:';
810 $socnets['yahoo']['title'] = wpforo_phrase('Yahoo', false);
811 }
812
813 if( isset($member['aim']) && $member['aim'] ){
814 $socnets['aim']['set'] = $member['aim'];
815 $socnets['aim']['value'] = $member['aim'];
816 $socnets['aim']['protocol'] = 'mailto:';
817 $socnets['aim']['title'] = wpforo_phrase('AOL IM', false);
818 }
819
820 if( isset($member['icq']) && $member['icq'] ){
821 $socnets['icq']['set'] = $member['icq'];
822 $socnets['icq']['value'] = 'www.icq.com/whitepages/cmd.php?uin=' . $member['icq'] . '&action=message';
823 $socnets['icq']['protocol'] = 'https://';
824 $socnets['icq']['title'] = wpforo_phrase('ICQ', false);
825 }
826
827 if( isset($member['msn']) && $member['msn'] ){
828 $socnets['msn']['set'] = $member['msn'];
829 $socnets['msn']['value'] = $member['msn'];
830 $socnets['msn']['protocol'] = 'mailto:';
831 $socnets['msn']['title'] = wpforo_phrase('MSN', false);
832 }
833
834 if( isset($member['skype']) && $member['skype'] ){
835 $socnets['skype']['set'] = $member['skype'];
836 $socnets['skype']['value'] = $member['skype'];
837 $socnets['skype']['protocol'] = 'skype:';
838 $socnets['skype']['title'] = wpforo_phrase('Skype', false);
839 }
840
841 ?>
842 <div class="wpf-member-socnet-wrap">
843 <?php if(!empty($socnets)): ?>
844 <?php foreach( $socnets as $key => $socnet ): ?>
845 <?php if( !$socnet['set'] ) continue; ?>
846 <?php $title = $member['display_name'] . ' - ' . $socnet['title']; ?>
847 <?php $url = ($key == 'skype') ? 'skype:' . esc_attr($socnet['value']) : esc_url($socnet['protocol'] . str_replace( array('https://', 'http://', 'skype:', 'mailto:'), '', $socnet['value'])); ?>
848 <a href="<?php echo $url ?>" class="wpf-member-socnet-button" title="<?php echo esc_attr($title) ?>">
849 <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) ?>" />
850 </a>
851 <?php endforeach; ?>
852 <?php endif; ?>
853 <?php do_action( 'wpforo_member_socnet_buttons', $member ); ?>
854 </div>
855 <?php
856 }
857 }
858
859 public function init_member_templates(){
860 $this->wpforo->member_tpls = array(
861 'account' => wpftpl('profile-account.php'),
862 'activity' => wpftpl('profile-activity.php'),
863 'subscriptions' => wpftpl('profile-subscriptions.php')
864 );
865 $this->wpforo->member_tpls = apply_filters('wpforo_member_templates_filter', $this->wpforo->member_tpls);
866 $this->wpforo->member_tpls['profile'] = wpftpl('profile-home.php');
867 }
868
869 function has_menu(){
870 return has_nav_menu( 'wpforo-menu' );
871 }
872
873 function nav_menu(){
874 if ( has_nav_menu( 'wpforo-menu' ) ){
875 $defaults = array(
876 'theme_location' => 'wpforo-menu',
877 'menu' => '',
878 'container' => '',
879 'container_class' => '',
880 'container_id' => '',
881 'menu_class' => 'wpf-menu',
882 'menu_id' => 'wpf-menu',
883 'echo' => true,
884 'fallback_cb' => 'wp_page_menu',
885 'before' => '',
886 'after' => '',
887 'link_before' => '',
888 'link_after' => '',
889 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>',
890 'depth' => 0,
891 'walker' => ''
892 );
893 wp_nav_menu( $defaults );
894 }
895 }
896
897 function init_nav_menu(){
898
899 if(isset($this->wpforo->current_object) && !empty($this->wpforo->current_object)){
900
901 extract($this->wpforo->current_object, EXTR_OVERWRITE);
902
903 $this->wpforo->menu['wpforo-home'] = array(
904 'href' => wpforo_home_url(),
905 'label' => wpforo_phrase('forums', FALSE),
906 'attr' => ((($template == 'forum' || $template == 'topic' || $template == 'post') && !isset($_GET['wpforo'])) ? ' class="wpforo-active"' : '' ),
907 'submenues' => array()
908 );
909
910 if($this->wpforo->perm->usergroup_can('vmem')){
911 $this->wpforo->menu['wpforo-members'] = array(
912 'href' => wpforo_home_url('members'),
913 'label' => wpforo_phrase('members', FALSE),
914 'attr' => ( $template == 'members' ? ' class="wpforo-active"' : '' ),
915 'submenues' => array()
916 );
917 }
918
919 if( is_user_logged_in() ){
920
921 $this->wpforo->menu['wpforo-profile-home'] = array(
922 'href' => $this->wpforo->member->get_profile_url($this->wpforo->current_userid),
923 'label' => wpforo_phrase('my profile', FALSE),
924 'attr' => ( isset($this->wpforo->member_tpls[$template]) && $this->wpforo->member_tpls[$template] ? ' class="wpforo-active"' : '' ),
925 'submenues' => array()
926 );
927 $this->wpforo->menu['wpforo-profile-account'] = array(
928 'href' => $this->wpforo->member->get_profile_url($this->wpforo->current_userid, 'account'),
929 'label' => wpforo_phrase('account', FALSE),
930 'attr' => ( $template == 'account' ? ' class="wpforo-active"' : '' ),
931 'submenues' => array()
932 );
933 $this->wpforo->menu['wpforo-profile-activity'] = array(
934 'href' => $this->wpforo->member->get_profile_url($this->wpforo->current_userid, 'activity'),
935 'label' => wpforo_phrase('activity', FALSE),
936 'attr' => ( $template == 'activity' ? ' class="wpforo-active"' : '' ),
937 'submenues' => array()
938 );
939 $this->wpforo->menu['wpforo-profile-subscriptions'] = array(
940 'href' => $this->wpforo->member->get_profile_url($this->wpforo->current_userid, 'subscriptions'),
941 'label' => wpforo_phrase('subscriptions', FALSE),
942 'attr' => ( $template == 'subscriptions' ? ' class="wpforo-active"' : '' ),
943 'submenues' => array()
944 );
945 $this->wpforo->menu['wpforo-logout'] = array(
946 'href' => wpforo_home_url('?wpforo=logout'),
947 'label' => wpforo_phrase('logout', FALSE),
948 'attr' => '',
949 'submenues' => array()
950 );
951
952 }else{
953
954 if( wpforo_feature('user-register', $this->wpforo) ){
955 $this->wpforo->menu['wpforo-register'] = array(
956 'href' => wpforo_register_url(),
957 'label' => wpforo_phrase('register', FALSE),
958 'attr' => ( isset($_GET['wpforo']) && $_GET['wpforo'] == 'signup' ? ' class="wpforo-active"' : '' ),
959 'submenues' => array()
960 );
961 }
962 $this->wpforo->menu['wpforo-login'] = array(
963 'href' => wpforo_login_url(),
964 'label' => wpforo_phrase('login', FALSE),
965 'attr' => ( isset($_GET['wpforo']) && $_GET['wpforo'] == 'signin' ? ' class="wpforo-active"' : '' ),
966 'submenues' => array()
967 );
968 }
969
970 $this->wpforo->menu = apply_filters('wpforo_menu_array_filter', $this->wpforo->menu);
971 }
972 }
973
974 /**
975 *
976 * Checks in current active theme options if certain layout exists.
977 *
978 * @since 1.0.0
979 *
980 * @param mixed $identifier Layout id (folder name) OR @layout variable in header ( 1 or Extended )
981 * @param string $identifier_type The type of first parameter 'id' OR 'name' (@layout)
982 *
983 * @return boolean true/false
984 *
985 **/
986 function layout_exists( $identifier, $identifier_type = 'id' ){
987
988 $layouts = $this->wpforo->theme_options['layouts'];
989
990 if( $identifier_type == 'id' ){
991 if( isset($layouts[$identifier]) && !empty($layouts[$identifier])){
992 return true;
993 }
994 else{
995 return false;
996 }
997 }
998 elseif( $identifier_type = 'name' ){
999 foreach( $layouts as $id => $layout ){
1000 if( !isset($layout['name']) && $layout['name'] == $identifier ){
1001 return true;
1002 }
1003 }
1004 return false;
1005 }
1006 }
1007
1008 /**
1009 *
1010 * Finds and returns all layouts information in array from theme's /layouts/ folder
1011 *
1012 * @since 1.0.0
1013 *
1014 * @param string $theme Theme id ( folder name ) e.g. 'classic'
1015 *
1016 * @return array
1017 *
1018 **/
1019 function find_layouts( $theme ){
1020 $layout_data = array();
1021 $layouts = $this->find_themes('/'.$theme.'/layouts', 'php', 'layout');
1022 if(!empty($layouts)){
1023 foreach( $layouts as $layout ){
1024 $lid = trim(basename(dirname( $layout['file']['value'] )), '/');
1025 $layout_data[$lid]['id'] = $lid;
1026 $layout_data[$lid]['name'] = $layout['name']['value'];
1027 $layout_data[$lid]['version'] = $layout['version']['value'];
1028 $layout_data[$lid]['description'] = $layout['description']['value'];
1029 $layout_data[$lid]['author'] = $layout['author']['value'];
1030 $layout_data[$lid]['url'] = $layout['layout_url']['value'];
1031 $layout_data[$lid]['file'] = $layout['file']['value'];
1032 }
1033 }
1034 return $layout_data;
1035 }
1036
1037 function show_layout_selectbox($layoutid = 0){
1038 $layouts = $this->find_layouts( WPFORO_THEME );
1039 if( !empty($layouts) ){
1040 foreach( $layouts as $layout ) : ?>
1041 <option value="<?php echo esc_attr(trim($layout['id'])) ?>" <?php echo ( $layoutid == $layout['id'] ? 'selected' : '' ); ?> ><?php echo esc_html($layout['name']) ?></option>
1042 <?php
1043 endforeach;
1044 }
1045 }
1046
1047 /**
1048 *
1049 * Finds and returns styles array from theme's /styles/colors.php file
1050 *
1051 * @since 1.0.0
1052 *
1053 * @param string $theme Theme id ( folder name ) e.g. 'classic'
1054 *
1055 * @return array
1056 *
1057 **/
1058 function find_styles( $theme ){
1059 $colors = array();
1060 $color_file = WPFORO_THEME_DIR . '/' . $theme . '/styles/colors.php';
1061 if( file_exists($color_file) ){
1062 include( $color_file );
1063 }
1064 return $colors;
1065 }
1066
1067 /**
1068 *
1069 * Scans certain theme directory and returns all information in array ( theme header, layouts, styles ).
1070 *
1071 * @since 1.0.0
1072 *
1073 * @param string $theme_file Theme folder name or main css file base path ( 'classic' OR classic/style.css' )
1074 *
1075 * @return array
1076 *
1077 **/
1078 function find_theme( $theme_file ){
1079 $theme = array();
1080 $theme_file = trim(trim($theme_file, '/'));
1081
1082 if( preg_match('|\.[\w\d]{2,4}$|is', $theme_file) ){
1083 $theme_folder = trim(basename(dirname($theme_file)), '/');
1084 }
1085 else{
1086 $theme_folder = $theme_file;
1087 $theme_file = $theme_file . '/style.css';
1088 }
1089
1090 if( !is_readable( WPFORO_THEME_DIR . '/' . $theme_file ) ){
1091 return $theme['error'] = __('Theme file not readable', 'wpforo') .' ('.$theme_file.')';
1092 }
1093 else{
1094 $theme_data = $this->find_theme_headers( WPFORO_THEME_DIR . '/' . $theme_file );
1095 $theme['id'] = $theme_folder;
1096 $theme['name'] = $theme_data['name']['value'];
1097 $theme['version'] = $theme_data['version']['value'];
1098 $theme['description'] = $theme_data['description']['value'];
1099 $theme['author'] = $theme_data['author']['value'];
1100 $theme['url'] = $theme_data['theme_url']['value'];
1101 $theme['file'] = $theme_file;
1102 $theme['folder'] = $theme_folder;
1103 $theme['layouts'] = $this->find_layouts( $theme_folder );
1104 $styles = $this->find_styles( $theme_folder );
1105 if(!empty($styles)){
1106 reset($styles);
1107 $theme['style'] = key($styles);
1108 $theme['styles'] = $styles;
1109 }
1110 return $theme;
1111 }
1112
1113 }
1114
1115 /**
1116 *
1117 * Scans wpForo themes (wpf-themes) folder, reads main files' headers and returns information about all themes in array.
1118 * This function can also be used to scan and get information about layouts in each theme /layouts/ folder.
1119 *
1120 * @since 1.0.0
1121 *
1122 * @param string $base_dir Absolute path to scan directory (e.g. /home/public_html/wp-content/plugins/wpforo/wpf-themes/)
1123 * @param string $ext File extension which may contain header information
1124 * @param string $mode 'theme' or 'layout'
1125 *
1126 * @return array
1127 *
1128 **/
1129 function find_themes( $base_dir = '', $ext = 'css', $mode = 'theme' ){
1130 $themes = array ();
1131 $themes_dir = @opendir( WPFORO_THEME_DIR . $base_dir );
1132 $theme_files = array();
1133 if( $themes_dir ){
1134 while( ($file = readdir( $themes_dir )) !== false ){
1135 if( substr($file, 0, 1) == '.' ) continue;
1136 if( is_dir( WPFORO_THEME_DIR . $base_dir .'/'.$file ) ){
1137 $themes_subdir = @opendir( WPFORO_THEME_DIR . $base_dir .'/'.$file );
1138 if( $themes_subdir ){
1139 while(($subfile = readdir( $themes_subdir ) ) !== false ){
1140 if( substr($subfile, 0, 1) == '.' ) continue;
1141 if( substr($subfile, -4) == '.' . $ext ) $theme_files[] = "$file/$subfile";
1142 }
1143 closedir( $themes_subdir );
1144 }
1145 }
1146 else{
1147 if( substr($file, -4) == '.' . $ext ) $theme_files[] = $file;
1148 }
1149 }
1150 closedir( $themes_dir );
1151 }
1152 if( empty($theme_files) ) return $themes;
1153 foreach( $theme_files as $theme_file ){
1154 if( !is_readable( WPFORO_THEME_DIR . $base_dir . '/' . $theme_file ) ) continue;
1155 if( $mode == 'theme' ){
1156 $theme_data = $this->find_theme_headers( WPFORO_THEME_DIR . $base_dir . '/' . $theme_file );
1157 }
1158 elseif( $mode == 'layout' ){
1159 $theme_data = $this->find_layout_headers( WPFORO_THEME_DIR . $base_dir . '/' . $theme_file );
1160 }
1161 if( empty($theme_data['name']['value']) ) continue;
1162 $themes[wpforo_clear_basename($theme_file)] = $theme_data;
1163 }
1164 return $themes;
1165 }
1166
1167 /**
1168 *
1169 * Reads theme main file's header variables and returns information in array.
1170 *
1171 * @since 1.0.0
1172 *
1173 * @param string $file Absolute path to file (e.g. /home/public_html/wp-content/plugins/wpforo/wpf-themes/style.css)
1174 *
1175 * @return array
1176 *
1177 **/
1178 function find_theme_headers( $file ){
1179 $theme_headers = array();
1180 $headers = array(
1181 'name' => 'Theme Name',
1182 'version' => 'Version',
1183 'description' => 'Description',
1184 'author' => 'Author',
1185 'theme_url' => 'Theme URI',
1186 );
1187 $fp = fopen( $file, 'r' );
1188 $data = fread( $fp, 8192 );
1189 fclose( $fp );
1190 $data = str_replace( "\r", "\n", $data );
1191 foreach ( $headers as $header_key => $header_name ){
1192 if ( preg_match( '|^[\s\t\/*#@]*' . preg_quote( $header_name, '|' ) . ':(.*)$|mi', $data, $match ) && $match[1] ){
1193 $theme_headers[$header_key]['name'] = $header_name;
1194 $theme_headers[$header_key]['value'] = trim(preg_replace("/\s*(?:\*\/|\?>).*/", '', $match[1]));
1195 }
1196 else{
1197 $theme_headers[$header_key]['name'] = $header_name;
1198 $theme_headers[$header_key]['value'] = '';
1199 }
1200 }
1201 $theme_headers['file']['name'] = 'file';
1202 $theme_headers['file']['value'] = $file;
1203 return $theme_headers;
1204 }
1205
1206 /**
1207 *
1208 * Reads layout main file's header variables and returns information in array.
1209 *
1210 * @since 1.0.0
1211 *
1212 * @param string $file Absolute path to file (e.g. /home/public_html/wp-content/plugins/wpforo/wpf-themes/layouts/1/forum.php)
1213 *
1214 * @return array
1215 *
1216 **/
1217 function find_layout_headers( $file ){
1218 $theme_headers = array();
1219 $headers = array(
1220 'name' => 'layout',
1221 'version' => 'version',
1222 'description' => 'description',
1223 'author' => 'author',
1224 'layout_url' => 'url',
1225 );
1226 $fp = fopen( $file, 'r' );
1227 $data = fread( $fp, 8192 );
1228 fclose( $fp );
1229 $data = str_replace( "\r", "\n", $data );
1230 foreach ( $headers as $header_key => $header_name ){
1231 if ( preg_match( '|^[\s\t\/*#@]*' . preg_quote( $header_name, '|' ) . ':(.*)$|mi', $data, $match ) && $match[1] ){
1232 $theme_headers[$header_key]['name'] = $header_name;
1233 $theme_headers[$header_key]['value'] = trim(preg_replace("/\s*(?:\*\/|\?>).*/", '', $match[1]));
1234 }
1235 else{
1236 $theme_headers[$header_key]['name'] = $header_name;
1237 $theme_headers[$header_key]['value'] = '';
1238 }
1239 }
1240 $theme_headers['file']['name'] = 'file';
1241 $theme_headers['file']['value'] = trim(str_replace( WPFORO_THEME_DIR, '', $file), '/');
1242 return $theme_headers;
1243 }
1244
1245 public function copyright(){
1246 if( wpforo_feature('copyright', $this->wpforo) ): ?>
1247 <div id="wpforo-poweredby">
1248 <p class="wpf-by">
1249 <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>
1250 </p>
1251 </div>
1252 <?php
1253 endif;
1254 }
1255
1256 public function member_menu( $userid, $menu = array() ){
1257 if( empty($menu) ) $menu = array('profile' => 'fa-user', 'account' => 'fa-cog', 'activity' => 'fa-comments-o', 'subscriptions' => 'fa-rss');
1258 $menu = apply_filters('wpforo_member_menu_filter', $menu, $userid);
1259 if( !($userid == $this->wpforo->current_userid || $this->wpforo->perm->usergroup_can('em')) ) unset($menu['account']);
1260 foreach( $menu as $key => $value ) : ?>
1261 <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)) ?>">
1262 <i style="font-size:14px; padding-right:3px;" class="fa <?php echo sanitize_html_class($value) ?>"></i> <?php wpforo_phrase($key) ?>
1263 </a>
1264 <?php
1265 endforeach;
1266 }
1267
1268 public function member_template(){
1269 global $wpforo;
1270 extract($this->wpforo->current_object, EXTR_OVERWRITE);
1271 extract($user, EXTR_OVERWRITE);
1272
1273 include( (isset($this->wpforo->member_tpls[$template]) && $this->wpforo->member_tpls[$template] ? $this->wpforo->member_tpls[$template] : $this->wpforo->member_tpls['profile']) );
1274 }
1275
1276 public function member_error(){
1277 echo apply_filters('wpforo_member_error_filter', wpforo_phrase('Members not found', FALSE));
1278 }
1279
1280 }
1281
1282 ?>