Beispiel #1
0
/**
 * Renders and displays a single Zikula block by blockinfo array or block id.
 *
 * Available attributes:
 *  - module    (string)    The internal name of the module that defines the block.
 *  - blockname (string)    The internal name of the block.
 *  - block     (int|array) Either the integer block id (bid) of the block, or
 *                          an array containing the blockinfo for the block.
 *  - position  (string)    The position of the block.
 *  - assign    (string)    If set, the results are assigned to the corresponding
 *                          template variable instead of being returned to the template (optional)
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the {@link Zikula_View} object.
 *
 * @return string The rendered output of the specified block.
 */
function smarty_function_blockshow($params, Zikula_View $view)
{
    $module = isset($params['module']) ? $params['module'] : null;
    $blockname = isset($params['blockname']) ? $params['blockname'] : null;
    $block = isset($params['block']) ? $params['block'] : null;
    $position = isset($params['position']) ? $params['position'] : null;
    $assign = isset($params['assign']) ? $params['assign'] : null;
    if (!$module) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('blockshow', 'module')));
        return;
    }
    if (!$blockname) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('blockshow', 'blockname')));
        return;
    }
    if (!$block) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('blockshow', 'id/info')));
        return;
    }
    if (!$position) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('blockshow', 'position')));
        return;
    }
    if (!is_array($block)) {
        $block = BlockUtil::getBlockInfo($block);
    }
    $block['position'] = $position;
    $output = BlockUtil::show($module, $blockname, $block);
    if ($assign) {
        $view->assign($assign, $output);
    } else {
        return $output;
    }
}
Beispiel #2
0
 public function showBlock($block, $blockname, $module)
 {
     if (!is_array($block)) {
         $block = \BlockUtil::getBlockInfo($block);
     }
     return \BlockUtil::show($module, $blockname, $block);
 }
Beispiel #3
0
 function display()
 {
     $id = $this->blockid;
     $blockinfo = BlockUtil::getBlockInfo($id);
     $modinfo = ModUtil::getInfo($blockinfo['mid']);
     $text = BlockUtil::show($modinfo['name'], $blockinfo['bkey'], $blockinfo);
     $this->view->assign('content', $text);
     return $this->view->fetch($this->getTemplate());
 }
Beispiel #4
0
/**
 * Display an existing Zikula block.
 *
 *  The block is choosen by its id.
 *  The block state is ignored, so even deactivated blocks can be shown.
 *  The parameters specific to the block can be overridden.
 *
 * Available parameters:
 *  - id        (numeric)   ID of the block to be displayed
 *  - name      (string)    Name of the block to be displayed (not used)
 *  - title     (string)    Overrides the block title
 *  - position  (string)    Overrides the block position
 *  - assign    (string)    The name of a template variable to which the output
 *                          of the block is assigned, instead of sending the
 *                          output to the template (optional)
 * - Any additional parameters are passed to the block as block variables,
 *   overriding any existing values.
 *
 * Examples:
 *
 * Insert the block with block ID (bid) 4 at the current position in the template
 *
 * <samp>{block id=4}</samp>
 *
 * Insert the block with block ID (bid) 5 at the current position in the
 * template, overriding the block's title.
 *
 * <samp>{block id=5 title='My Block 5'}</samp>
 *
 * Store the output generated by retrieving the block with ID 6 in the template
 * variable $myBlockContents.
 *
 * <samp>{block id=6 assign='myBlockContents'}</samp>
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the {@link Zikula_View} object.
 *
 * @return string The block.
 *
 * @todo the attribute 'name' is not used.
 *
 */
function smarty_function_block($params, Zikula_View $view)
{
    $bid = isset($params['bid']) ? (int) $params['bid'] : 0;
    $name = isset($params['name']) ? $params['name'] : null;
    $title = isset($params['title']) ? $params['title'] : null;
    $position = isset($params['position']) ? $params['position'] : null;
    $assign = isset($params['assign']) ? $params['assign'] : null;
    // unset the variables for the function, leaving the ones for the block
    unset($params['bid']);
    unset($params['name']);
    unset($params['title']);
    unset($params['position']);
    unset($params['assign']);
    if (!$bid) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('pnblock', 'bid')));
        return false;
    }
    //  render the block
    $blockinfo = BlockUtil::getBlockInfo($bid);
    // overwrite block title
    if ($title) {
        $blockinfo['title'] = $title;
    }
    if ($position) {
        $blockinfo['position'] = $position;
    }
    $blockinfo['bid'] = $bid;
    // bid is not return by BlockGetInfo.
    // Overwrite block specific config vars.
    // Only the new style is supported.
    if (count($params) > 0) {
        $_vars = BlockUtil::varsFromContent($blockinfo['content']);
        $_vars = array_merge($_vars, $params);
        $blockinfo['content'] = BlockUtil::varsToContent($_vars);
    }
    // We need the module name.
    $modinfo = ModUtil::getInfo($blockinfo['mid']);
    if (!is_array($modinfo) || !isset($modinfo['name'])) {
        $modinfo = array('name' => 'core');
    }
    // show the block and capture its contents
    $content = BlockUtil::show($modinfo['name'], $blockinfo['bkey'], $blockinfo);
    if ($assign) {
        $view->assign($assign, $content);
    } else {
        return $content;
    }
}
Beispiel #5
0
/**
 * show a block
 *
 * @deprecated
 * @see BlockUtil::show()
 *
 * @param string $modname module name
 * @param string $block name of the block
 * @param array $blockinfo information parameters
 * @return mixed blockinfo array or null
 */
function pnBlockShow($modname, $block, $blockinfo = array())
{
    LogUtil::log(__f('Warning! Function %1$s is deprecated. Please use %2$s instead.', array(__FUNCTION__, 'BlockUtil::show()')), E_USER_DEPRECATED);
    return BlockUtil::show($modname, $block, $blockinfo);
}