add wpforo customization for seminar event.

This commit is contained in:
CBS Information System 2020-12-02 18:34:47 +09:00
parent efad602546
commit 656800c92f
5 changed files with 467 additions and 5 deletions

View File

@ -217,7 +217,8 @@ function cbsonline_add_page_to_tag_archive($obj)
// override date_format option // override date_format option
add_filter('option_date_format', 'cbsonline_date_format'); add_filter('option_date_format', 'cbsonline_date_format');
function cbsonline_date_format($format) { function cbsonline_date_format($format)
{
$lang = get_query_var('lang', ''); $lang = get_query_var('lang', '');
switch ($lang) { switch ($lang) {
case 'ja': case 'ja':
@ -225,5 +226,263 @@ function cbsonline_date_format($format) {
case 'en_US': case 'en_US':
return 'D, d M Y'; return 'D, d M Y';
} }
return $format; return $format;
} }
// for wpforo
add_filter('wpforo_after_init_current_object', 'cbsonline_wpforo_after_init_current_object', 10, 2);
function cbsonline_wpforo_after_init_current_object($current_object, $wpf_url_parse)
{
if (wpfval($current_object, 'forum_slug')) {
$topic = wpfval($current_object, 'topic_slug') ? WPF()->topic->get_topic(['slug' => $current_object['topic_slug']], false) : false;
$args = (empty($topic) ? ['slug' => $current_object['forum_slug']] : $topic['forumid']);
if ($forum = WPF()->forum->get_forum($args)) {
if ('topic' === $current_object['template']) {
$args = [
'offset' => ($current_object['paged'] - 1) * $current_object['items_per_page'],
'row_count' => $current_object['items_per_page'],
'forumid' => $current_object['forumid'],
'orderby' => 'type, metavalue, modified',
'order' => 'DESC',
'join' => ' INNER JOIN `'.WPF()->tables->postmeta.'` AS `m1` ON `m1`.`postid`=`'.WPF()->tables->topics.'`.`first_postid` AND `m1`.`metakey`=\'seminar_date\'',
];
$current_object['topics'] = cbsonline_wpforo_topic_get_topics($args, $current_object['items_count']);
}
} else {
$current_object['is_404'] = true;
}
}
return $current_object;
}
function cbsonline_wpforo_get_topic_fields_list()
{
static $ret = [];
if (!empty($ret)) {
return $ret;
}
$fields = WPF()->post->get_topic_fields_list();
foreach ($fields as $name) {
$ret[$name] = WPF()->post->get_field($name);
}
return $ret;
}
function cbsonline_wpforo_get_topic_custom_fields($topic_id)
{
$fields = cbsonline_wpforo_get_topic_fields_list();
$postmetas = WPF()->postmeta->get_postmeta($topic_id, '', true);
$ret = [];
foreach ($fields as $name => $field) {
if ($postmeta = wpfval($postmetas, $name)) {
if (!(int) wpfval($fields[$name], 'isDefault')) {
$field['value'] = $postmeta;
$field = WPF()->form->prepare_values(WPF()->form->esc_field($field));
$ret[$name] = wpfval($field, 'value');
}
}
}
return $ret;
}
function cbsonline_wpforo_topic_get_topics($args = [], &$items_count = 0, $count = true)
{
$cache = WPF()->cache->on('object_cashe');
$default = [
'include' => [], // array( 2, 10, 25 )
'exclude' => [], // array( 2, 10, 25 )
'forumids' => [],
'forumid' => null,
'userid' => null, // user id in DB
'type' => null, // 0, 1, etc . . .
'solved' => null,
'closed' => null,
'status' => null, // 0, 1, etc . . .
'private' => null, // 0, 1, etc . . .''
'pollid' => null,
'orderby' => 'type, topicid', // type, topicid, modified, created
'order' => 'DESC', // ASC DESC
'offset' => null, // this use when you give row_count
'row_count' => null, // 4 or 1 ...
'permgroup' => null, // Checks permissions based on attribute value not on current user usergroup
'read' => null, // true / false
'where' => null,
'join' => null, // join clause
];
$args = wpforo_parse_args($args, $default);
if (is_array($args) && !empty($args)) {
extract($args, EXTR_OVERWRITE);
if (0 === $row_count) {
return [];
}
$include = wpforo_parse_args($include);
$exclude = wpforo_parse_args($exclude);
$forumids = wpforo_parse_args($forumids);
$guest = [];
$wheres = [];
if (!is_null($read)) {
$last_read_postid = WPF()->log->get_all_read('post');
if ($read) {
if ($last_read_postid) {
$wheres[] = '`last_post` <= '.intval($last_read_postid);
}
$include_read = WPF()->log->get_read();
$include = array_merge($include, $include_read);
} else {
if ($last_read_postid) {
$wheres[] = '`last_post` > '.intval($last_read_postid);
}
$exclude_read = WPF()->log->get_read();
$exclude = array_merge($exclude, $exclude_read);
}
}
if (!empty($include)) {
$wheres[] = '`topicid` IN('.implode(', ', array_map('intval', $include)).')';
}
if (!empty($exclude)) {
$wheres[] = '`topicid` NOT IN('.implode(', ', array_map('intval', $exclude)).')';
}
if (!empty($forumids)) {
$wheres[] = '`forumid` IN('.implode(', ', array_map('intval', $forumids)).')';
}
if (!is_null($forumid)) {
$wheres[] = '`forumid` = '.intval($forumid);
}
if (!is_null($userid)) {
$wheres[] = '`userid` = '.wpforo_bigintval($userid);
}
if (!is_null($solved)) {
$wheres[] = '`solved` = '.intval($solved);
}
if (!is_null($closed)) {
$wheres[] = '`closed` = '.intval($closed);
}
if (!is_null($type)) {
$wheres[] = '`type` = '.intval($type);
}
if (!is_null($where)) {
$wheres[] = $where;
}
if (!is_user_logged_in()) {
$guest = WPF()->member->get_guest_cookies();
}
if (empty($forumids)) {
if (isset($forumid) && !WPF()->perm->forum_can('vf', $forumid, $permgroup)) {
return [];
}
}
if (isset($forumid) && $forumid) {
if (WPF()->perm->forum_can('vp', $forumid, $permgroup)) {
if (!is_null($private)) {
$wheres[] = ' `private` = '.intval($private);
}
} elseif (isset(WPF()->current_userid) && WPF()->current_userid) {
$wheres[] = ' ( `private` = 0 OR (`private` = 1 AND `userid` = '.intval(WPF()->current_userid).') )';
} elseif (wpfval($guest, 'email')) {
$wheres[] = " ( `private` = 0 OR (`private` = 1 AND `email` = '".sanitize_email($guest['email'])."') )";
} else {
$wheres[] = ' `private` = 0';
}
} else {
if (!is_null($private)) {
$wheres[] = ' `private` = '.intval($private);
}
}
if (isset($forumid) && $forumid) {
if (WPF()->perm->forum_can('au', $forumid, $permgroup)) {
if (!is_null($status)) {
$wheres[] = ' `status` = '.intval($status);
}
} elseif (isset(WPF()->current_userid) && WPF()->current_userid) {
$wheres[] = ' ( `status` = 0 OR (`status` = 1 AND `userid` = '.intval(WPF()->current_userid).') )';
} elseif (wpfval($guest, 'email')) {
$wheres[] = " ( `status` = 0 OR (`status` = 1 AND `email` = '".sanitize_email($guest['email'])."') )";
} else {
$wheres[] = ' `status` = 0';
}
} else {
if (!is_null($status)) {
$wheres[] = ' `status` = '.intval($status);
}
}
if (function_exists('WPF_POLL')) {
if (!is_null($pollid)) {
$wheres[] = ' `pollid` <> 0';
}
}
$sql = 'SELECT `'.WPF()->tables->topics.'`.* FROM `'.WPF()->tables->topics.'`';
if (!is_null($join)) {
$sql .= $join;
}
if (!empty($wheres)) {
$sql .= ' WHERE '.implode(' AND ', $wheres);
}
if ($count) {
$item_count_sql = preg_replace('#SELECT.+?FROM#isu', 'SELECT count(*) FROM', $sql);
if ($item_count_sql) {
$items_count = WPF()->db->get_var($item_count_sql);
}
}
$sql .= ' ORDER BY '.str_replace(',', ' '.esc_sql($order).',', esc_sql($orderby)).' '.esc_sql($order);
if (!is_null($row_count)) {
if (!is_null($offset)) {
$sql .= esc_sql(" LIMIT $offset,$row_count");
} else {
$sql .= esc_sql(" LIMIT $row_count");
}
}
if (!is_null($join)) {
$keys = ['topics', 'forumid', 'first_postid', 'userid', 'title', 'slug', 'created', 'modified', 'last_post', 'posts', 'votes', 'answers', 'views', 'meta_key', 'meta_desc', 'type', 'solved', 'closed', 'has_attach', 'private', 'status', 'name', 'email', 'prefix', 'tags'];
foreach ($keys as $key) {
$sql = str_replace(' `'.$key.'`', ' `'.WPF()->tables->topics.'`.`'.$key.'`', $sql);
}
}
if ($cache) {
$object_key = md5($sql.WPF()->current_user_groupid);
$object_cache = WPF()->cache->get($object_key);
if (!empty($object_cache)) {
if (!empty($object_cache['items'])) {
$access_filter = apply_filters('wpforo_topic_access_filter_cache', true);
if ($access_filter) {
return WPF()->topic->access_filter($object_cache['items'], $permgroup);
} else {
return $object_cache['items'];
}
}
}
}
$topics = WPF()->db->get_results($sql, ARRAY_A);
$topics = apply_filters('wpforo_get_topics', $topics);
if ($cache && isset($object_key) && !empty($topics)) {
wpForoTopic::$cache['topics'][$object_key]['items'] = $topics;
wpForoTopic::$cache['topics'][$object_key]['items_count'] = $items_count;
}
if (!empty($forumids) || !$forumid) {
$topics = WPF()->topic->access_filter($topics, $permgroup);
}
return $topics;
}
}

21
page-bulletin.php Normal file
View File

@ -0,0 +1,21 @@
<?php
get_header(); ?>
<!-- [ #container ] -->
<div id="container" class="innerBox">
<!-- [ #content ] -->
<div id="content" class="content wide">
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" class="entry-content">
<?php the_content(); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-link">' . 'Pages:', 'after' => '</div>' ) ); ?>
</div><!-- .entry-content -->
<?php endwhile; ?>
</div>
<!-- [ /#content ] -->
</div>
<!-- [ /#container ] -->
<?php get_footer(); ?>

View File

@ -313,3 +313,25 @@ form#searchform input#searchsubmit {
background-image: -ms-linear-gradient(left, #f0f0f0, #8c8b8b, #f0f0f0); background-image: -ms-linear-gradient(left, #f0f0f0, #8c8b8b, #f0f0f0);
background-image: -o-linear-gradient(left, #f0f0f0, #8c8b8b, #f0f0f0); background-image: -o-linear-gradient(left, #f0f0f0, #8c8b8b, #f0f0f0);
} }
/* wpforo */
#wpforo #wpforo-wrap .wpfl-2 .head-stat-posts,
#wpforo #wpforo-wrap .wpfl-2 .wpforo-topic-stat-posts {
width: 1% !important;
}
#wpforo #wpforo-wrap .wpfl-2 .head-stat-views,
#wpforo #wpforo-wrap .wpfl-2 .wpforo-topic-stat-views {
width:14% !important;
}
#wpforo #wpforo-wrap .wpfl-2 .wpforo-topic-stat-views {
font-size: 13px !important;
}
#wpforo #wpforo-wrap .wpfl-2 .wpforo-topic-custom_fields {
font-size: 12px;
}
#wpforo #wpforo-wrap .wpfl-2 .wpforo-topic-custom_fields .label {
color: #ff812d;
}
#wpforo #wpforo-wrap .wpfl-2 .wpforo-topic-custom_fields .label::after {
content: ': ';
}

