19 $db = XoopsDatabaseFactory::getDatabaseConnection();
21 if($mods==null || empty($mods))
26 foreach($mods as
$mod){
28 if(!file_exists(XOOPS_ROOT_PATH.
'/modules/'.$mod[
'dirname'].
'/xoops_version.php'))
32 $module =
new XoopsModule();
33 $module->loadInfoAsVar($mod[
'dirname']);
35 $list[$mod[
'dirname']] = array(
36 'name' => $mod[
'name'],
37 'blocks' => $module->getInfo(
'blocks')
43 $list =
RMEvents::get()->run_event(
'rmcommon.available.widgets', $list);
51 $db = XoopsDatabaseFactory::getDatabaseConnection();
52 $result =
$db->query(
"SELECT * FROM " .
$db->prefix(
"rmc_blocks_positions"));
55 $pos[$row[
'id_position']] = $row;
68 foreach(self::block_positions() as
$id => $row){
69 $sides[
$id] = $row[
'tag'];
70 $blocks[$row[
'tag']] = array();
73 $startMod = ( $xoopsConfig[
'startpage'] ==
'--' ) ?
'system' : $xoopsConfig[
'startpage'];
74 if ( @is_object( $xoopsModule ) ) {
75 list(
$mid, $dirname ) = array( $xoopsModule->getVar(
'mid'), $xoopsModule->getVar(
'dirname') );
76 $isStart = ( substr( $_SERVER[
'PHP_SELF'], -9 ) ==
'index.php' && $xoopsConfig[
'startpage'] == $dirname );
79 list(
$mid, $dirname ) = array( $sys->getVar(
'mid'),
'system' );
80 $isStart = !@empty(
$GLOBALS[
'xoopsOption'][
'show_cblock'] );
83 $groups = @is_object( $xoopsUser ) ? $xoopsUser->getGroups() : array( XOOPS_GROUP_ANONYMOUS );
85 $subpage = isset($xoopsOption[
'module_subpage']) ? $xoopsOption[
'module_subpage'] :
'';
88 $barray = self::get_blocks($groups,
$mid, $isStart, XOOPS_BLOCK_VISIBLE,
'', 1, $subpage);
90 foreach($barray as $block){
92 $side = $sides[$block->getVar(
'canvas')];
93 if(
$content = self::buildBlock($block)){
98 unset($side,$sides,
$content,$subpage,$barray,$groups,$startMod);
104 public function get_blocks($groupid,
$mid=0, $toponlyblock=
false, $visible=null, $orderby=
'b.weight,b.wid', $isactive=1, $subpage=
''){
106 $orderby = $orderby==
'' ?
'b.weight,b.bid' : $orderby;
108 $db =& XoopsDatabaseFactory::getDatabaseConnection();
110 $sql =
"SELECT DISTINCT gperm_itemid FROM ".$db->prefix(
'group_permission').
" WHERE (gperm_name = 'rmblock_read') AND gperm_modid = 1";
111 if ( is_array($groupid) ) {
112 $sql .=
' AND gperm_groupid IN ('.implode(
',', $groupid).
',0)';
114 if (intval($groupid) > 0) {
115 $sql .=
' AND gperm_groupid IN (0,'.$groupid.
')';
123 $blockids[] = $myrow[
'gperm_itemid'];
126 if (!empty($blockids)) {
127 $sql =
'SELECT b.* FROM '.$db->prefix(
'rmc_blocks').
' b, '.
$db->prefix(
'rmc_bkmod').
' m WHERE m.bid=b.bid';
128 $sql .=
' AND b.isactive='.$isactive;
129 if (isset($visible)) {
130 $sql .=
' AND b.visible='.intval($visible);
134 $sql .=
' AND m.mid IN (0,'.$mid;
141 $sql .=
' AND m.mid IN (0,1)';
146 $sql .= $subpage!=
'' ?
" AND (m.page='$subpage' OR m.page='--')" :
'';
147 $sql .=
' AND b.bid IN ('.implode(
',', $blockids).
')';
148 $sql .=
' ORDER BY '.$orderby;
152 $block->assignVars($myrow);
153 $ret[$myrow[
'bid']] = $block;
164 global $xoopsTpl, $xoTheme;
165 $template = $xoopsTpl;
168 'id' => $bobj->getVar(
'bid') ,
169 'module' => $bobj->getVar(
'dirname') ,
170 'title' => $bobj->getVar(
'name') ,
172 'weight' => $bobj->getVar(
'weight'));
174 $bcachetime = intval($bobj->getVar(
'bcachetime'));
175 if (empty($bcachetime)) {
176 $template->caching = 0;
178 $template->caching = 2;
179 $template->cache_lifetime = $bcachetime;
181 $template->setCompileId($bobj->getVar(
'dirname',
'n'));
182 if($bobj->getVar(
'element_type')==
'plugin'){
183 $tplName = XOOPS_ROOT_PATH.
'/modules/'.$bobj->getVar(
'element').
'/plugins/'.$bobj->getVar(
'dirname').
'/templates/blocks/'.$bobj->getVar(
'template');
185 $tplName = ($tplName = $bobj->getVar(
'template')) ?
"db:$tplName" :
'db:system_block_dummy.html';
187 $cacheid = $xoTheme->generateCacheId(
'blk_' . $bobj->getVar(
'bid'));
193 if (!$bcachetime || !$template->is_cached($tplName, $cacheid)) {
195 if ($bresult = $bobj->buildBlock()) {
196 $template->assign(
'block', $bresult);
197 $block[
'content'] = $template->fetch($tplName, $cacheid);
202 $xoopsLogger->addBlock($bobj->getVar(
'name'),
true, $bcachetime);
203 $block[
'content'] = $template->fetch($tplName, $cacheid);
206 $template->setCompileId();