本文整理汇总了PHP中XoopsBlock::getVar方法的典型用法代码示例。如果您正苦于以下问题:PHP XoopsBlock::getVar方法的具体用法?PHP XoopsBlock::getVar怎么用?PHP XoopsBlock::getVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XoopsBlock
的用法示例。
在下文中一共展示了XoopsBlock::getVar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clone_block
function clone_block($bid)
{
global $xoopsConfig;
xoops_cp_header();
$myblock = new XoopsBlock($bid);
$db =& Database::getInstance();
$sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . intval($bid);
$result = $db->query($sql);
$modules = array();
while ($row = $db->fetchArray($result)) {
$modules[] = intval($row['module_id']);
}
$is_custom = $myblock->isCustom();
$groupperm_handler =& xoops_gethandler('groupperm');
$groups =& $groupperm_handler->getGroupIds("block_read", $bid);
$block = array('form_title' => _AM_CLONEBLOCK, 'name' => $myblock->getVar('name'), 'title' => $myblock->getVar('title'), 'side' => $myblock->getVar('side'), 'weight' => $myblock->getVar('weight'), 'visible' => $myblock->getVar('visible'), 'content' => $myblock->getVar('content', 'N'), 'modules' => $modules, 'is_custom' => $is_custom, 'ctype' => $myblock->getVar('c_type'), 'cachetime' => $myblock->getVar('bcachetime'), 'op' => 'clone_ok', 'bid' => $myblock->getVar('bid'), 'edit_form' => $myblock->getOptions(), 'template' => $myblock->getVar('template'), 'options' => $myblock->getVar('options'), 'groups' => $groups);
echo '<a href="admin.php?fct=blocksadmin">' . _AM_BADMIN . '</a> <span style="font-weight:bold;">»»</span> ' . _AM_CLONEBLOCK . '<br /><br />';
include XOOPS_ROOT_PATH . '/modules/system/admin/blocksadmin/blockform.php';
$form->display();
xoops_cp_footer();
exit;
}
示例2: myblocksadmin_update_block
function myblocksadmin_update_block($bid, $bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bcachetime, $bmodule, $options = array())
{
global $xoopsConfig;
if (empty($bmodule)) {
xoops_cp_header();
xoops_error(sprintf(_AM_NOTSELNG, _AM_VISIBLEIN));
xoops_cp_footer();
exit;
}
$myblock = new XoopsBlock($bid);
// $myblock->setVar('side', $bside); GIJ -
if ($bside >= 0) {
$myblock->setVar('side', $bside);
}
// GIJ +
$myblock->setVar('weight', $bweight);
$myblock->setVar('visible', $bvisible);
$myblock->setVar('title', $btitle);
$myblock->setVar('content', $bcontent);
$myblock->setVar('bcachetime', $bcachetime);
if (isset($options) && count($options) > 0) {
$options = implode('|', $options);
$myblock->setVar('options', $options);
}
if ($myblock->getVar('block_type') == 'C') {
switch ($bctype) {
case 'H':
$name = _AM_CUSTOMHTML;
break;
case 'P':
$name = _AM_CUSTOMPHP;
break;
case 'S':
$name = _AM_CUSTOMSMILE;
break;
default:
$name = _AM_CUSTOMNOSMILE;
break;
}
$myblock->setVar('name', $name);
$myblock->setVar('c_type', $bctype);
} else {
$myblock->setVar('c_type', 'H');
}
$msg = _AM_DBUPDATED;
if ($myblock->store() != false) {
$db =& Database::getInstance();
$sql = sprintf("DELETE FROM %s WHERE block_id = %u", $db->prefix('block_module_link'), $bid);
$db->query($sql);
foreach ($bmodule as $bmid) {
$sql = sprintf("INSERT INTO %s (block_id, module_id) VALUES (%u, %d)", $db->prefix('block_module_link'), $bid, intval($bmid));
$db->query($sql);
}
include_once XOOPS_ROOT_PATH . '/class/template.php';
$xoopsTpl = new XoopsTpl();
$xoopsTpl->xoops_setCaching(2);
if ($myblock->getVar('template') != '') {
if ($xoopsTpl->is_cached('db:' . $myblock->getVar('template'))) {
if (!$xoopsTpl->clear_cache('db:' . $myblock->getVar('template'))) {
$msg = 'Unable to clear cache for block ID' . $bid;
}
}
} else {
if ($xoopsTpl->is_cached('db:system_dummy.html', 'block' . $bid)) {
if (!$xoopsTpl->clear_cache('db:system_dummy.html', 'block' . $bid)) {
$msg = 'Unable to clear cache for block ID' . $bid;
}
}
}
} else {
$msg = 'Failed update of block. ID:' . $bid;
}
// redirect_header('admin.php?fct=blocksadmin&t='.time(),1,$msg);
// exit(); GIJ -
return $msg;
// GIJ +
}
示例3: previewContent
function previewContent($block_data)
{
$bid = intval($block_data['bid']);
if (!$block_data['is_custom']) {
return '';
}
if (empty($this->preview_request)) {
return '';
}
//HACK by domifara
//TODO : need no hook block at this
$block = new XoopsBlock($bid);
if ($block->getVar('mid')) {
return '';
}
$block->setVar('title', $block_data['title']);
$block->setVar('content', $block_data['content']);
restore_error_handler();
$original_level = error_reporting(E_ALL);
// $ret = $block->getContent( 'S' , $block_data['ctype'] ) ;
$c_type = $block_data['ctype'];
if ($c_type == 'H') {
$ret = str_replace('{X_SITEURL}', XOOPS_URL . '/', $block->getVar('content', 'N'));
} else {
if ($c_type == 'P') {
ob_start();
echo eval($block->getVar('content', 'N'));
$content = ob_get_contents();
ob_end_clean();
$ret = str_replace('{X_SITEURL}', XOOPS_URL . '/', $content);
} else {
if ($c_type == 'S') {
$myts =& MyTextSanitizer::getInstance();
$content = str_replace('{X_SITEURL}', XOOPS_URL . '/', $block->getVar('content', 'N'));
$ret = $myts->displayTarea($content, 1, 1);
} else {
$myts =& MyTextSanitizer::getInstance();
$content = str_replace('{X_SITEURL}', XOOPS_URL . '/', $block->getVar('content', 'N'));
$ret = $myts->displayTarea($content, 1, 0);
}
}
}
error_reporting($original_level);
return $ret;
}
示例4: list
function plugin_xoopsblock_convert()
{
if ($this->root->module['platform'] !== "xoops") {
return '';
}
static $css_show = FALSE;
list($tgt, $option1, $option2) = array_pad(func_get_args(), 3, "");
$tgt_bids = array();
if (!$tgt || $tgt === "?") {
$tgt = "?";
} else {
foreach (explode(",", $tgt) as $_bid) {
if (preg_match("/^\\d+\$/", $_bid) && $_bid > 0) {
$tgt_bids[] = $_bid;
}
}
}
$align = "left";
$around = false;
$width = "";
$arg = array();
if (preg_match("/^(left|center|right)\$/i", $option2, $arg)) {
$align = $arg[1];
}
if (preg_match("/^(left|center|right)\$/i", $option1, $arg)) {
$align = $arg[1];
}
if (preg_match("/^(around|float|width)(:?w?([\\d]+%?)(?:px)?)?\$/i", $option2, $arg)) {
if ($arg[1]) {
$around = true;
}
$width = !strstr($arg[3], "%") ? $arg[3] . "px" : $arg[3];
$width = "width:" . $width . ";";
}
if (preg_match("/^(around|float|width)(:?w?([\\d]+%?)(?:px)?)?\$/i", $option1, $arg)) {
if ($arg[1]) {
$around = true;
}
$width = !strstr($arg[3], "%") ? $arg[3] . "px" : $arg[3];
$width = "width:" . $width . ";";
}
if ($align === 'center') {
if (!$width) {
$width = 'width:auto;';
}
$style = ' style="margin-left:auto;margin-right:auto;' . $width . '"';
$around = false;
} else {
$style = ' style="float:' . $align . ';' . $width . '"';
}
$clear = $around ? '' : '<div style="clear:both;"></div>';
global $xoopsUser;
$xoopsblock = new XoopsBlock();
$xoopsgroup = new XoopsGroup();
$arr = array();
$side = null;
if ($this->root->userinfo['admin']) {
$arr = $xoopsblock->getAllBlocks();
} else {
if ($xoopsUser) {
$arr = $xoopsblock->getAllBlocksByGroup($xoopsUser->groups());
} else {
$arr = $xoopsblock->getAllBlocksByGroup($this->plugin_xoopsblock_getByType("Anonymous"));
}
}
$ret = "";
if ($tgt == "?") {
foreach ($arr as $myblock) {
$block = array();
$block_type = @$myblock->getVar("type") ? $myblock->getVar("type") : $myblock->getVar("block_type");
$name = @$myblock->getVar("title") ? $myblock->getVar("title") : $myblock->getVar("name");
$bid = $myblock->getVar('bid');
$ret .= "<li>(" . $bid . ")" . $name . "</li>";
}
} else {
global $xoopsTpl;
require_once XOOPS_ROOT_PATH . '/class/template.php';
$xoopsTpl = new XoopsTpl();
if (is_object($xoopsUser)) {
$xoopsTpl->assign(array('xoops_isuser' => true, 'xoops_userid' => $xoopsUser->getVar('uid'), 'xoops_uname' => $xoopsUser->getVar('uname'), 'xoops_isadmin' => $xoopsUser->isAdmin()));
}
$xoopsTpl->assign('xoops_requesturi', htmlspecialchars($GLOBALS['xoopsRequestUri'], ENT_QUOTES));
foreach ($tgt_bids as $bid) {
$myblock = new XoopsBlock($bid);
$_bid = $myblock->getVar('bid');
if (!empty($_bid)) {
$bcachetime = $myblock->getVar('bcachetime');
// Only a guest enable cache. by nao-pon
//if (empty($bcachetime)) {
if ($bcachetime % 10 == 1) {
$bcachetime_guest = TRUE;
$bcachetime = $bcachetime - 1;
} else {
$bcachetime_guest = FALSE;
}
if (empty($bcachetime) || is_object($xoopsUser) && $bcachetime_guest) {
//if (empty($bcachetime)) {
$xoopsTpl->xoops_setCaching(0);
} else {
$xoopsTpl->xoops_setCaching(2);
//.........这里部分代码省略.........
示例5: getEntryIndex
function getEntryIndex()
{
return $this->_mBlock->getVar('side');
}
示例6: buildBlock
/**
* XoopsThemeBlocksPlugin::buildBlock()
*
* @param XoopsBlock $xobject
* @param XoopsTpl $template
* @return array|bool
*/
public function buildBlock($xobject, &$template)
{
$xoops = Xoops::getInstance();
// The lame type workaround will change
// bid is added temporarily as workaround for specific block manipulation
$dirname = $xobject->getVar('dirname');
$block = array('id' => $xobject->getVar('bid'), 'module' => $dirname, 'title' => $xobject->getVar('title'), 'weight' => $xobject->getVar('weight'), 'lastmod' => $xobject->getVar('last_modified'));
$bcachetime = (int) $xobject->getVar('bcachetime');
if (empty($bcachetime)) {
$template->caching = 0;
} else {
$template->caching = 2;
$template->cache_lifetime = $bcachetime;
}
$template->setCompileId($dirname);
$tplName = ($tplName = $xobject->getVar('template')) ? "block:{$dirname}/{$tplName}" : "module:system/system_block_dummy.tpl";
//$tplName = str_replace('.html', '.tpl', $tplName);
$cacheid = $this->generateCacheId('blk_' . $xobject->getVar('bid'));
$xoops->preload()->triggerEvent('core.themeblocks.buildblock.start', array($xobject, $template->isCached($tplName, $cacheid)));
if (!$bcachetime || !$template->isCached($tplName, $cacheid)) {
//Get theme metas
$old = array();
if ($this->theme && $bcachetime) {
foreach ($this->theme->metas as $type => $value) {
$old[$type] = $this->theme->metas[$type];
}
}
//build block
if ($bresult = $xobject->buildBlock()) {
$template->assign('block', $bresult);
$block['content'] = $template->fetch($tplName, $cacheid);
} else {
$block = false;
}
//check if theme added new metas
if ($this->theme && $bcachetime) {
$metas = array();
foreach ($this->theme->metas as $type => $value) {
$dif = Xoops_Utils::arrayRecursiveDiff($this->theme->metas[$type], $old[$type]);
if (count($dif)) {
$metas[$type] = $dif;
}
}
if (count($metas)) {
Xoops_Cache::write($cacheid, $metas);
}
}
} else {
$block['content'] = $template->fetch($tplName, $cacheid);
}
//add block cached metas
if ($this->theme && $bcachetime) {
if ($metas = Xoops_Cache::read($cacheid)) {
foreach ($metas as $type => $value) {
$this->theme->metas[$type] = array_merge($this->theme->metas[$type], $metas[$type]);
}
}
}
$template->setCompileId();
return $block;
}
示例7: XoopsBlock
} else {
if ($op == 'save') {
$block['form_title'] = _AM_ADDBLOCK;
} else {
$block['form_title'] = _AM_CLONEBLOCK;
}
$myblock = new XoopsBlock();
$myblock->setVar('block_type', 'C');
}
$myts =& MyTextSanitizer::getInstance();
$myblock->setVar('title', $myts->stripSlashesGPC($btitle));
$myblock->setVar('content', $myts->stripSlashesGPC($bcontent));
$dummyhtml = '<html><head><meta http-equiv="content-type" content="text/html; charset=' . _CHARSET . '" />';
$dummyhtml .= '<meta http-equiv="content-language" content="' . _LANGCODE . '" /><title>' . $xoopsConfig['sitename'] . '</title>';
$dummyhtml .= '<link rel="stylesheet" type="text/css" media="all" href="' . xoops_getcss($xoopsConfig['theme_set']) . '" />';
$dummyhtml .= '</head><body><table><tr><th>' . $myblock->getVar('title') . '</th></tr><tr><td>';
$dummyhtml .= $myblock->getContent('S', $bctype) . '</td></tr></table></body></html>';
$block['groups'] = $bgroups;
$block['edit_form'] = false;
$block['template'] = '';
$block['op'] = $op;
$block['side'] = $bside;
$block['weight'] = $bweight;
$block['visible'] = $bvisible;
$block['title'] = $myblock->getVar('title', 'E');
$block['content'] = $myblock->getVar('content', 'E');
$block['modules'] =& $bmodule;
$block['ctype'] = isset($bctype) ? $bctype : $myblock->getVar('c_type');
$block['is_custom'] = true;
$block['cachetime'] = intval($bcachetime);
echo '<a href="admin.php?fct=blocksadmin">' . _AM_BADMIN . '</a> <span style="font-weight:bold;">»»</span> ' . $block['form_title'] . '<br /><br />';
示例8: XoopsBlock
$block['form_title'] = _AM_EDITBLOCK;
$myblock = new XoopsBlock($bid);
$block['name'] = $myblock->getVar('name');
} else {
if ($op == 'save') {
$block['form_title'] = _AM_ADDBLOCK;
} else {
$block['form_title'] = _AM_CLONEBLOCK;
}
$myblock = new XoopsBlock();
$myblock->setVar('block_type', 'C');
}
$myts =& MyTextSanitizer::getInstance();
$myblock->setVar('title', $myts->stripSlashesGPC($btitle));
$myblock->setVar('content', $myts->stripSlashesGPC($bcontent));
$dummyhtml = '<html><head><meta http-equiv="content-type" content="text/html; charset=' . _CHARSET . '" /><meta http-equiv="content-language" content="' . _LANGCODE . '" /><title>' . $xoopsConfig['sitename'] . '</title><link rel="stylesheet" type="text/css" media="all" href="' . xoops_getcss($xoopsConfig['theme_set']) . '" /></head><body><table><tr><th>' . $myblock->getVar('title') . '</th></tr><tr><td>' . $myblock->getContent('S', $bctype) . '</td></tr></table></body></html>';
$block['edit_form'] = false;
$block['template'] = '';
$block['op'] = $op;
$block['side'] = $bside;
$block['weight'] = $bweight;
$block['visible'] = $bvisible;
$block['title'] = $myblock->getVar('title', 'E');
$block['content'] = $myblock->getVar('content', 'E');
$block['modules'] =& $bmodule;
$block['ctype'] = isset($bctype) ? $bctype : $myblock->getVar('c_type');
$block['is_custom'] = true;
$block['cachetime'] = intval($bcachetime);
echo '<a href="admin.php?fct=blocksadmin">' . _AM_BADMIN . '</a> <span style="font-weight:bold;">»»</span> ' . $block['form_title'] . '<br /><br />';
include XOOPS_ROOT_PATH . '/modules/system/admin/blocksadmin/blockform.php';
$form->display();
示例9: previewContent
function previewContent($block_data)
{
$bid = intval($block_data['bid']);
if (!$block_data['is_custom']) {
return '';
}
if (empty($this->preview_request)) {
return '';
}
$block = new XoopsBlock($bid);
if ($block->getVar('mid')) {
return '';
}
$block->setVar('title', $block_data['title']);
$block->setVar('content', $block_data['content']);
restore_error_handler();
$original_level = error_reporting(E_ALL);
$ret = $block->getContent('S', $block_data['ctype']);
error_reporting($original_level);
return $ret;
}
示例10: getAllBlocks
/**
* @param string $rettype
* @param boolean $side
* @param null $visible
* @param string $orderby
* @param int $isactive
* @return array
*/
public function getAllBlocks($rettype = "object", $side = null, $visible = null, $orderby = "side,weight,bid", $isactive = 1)
{
$ret = array();
$qb = $this->db2->createXoopsQueryBuilder();
$eb = $qb->expr();
$qb->fromPrefix('newblocks', null)->where($eb->eq('isactive', $qb->createNamedParameter($isactive, \PDO::PARAM_INT)));
if (isset($side)) {
// get both sides in sidebox? (some themes need this)
if ($side == XOOPS_SIDEBLOCK_BOTH) {
$qb->andWhere($eb->in('side', array(0, 1)));
} elseif ($side == XOOPS_CENTERBLOCK_ALL) {
$qb->andWhere($eb->in('side', array(3, 4, 5, 7, 8, 9)));
} else {
$qb->andWhere($eb->eq('side', $qb->createNamedParameter($side, \PDO::PARAM_INT)));
}
}
if (isset($visible)) {
$qb->andWhere($eb->eq('visible', $qb->createNamedParameter($visible, \PDO::PARAM_INT)));
}
$qb->orderBy($orderby);
switch ($rettype) {
case "object":
$qb->select('*');
$result = $qb->execute();
while ($myrow = $result->fetch(\PDO::FETCH_ASSOC)) {
$ret[] = new XoopsBlock($myrow);
}
break;
case "list":
$qb->select('*');
$result = $qb->execute();
while ($myrow = $result->fetch(\PDO::FETCH_ASSOC)) {
$block = new XoopsBlock($myrow);
$title = $block->getVar("title");
$title = empty($title) ? $block->getVar("name") : $title;
$ret[$block->getVar("bid")] = $title;
}
break;
case "id":
$qb->select('bid');
$result = $qb->execute();
while ($myrow = $result->fetch(\PDO::FETCH_ASSOC)) {
$ret[] = $myrow['bid'];
}
break;
}
return $ret;
}
示例11: getAllBlocks
/**
* XoopsBlock::getAllBlocks()
*
* @param string $rettype
* @param mixed $side
* @param mixed $visible
* @param string $orderby
* @param integer $isactive
* @return array
*/
public function getAllBlocks($rettype = 'object', $side = null, $visible = null, $orderby = 'side,weight,bid', $isactive = 1)
{
$db = XoopsDatabaseFactory::getDatabaseConnection();
$ret = array();
$where_query = ' WHERE isactive=' . $isactive;
if (isset($side)) {
// get both sides in sidebox? (some themes need this)
if ($side == XOOPS_SIDEBLOCK_BOTH) {
$side = '(side=0 OR side=1)';
} elseif ($side == XOOPS_CENTERBLOCK_ALL) {
$side = '(side=3 OR side=4 OR side=5 OR side=7 OR side=8 OR side=9)';
} elseif ($side == XOOPS_FOOTERBLOCK_ALL) {
$side = '(side=10 OR side=11 OR side=12)';
} else {
$side = 'side=' . $side;
}
$where_query .= ' AND ' . $side;
}
if (isset($visible)) {
$where_query .= ' AND visible=.' . $visible;
}
$where_query .= ' ORDER BY ' . $orderby;
switch ($rettype) {
case 'object':
$sql = 'SELECT * FROM ' . $db->prefix('newblocks') . '' . $where_query;
$result = $db->query($sql);
while ($myrow = $db->fetchArray($result)) {
$ret[] = new XoopsBlock($myrow);
}
break;
case 'list':
$sql = 'SELECT * FROM ' . $db->prefix('newblocks') . '' . $where_query;
$result = $db->query($sql);
while ($myrow = $db->fetchArray($result)) {
$block = new XoopsBlock($myrow);
$title = $block->getVar('title');
$title = empty($title) ? $block->getVar('name') : $title;
$ret[$block->getVar('bid')] = $title;
}
break;
case 'id':
$sql = 'SELECT bid FROM ' . $db->prefix('newblocks') . '' . $where_query;
$result = $db->query($sql);
while ($myrow = $db->fetchArray($result)) {
$ret[] = $myrow['bid'];
}
break;
}
//echo $sql;
return $ret;
}
示例12: count
$myblock->setVar('visible', $_POST['bvisible']);
$myblock->setVar('title', $_POST['btitle']);
$myblock->setVar('content', $bcontent);
$myblock->setVar('bcachetime', $bcachetime);
$options_count = count($options);
if ($options_count > 0) {
//Convert array values to comma-separated
for ($i = 0; $i < $options_count; $i++) {
if (is_array($options[$i])) {
$options[$i] = implode(',', $options[$i]);
}
}
$options = implode('|', $options);
$myblock->setVar('options', $options);
}
if ($myblock->getVar('block_type') == 'C') {
switch ($bctype) {
case 'H':
$name = _AM_CUSTOMHTML;
break;
case 'P':
$name = _AM_CUSTOMPHP;
break;
case 'S':
$name = _AM_CUSTOMSMILE;
break;
default:
$name = _AM_CUSTOMNOSMILE;
break;
}
$myblock->setVar('name', $name);
示例13: previewContent
function previewContent($block_data)
{
$bid = intval($block_data['bid']);
if (!$block_data['is_custom']) {
return '';
}
if (empty($this->preview_request)) {
return '';
}
//HACK by domifara
//TODO : need no hook block at this
$block = new XoopsBlock($bid);
/*
$handler =& xoops_gethandler('block');
$block =& $handler->create(false) ;
$block->load($bid) ;
*/
if ($block->getVar('mid')) {
return '';
}
$block->setVar('title', $block_data['title']);
$block->setVar('content', $block_data['content']);
restore_error_handler();
$original_level = error_reporting(E_ALL);
$ret = $block->getContent('S', $block_data['ctype']);
error_reporting($original_level);
return $ret;
}
示例14: XoopsBlock
function clone_block_ok($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options)
{
global $xoopsUser;
$block = new XoopsBlock($bid);
$clone =& $block->xoopsClone();
if (empty($bmodule)) {
xoops_cp_header();
xoops_error(sprintf(_AM_NOTSELNG, _AM_VISIBLEIN));
xoops_cp_footer();
exit;
}
$clone->setVar('side', $bside);
$clone->setVar('weight', $bweight);
$clone->setVar('visible', $bvisible);
$clone->setVar('content', $bcontent);
//$clone->setVar('title', $btitle);
$clone->setVar('bcachetime', $bcachetime);
if (isset($options) && count($options) > 0) {
$options = implode('|', $options);
$clone->setVar('options', $options);
}
$clone->setVar('bid', 0);
if ($block->getVar('block_type') == 'C' || $block->getVar('block_type') == 'E') {
$clone->setVar('block_type', 'E');
} else {
$clone->setVar('block_type', 'D');
}
$newid = $clone->store();
if (!$newid) {
xoops_cp_header();
$clone->getHtmlErrors();
xoops_cp_footer();
exit;
}
if ($clone->getVar('template') != '') {
$tplfile_handler =& xoops_gethandler('tplfile');
$btemplate =& $tplfile_handler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $bid);
if (count($btemplate) > 0) {
$tplclone =& $btemplate[0]->xoopsClone();
$tplclone->setVar('tpl_id', 0);
$tplclone->setVar('tpl_refid', $newid);
$tplman->insert($tplclone);
}
}
$db =& Database::getInstance();
foreach ($bmodule as $bmid) {
$sql = 'INSERT INTO ' . $db->prefix('block_module_link') . ' (block_id, module_id) VALUES (' . $newid . ', ' . $bmid . ')';
$db->query($sql);
}
$groups =& $xoopsUser->getGroups();
$count = count($groups);
for ($i = 0; $i < $count; $i++) {
$sql = "INSERT INTO " . $db->prefix('group_permission') . " (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (" . $groups[$i] . ", " . $newid . ", 1, 'block_read')";
$db->query($sql);
}
redirect_header('admin.php?fct=blocksadmin&t=' . time(), 1, _AM_DBUPDATED);
}
示例15: getForm
/**
* getForm - get block edit form
*
* @param string $mode mode for form, edit or clone
*
* @return void
*/
public function getForm($mode = 'edit')
{
$xoops = Xoops::getInstance();
$xoops->loadLanguage('blocks', 'system');
if ($this->obj->isNew()) {
$title = SystemLocale::ADD_BLOCK;
$modules = array(-1);
$groups = array(FixedGroups::USERS, FixedGroups::ANONYMOUS, FixedGroups::ADMIN);
$this->obj->setVar('block_type', 'C');
$this->obj->setVar('visible', 1);
$op = 'save';
} else {
$title = '';
$modules = array();
// Search modules
$blockmodulelink_handler = $xoops->getHandlerBlockmodulelink();
$criteria = new CriteriaCompo(new Criteria('block_id', $this->obj->getVar('bid')));
$blockmodulelink = $blockmodulelink_handler->getObjects($criteria);
/* @var $link XoopsBlockmodulelink */
foreach ($blockmodulelink as $link) {
$modules[] = $link->getVar('module_id');
}
// Search perms
$groupperm_handler = $xoops->getHandlerGroupperm();
$groups = $groupperm_handler->getGroupIds('block_read', $this->obj->getVar('bid'));
switch ($mode) {
case 'edit':
$title = SystemLocale::EDIT_BLOCK;
break;
case 'clone':
$title = SystemLocale::CLONE_BLOCK;
$this->obj->setVar('bid', 0);
if ($this->obj->isCustom()) {
$this->obj->setVar('block_type', 'C');
} else {
$this->obj->setVar('block_type', 'D');
}
break;
}
$op = 'save';
}
parent::__construct($title, 'blockform', 'admin.php', 'post', true);
if (!$this->obj->isNew()) {
$this->addElement(new Xoops\Form\Label(XoopsLocale::NAME, $this->obj->getVar('name')));
}
// Side position
$side_select = new Xoops\Form\Select(XoopsLocale::SIDE, 'side', $this->obj->getVar('side'));
$side_select->addOptionArray(array(0 => XoopsLocale::LEFT, 1 => XoopsLocale::RIGHT, 3 => SystemLocale::TOP_LEFT, 4 => SystemLocale::TOP_RIGHT, 5 => SystemLocale::TOP_CENTER, 7 => SystemLocale::BOTTOM_LEFT, 8 => SystemLocale::BOTTOM_RIGHT, 9 => SystemLocale::BOTTOM_CENTER));
$this->addElement($side_select);
// Order
$weight = new Xoops\Form\Text(XoopsLocale::WEIGHT, 'weight', 1, 5, $this->obj->getVar('weight'), '');
$weight->setPattern('^\\d+$', XoopsLocale::E_YOU_NEED_A_POSITIVE_INTEGER);
$this->addElement($weight, true);
// Display
$this->addElement(new Xoops\Form\RadioYesNo(XoopsLocale::VISIBLE, 'visible', $this->obj->getVar('visible')));
// Visible In
$mod_select = new Xoops\Form\Select(XoopsLocale::VISIBLE_IN, 'modules', $modules, 5, true);
$criteria = new CriteriaCompo(new Criteria('hasmain', 1));
$criteria->add(new Criteria('isactive', 1));
$module_list = $xoops->getHandlerModule()->getNameList($criteria);
$module_list[-1] = XoopsLocale::TOP_PAGE;
$module_list[0] = XoopsLocale::ALL_PAGES;
ksort($module_list);
$mod_select->addOptionArray($module_list);
$this->addElement($mod_select);
// Title
$this->addElement(new Xoops\Form\Text(XoopsLocale::TITLE, 'title', 5, 255, $this->obj->getVar('title')), false);
if ($this->obj->isNew() || $this->obj->isCustom()) {
$editor_configs = array();
$editor_configs["name"] = "content_block";
$editor_configs["value"] = $this->obj->getVar('content', 'e');
$editor_configs["rows"] = 15;
$editor_configs["cols"] = 6;
$editor_configs["editor"] = $xoops->getModuleConfig('blocks_editor', 'system');
$this->addElement(new Xoops\Form\Editor(XoopsLocale::CONTENT, "content_block", $editor_configs), true);
if (in_array($editor_configs["editor"], array('dhtmltextarea', 'textarea'))) {
$ctype_select = new Xoops\Form\Select(SystemLocale::CONTENT_TYPE, 'c_type', $this->obj->getVar('c_type'));
$ctype_select->addOptionArray(array('H' => XoopsLocale::HTML, 'P' => SystemLocale::PHP_SCRIPT, 'S' => SystemLocale::AUTO_FORMAT_SMILIES_ENABLED, 'T' => SystemLocale::AUTO_FORMAT_SMILIES_DISABLED));
$this->addElement($ctype_select);
} else {
$this->addElement(new Xoops\Form\Hidden('c_type', 'H'));
}
} else {
if ($this->obj->getVar('template') != '') {
$tplfile_handler = $xoops->getHandlerTplfile();
$btemplate = $tplfile_handler->find($xoops->getConfig('template_set'), 'block', $this->obj->getVar('bid'));
if (count($btemplate) > 0) {
$this->addElement(new Xoops\Form\Label(XoopsLocale::CONTENT, '<a href="' . \XoopsBaseConfig::get('url') . '/modules/system/admin.php?fct=tplsets&op=edittpl&id=' . $btemplate[0]->getVar('tpl_id') . '">' . SystemLocale::EDIT_TEMPLATE . '</a>'));
} else {
$btemplate2 = $tplfile_handler->find('default', 'block', $this->obj->getVar('bid'));
if (count($btemplate2) > 0) {
$this->addElement(new Xoops\Form\Label(XoopsLocale::CONTENT, '<a href="' . \XoopsBaseConfig::get('url') . '/modules/system/admin.php?fct=tplsets&op=edittpl&id=' . $btemplate2[0]->getVar('tpl_id') . '" rel="external">' . SystemLocale::EDIT_TEMPLATE . '</a>'));
}
//.........这里部分代码省略.........