19 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
62 $this->assignVars($id);
65 $obj =& $blkhandler->get($id);
66 foreach(array_keys($obj->getVars()) as
$i) {
67 $this->assignVar($i, $obj->getVar($i,
'n'));
77 function id($format =
'n')
79 return $this->getVar(
'bid', $format);
85 function bid($format =
'')
87 return $this->getVar(
'bid', $format);
93 function mid($format =
'')
95 return $this->getVar(
'mid', $format);
101 function func_num($format =
'')
103 return $this->getVar(
'func_num', $format);
109 function options($format =
'')
111 return $this->getVar(
'options', $format);
117 function name($format =
'')
119 return $this->getVar(
'name', $format);
126 return $this->getVar(
'title', $format);
132 function content($format =
'')
134 return $this->getVar(
'content', $format);
140 function side($format =
'')
142 return $this->getVar(
'side', $format);
148 function weight($format =
'')
150 return $this->getVar(
'weight', $format);
156 function visible($format =
'')
158 return $this->getVar(
'visible', $format);
164 function block_type($format =
'')
166 return $this->getVar(
'block_type', $format);
172 function c_type($format =
'')
174 return $this->getVar(
'c_type', $format);
180 function isactive($format =
'')
182 return $this->getVar(
'isactive', $format);
188 function dirname($format =
'')
190 return $this->getVar(
'dirname', $format);
196 function func_file($format =
'')
198 return $this->getVar(
'func_file', $format);
204 function show_func($format =
'')
206 return $this->getVar(
'show_func', $format);
212 function edit_func($format =
'')
214 return $this->getVar(
'edit_func', $format);
220 function template($format =
'')
222 return $this->getVar(
'template', $format);
228 function bcachetime($format =
'')
230 return $this->getVar(
'bcachetime', $format);
236 function last_modified($format =
'')
238 return $this->getVar(
'last_modified', $format);
253 function getContent($format =
's', $c_type =
'T')
255 $format = strtolower($format);
256 $c_type = strtoupper($c_type);
259 if ($c_type ==
'H') {
260 return str_replace(
'{X_SITEURL}', XOOPS_URL .
'/', $this->getVar(
'content',
'n'));
261 }
else if ($c_type ==
'P') {
263 echo eval($this->getVar(
'content',
'n'));
266 return str_replace(
'{X_SITEURL}', XOOPS_URL .
'/',
$content);
267 }
else if ($c_type ==
'S') {
269 $content = str_replace(
'{X_SITEURL}', XOOPS_URL .
'/', $this->getVar(
'content',
'n'));
273 $content = str_replace(
'{X_SITEURL}', XOOPS_URL .
'/', $this->getVar(
'content',
'n'));
278 return $this->getVar(
'content',
'e');
281 return $this->getVar(
'content',
'n');
291 function getOptions()
293 if (!$this->isCustom()) {
294 $edit_func = $this->getVar(
'edit_func');
298 if (file_exists(XOOPS_ROOT_PATH .
'/modules/' . $this->getVar(
'dirname') .
'/blocks/' . $this->getVar(
'func_file'))) {
299 if (file_exists(XOOPS_ROOT_PATH .
'/modules/' . $this->getVar(
'dirname') .
'/language/' .
$GLOBALS[
'xoopsConfig'][
'language'] .
'/blocks.php')) {
300 include_once XOOPS_ROOT_PATH .
'/modules/' . $this->getVar(
'dirname') .
'/language/' .
$GLOBALS[
'xoopsConfig'][
'language'] .
'/blocks.php';
301 }
else if (file_exists(XOOPS_ROOT_PATH .
'/modules/' . $this->getVar(
'dirname') .
'/language/english/blocks.php')) {
302 include_once XOOPS_ROOT_PATH .
'/modules/' . $this->getVar(
'dirname') .
'/language/english/blocks.php';
304 include_once XOOPS_ROOT_PATH .
'/modules/' . $this->getVar(
'dirname') .
'/blocks/' . $this->getVar(
'func_file');
305 $options = explode(
'|', $this->getVar(
'options'));
321 return in_array($this->getVar(
"block_type"), array(
347 function &create($isNew =
true)
368 $sql =
'SELECT * FROM ' . $this->db->prefix(
'newblocks') .
' WHERE bid=' . $id;
370 $numrows = $this->db->getRowsNum(
$result);
373 $block->assignVars($this->db->fetchArray(
$result));
386 function insert(&$block)
391 if (!is_a($block,
'xoopsblock')) {
394 if (!$block->isDirty()) {
397 if (!$block->cleanVars()) {
400 foreach ($block->cleanVars as $k => $v) {
403 if ($block->isNew()) {
404 $bid = $this->db->genId(
'newblocks_bid_seq');
405 $sql = sprintf(
"INSERT INTO %s (bid, mid, func_num, options, name, title, content, side, weight, visible, block_type, c_type, isactive, dirname, func_file, show_func, edit_func, template, bcachetime, last_modified) VALUES (%u, %u, %u, '%s', '%s', '%s', '%s', %u, %u, %u, '%s', '%s', %u, '%s', '%s', '%s', '%s', '%s', %u, %u)", $this->db->prefix(
'newblocks'), $bid,
$mid, $func_num,
$options, $name,
$title,
$content, $side, $weight, $visible, $block_type, $c_type, 1,
$dirname, $func_file, $show_func, $edit_func, $template, $bcachetime, time());
407 $sql = sprintf(
"UPDATE %s SET func_num = %u, options = '%s', name = '%s', title = '%s', content = '%s', side = %u, weight = %u, visible = %u, c_type = '%s', isactive = %u, func_file = '%s', show_func = '%s', edit_func = '%s', template = '%s', bcachetime = %u, last_modified = %u WHERE bid = %u", $this->db->prefix(
'newblocks'), $func_num,
$options, $name,
$title,
$content, $side, $weight, $visible, $c_type, $isactive, $func_file, $show_func, $edit_func, $template, $bcachetime, time(), $bid);
413 $bid = $this->db->getInsertId();
415 $block->assignVar(
'bid', $bid);
425 function delete(&$block)
430 if (!is_a($block,
'xoopsblock')) {
433 $id = $block->getVar(
'bid');
434 $sql = sprintf(
"DELETE FROM %s WHERE bid = %u", $this->db->prefix(
'newblocks'), $id);
438 $sql = sprintf(
"DELETE FROM %s WHERE block_id = %u", $this->db->prefix(
'block_module_link'), $id);
439 $this->db->query(
$sql);
449 function getObjects(
$criteria = null, $id_as_key =
false)
453 $sql =
'SELECT DISTINCT(b.bid), b.* FROM ' . $this->db->prefix(
'newblocks') .
' b LEFT JOIN ' . $this->db->prefix(
'block_module_link') .
' l ON b.bid=l.block_id';
463 while ($myrow = $this->db->fetchArray(
$result)) {
465 $block->assignVars($myrow);
469 $ret[$myrow[
'bid']] = & $block;
484 $blocks = $this->getObjects(
$criteria,
true);
486 foreach(array_keys($blocks) as
$i) {
487 $name = (!$blocks[
$i]->isCustom()) ? $blocks[$i]->getVar(
'name') : $blocks[
$i]->getVar(
'title');
493 ##################### Deprecated Methods ######################
498 function getByModule($moduleid, $asobject =
true, $id_as_key =
false)
500 trigger_error(__CLASS__ .
"::" . __FUNCTION__ .
' is deprecated', E_USER_WARNING);
504 function getAllByGroupModule($groupid,
$module_id = 0, $toponlyblock =
false, $visible = null, $orderby =
'i.weight,i.instanceid', $isactive = 1)
506 trigger_error(__CLASS__ .
"::" . __FUNCTION__ .
' is deprecated', E_USER_WARNING);
510 function getAdminBlocks($groupid, $orderby=
'i.weight,i.instanceid')
512 trigger_error(__CLASS__ .
"::" . __FUNCTION__ .
' is deprecated', E_USER_WARNING);
516 function assignBlocks()
518 trigger_error(__CLASS__ .
"::" . __FUNCTION__ .
' is deprecated', E_USER_WARNING);