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

Source for file pnsearchapi.php

Documentation is available at pnsearchapi.php

  1. <?php
  2. /**
  3.  * Zikula Application Framework
  4.  *
  5.  * @copyright (c) 2002, Zikula Development Team
  6.  * @link http://www.zikula.org
  7.  * @version $Id: pnsearchapi.php 24342 2008-06-06 12:03:14Z markwest $
  8.  * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
  9.  * @package Zikula_Value_Addons
  10.  * @subpackage FAQ
  11.  */
  12.  
  13. /**
  14.  * Search plugin info
  15.  **/
  16.  
  17. function faq_searchapi_info()
  18. {
  19.     return array('title' => 'FAQ'
  20.                  'functions' => array('FAQ' => 'search'));
  21. }
  22.  
  23. /**
  24.  * Search form component
  25.  **/
  26.  
  27. function faq_searchapi_options($args)
  28. {
  29.     if (SecurityUtil::checkPermission'FAQ::''::'ACCESS_READ)) {
  30.         $pnRender pnRender::getInstance('FAQ');
  31.         $pnRender->assign('active',(isset($args['active'])&&isset($args['active']['FAQ']))||(!isset($args['active'])));
  32.         return $pnRender->fetch('faq_search_options.htm');
  33.     }
  34.  
  35.     return '';
  36. }
  37.  
  38. /**
  39.  * Search plugin main function
  40.  **/
  41.  
  42. function faq_searchapi_search($args)
  43. {
  44.     pnModDBInfoLoad('Search');
  45.     $pntable pnDBGetTables();
  46.     $faqtable $pntable['faqanswer'];
  47.     $faqcolumn $pntable['faqanswer_column'];
  48.     $searchTable $pntable['search_result'];
  49.     $searchColumn $pntable['search_result_column'];
  50.  
  51.     $where search_construct_where($args
  52.                                     array($faqcolumn['question']
  53.                                           $faqcolumn['answer'])
  54.                                     null);
  55.  
  56.     $sessionId session_id();
  57.  
  58.     // define the permission filter to apply
  59.     $permFilter array(array('realm'          => 0,
  60.                               'component_left' => 'FAQ',
  61.                               'instance_left'  => 'faqid',
  62.                               'instance_right' => '',
  63.                               'level'          => ACCESS_READ));
  64.     // get the result set
  65.     $objArray DBUtil::selectObjectArray('faqanswer'$where'faqid'1-1''$permFilter);
  66.     if ($objArray === false{
  67.         return LogUtil::registerError (_GETFAILED);
  68.     }
  69.  
  70.     $addcategorytitletopermalink pnModGetVar('FAQ''addcategorytitletopermalink');
  71.  
  72.     $insertSql 
  73. "INSERT INTO $searchTable
  74.   ($searchColumn[title],
  75.    $searchColumn[text],
  76.    $searchColumn[extra],
  77.    $searchColumn[created],
  78.    $searchColumn[module],
  79.    $searchColumn[session])
  80. VALUES ";
  81.  
  82.     // Process the result set and insert into search result table
  83.     foreach ($objArray as $obj{
  84.         if ($addcategorytitletopermalink{
  85.             $extra serialize(array('faqid' => $obj['faqid']'cat' => isset($obj['__CATEGORIES__']['Main']['name']$obj['__CATEGORIES__']['Main']['name'null));
  86.         else {
  87.             $extra serialize(array('faqid' => $obj['faqid']));
  88.         }
  89.         $sql $insertSql '(' 
  90.                    . '\'' DataUtil::formatForStore($obj['question']'\', '
  91.                    . '\'' DataUtil::formatForStore($obj['answer']'\', '
  92.                    . '\'' DataUtil::formatForStore($extra'\', '
  93.                    . '\'' DataUtil::formatForStore($obj['cr_date']'\', '
  94.                    . '\'' 'FAQ' '\', '
  95.                    . '\'' DataUtil::formatForStore($sessionId'\')';
  96.         $insertResult DBUtil::executeSQL($sql);
  97.         if (!$insertResult{
  98.             return LogUtil::registerError (_GETFAILED);
  99.         }
  100.     }
  101.  
  102.     return true;
  103. }
  104.  
  105. /**
  106.  * Do last minute access checking and assign URL to items
  107.  *
  108.  * Access checking is ignored since access check has
  109.  * already been done. But we do add a URL to the found item
  110.  */
  111. function faq_searchapi_search_check(&$args)
  112. {
  113.     $datarow &$args['datarow'];
  114.     $extra unserialize($datarow['extra']);
  115.  
  116.     $datarow['url'pnModUrl('FAQ''user''display'array('faqid' => $extra['faqid']'cat' => $extra['cat']));
  117.  
  118.     return true;
  119. }

Documentation generated on Fri, 18 Jul 2008 21:54:19 +0200 by phpDocumentor 1.4.1