95
wpforo/layouts/2/post.php Normal file
View File

@ -0,0 +1,95 @@
<?php
// Exit if accessed directly
if( !defined( 'ABSPATH' ) ) exit;
?>
<div class="wpfl-2">
<div class="wpforo-post-head">
<div class="wpf-left">&nbsp;
<a href="<?php echo esc_url( wpforo_post($topic['last_post'], 'url') ); ?>" class="wpfcl-2"><i class="far fa-caret-square-down wpfsx wpfcl-3"></i> &nbsp; <span class="wpfcl-3"><?php wpforo_phrase('Last Post'); ?></span></a>
<?php do_action( 'wpforo_topic_head_left', $forum, $topic ) ?>
</div>
<div class="wpf-right">
<?php do_action( 'wpforo_topic_head_right', $forum, $topic ) ?>
<?php wpforo_post_buttons( 'icon-text', 'tools', $forum ); ?>&nbsp;
<?php if( wpforo_feature('rss-feed') ): ?><a href="<?php WPF()->feed->rss2_url(); ?>" class="wpfcl-2" title="<?php wpforo_phrase('Topic RSS Feed') ?>"><span class="wpfcl-3"><?php wpforo_phrase('RSS') ?></span> <i class="fas fa-rss wpfsx wpfcl-3"></i></a><?php endif; ?>
</div>
<div class="wpf-clear"></div>
</div>
<?php wpforo_moderation_tools(); ?>
<?php foreach($posts as $key => $post) : ?>
<?php $member = wpforo_member($post); $post_url = wpforo_post($post['postid'],'url'); ?>
<div id="post-<?php echo wpforo_bigintval($post['postid']) ?>" data-postid="<?php echo wpforo_bigintval($post['postid']) ?>" data-userid="<?php echo wpforo_bigintval($member['userid']) ?>" data-mention="<?php echo esc_attr( $member['user_nicename'] ) ?>" data-isowner="<?php echo esc_attr( (int) (bool) wpforo_is_owner($member['userid']) ) ?>" class="post-wrap wpfn-<?php echo ($key+1); ?><?php if( $post['is_first_post'] ) echo ' wpfp-first' ?>">
<?php wpforo_share_toggle($post_url, $post['body']); ?>
<div class="wpforo-post wpfcl-1">
<div class="wpf-left">
<?php if( WPF()->perm->usergroup_can('va') && wpforo_feature('avatars') ): ?>
<div class="author-avatar"><?php echo WPF()->member->avatar($member, 'alt="'.esc_attr($member['display_name']).'"', 110) ?></div>
<?php endif; ?>
<div class="author-data">
<div class="author-name"><span><?php WPF()->member->show_online_indicator($member['userid']) ?></span>&nbsp;<?php wpforo_member_link($member); ?></div>
<?php wpforo_member_nicename($member, '@'); ?>
<div class="wpf-member-profile-buttons">
<?php WPF()->tpl->member_buttons($member) ?>
</div>
<div class="author-title">
<?php wpforo_member_title($member) ?>
</div>
<?php wpforo_member_badge($member) ?>
</div>
<div class="wpf-clear"></div>
</div><!-- left -->
<div class="wpf-right">
<div class="wpforo-post-content-top">
<div class="wpf-post-actions">
<?php if( $post['is_first_post'] ){
$buttons = array( 'solved', 'sticky', 'private', 'close', 'report', 'delete', 'link' );
}else{
$buttons = array( 'report', 'delete', 'link' );
}
wpforo_post_buttons( 'icon-text', $buttons, $forum, $topic, $post );
?>
</div>
<?php wpforo_share_toggle($post_url, $post['body'], 'top'); ?>
</div>
<div class="wpforo-post-content">
<?php wpforo_content($post); ?>
<?php wpforo_post_edited($post); ?>
<?php do_action( 'wpforo_tpl_post_loop_after_content', $post, $member ) ?>
<?php if( wpforo_feature('signature') ): ?>
<?php if($member['signature']): ?><div class="wpforo-post-signature"><?php wpforo_signature( $member ) ?></div><?php endif; ?>
<?php endif; ?>
<div class="wpf-post-button-actions">
<?php
$buttons = array( 'reply', 'quote', 'approved', 'edit', 'like' );
wpforo_post_buttons( 'icon-text', $buttons, $forum, $topic, $post );
?>
<?php if($post['status']): ?>
<span class="wpf-mod-message"><i class="fas fa-exclamation-circle" aria-hidden="true"></i> <?php wpforo_phrase('Awaiting moderation') ?></span>
<?php endif; ?>
</div>
</div>
<div class="wpforo-post-content-bottom">
<div class="cbleft wpfcl-0"><?php wpforo_phrase('Posted') ?> : <?php wpforo_date($post['created'], 'd/m/Y g:i a') ?>
<?php wpforo_post_likers($post['postid']); ?>
</div>
<div class="wpf-clear"></div>
</div>
</div><!-- right -->
<div class="wpf-clear"></div>
</div><!-- wpforo-post -->
</div><!-- post-wrap -->
<?php if( $post['is_first_post'] ): ?>
<div class="wpforo-topic-meta">
<?php wpforo_tags( $topic ); ?>
</div>
<?php endif; ?>
<?php do_action( 'wpforo_loop_hook', $key ) ?>
<?php endforeach; ?>
</div><!-- wpfl-2 -->

