discuz 一些的代码片段

admin 4个月前 1293 阅读

验证码代码
source/module/misc/misc_seccode.php

插件后台 是否在会员组中存在

$groupids = (array)unserialize($_G['cache']['plugin']['cmsbj_threadnotice']['opgroup']);
$isuser = in_array('', $groupids) ? TRUE : (in_array($_G['groupid'], $groupids) ? TRUE : FALSE);

根据会员组 ID 获取组名称

$_G['cache']['usergroups'][会员组 ID]['grouptitle']

获取用户相册,识别远程或本地 pic_cover_get();

<!--{eval $space['albums'] = C::t('home_album')->fetch_all_by_uid($space['uid'], 'updatetime', 0, 4);}-->
<div class="row row-xs">
<!--{loop $space['albums'] $albums}-->
<!--{eval $albums['pic'] = pic_cover_get($albums['pic'],$albums['picflag']);}-->
<div class="col-6">
<div class="media media-16x9 r">
<a class="media-content media-16x9"><img src="{$albums['pic']}"></a>
</div>
</div>
<!--{/loop}-->
</div>

人性化时间

{echo dgmdate($value[dateline], 'u', '9999', getglobal('setting/dateformat'))}

文章归档

$zblogs = DB::fetch_all("SELECT DISTINCT(FROM_UNIXTIME(dateline,'%Y-%m')) as month,count(*) as monthcount FROM ".DB::table("home_blog")." GROUP BY month ORDER BY `month` DESC");

获取所有门户栏目

loadcache('portalcategory');
$scats = $_G['cache']['portalcategory'];
$topcategory = $subcategory = array();
foreach($scats as $value) {
  if($value['upid'] == 0) {
    $topcategory[] = $value;
    if($value['children']) {
      foreach($value['children'] as $val) {
          $subcategory[] = $scats[$val];
      }
    }
  }
}

<!--{loop $topcategory $topval}-->
<a href="{$topval['caturl']}" class="list-group-item i-con-h-a{if $_G['gp_catid']==$topval['catid']} active{/if}">
<i class="mr-2 i-con i-con-menu"></i>{$topval['catname']}
</a>
<!--{loop $subcategory $subval}-->
<!--{if $subval['upid'] == $topval['catid']}-->
<a href="{$subval['caturl']}" class="list-group-item i-con-h-a{if $_G['gp_catid']==$subval['catid']} active{/if}">
<i class="i-con"></i><i class="mr-2 i-con i-con-menu"></i>{$subval['catname']}
</a>
<!--{/if}-->
<!--{/loop}-->
<!--{/loop}-->

调用日历

<div class="card" data-plugin="schedule">
<div class="card-header d-flex align-items-center justify-content-between">
<span class="font-weight-bold"><i class="fa fa-folder mr-2"></i>日志日历</span>
<span><a href="home.php?mod=space&uid={$space['uid']}&do=blog&view=me&from=space" data-toggle="tooltip" data-placement="top" title="" data-original-title="{lang all}{lang blog}"><i class="fa fa-ellipsis-h"></i></a></span>
</div>
<div class="card-body">
<div id="schedule-box"><div class="text-center py-5"><i class="fa fa-spinner fa-spin fa-2x"></i></div></div>
</div>
</div>
<script type="text/javascript">
jQuery.ajaxSetup({
error:function(x,e){
jQuery("#schedule-box").html('<div class="text-center text-muted">暂无记录</div>');
return false;
}
});
jQuery.getJSON("public/json/home/blog-1-calendar.json",function(result){
var mySchedule = new Schedule({
el: '#schedule-box',
dataDate : result,
})
});
</script>

