本文整理汇总了PHP中XoopsBlock::getNonGroupedBlocks方法的典型用法代码示例。如果您正苦于以下问题:PHP XoopsBlock::getNonGroupedBlocks方法的具体用法?PHP XoopsBlock::getNonGroupedBlocks怎么用?PHP XoopsBlock::getNonGroupedBlocks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XoopsBlock
的用法示例。
在下文中一共展示了XoopsBlock::getNonGroupedBlocks方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: list_blocks
function list_blocks()
{
global $xoopsUser, $xoopsConfig;
include_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
//OpenTable();
$selmod = isset($_GET['selmod']) ? intval($_GET['selmod']) : 0;
$selvis = isset($_GET['selvis']) ? intval($_GET['selvis']) : 2;
$selgrp = isset($_GET['selgrp']) ? intval($_GET['selgrp']) : XOOPS_GROUP_USERS;
echo "\r\n <h4 style='text-align:left;'>" . _AM_BADMIN . "</h4>";
echo '<form action="admin.php" method="get">';
$form = "<select size=\"1\" name=\"selmod\" onchange=\"location='" . XOOPS_URL . "/modules/system/admin.php?fct=blocksadmin&selvis={$selvis}&selgrp={$selgrp}&selmod='+this.options[this.selectedIndex].value\">";
$module_handler =& xoops_gethandler('module');
$criteria = new CriteriaCompo(new Criteria('hasmain', 1));
$criteria->add(new Criteria('isactive', 1));
$module_list =& $module_handler->getList($criteria);
$toponlyblock = false;
$module_list[-1] = _AM_TOPPAGE;
$selmod = isset($_GET['selmod']) ? intval($_GET['selmod']) : -1;
ksort($module_list);
foreach ($module_list as $k => $v) {
$sel = '';
if ($k == $selmod) {
$sel = ' selected="selected"';
}
$form .= '<option value="' . $k . '"' . $sel . '>' . $v . '</option>';
}
$form .= '</select> <input type="hidden" name="fct" value="blocksadmin" />';
printf(_AM_SVISIBLEIN, $form);
$member_handler =& xoops_gethandler('member');
$group_list =& $member_handler->getGroupList();
$group_sel = _AM_GROUP . " <select size=\"1\" name=\"selgrp\" onchange=\"location='" . XOOPS_URL . "/modules/system/admin.php?fct=blocksadmin&selvis={$selvis}&selmod={$selmod}&selgrp='+this.options[this.selectedIndex].value\">";
$group_list[0] = '#' . _AM_UNASSIGNED;
// fix for displaying blocks unassigned to any group
foreach ($group_list as $k => $v) {
$sel = '';
if ($k == $selgrp) {
$sel = ' selected="selected"';
}
$group_sel .= '<option value="' . $k . '"' . $sel . '>' . $v . '</option>';
}
$group_sel .= '</select> ';
echo $group_sel;
echo _AM_VISIBLE . " <select size=\"1\" name=\"selvis\" onchange=\"location='" . XOOPS_URL . "/modules/system/admin.php?fct=blocksadmin&selmod={$selmod}&selgrp={$selgrp}&selvis='+this.options[this.selectedIndex].value\">";
$selvis0 = $selvis1 = $selvis2 = "";
switch ($selvis) {
case 0:
$selvis0 = 'selected="selected"';
break;
case 1:
$selvis1 = 'selected="selected"';
break;
case 2:
default:
$selvis2 = 'selected="selected"';
break;
}
echo '<option value="0" ' . $selvis0 . '>' . _NO . '</option>';
echo '<option value="1" ' . $selvis1 . '>' . _YES . '</option>';
echo '<option value="2" ' . $selvis2 . '>' . _ALL . '</option>';
echo '</select> <input type="submit" value="' . _GO . '" name="selsubmit" />';
echo '</form>';
echo "<form action='admin.php' name='blockadmin' method='post'>\r\n <table width='100%' class='outer' cellpadding='4' cellspacing='1'>\r\n <tr valign='middle'><th width='20%'>" . _AM_BLKDESC . "</th><th>" . _AM_TITLE . "</th><th>" . _AM_MODULE . "</th><th align='center' nowrap='nowrap'>" . _AM_SIDE . "<br />" . _LEFT . "-" . _CENTER . "-" . _RIGHT . "</th><th align='center'>" . _AM_WEIGHT . "</th><th align='center'>" . _AM_VISIBLE . "</th><th align='right'>" . _AM_ACTION . "</th></tr>\r\n ";
if ($selvis == 2) {
$selvis = null;
}
if ($selgrp == 0) {
// get blocks that are not assigned to any groups
$block_arr =& XoopsBlock::getNonGroupedBlocks($selmod, $toponlyblock, $selvis, 'b.side,b.weight,b.bid');
} else {
$block_arr =& XoopsBlock::getAllByGroupModule($selgrp, $selmod, $toponlyblock, $selvis, 'b.side,b.weight,b.bid');
}
$block_count = count($block_arr);
$class = 'even';
$module_list2 =& $module_handler->getList();
// for custom blocks
$module_list2[0] = ' ';
foreach (array_keys($block_arr) as $i) {
$sel0 = $sel1 = $ssel0 = $ssel1 = $ssel2 = $ssel3 = $ssel4 = "";
if ($block_arr[$i]->getVar("visible") == 1) {
$sel1 = " checked='checked'";
} else {
$sel0 = " checked='checked'";
}
if ($block_arr[$i]->getVar("side") == XOOPS_SIDEBLOCK_LEFT) {
$ssel0 = " checked='checked'";
} elseif ($block_arr[$i]->getVar("side") == XOOPS_SIDEBLOCK_RIGHT) {
$ssel1 = " checked='checked'";
} elseif ($block_arr[$i]->getVar("side") == XOOPS_CENTERBLOCK_LEFT) {
$ssel2 = " checked='checked'";
} elseif ($block_arr[$i]->getVar("side") == XOOPS_CENTERBLOCK_RIGHT) {
$ssel4 = " checked='checked'";
} elseif ($block_arr[$i]->getVar("side") == XOOPS_CENTERBLOCK_CENTER) {
$ssel3 = " checked='checked'";
}
if ($block_arr[$i]->getVar("title") == "") {
$title = " ";
} else {
$title = $block_arr[$i]->getVar("title");
}
$name = $block_arr[$i]->getVar("name");
//.........这里部分代码省略.........
示例2: list_blocks
function list_blocks()
{
global $xoopsUser, $xoopsConfig, $xoopsDB;
include_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
$module_handler =& xoops_gethandler('module');
$criteria = new CriteriaCompo(new Criteria('hasmain', 1));
$criteria->add(new Criteria('isactive', 1));
// Modules for blocks to be visible in
$display_list = $module_handler->getList($criteria);
unset($criteria);
// Modules generating the blocks
$generator_list = $module_handler->getList();
// for custom blocks
$generator_list[0] = _AM_CUSTOM;
$requests = array("selmod" => -1, "selgen" => 1, "selvis" => -1, "selgrp" => XOOPS_GROUP_USERS);
foreach ($requests as $req => $def) {
if (isset($_GET[$req])) {
${$req} = intval($_GET[$req]);
} elseif (isset($_COOKIE[$req])) {
${$req} = intval($_COOKIE[$req]);
} else {
${$req} = $def;
}
}
echo "<h4>" . _AM_BADMIN . "</h4>";
// For selection of generated by
echo '<form action="admin.php" method="get">';
$form = "<select size=\"1\" name=\"selgen\" onchange=\"location='" . XOOPS_URL . "/modules/system/admin.php?fct=blocksadmin&selmod={$selmod}&selvis={$selvis}&selgrp={$selgrp}&selgen='+this.options[this.selectedIndex].value\">";
$generator_list[-1] = _AM_TYPES;
ksort($generator_list);
foreach ($generator_list as $k => $v) {
$form .= '<option value="' . $k . '"' . ($k == $selgen ? ' selected="selected"' : '') . '>' . $v . '</option>';
}
$form .= '</select> ';
printf(_AM_GENERATOR, $form);
// For selection of visible in
$form = "<select size=\"1\" name=\"selmod\" onchange=\"location='" . XOOPS_URL . "/modules/system/admin.php?fct=blocksadmin&selgen={$selgen}&selvis={$selvis}&selgrp={$selgrp}&selmod='+this.options[this.selectedIndex].value\">";
//$toponlyblock = false;
ksort($display_list);
$display_list_spec[-2] = _AM_TYPES;
$display_list_spec[0] = _AM_ALLPAGES;
$display_list_spec[-1] = _AM_TOPPAGE;
$display_list = $display_list_spec + $display_list;
foreach ($display_list as $k => $v) {
$form .= '<option value="' . $k . '"' . ($k == $selmod ? ' selected="selected"' : '') . '>' . $v . '</option>';
}
$form .= '</select> ';
// <input type="hidden" name="fct" value="blocksadmin" />';
printf(_AM_SVISIBLEIN, $form);
unset($display_list[-2]);
// For selection of group access
$member_handler =& xoops_gethandler('member');
$group_list = $member_handler->getGroupList();
$group_sel = _AM_GROUP . " <select size=\"1\" name=\"selgrp\" onchange=\"location='" . XOOPS_URL . "/modules/system/admin.php?fct=blocksadmin&selgen={$selgen}&selvis={$selvis}&selmod={$selmod}&selgrp='+this.options[this.selectedIndex].value\">";
$group_list[0] = _AM_UNASSIGNED;
$group_list[-1] = _AM_TYPES;
foreach ($group_list as $k => $v) {
$group_sel .= '<option value="' . $k . '"' . ($k == $selgrp ? ' selected="selected"' : '') . '>' . $v . '</option>';
}
$group_sel .= '</select> ';
echo $group_sel;
// For selection of visiblility
echo _AM_VISIBLE . " <select size=\"1\" name=\"selvis\" onchange=\"location='" . XOOPS_URL . "/modules/system/admin.php?fct=blocksadmin&selgen={$selgen}&selmod={$selmod}&selgrp={$selgrp}&selvis='+this.options[this.selectedIndex].value\">";
echo '<option value="0"' . ($selvis == 0 ? ' selected="selected"' : '') . '>' . _NO . '</option>';
echo '<option value="1"' . ($selvis == 1 ? ' selected="selected"' : '') . '>' . _YES . '</option>';
echo '<option value="-1"' . ($selvis == -1 ? ' selected="selected"' : '') . '>' . _AM_TYPES . '</option>';
echo '</select> <input type="hidden" name="fct" value="blocksadmin" /><input type="submit" value="' . _GO . '" name="selsubmit" />';
echo '</form><br />';
echo "<form action='admin.php' name='blockadmin' method='post'>\r\n <table width='100%' class='outer' cellpadding='4' cellspacing='1'>\r\n <tr valign='middle' align='center'>\r\n <th width='15%'>" . _AM_TITLE . "</th>\r\n <th width='20%'>" . _AM_BLKDESC . "</th>\r\n <th width='10%'>" . _AM_MODULE . "</th>\r\n <th width='10%' nowrap='nowrap'>" . _AM_SIDE . "<br />" . _LEFT . "-" . _CENTER . "-" . _RIGHT . "</th>\r\n <th width='10%'>" . _AM_VISIBLEIN . "</th>\r\n <th width='10%'>" . _AM_BCACHETIME . "</th>\r\n <th width='10%'>" . _AM_VISIBLE . "</th>\r\n <th width='10%'>" . _AM_WEIGHT . "</th>\r\n <th>" . _AM_ACTION . "</th>\r\n </tr>\r\n ";
if ($selvis == -1) {
//$selvis = null;
}
$order_block = (isset($selvis) ? "" : "b.visible DESC, ") . "b.side,b.weight,b.bid";
$vis_block = $selvis == -1 ? null : $selvis;
$mod_block = $selmod == -2 ? null : $selmod;
if ($selgrp == 0) {
// get blocks that are not assigned to any groups
$block_arr = XoopsBlock::getNonGroupedBlocks($mod_block, $toponlyblock = false, $vis_block, $order_block);
} else {
$grp_block = $selgrp == -1 ? null : $selgrp;
$block_arr = XoopsBlock::getAllByGroupModule($grp_block, $mod_block, $toponlyblock = false, $vis_block, $order_block);
}
if ($selgen >= 0) {
foreach (array_keys($block_arr) as $bid) {
if ($block_arr[$bid]->getVar("mid") != $selgen) {
unset($block_arr[$bid]);
}
}
}
//xoops_result(array_keys($block_arr));
$block_count = count($block_arr);
$class = 'even';
$block_mod = array();
if ($block_count) {
$sql = 'SELECT block_id, module_id FROM ' . $xoopsDB->prefix('block_module_link') . ' WHERE block_id IN (' . implode(', ', array_keys($block_arr)) . ')';
$result = $xoopsDB->query($sql);
while ($row = $xoopsDB->fetchArray($result)) {
$block_mod[$row['block_id']][] = $row['module_id'];
}
}
//.........这里部分代码省略.........