View File

@ -0,0 +1,65 @@
<?php
// Exit if accessed directly
if( !defined( 'ABSPATH' ) ) exit;
// NIU:
$topic_fields = cbsonline_wpforo_get_topic_fields_list();
?>
<div class="wpfl-2">
<div class="wpforo-topic-head">
<div class="head-title"><?php echo wpfval($topic_fields['title'], 'label'); ?></div>
<div class="head-stat-lastpost"><?php wpforo_phrase('Last Post') ?></div>
<div class="head-stat-views"><?php echo wpfval($topic_fields['seminar_date'], 'label').' / '.wpfval($topic_fields['seminar_time'], 'label'); ?></div>
<div class="head-stat-posts"></div>
<br class="wpf-clear">
</div>
<?php foreach($topics as $key => $topic) : ?>
<?php
$last_poster = array();
$last_post = array();
$member = wpforo_member($topic);
if(isset($topic['last_post']) && $topic['last_post'] != 0){
$last_post = wpforo_post($topic['last_post']);
$last_poster = wpforo_member($last_post);
}
$topic_url = wpforo_topic($topic['topicid'], 'url');
// NIU:
$topic_custom_fields = cbsonline_wpforo_get_topic_custom_fields($topic['first_postid']);
?>
<div class="topic-wrap <?php wpforo_unread($topic['topicid'], 'topic'); ?>">
<div class="wpforo-topic">
<?php if( WPF()->perm->usergroup_can('va') && wpforo_feature('avatars') ): ?>
<div class="wpforo-topic-avatar"><?php echo WPF()->member->avatar($member, 'alt="'.esc_attr($member['display_name']).'"', 48) ?></div>
<?php endif; ?>
<div class="wpforo-topic-info">
<p class="wpforo-topic-title"><a href="<?php wpforo_unread_url( $topic['topicid'], $topic_url ) ?>"><?php wpforo_topic_icon($topic); ?><?php echo esc_html($topic['title']) ?></a> <?php wpforo_unread_button($topic['topicid'], $topic_url); ?> <?php wpforo_viewing( $topic ); ?></p>
<p class="wpforo-topic-custom_fields spearker">
<span class="label"><?php echo wpfval($topic_fields['speaker_name'], 'label'); ?></span><span class="value"><?php echo $topic_custom_fields['speaker_name']; ?>
</p>
<p class="wpforo-topic-custom_fields host">
<span class="label"><?php echo wpfval($topic_fields['host'], 'label'); ?></span><span class="value"><?php echo $topic_custom_fields['host']; ?>
</p>
<div class="wpforo-topic-badges"><?php wpforo_hook('wpforo_topic_info_end', $topic); ?></div>
</div>
<?php if(isset($topic['last_post']) && $topic['last_post'] != 0) : ?>
<div class="wpforo-topic-stat-lastpost"><span><?php wpforo_member_link($last_poster, 'by'); ?> <a href="<?php echo esc_url($last_post['url']) ?>" title="<?php wpforo_phrase('View the latest post') ?>"><i class="fas fa-chevron-right fa-sx wpfcl-a"></i></a></span><br> <?php wpforo_date($last_post['created']); ?></div>
<?php else: ?>
<div class="wpforo-topic-stat-lastpost"><?php wpforo_phrase('Replies not found') ?></div>
<?php endif; ?>
<div class="wpforo-topic-stat-views"><?php echo $topic_custom_fields['seminar_date']; ?><br /><?php echo $topic_custom_fields['seminar_time']; ?></div>
<div class="wpforo-topic-stat-posts"></div>
<br class="wpf-clear">
</div><!-- wpforo-topic -->
</div><!-- topic-wrap -->
<?php do_action( 'wpforo_loop_hook', $key ) ?>
<?php endforeach; ?>
</div><!-- wpfl-2 -->