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

Source for file sigma-example.php

Documentation is available at sigma-example.php

  1. <?php 
  2. /**
  3. * Example usage for Search_Mnogosearch renderer
  4. * with Sigma Templates and Pager.
  5. *
  6. @author Gerrit Goetsch <goetsch@cross-solution.de>
  7. *  $Id: sigma-example.php,v 1.2 2004/11/10 10:33:14 goetsch Exp $
  8. */
  9. require_once 'Search/Mnogosearch.php';
  10. require_once 'Search/Mnogosearch/Renderer/Sigma.php';
  11.  
  12. require_once 'HTML/QuickForm.php';
  13. require_once 'HTML/QuickForm/Renderer/ITStatic.php';
  14. require_once 'HTML/Template/Sigma.php';
  15. require_once 'Pager/Pager.php';
  16.  
  17. // define the DNS to mnogosearch
  18. // define('DSN_MNOGOSEARCH', 'mysql://user:password@localhost/database');
  19. include 'config.php';
  20.  
  21. $tpl new HTML_Template_Sigma(dirname(__FILE__).'/renderers/templates/');
  22. $tpl->loadTemplateFile('search.html'falsetrue);
  23. $tpl->setVariable("subject""Search_Mnogosearch renderer example for the sigma renderer");
  24.  
  25. $perPage = 10;
  26. // some parameters
  27. $params = array ();
  28. $params['excerptsize']      "400";
  29. $params['excerptpadding']   "64";
  30. $params['pagesize']         $perPage;
  31. $params['mode']             'UDM_MODE_ALL';
  32. $params['sortorder']        'DRP';
  33. $params['detectclones']     = 1; 
  34. $params['cachemode']        = 0; 
  35. $params['crosswords']       = 0; 
  36. $params['minwordlength']    = 2;
  37. $params['charset']          "iso-8859-1";
  38. $params['dateformat']       "%d-%m-%y";
  39.  
  40. // Limits
  41. $limits = array ();
  42. // create a new Search_Mnogosearch Object    
  43. $search Search_Mnogosearch::connect(DSN_MNOGOSEARCH."/?dbmode=multi");
  44. // set the http parameters if you want.
  45. $search->setHttpParameters(array (
  46.     'page'    => 'page'
  47.     'group'   => 'group',   
  48.     'query'   => 'words'
  49. ));
  50.  
  51. // set the parameters
  52. $search->setParameters($params);
  53. $search->setLimits($limits);
  54.  
  55. $sigma = new Search_Mnogosearch_Renderer_Sigma($tpl);
  56. $sigma->setVariableNames(array (
  57.     'contentmain'   => 'contentmain',
  58.     'query'         => 'query',
  59.     'date'          => 'date'
  60. ));
  61.  
  62. // set the template to use
  63. $sigma->setTemplates(array (
  64.     'groupbysite'   => 'bygroup.html'
  65.     'single'        => 'result.html'
  66.     'noresult'      => 'noresult.html'
  67. ));
  68.  
  69. // set the pager options
  70. $sigma->setPagerOptions(array (
  71.     'firstPageText' => '<< '
  72.     'lastPageText'  => ' >>'
  73.     'nextImg'       => ' >'
  74.     'prevImg'       => '< '
  75. ));
  76.  
  77. // set section weight factors
  78. $search->setSectionWeights(array(
  79.     1 => '1',   // body
  80.     2 => '2',   // title
  81.     3 => '2',   // keywords
  82.     5 => '4'    // Organization (custom) 
  83. ));
  84.  
  85. $sigma->setHighlightTags(array(
  86.     'begin'  => '<font color="#003300"><b>',
  87.     'end'    => '</b></font>'));
  88.     
  89. $search->accept($sigma);
  90.  
  91. $search->disconnect();
  92.  
  93. print $tpl->get();
  94.  
  95. ?>

Documentation generated on Mon, 11 Mar 2019 14:31:31 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.