模态框搜索

    <div class="modal fade" id="main-search" data-backdrop="true">
      <div class="modal-dialog modal-top bg-white b-b">
          <div>
            <div class="container">
              <div class="py-4">
                  <div class="col-md-6 mx-auto">
                      <!--{if $_G['setting']['search']}-->
                            <!--{eval $slist = array();}-->
                            <!--{if $_G['fid'] && $_G['forum']['status'] != 3 && $mod != 'group'}--><!--{block slist[forumfid]}--><li><a href="javascript:;" rel="curforum" fid="$_G[fid]" >{lang search_this_forum}</a></li><!--{/block}--><!--{/if}-->
                            <!--{if $_G['setting']['portalstatus'] && $_G['setting']['search']['portal']['status'] && ($_G['group']['allowsearch'] & 1 || $_G['adminid'] == 1)}--><!--{block slist[portal]}--><li><a href="javascript:;" rel="article">{lang article}</a></li><!--{/block}--><!--{/if}-->
                            <!--{if $_G['setting']['search']['forum']['status'] && ($_G['group']['allowsearch'] & 2 || $_G['adminid'] == 1)}--><!--{block slist[forum]}--><li><a href="javascript:;" rel="forum" class="curtype">{lang thread}</a></li><!--{/block}--><!--{/if}-->
                            <!--{if helper_access::check_module('blog') && $_G['setting']['search']['blog']['status'] && ($_G['group']['allowsearch'] & 4 || $_G['adminid'] == 1)}--><!--{block slist[blog]}--><li><a href="javascript:;" rel="blog">{lang blog}</a></li><!--{/block}--><!--{/if}-->
                            <!--{if helper_access::check_module('album') && $_G['setting']['search']['album']['status'] && ($_G['group']['allowsearch'] & 8 || $_G['adminid'] == 1)}--><!--{block slist[album]}--><li><a href="javascript:;" rel="album">{lang album}</a></li><!--{/block}--><!--{/if}-->
                            <!--{if $_G['setting']['groupstatus'] && $_G['setting']['search']['group']['status'] && ($_G['group']['allowsearch'] & 16 || $_G['adminid'] == 1)}--><!--{block slist[group]}--><li><a href="javascript:;" rel="group">$_G['setting']['navs'][3]['navname']</a></li><!--{/block}--><!--{/if}-->
                            <!--{block slist[user]}--><li><a href="javascript:;" rel="user">{lang users}</a></li><!--{/block}-->
                        <!--{/if}-->
                        <!--{if $_G['setting']['search'] && $slist}-->
                        <div class="{if $_G['setting']['srchhotkeywords'] && count($_G['setting']['srchhotkeywords']) > 5}scbar_narrow {/if}cl">
                            <form id="scbar_form" method="{if $_G[fid] && !empty($searchparams[url])}get{else}post{/if}" autocomplete="off" onsubmit="searchFocus($('scbar_txt'))" action="{if $_G[fid] && !empty($searchparams[url])}$searchparams[url]{else}search.php?searchsubmit=yes{/if}" target="_blank">
                                <input type="hidden" name="mod" id="scbar_mod" value="search" />
                                <input type="hidden" name="formhash" value="{FORMHASH}" />
                                <input type="hidden" name="srchtype" value="title" />
                                <input type="hidden" name="srhfid" value="$_G[fid]" />
                                <input type="hidden" name="srhlocality" value="$_G['basescript']::{CURMODULE}" />
                                <!--{if !empty($searchparams[params])}-->
                                    <!--{loop $searchparams[params] $key $value}-->
                                    <!--{eval $srchotquery .= '&' . $key . '=' . rawurlencode($value);}-->
                                    <input type="hidden" name="$key" value="$value" />
                                    <!--{/loop}-->
                                    <input type="hidden" name="source" value="discuz" />
                                    <input type="hidden" name="fId" id="srchFId" value="$_G[fid]" />
                                    <input type="hidden" name="q" id="cloudsearchquery" value="" />
                          <div style="display: none; position: absolute; top:37px; left:44px;" id="sg">
                              <div id="st_box" cellpadding="2" cellspacing="0"></div>
                          </div>
                                <!--{/if}-->
                                <div class="py-4 text-center"><h2 class="h2">{lang search}一下</h2><a href="javascript:;" class="i-con-h-a" style="position: absolute;right: 1rem;top: 1rem;" onclick="jQuery('#main-search').modal('hide');;"><i class="mr-2 i-con i-con-close w-40"></i></a></div>
                                <div class="input-group mb-3">
                          <div class="input-group-prepend">
                            <button class="btn btn-outline-light dropdown-toggle text-secondary" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" id="scbar_type" onclick="showMenu(this.id)" hidefocus="true">{lang search}</button>
                            <div class="dropdown-menu" id="scbar_type_menu" x-placement="bottom-start">
                              <!--{echo implode('', $slist);}-->
                            </div>
                          </div>
                          <input type="text" class="form-control" name="srchtxt" id="scbar_txt" value="{lang enter_content}" autocomplete="off" x-webkit-speech speech />
                          <div class="input-group-append">
                            <button type="submit" name="searchsubmit" id="scbar_btn" sc="1" class="btn btn-primary px-4" value="true">{lang search}</button>
                          </div>
                        </div>
                        <!--{if $_G['setting']['srchhotkeywords']}-->
                                <div id="scbar_hot">
                                    <div class="d-flex nav-active-border nav-active-text-primary b-primary">
                                <ul class="nav">
                                  <li class="nav-item">
                                    <span class="nav-link py-2 pl-0"><strong>{lang hot_search}:</strong></span>
                                  </li>
                                  <!--{loop $_G['setting']['srchhotkeywords'] $val}-->
                                            <!--{if $val=trim($val)}-->
                                                <!--{eval $valenc=rawurlencode($val);}-->
                                                <!--{block srchhotkeywords[]}-->
                                                    <!--{if !empty($searchparams[url])}-->
                                                        <li class="nav-item"><a href="$searchparams[url]?q=$valenc&source=hotsearch{$srchotquery}" target="_blank"class="nav-link py-2" sc="1">$val</a></li>
                                                    <!--{else}-->
                                                        <li class="nav-item"><a href="search.php?mod=forum&srchtxt=$valenc&formhash={FORMHASH}&searchsubmit=true&source=hotsearch" target="_blank" class="nav-link py-2" sc="1">$val</a></li>
                                                    <!--{/if}-->
                                                <!--{/block}-->
                                            <!--{/if}-->
                                        <!--{/loop}-->
                                        <!--{echo implode('', $srchhotkeywords);}-->
                                </ul>
                              </div>
                                </div>
                                <!--{/if}-->
                            </form>
                        </div>
                        <script type="text/javascript" reload="1">
                            initSearchmenu('scbar', '$searchparams[url]');
                        </script>
                        <!--{/if}-->
                </div>
              </div>
            </div>
        </div>
      </div>
    </div>

editormd 夜间模式,改变样式

jQuery(".editormd-html-preview").addClass('editormd-preview-theme-dark');
回复 0
登录之后才能参与