/Services/Search/classes/Like/class.ilLikeForumSearch.php

https://github.com/ILIAS-eLearning/ILIAS · PHP · 89 lines · 39 code · 9 blank · 41 comment · 2 complexity · 0af84b44d06032c96907b0c1c3d1bae2 MD5 · raw file

  1. <?php
  2. /*
  3. +-----------------------------------------------------------------------------+
  4. | ILIAS open source |
  5. +-----------------------------------------------------------------------------+
  6. | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
  7. | |
  8. | This program is free software; you can redistribute it and/or |
  9. | modify it under the terms of the GNU General Public License |
  10. | as published by the Free Software Foundation; either version 2 |
  11. | of the License, or (at your option) any later version. |
  12. | |
  13. | This program is distributed in the hope that it will be useful, |
  14. | but WITHOUT ANY WARRANTY; without even the implied warranty of |
  15. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
  16. | GNU General Public License for more details. |
  17. | |
  18. | You should have received a copy of the GNU General Public License |
  19. | along with this program; if not, write to the Free Software |
  20. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
  21. +-----------------------------------------------------------------------------+
  22. */
  23. /**
  24. * Class ilForumSearch
  25. *
  26. * Performs Mysql Like search in object_data title and description
  27. *
  28. * @author Stefan Meyer <smeyer.ilias@gmx.de>
  29. * @version $Id$
  30. *
  31. * @package ilias-search
  32. *
  33. */
  34. include_once 'Services/Search/classes/class.ilForumSearch.php';
  35. class ilLikeForumSearch extends ilForumSearch
  36. {
  37. public function __createPostAndCondition()
  38. {
  39. global $DIC;
  40. $ilDB = $DIC['ilDB'];
  41. /*
  42. $concat = " CONCAT(";
  43. $concat .= 'pos_message,pos_subject';
  44. $concat .= ") ";
  45. */
  46. $concat = $ilDB->concat(
  47. array(
  48. array('pos_subject','text'),
  49. array('pos_message','text'))
  50. );
  51. $and = " AND ( ";
  52. $counter = 0;
  53. foreach ($this->query_parser->getQuotedWords() as $word) {
  54. if ($counter++) {
  55. $and .= " OR";
  56. }
  57. #$and .= $concat;
  58. #$and .= ("LIKE ('%".$word."%')");
  59. $and .= $ilDB->like($concat, 'clob', '%' . $word . '%');
  60. }
  61. return $and . ") ";
  62. }
  63. public function __createTopicAndCondition()
  64. {
  65. global $DIC;
  66. $ilDB = $DIC['ilDB'];
  67. $field = 'thr_subject ';
  68. $and = " AND( ";
  69. $counter = 0;
  70. foreach ($this->query_parser->getQuotedWords() as $word) {
  71. if ($counter++) {
  72. $and .= " OR ";
  73. }
  74. #$and .= $field;
  75. #$and .= ("LIKE ('%".$word."%')");
  76. $and .= $ilDB->like($field, 'text', '%' . $word . '%');
  77. }
  78. return $and . " ) ";
  79. }
  80. }