Zikula_Template_Plugins
[ class tree: Zikula_Template_Plugins ] [ index: Zikula_Template_Plugins ] [ all elements ]

Source for file function.pnblock.php

Documentation is available at function.pnblock.php

  1. <?php
  2. /**
  3.  * Zikula Application Framework
  4.  *
  5.  * @copyright (c) 2004, Zikula Development Team
  6.  * @link http://www.zikula.org
  7.  * @version $Id: function.pnblock.php 24342 2008-06-06 12:03:14Z markwest $
  8.  * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
  9.  * @package Zikula_Template_Plugins
  10.  * @subpackage Functions
  11.  */
  12.  
  13. /**
  14.  * Smarty function to display an existing Zikula block.
  15.  *
  16.  * The block is choosen by its id.
  17.  *
  18.  * The block state is ignored, so even deactivated blocks
  19.  * can be shown.
  20.  *
  21.  * The block specific parameters can be overwritten,
  22.  * considering they are known.
  23.  *
  24.  * Available parameters:
  25.  *   - id        id of block to be displayed
  26.  *   - name      title of block to be displayed
  27.  *   - title     Overwrites block title
  28.  *   - position  Overwrites position (l,c,r)
  29.  *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out
  30.  *
  31.  * Example
  32.  *   TBD
  33.  *
  34.  *
  35.  * @author   Andreas Stratmann
  36.  * @author   Jörg Napp
  37.  * @since    03/05/23
  38.  * @param    array    $params      All attributes passed to this function from the template
  39.  * @param    object   &$smarty     Reference to the Smarty object
  40.  * @return   string   the block
  41.  */
  42. function smarty_function_pnblock ($params&$smarty)
  43. {
  44.     $bid      = isset($params['bid'])      ? (int)$params['bid'0;
  45.     $name     = isset($params['name'])     $params['name']     null;
  46.     $title    = isset($params['title'])    $params['title']    null;
  47.     $position = isset($params['position']$params['position'null;
  48.     $assign   = isset($params['assign'])   $params['assign']   null;
  49.  
  50.     // unset the variables for the function, leaving the ones for the block
  51.     unset($params['bid']);
  52.     unset($params['name']);
  53.     unset($params['title']);
  54.     unset($params['position']);
  55.     unset($params['assign']);
  56.  
  57.     if (!$bid{
  58.         $smarty->trigger_error('pnblock: block id [bid] required');
  59.         return false;
  60.     }
  61.  
  62.     //  render the block
  63.     $blockinfo pnBlockGetInfo($bid);
  64.  
  65.     // overwrite block title
  66.     if ($title{
  67.         $blockinfo['title'$title;
  68.     }
  69.  
  70.     if ($position{
  71.         $blockinfo['position'$position;
  72.     }
  73.  
  74.     $blockinfo['bid'$bid// bid is not return by BlockGetInfo.
  75.  
  76.     // Overwrite block specific config vars.
  77.     // Only the new style is supported.
  78.     if (count($params0{
  79.         $_vars pnBlockVarsFromContent($blockinfo['content']);
  80.         $_vars array_merge($_vars$params);
  81.         $blockinfo['content'pnBlockVarsToContent($_vars);
  82.     }
  83.  
  84.     // We need the module name.
  85.     $modinfo pnModGetInfo($blockinfo['mid']);
  86.     if (!is_array($modinfo|| !isset($modinfo['name'])) {
  87.         $modinfo array('name' => 'core');
  88.     }
  89.  
  90.     // show the block and capture its contents
  91.     $content pnBlockShow($modinfo['name']$blockinfo['bkey']$blockinfo);
  92.  
  93.     if ($assign{
  94.         $smarty->assign($assign$content);
  95.     else {
  96.         return $content;
  97.     }
  98. }

Documentation generated on Fri, 18 Jul 2008 21:45:35 +0200 by phpDocumentor 1.4.1