📄 system_blocks.php
字号:
$block['recommendlink'] = "<a href=\"javascript:openWithSelfMain('".XOOPS_URL."/misc.php?action=showpopups&type=friend&op=sendform&t=".time()."','friend',".$options[0].",".$options[1].")\">"._MB_SYSTEM_RECO."</a>";
return $block;
}
function b_system_newmembers_show($options)
{
$block = array();
$criteria = new CriteriaCompo(new Criteria('level', 0, '>'));
$limit = (!empty($options[0])) ? $options[0] : 10;
$criteria->setOrder('DESC');
$criteria->setSort('user_regdate');
$criteria->setLimit($limit);
$member_handler =& xoops_gethandler('member');
$newmembers = $member_handler->getUsers($criteria);
$count = count($newmembers);
for ($i = 0; $i < $count; $i++) {
if ( $options[1] == 1 ) {
$block['users'][$i]['avatar'] = $newmembers[$i]->getVar('user_avatar') != 'blank.gif' ? XOOPS_UPLOAD_URL.'/'.$newmembers[$i]->getVar('user_avatar') : '';
} else {
$block['users'][$i]['avatar'] = '';
}
$block['users'][$i]['id'] = $newmembers[$i]->getVar('uid');
$block['users'][$i]['name'] = $newmembers[$i]->getVar('uname');
$block['users'][$i]['joindate'] = formatTimestamp($newmembers[$i]->getVar('user_regdate'), 's');
}
return $block;
}
function b_system_topposters_show($options)
{
$block = array();
$criteria = new CriteriaCompo(new Criteria('level', 0, '>'));
$limit = (!empty($options[0])) ? $options[0] : 10;
$size = count($options);
for ( $i = 2; $i < $size; $i++) {
$criteria->add(new Criteria('rank', $options[$i], '<>'));
}
$criteria->setOrder('DESC');
$criteria->setSort('posts');
$criteria->setLimit($limit);
$member_handler =& xoops_gethandler('member');
$topposters =& $member_handler->getUsers($criteria);
$count = count($topposters);
for ($i = 0; $i < $count; $i++) {
$block['users'][$i]['rank'] = $i+1;
if ( $options[1] == 1 ) {
$block['users'][$i]['avatar'] = $topposters[$i]->getVar('user_avatar') != 'blank.gif' ? XOOPS_UPLOAD_URL.'/'.$topposters[$i]->getVar('user_avatar') : '';
} else {
$block['users'][$i]['avatar'] = '';
}
$block['users'][$i]['id'] = $topposters[$i]->getVar('uid');
$block['users'][$i]['name'] = $topposters[$i]->getVar('uname');
$block['users'][$i]['posts'] = $topposters[$i]->getVar('posts');
}
return $block;
}
function b_system_comments_show($options)
{
$block = array();
include_once XOOPS_ROOT_PATH.'/include/comment_constants.php';
$comment_handler =& xoops_gethandler('comment');
$criteria = new CriteriaCompo(new Criteria('com_status', XOOPS_COMMENT_ACTIVE));
$criteria->setLimit(intval($options[0]));
$criteria->setSort('com_created');
$criteria->setOrder('DESC');
$comments = $comment_handler->getObjects($criteria, true);
$member_handler =& xoops_gethandler('member');
$module_handler =& xoops_gethandler('module');
$modules = $module_handler->getObjects(new Criteria('hascomments', 1), true);
$comment_config = array();
foreach (array_keys($comments) as $i) {
$mid = $comments[$i]->getVar('com_modid');
$com['module'] = '<a href="'.XOOPS_URL.'/modules/'.$modules[$mid]->getVar('dirname').'/">'.$modules[$mid]->getVar('name').'</a>';
if (!isset($comment_config[$mid])) {
$comment_config[$mid] = $modules[$mid]->getInfo('comments');
}
$com['id'] = $i;
$com['title'] = '<a href="'.XOOPS_URL.'/modules/'.$modules[$mid]->getVar('dirname').'/'.$comment_config[$mid]['pageName'].'?'.$comment_config[$mid]['itemName'].'='.$comments[$i]->getVar('com_itemid').'&com_id='.$i.'&com_rootid='.$comments[$i]->getVar('com_rootid').'&'.htmlspecialchars($comments[$i]->getVar('com_exparams')).'#comment'.$i.'">'.$comments[$i]->getVar('com_title').'</a>';
$com['icon'] = htmlspecialchars( $comments[$i]->getVar('com_icon'), ENT_QUOTES );
$com['icon'] = ($com['icon'] != '') ? $com['icon'] : 'icon1.gif';
$com['time'] = formatTimestamp($comments[$i]->getVar('com_created'),'m');
if ($comments[$i]->getVar('com_uid') > 0) {
$poster =& $member_handler->getUser($comments[$i]->getVar('com_uid'));
if (is_object($poster)) {
$com['poster'] = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$comments[$i]->getVar('com_uid').'">'.$poster->getVar('uname').'</a>';
} else {
$com['poster'] = $GLOBALS['xoopsConfig']['anonymous'];
}
} else {
$com['poster'] = $GLOBALS['xoopsConfig']['anonymous'];
}
$block['comments'][] =& $com;
unset($com);
}
return $block;
}
// RMV-NOTIFY
function b_system_notification_show()
{
global $xoopsConfig, $xoopsUser, $xoopsModule;
include_once XOOPS_ROOT_PATH . '/include/notification_functions.php';
include_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/notification.php';
// Notification must be enabled, and user must be logged in
if (empty($xoopsUser) || !notificationEnabled('block')) {
return false; // do not display block
}
$notification_handler =& xoops_gethandler('notification');
// Now build the a nested associative array of info to pass
// to the block template.
$block = array();
$categories =& notificationSubscribableCategoryInfo();
if (empty($categories)) {
return false;
}
foreach ($categories as $category) {
$section['name'] = $category['name'];
$section['title'] = $category['title'];
$section['description'] = $category['description'];
$section['itemid'] = $category['item_id'];
$section['events'] = array();
$subscribed_events =& $notification_handler->getSubscribedEvents ($category['name'], $category['item_id'], $xoopsModule->getVar('mid'), $xoopsUser->getVar('uid'));
foreach (notificationEvents($category['name'], true) as $event) {
if (!empty($event['admin_only']) && !$xoopsUser->isAdmin($xoopsModule->getVar('mid'))) {
continue;
}
$subscribed = in_array($event['name'], $subscribed_events) ? 1 : 0;
$section['events'][$event['name']] = array ('name'=>$event['name'], 'title'=>$event['title'], 'caption'=>$event['caption'], 'description'=>$event['description'], 'subscribed'=>$subscribed);
}
$block['categories'][$category['name']] = $section;
}
// Additional form data
$block['target_page'] = "notification_update.php";
// FIXME: better or more standardized way to do this?
$script_url = explode('/', $_SERVER['PHP_SELF']);
$script_name = $script_url[count($script_url)-1];
$block['redirect_script'] = $script_name;
$block['submit_button'] = _NOT_UPDATENOW;
$block['notification_token'] = $GLOBALS['xoopsSecurity']->createToken();
return $block;
}
function b_system_comments_edit($options)
{
$inputtag = "<input type='text' name='options[]' value='".intval($options[0])."' />";
$form = sprintf(_MB_SYSTEM_DISPLAYC, $inputtag);
return $form;
}
function b_system_topposters_edit($options)
{
include_once XOOPS_ROOT_PATH.'/class/xoopslists.php';
$inputtag = "<input type='text' name='options[]' value='".intval($options[0])."' />";
$form = sprintf(_MB_SYSTEM_DISPLAY,$inputtag);
$form .= "<br />"._MB_SYSTEM_DISPLAYA." <input type='radio' id='options[]' name='options[]' value='1'";
if ( $options[1] == 1 ) {
$form .= " checked='checked'";
}
$form .= " /> "._YES."<input type='radio' id='options[]' name='options[]' value='0'";
if ( $options[1] == 0 ) {
$form .= " checked='checked'";
}
$form .= " /> "._NO."";
$form .= "<br />"._MB_SYSTEM_NODISPGR."<br /><select id='options[]' name='options[]' multiple='multiple'>";
$ranks =& XoopsLists::getUserRankList();
$size = count($options);
foreach ($ranks as $k => $v) {
$sel = "";
for ( $i = 2; $i < $size; $i++ ) {
if ($k == $options[$i]) {
$sel = " selected='selected'";
}
}
$form .= "<option value='$k'$sel>$v</option>";
}
$form .= "</select>";
return $form;
}
function b_system_newmembers_edit($options)
{
$inputtag = "<input type='text' name='options[]' value='".$options[0]."' />";
$form = sprintf(_MB_SYSTEM_DISPLAY,$inputtag);
$form .= "<br />"._MB_SYSTEM_DISPLAYA." <input type='radio' id='options[]' name='options[]' value='1'";
if ( $options[1] == 1 ) {
$form .= " checked='checked'";
}
$form .= " /> "._YES."<input type='radio' id='options[]' name='options[]' value='0'";
if ( $options[1] == 0 ) {
$form .= " checked='checked'";
}
$form .= " /> "._NO."";
return $form;
}
function b_system_info_edit($options)
{
$form = _MB_SYSTEM_PWWIDTH." ";
$form .= "<input type='text' name='options[]' value='".$options[0]."' />";
$form .= "<br />"._MB_SYSTEM_PWHEIGHT." ";
$form .= "<input type='text' name='options[]' value='".$options[1]."' />";
$form .= "<br />".sprintf(_MB_SYSTEM_LOGO,XOOPS_URL."/images/")." ";
$form .= "<input type='text' name='options[]' value='".$options[2]."' />";
$chk = "";
$form .= "<br />"._MB_SYSTEM_SADMIN." ";
if ( $options[3] == 1 ) {
$chk = " checked='checked'";
}
$form .= "<input type='radio' name='options[3]' value='1'".$chk." /> "._YES."";
$chk = "";
if ( $options[3] == 0 ) {
$chk = " checked=\"checked\"";
}
$form .= " <input type='radio' name='options[3]' value='0'".$chk." />"._NO."";
return $form;
}
function b_system_themes_show($options)
{
global $xoopsConfig;
$theme_options = '';
foreach ($xoopsConfig['theme_set_allowed'] as $theme) {
$theme_options .= '<option value="'.$theme.'"';
if ($theme == $xoopsConfig['theme_set']) {
$theme_options .= ' selected="selected"';
}
$theme_options .= '>'.$theme.'</option>';
}
$block = array();
if ($options[0] == 1) {
$block['theme_select'] = "<img vspace=\"2\" id=\"xoops_theme_img\" src=\"".XOOPS_THEME_URL."/".$xoopsConfig['theme_set']."/shot.gif\" alt=\"screenshot\" width=\"".intval($options[1])."\" /><br /><select id=\"xoops_theme_select\" name=\"xoops_theme_select\" onchange=\"showImgSelected('xoops_theme_img', 'xoops_theme_select', 'themes', '/shot.gif', '".XOOPS_URL."');\">".$theme_options."</select><input type=\"submit\" value=\""._GO."\" />";
} else {
$block['theme_select'] = '<select name="xoops_theme_select" onchange="submit();" size="3">'.$theme_options.'</select>';
}
$block['theme_select'] .= '<br />('.sprintf(_MB_SYSTEM_NUMTHEME, '<b>'.count($xoopsConfig['theme_set_allowed']).'</b>').')<br />';
return $block;
}
function b_system_themes_edit($options)
{
$chk = "";
$form = _MB_SYSTEM_THSHOW." ";
if ( $options[0] == 1 ) {
$chk = " checked='checked'";
}
$form .= "<input type='radio' name='options[0]' value='1'".$chk." /> "._YES;
$chk = "";
if ( $options[0] == 0 ) {
$chk = ' checked="checked"';
}
$form .= ' <input type="radio" name="options[0]" value="0"'.$chk.' />'._NO;
$form .= '<br />'._MB_SYSTEM_THWIDTH.' ';
$form .= "<input type='text' name='options[1]' value='".$options[1]."' />";
return $form;
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -