本文整理汇总了PHP中XoopsBlock::isCustom方法的典型用法代码示例。如果您正苦于以下问题:PHP XoopsBlock::isCustom方法的具体用法?PHP XoopsBlock::isCustom怎么用?PHP XoopsBlock::isCustom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XoopsBlock
的用法示例。
在下文中一共展示了XoopsBlock::isCustom方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_buildBlock
public function test_buildBlock()
{
$instance = new XoopsBlock();
$value = $instance->buildBlock();
$this->assertSame(false, $value);
$instance->setVar('block_type', '');
$value = $instance->isCustom();
$this->assertFalse($value);
$value = $instance->buildBlock();
$this->assertSame(false, $value);
$instance->setVar('block_type', 'C');
$value = $instance->isCustom();
$this->assertTrue($value);
$instance->setVar('dirname', 'page');
$instance->setVar('func_file', 'page_blocks.php');
$instance->setVar('show_func', 'page_blocks_show');
$instance->setVar('options', 'a|b|c|d|e');
$value = $instance->buildBlock();
$this->assertSame(false, $value);
$instance->setVar('dirname', 'page');
$instance->setVar('func_file', 'page_blocks.php');
$instance->setVar('show_func', 'function_not_exists');
$instance->setVar('options', 'a|b|c|d|e');
$value = $instance->buildBlock();
$this->assertSame(false, $value);
$instance->setVar('dirname', 'page');
$instance->setVar('func_file', 'file_not_found.php');
$instance->setVar('show_func', 'page_blocks_show');
$instance->setVar('options', 'a|b|c|d|e');
$value = $instance->buildBlock();
$this->assertSame(false, $value);
}
示例2: clone_block_ok
function clone_block_ok($bid, $bside, $bweight, $bvisible, $btitle, $bcontent, $bcachetime, $bmodule, $options = array(), $bgroups = array())
{
global $xoopsUser;
/*
if (empty($bmodule)) {
xoops_cp_header();
xoops_error(sprintf(_AM_NOTSELNG, _AM_VISIBLEIN));
xoops_cp_footer();
exit();
}
*/
$block = new XoopsBlock($bid);
$clone =& $block->xoopsClone();
$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);
// Custom block
if ($block->isCustom()) {
$clone->setVar('block_type', 'C');
// Clone of system or module block
} 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);
$tplfile_handler->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);
}
$groupperm_handler =& xoops_gethandler('groupperm');
foreach ($bgroups as $groupid) {
$groupperm_handler->addRight("block_read", $newid, $groupid);
}
redirect_header('admin.php?fct=blocksadmin&t=' . time(), 1, _AM_DBUPDATED);
}
示例3: 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>'));
}
//.........这里部分代码省略.........