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

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