72 $blkhandler =
$xoops->getHandlerBlock();
73 $obj = $blkhandler->get(
$id);
74 foreach (array_keys($obj->getVars()) as
$i) {
75 $this->
assignVar($i, $obj->getVar($i,
'n'));
88 public function id($format =
'n')
90 return $this->
getVar(
'bid', $format);
97 public function bid($format =
'')
99 return $this->
getVar(
'bid', $format);
106 public function mid($format =
'')
108 return $this->
getVar(
'mid', $format);
117 return $this->
getVar(
'func_num', $format);
126 return $this->
getVar(
'options', $format);
133 public function name($format =
'')
135 return $this->
getVar(
'name', $format);
144 return $this->
getVar(
'title', $format);
153 return $this->
getVar(
'content', $format);
160 public function side($format =
'')
162 return $this->
getVar(
'side', $format);
171 return $this->
getVar(
'weight', $format);
180 return $this->
getVar(
'visible', $format);
189 return $this->
getVar(
'block_type', $format);
198 return $this->
getVar(
'c_type', $format);
207 return $this->
getVar(
'isactive', $format);
216 return $this->
getVar(
'dirname', $format);
225 return $this->
getVar(
'func_file', $format);
234 return $this->
getVar(
'show_func', $format);
243 return $this->
getVar(
'edit_func', $format);
250 public function template($format =
'')
252 return $this->
getVar(
'template', $format);
261 return $this->
getVar(
'bcachetime', $format);
270 return $this->
getVar(
'last_modified', $format);
287 $format = strtolower($format);
288 $c_type = strtoupper($c_type);
296 if ($c_type ==
'H') {
297 return str_replace(
'{X_SITEURL}', $this->xoops_url .
'/', $this->
getVar(
'content',
'n'));
299 if ($c_type ==
'P') {
301 echo eval($this->
getVar(
'content',
'n'));
304 return str_replace(
'{X_SITEURL}', $this->xoops_url .
'/',
$content);
306 if ($c_type ==
'S') {
308 $content = str_replace(
'{X_SITEURL}', $this->xoops_url .
'/', $this->
getVar(
'content',
'n'));
319 return $this->
getVar(
'content',
'e');
322 return $this->
getVar(
'content',
'n');
336 $edit_func = (string)$this->
getVar(
'edit_func');
341 $xoops->loadLanguage(
'blocks', $this->
getVar(
'dirname'));
342 include_once $this->xoops_root_path .
'/modules/' . $this->
getVar(
'dirname') .
'/blocks/' . $this->
getVar(
'func_file');
343 if (function_exists($edit_func)) {
364 return in_array($this->
getVar(
"block_type"), array(
'C',
'E'));
381 $show_func = (string)$this->
getVar(
'show_func');
390 $xoops->loadLanguage(
'blocks', $this->
getVar(
'dirname'));
392 include_once $func_file;
394 if (function_exists($show_func)) {
407 if (empty($block[
'content'])) {
424 parent::__construct($db,
'newblocks',
'XoopsBlock',
'bid',
'name');
434 $obj->
setVar(
'last_modified', time());
435 return parent::insert($obj, $force);
446 if (!parent::delete($obj)) {
449 $qb = $this->db2->createXoopsQueryBuilder();
451 $qb ->deletePrefix(
'group_permission', null)
452 ->where($eb->eq(
'gperm_name', $eb->literal(
'block_read')))
453 ->andWhere($eb->eq(
'gperm_itemid', $qb->createNamedParameter($obj->
getVar(
'bid'), \PDO::PARAM_INT)))
454 ->andWhere($eb->eq(
'gperm_modid', $qb->createNamedParameter(1, \PDO::PARAM_INT)))
457 $qb ->deletePrefix(
'block_module_link', null)
458 ->where($eb->eq(
'block_id', $qb->createNamedParameter($obj->
getVar(
'bid'), \PDO::PARAM_INT)))
474 $qb = $this->db2->createXoopsQueryBuilder();
476 $qb ->select(
'DISTINCT(b.bid)')
478 ->fromPrefix(
'newblocks',
'b')
479 ->leftJoinPrefix(
'b',
'block_module_link',
'l', $eb->eq(
'b.bid',
'l.block_id'));
489 while ($myrow =
$result->fetch(\PDO::FETCH_ASSOC)) {
491 $block->assignVars($myrow);
495 $ret[$myrow[
'bid']] = $block;
511 $blocks = $this->getObjects(
$criteria,
true);
513 foreach (array_keys($blocks) as
$i) {
514 $name = (!$blocks[
$i]->isCustom()) ? $blocks[$i]->getVar(
'name') : $blocks[
$i]->getVar(
'title');
540 $qb = $this->db2->createXoopsQueryBuilder();
545 $qb ->select(
'b.bid');
547 $qb ->fromPrefix(
'newblocks',
'b')
548 ->leftJoinPrefix(
'b',
'group_permission',
'l', $eb->eq(
'b.bid',
'l.gperm_itemid'))
549 ->where($eb->eq(
'gperm_name', $eb->literal(
'block_read')))
550 ->andWhere($eb->eq(
'gperm_modid', 1));
552 if (is_array($groupid)) {
553 if (count($groupid) > 1) {
555 foreach ($groupid as $gid) {
556 $in[] = $qb->createNamedParameter($gid, \PDO::PARAM_INT);
558 $qb->andWhere($eb->in(
'l.gperm_groupid', $in));
561 $qb->andWhere($eb->eq(
'l.gperm_groupid', $qb->createNamedParameter($groupid, \PDO::PARAM_INT)));
563 $qb->andWhere($eb->eq(
'b.isactive', $qb->createNamedParameter($isactive, \PDO::PARAM_INT)));
567 $qb->andWhere($eb->in(
'b.side', array(0,1)));
569 $qb->andWhere($eb->in(
'b.side', array(3,4,5,7,8,9)));
571 $qb->andWhere($eb->eq(
'b.side', $qb->createNamedParameter($side, \PDO::PARAM_INT)));
575 $qb->andWhere($eb->eq(
'b.visible', $qb->createNamedParameter(
$visible, \PDO::PARAM_INT)));
577 $qb->orderBy($orderby);
580 while ($myrow =
$result->fetch(\PDO::FETCH_ASSOC)) {
581 if (!in_array($myrow[
'bid'], $added)) {
583 $ret[] = $myrow[
'bid'];
587 array_push($added, $myrow[
'bid']);
601 public function getAllBlocks($rettype =
"object", $side = null,
$visible = null, $orderby =
"side,weight,bid", $isactive = 1)
604 $qb = $this->db2->createXoopsQueryBuilder();
607 $qb ->fromPrefix(
'newblocks', null)
608 ->where($eb->eq(
'isactive', $qb->createNamedParameter($isactive, \PDO::PARAM_INT)));
612 $qb->andWhere($eb->in(
'side', array(0,1)));
614 $qb->andWhere($eb->in(
'side', array(3,4,5,7,8,9)));
616 $qb->andWhere($eb->eq(
'side', $qb->createNamedParameter($side, \PDO::PARAM_INT)));
620 $qb->andWhere($eb->eq(
'visible', $qb->createNamedParameter(
$visible, \PDO::PARAM_INT)));
622 $qb->orderBy($orderby);
627 while ($myrow =
$result->fetch(\PDO::FETCH_ASSOC)) {
634 while ($myrow =
$result->fetch(\PDO::FETCH_ASSOC)) {
636 $title = $block->getVar(
"title");
637 $title = empty($title) ? $block->getVar(
"name") : $title;
638 $ret[$block->getVar(
"bid")] = $title;
644 while ($myrow =
$result->fetch(\PDO::FETCH_ASSOC)) {
645 $ret[] = $myrow[
'bid'];
660 $qb = $this->db2->createXoopsQueryBuilder();
663 $qb ->fromPrefix(
'newblocks', null)
664 ->where($eb->eq(
'mid', $qb->createNamedParameter($moduleid, \PDO::PARAM_INT)));
665 if ($asobject ==
true) {
673 while ($myrow =
$result->fetch(\PDO::FETCH_ASSOC)) {
677 $ret[] = $myrow[
'bid'];
697 $toponlyblock =
false,
699 $orderby =
'b.weight, m.block_id',
704 $qb = $this->db2->createXoopsQueryBuilder();
708 if (isset($groupid)) {
709 $qb ->select(
'DISTINCT gperm_itemid')
710 ->fromPrefix(
'group_permission', null)
711 ->where($eb->eq(
'gperm_name', $eb->literal(
'block_read')))
712 ->andWhere(
'gperm_modid=1');
714 if (is_array($groupid) AND !empty($groupid)) {
715 $qb->andWhere($eb->in(
'gperm_groupid', $groupid));
717 if (intval($groupid) > 0) {
718 $qb->andWhere($eb->eq(
'gperm_groupid', $groupid));
722 $blockids =
$result->fetchAll(\PDO::FETCH_COLUMN, 0);
725 $qb->resetQueryParts();
728 ->fromPrefix(
'newblocks',
'b')
729 ->where($eb->eq(
'b.isactive', $qb->createNamedParameter($isactive, \PDO::PARAM_INT)));
731 $qb->andWhere($eb->eq(
'b.visible', $qb->createNamedParameter(
$visible, \PDO::PARAM_INT)));
734 $qb ->fromPrefix(
'block_module_link',
'm')
735 ->andWhere($eb->eq(
'm.block_id',
'b.bid'));
751 $qb->andWhere($eb->in(
'm.module_id', $in));
753 $qb->andWhere($eb->eq(
'm.module_id', $in));
756 if (!empty($blockids)) {
757 $qb->andWhere($eb->in(
'b.bid', $blockids));
759 $qb->orderBy($orderby);
761 while ($myrow =
$result->fetch(\PDO::FETCH_ASSOC)) {
763 $ret[$myrow[
'bid']] = $block;
783 $qb = $this->db2->createXoopsQueryBuilder();
786 $qb ->select(
'DISTINCT(bid)')
787 ->fromPrefix(
'newblocks', null);
789 $bids =
$result->fetchAll(\PDO::FETCH_COLUMN, 0);
791 $qb->resetQueryParts();
793 $qb ->select(
'DISTINCT(p.gperm_itemid)')
794 ->fromPrefix(
'group_permission',
'p')
795 ->fromPrefix(
'groups',
'g')
796 ->where($eb->eq(
'g.groupid',
'p.gperm_groupid'))
797 ->andWhere($eb->eq(
'p.gperm_name', $eb->literal(
'block_read')));
799 $grouped =
$result->fetchAll(\PDO::FETCH_COLUMN, 0);
801 $non_grouped = array_diff($bids, $grouped);
803 if (!empty($non_grouped)) {
804 $qb->resetQueryParts();
807 ->fromPrefix(
'newblocks',
'b')
808 ->where($eb->eq(
'b.isactive', $qb->createNamedParameter($isactive, \PDO::PARAM_INT)));
810 $qb->andWhere($eb->eq(
'b.visible', $qb->createNamedParameter(
$visible, \PDO::PARAM_INT)));
813 $sql =
'SELECT b.* FROM ' . $this->db2->prefix(
'newblocks') .
' b, '
814 . $this->db2->prefix(
'block_module_link') .
' m';
815 $sql .=
' WHERE b.isactive=' . intval($isactive);
820 $qb ->fromPrefix(
'block_module_link',
'm')
821 ->andWhere($eb->eq(
'm.block_id',
'b.bid'));
837 $qb->andWhere($eb->in(
'm.module_id', $in));
839 $qb->andWhere($eb->eq(
'm.module_id', $in));
842 $qb->andWhere($eb->in(
'b.bid', $non_grouped));
843 $qb->orderBy($orderby);
845 while ($myrow =
$result->fetch(\PDO::FETCH_ASSOC)) {
847 $ret[$myrow[
'bid']] = $block;
864 $funcNum = intval($funcNum);
865 $moduleId = intval($moduleId);
866 if ($funcNum < 1 || $moduleId < 1) {
871 $qb = $this->db2->createXoopsQueryBuilder();
874 $qb ->select(
'COUNT(*)')
875 ->fromPrefix(
'newblocks', null)
876 ->where($eb->eq(
'mid', $qb->createNamedParameter($moduleId, \PDO::PARAM_INT)))
877 ->andWhere($eb->eq(
'func_num', $qb->createNamedParameter($funcNum, \PDO::PARAM_INT)));
879 if (isset($showFunc)) {
881 $qb->andWhere($eb->eq(
'show_func', $qb->createNamedParameter($showFunc, \PDO::PARAM_STR)));
883 if (!
$result = $qb->execute()) {
905 if ($position == 0) {
908 if ($position == 1) {
924 if ($newtitle !=
'') {
927 $ret = $originaltitle;
941 if (isset($groupid)) {
942 $qb = $this->db2->createXoopsQueryBuilder();
945 $qb ->select(
'DISTINCT(gperm_itemid)')
946 ->fromPrefix(
'group_permission',
'p')
947 ->fromPrefix(
'groups',
'g')
948 ->where($eb->eq(
'p.gperm_name', $eb->literal(
'block_read')))
949 ->andWhere(
'gperm_modid=1');
951 if (is_array($groupid)) {
952 $qb->andWhere($eb->in(
'gperm_groupid', $groupid));
954 if (intval($groupid) > 0) {
955 $qb->andWhere($eb->eq(
'gperm_groupid', $groupid));
960 $blockids =
$result->fetchAll(\PDO::FETCH_COLUMN, 0);
getByModule($moduleid, $asobject=true)
getNameList(CriteriaElement $criteria=null)
buildTitle($originaltitle, $newtitle= '')
getNonGroupedBlocks($module_id=0, $toponlyblock=false, $visible=null, $orderby= 'b.weight, m.block_id', $isactive=1)
getContent($format= 's', $c_type= 'T')
getAllByGroupModule($groupid, $module_id=0, $toponlyblock=false, $visible=null, $orderby= 'b.weight, m.block_id', $isactive=1)
getAllBlocksByGroup($groupid, $asobject=true, $side=null, $visible=null, $orderby="b.weight,b.bid", $isactive=1)
countSimilarBlocks($moduleId, $funcNum, $showFunc=null)
__construct(Connection $db=null)
getVar($key, $format= 's')
buildContent($position, $content="", $contentdb="")
insertBlock(XoopsBlock &$obj, $force=false)
getDistinctObjects(CriteriaElement $criteria=null, $id_as_key=false)
last_modified($format= '')
deleteBlock(XoopsBlock &$obj)
const XOOPS_CENTERBLOCK_ALL
setVar($key, $value, $not_gpc=false)
initVar($key, $data_type, $value=null, $required=false, $maxlength=null, $options= '')
getAllBlocks($rettype="object", $side=null, $visible=null, $orderby="side,weight,bid", $isactive=1)
const XOOPS_SIDEBLOCK_BOTH