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

Source for file search.php

Documentation is available at search.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: search.php 24342 2008-06-06 12:03:14Z markwest $
  8.  * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
  9.  * @package Zikula_System_Modules
  10.  * @subpackage Blocks
  11.  */
  12.  
  13. /**
  14.  * initialise block
  15.  *
  16.  * @author       The Zikula Development Team
  17.  */
  18. {
  19.     // Security
  20.     pnSecAddSchema('Searchblock::''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'       => 'Search',
  31.                  'module'          => 'Search',
  32.                  'text_type_long'  => 'Search Box',
  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 Search_searchblock_display($blockinfo)
  48. {
  49.     // Security check
  50.     if (!SecurityUtil::checkPermission('Searchblock::'"$blockinfo[title]::"ACCESS_READ)) {
  51.         return;
  52.     }
  53.  
  54.     // Get current content
  55.     $vars pnBlockVarsFromContent($blockinfo['content']);
  56.  
  57.     // Create output object
  58.     $pnRender pnRender::getInstance('Search');
  59.  
  60.     // set some defaults
  61.     if (!isset($vars['displaySearchBtn'])) {
  62.         $vars['displaySearchBtn'0;
  63.     }
  64.  
  65.     // add the module vars
  66.     $vars['modvar'pnModGetVar('Search');
  67.  
  68.     // assign the block vars array
  69.     $pnRender->assign('vars',$vars);
  70.  
  71.     // set a title if one isn't present
  72.     if (empty($blockinfo['title'])) {
  73.         $blockinfo['title'_SEARCH;
  74.     }
  75.  
  76.     // return the rendered block
  77.     $blockinfo['content'$pnRender->fetch('search_block_search.htm');
  78.     return pnBlockThemeBlock($blockinfo);
  79. }
  80.  
  81. /**
  82.  * modify block settings
  83.  *
  84.  * @author       The Zikula Development Team
  85.  * @param        array       $blockinfo     a blockinfo structure
  86.  * @return       output      the bock form
  87.  */
  88. function Search_searchblock_modify($blockinfo)
  89. {
  90.     // Get current content
  91.     $vars pnBlockVarsFromContent($blockinfo['content']);
  92.  
  93.     // get all the search plugins
  94.     $search_modules pnModAPIFunc('Search''user''getallplugins');
  95.  
  96.     // set some defaults
  97.     if (!isset($vars['displaySearchBtn'])) {
  98.         $vars['displaySearchBtn'0;
  99.     }
  100.  
  101.     // load user language file
  102.     pnModLangLoad('Search''user');
  103.  
  104.  
  105.     $searchmodules array();
  106.     if (is_array($search_modules)) {
  107.         foreach($search_modules as $mods{
  108.             $searchmodules[array('module' => pnModAPIFunc($mods['title']'Search''options'$vars));
  109.         }
  110.     }
  111.  
  112.     // Create output object
  113.     $pnRender pnRender::getInstance('Search');
  114.  
  115.     // assign the block vars array
  116.     $pnRender->assign('searchvars'$vars);
  117.     $pnRender->assign('searchmodules'$searchmodules);
  118.  
  119.     return $pnRender->fetch('search_block_search_modify.htm');
  120. }
  121.  
  122. /**
  123.  * update block settings
  124.  *
  125.  * @author       The Zikula Development Team
  126.  * @param        array       $blockinfo     a blockinfo structure
  127.  * @return       $blockinfo  the modified blockinfo structure
  128.  */
  129. function Search_searchblock_update($blockinfo)
  130. {
  131.     // list of vars that don't need to be saved
  132.     $search_reserved_vars array('authid''bid''title''positions''language''submit',
  133.                                   'refresh''filter''type''functions''customargs');
  134.  
  135.     // Get current content
  136.     $vars pnBlockVarsFromContent($blockinfo['content']);
  137.  
  138.     foreach($_POST as $key => $value{
  139.         if (in_array($key$search_reserved_vars)) {
  140.             continue;
  141.         }
  142.         $vars[$key$value;
  143.     }
  144.  
  145.     // write back the new contents
  146.     $blockinfo['content'pnBlockVarsToContent($vars);
  147.  
  148.     // clear the block cache
  149.     $pnRender pnRender::getInstance('Search');
  150.     $pnRender->clear_cache('search_block_search.htm');
  151.  
  152.     return($blockinfo);
  153. }

Documentation generated on Fri, 18 Jul 2008 21:56:41 +0200 by phpDocumentor 1.4.1