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

Source for file finclude.php

Documentation is available at finclude.php

  1. <?php
  2. /**
  3.  * Zikula Application Framework
  4.  * @copyright (c) 2001, Zikula Development Team
  5.  * @link http://www.zikula.org
  6.  * @version $Id: finclude.php 24342 2008-06-06 12:03:14Z markwest $
  7.  * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
  8.  * @package Zikula_System_Modules
  9.  * @subpackage Blocks
  10.  * @author Patric Kellum
  11.  */
  12.  
  13. /**
  14.  * initialise block
  15.  *
  16.  * @author       The Zikula Development Team
  17.  */
  18. {
  19.     // Security
  20.     pnSecAddSchema('fincludeblock::''Block title::');
  21. }
  22.  
  23. /**
  24.  * get information on block
  25.  *
  26.  * @author       The Zikula Development Team
  27.  * @return       array       The block information
  28.  */
  29. {
  30.     return array('text_type'       => 'Include',
  31.                  'module'          => 'Blocks',
  32.                  'text_type_long'  => 'Simple File Include',
  33.                  'allow_multiple'  => true,
  34.                  'form_content'    => false,
  35.                  'form_refresh'    => false,
  36.                  'show_preview'    => true,
  37.                  'admin_tableless' => true);
  38. }
  39.  
  40. /**
  41.  * display block
  42.  *
  43.  * @author       The Zikula Development Team
  44.  * @param        array       $blockinfo     a blockinfo structure
  45.  * @return       output      the rendered bock
  46.  */
  47. function Blocks_fincludeblock_display($blockinfo)
  48. {
  49.     if (!SecurityUtil::checkPermission('fincludeblock::'"$blockinfo[title]::"ACCESS_READ)) {
  50.         return;
  51.     }
  52.  
  53.     // Get current content
  54.     $vars pnBlockVarsFromContent($blockinfo['content']);
  55.  
  56.     // Defaults
  57.     if (empty($vars['filo'])) {
  58.         $vars['filo''/path/to/file.txt';
  59.     }
  60.     if (empty($vars['typo'])) {
  61.         $vars['typo'0;
  62.     }
  63.  
  64.     if (!file_exists($vars['filo'])) {
  65.         if (SecurityUtil::checkPermission('fincludeblock::'"$blockinfo[title]::"ACCESS_EDIT)) {
  66.             $blockinfo['content'pnML('_FILEDOESNOTEXIST'array('f' => $vars['filo']));
  67.             return pnBlockThemeBlock($blockinfo);
  68.         else {
  69.             return;
  70.         }
  71.     }
  72.  
  73.     $blockinfo['content''';
  74.     switch ($vars['typo']{
  75.         case 0:
  76.             $blockinfo['content'nl2br(file_get_contents($vars['filo']));
  77.             break;
  78.         case 1:
  79.             $blockinfo['content'DataUtil::formatForDisplay(file_get_contents($vars['filo']));
  80.             break;
  81.         case 2:
  82.             ob_start();
  83.             include DataUtil::formatForOS($vars['filo']);
  84.             $blockinfo['content'ob_get_clean();
  85.             break;
  86.         default:
  87.             return;
  88.     }
  89.     return pnBlockThemeBlock($blockinfo);
  90. }
  91.  
  92. /**
  93.  * modify block settings
  94.  *
  95.  * @author       The Zikula Development Team
  96.  * @param        array       $blockinfo     a blockinfo structure
  97.  * @return       output      the bock form
  98.  */
  99. function Blocks_fincludeblock_modify($blockinfo)
  100. {
  101.     // Get current content
  102.     $vars pnBlockVarsFromContent($blockinfo['content']);
  103.  
  104.     // Defaults
  105.     if (empty($vars['filo'])) {
  106.         $vars['filo''/path/to/file.txt';
  107.     }
  108.     if (empty($vars['typo'])) {
  109.         $vars['typo'0;
  110.     }
  111.  
  112.     // Create output object - this object will store all of our output so that
  113.     // we can return it easily when required
  114.     $pnRender pnRender::getInstance('Blocks');
  115.  
  116.     // assign the vars
  117.     $pnRender->assign($vars);
  118.  
  119.     // return the output
  120.     return $pnRender->fetch('blocks_block_finclude_modify.htm');
  121. }
  122.  
  123. /**
  124.  * update block settings
  125.  *
  126.  * @author       The Zikula Development Team
  127.  * @param        array       $blockinfo     a blockinfo structure
  128.  * @return       $blockinfo  the modified blockinfo structure
  129.  */
  130. function Blocks_fincludeblock_update($blockinfo)
  131. {
  132.     // Get current content
  133.     $vars pnBlockVarsFromContent($blockinfo['content']);
  134.  
  135.     // alter the corresponding variable
  136.     $vars['filo'FormUtil::getPassedValue('filo');
  137.     $vars['typo'FormUtil::getPassedValue('typo');
  138.  
  139.     // write back the new contents
  140.     $blockinfo['content'pnBlockVarsToContent($vars);
  141.  
  142.     return $blockinfo;
  143. }

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