当前位置: 首页>>代码示例>>PHP>>正文


PHP XoopsBlock::setVar方法代码示例

本文整理汇总了PHP中XoopsBlock::setVar方法的典型用法代码示例。如果您正苦于以下问题:PHP XoopsBlock::setVar方法的具体用法?PHP XoopsBlock::setVar怎么用?PHP XoopsBlock::setVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XoopsBlock的用法示例。


在下文中一共展示了XoopsBlock::setVar方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: XoopsBlock

 function order_block($bid, $weight, $visible, $side)
 {
     $myblock = new XoopsBlock($bid);
     $myblock->setVar('weight', $weight);
     $myblock->setVar('visible', $visible);
     $myblock->setVar('side', $side);
     $myblock->store();
 }
开发者ID:hiro1173,项目名称:legacy,代码行数:8,代码来源:blocksadmin.php

示例2: order_block

function order_block($bid, $weight, $visible, $side, $title, $bmodule, $bcachetime)
{
    $myblock = new XoopsBlock($bid);
    $myblock->setVar('title', $title);
    $myblock->setVar('weight', $weight);
    $myblock->setVar('visible', $visible);
    $myblock->setVar('side', $side);
    $myblock->setVar('bcachetime', $bcachetime);
    $myblock->store();
    $db =& Database::getInstance();
    $sql = sprintf("DELETE FROM %s WHERE block_id = %u", $db->prefix('block_module_link'), $bid);
    $db->queryF($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->queryF($sql);
    }
}
开发者ID:gauravsaxena21,项目名称:simantz,代码行数:17,代码来源:blocksadmin.php

示例3: 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 +
}
开发者ID:severnaya99,项目名称:Sg-2010,代码行数:77,代码来源:blocksadmin.inc.php

示例4: 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);
 }
开发者ID:RanLee,项目名称:XoopsCore,代码行数:32,代码来源:blockTest.php

示例5: 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;
 }
开发者ID:hiro1173,项目名称:legacy,代码行数:45,代码来源:MyBlocksAdminForX25.class.php

示例6: XoopsBlock

     exit;
 }
 xoops_cp_header();
 if (isset($bid)) {
     $block['bid'] = $bid;
     $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 . '" />';
 $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;
开发者ID:gauravsaxena21,项目名称:simantz,代码行数:31,代码来源:main.php

示例7: 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&amp;op=edittpl&amp;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&amp;op=edittpl&amp;id=' . $btemplate2[0]->getVar('tpl_id') . '" rel="external">' . SystemLocale::EDIT_TEMPLATE . '</a>'));
                 }
//.........这里部分代码省略.........
开发者ID:RanLee,项目名称:XoopsCore,代码行数:101,代码来源:block.php

示例8: insertBlock

 /**
  * @param XoopsBlock $obj
  * @param bool $force
  * @return mixed
  */
 public function insertBlock(XoopsBlock &$obj, $force = false)
 {
     $obj->setVar('last_modified', time());
     return parent::insert($obj, $force);
 }
开发者ID:RanLee,项目名称:XoopsCore,代码行数:10,代码来源:block.php

示例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;
 }
开发者ID:BackupTheBerlios,项目名称:peakxoops-svn,代码行数:21,代码来源:MyBlocksAdmin.class.php

示例10: intval

 $bid = !empty($_POST['bid']) ? intval($_POST['bid']) : 0;
 if ($bid <= 0) {
     exit;
 }
 $bcachetime = isset($_POST['bcachetime']) ? intval($_POST['bcachetime']) : 0;
 $options = isset($_POST['options']) ? $_POST['options'] : array();
 $bcontent = isset($_POST['bcontent']) ? $_POST['bcontent'] : '';
 $bctype = isset($_POST['bctype']) ? $_POST['bctype'] : '';
 if (empty($_POST['bmodule']) || !XoopsMultiTokenHandler::quickValidate('block')) {
     xoops_cp_header();
     xoops_error(sprintf(_AM_NOTSELNG, _AM_VISIBLEIN));
     xoops_cp_footer();
     exit;
 }
 $myblock = new XoopsBlock($bid);
 $myblock->setVar('side', $_POST['bside']);
 $myblock->setVar('weight', $_POST['bweight']);
 $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);
开发者ID:koki-h,项目名称:xoops_utf8,代码行数:31,代码来源:main.php

示例11: 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;
 }
开发者ID:hiro1173,项目名称:legacy,代码行数:28,代码来源:MyBlocksAdmin.class.php

示例12: setBlockPosition

 /**
  * set block position
  *
  * @access public
  * @param int $bid block id
  * @param bool $visible visible flag
  * @param int $side
  *        0: sideblock - left
  *        1: sideblock - right
  *        2: sideblock - left and right
  *        3: centerblock - left
  *        4: centerblock - right
  *        5: centerblock - center
  *        6: centerblock - left, right, center
  * @param int $weight weight
  * @return bool false if failure
  */
 function setBlockPosition($bid, $visible, $side, $weight)
 {
     $block = new XoopsBlock();
     $block->load($bid);
     if (!is_null($visible)) {
         $block->setVar('visible', $visible ? 1 : 0, true);
         // not gpc
     }
     if (!is_null($side)) {
         $block->setVar('side', $side, true);
         // not gpc
     }
     if (!is_null($weight)) {
         $block->setVar('weight', $weight, true);
         // not gpc
     }
     return $block->store();
 }
开发者ID:XoopsModules25x,项目名称:xcl-module-xoonips,代码行数:35,代码来源:xoonips_admin_xoops.class.php


注:本文中的XoopsBlock::setVar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。