BxGSearchModule.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. /***************************************************************************
  3. * Dolphin Smart Community Builder
  4. * -------------------
  5. * begin : Mon Mar 23 2006
  6. * copyright : (C) 2007 BoonEx Group
  7. * website : http://www.boonex.com
  8. * This file is part of Dolphin - Smart Community Builder
  9. *
  10. * Dolphin is free software; you can redistribute it and/or modify it under
  11. * the terms of the GNU General Public License as published by the
  12. * Free Software Foundation; either version 2 of the
  13. * License, or any later version.
  14. *
  15. * Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  16. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  17. * See the GNU General Public License for more details.
  18. * You should have received a copy of the GNU General Public License along with Dolphin,
  19. * see license.txt file; if not, write to marketing@boonex.com
  20. ***************************************************************************/
  21. function bx_gsearch_import ($sClassPostfix, $aModuleOverwright = array()) {
  22. global $aModule;
  23. $a = $aModuleOverwright ? $aModuleOverwright : $aModule;
  24. if (!$a || $a['uri'] != 'google_search') {
  25. $oMain = BxDolModule::getInstance('bx_google_search');
  26. $a = $oMain->_aModule;
  27. }
  28. bx_import ($sClassPostfix, $a) ;
  29. }
  30. bx_import('BxDolModule');
  31. bx_import('BxDolPaginate');
  32. bx_import('BxDolAlerts');
  33. /**
  34. * Google Site Search module by BoonEx
  35. *
  36. * This module allow user to search the site using Google Site Search
  37. *
  38. *
  39. *
  40. * Profile's Wall:
  41. * no wall events
  42. *
  43. *
  44. *
  45. * Spy:
  46. * no spy events
  47. *
  48. *
  49. *
  50. * Memberships/ACL:
  51. * no acl's - everybody can use it
  52. *
  53. *
  54. *
  55. * Service methods:
  56. *
  57. * Get search control html
  58. * @see BxGSearchModule::serviceGetSearchControl
  59. * BxDolService::call('google_search', 'get_search_control', array());
  60. *
  61. *
  62. *
  63. * Alerts:
  64. * no alerts
  65. *
  66. */
  67. class BxGSearchModule extends BxDolModule {
  68. var $_iProfileId;
  69. function BxGSearchModule(&$aModule) {
  70. parent::BxDolModule($aModule);
  71. $GLOBALS['aModule'] = $aModule;
  72. $this->_iProfileId = $GLOBALS['logged']['member'] || $GLOBALS['logged']['admin'] ? $_COOKIE['memberID'] : 0;
  73. $GLOBALS['oBxGSearchModule'] = &$this;
  74. }
  75. function actionHome () {
  76. bx_gsearch_import ('PageMain');
  77. $oPage = new BxGSearchPageMain ($this);
  78. $this->_oTemplate->pageStart();
  79. echo $oPage->getCode();
  80. $this->_oTemplate->addJs ('http://www.google.com/jsapi');
  81. $this->_oTemplate->addCss ('main.css');
  82. $this->_oTemplate->pageCode(_t('_bx_gsearch'), false, false);
  83. }
  84. function actionAdministration () {
  85. if (!$this->isAdmin()) {
  86. $this->_oTemplate->displayAccessDenied ();
  87. return;
  88. }
  89. $iId = $this->_oDb->getSettingsCategory('Google Search');
  90. if(empty($iId)) {
  91. $this->_oTemplate->displayPageNotFound ();
  92. return;
  93. }
  94. $this->_oTemplate->pageStart();
  95. bx_import('BxDolAdminSettings');
  96. $mixedResult = '';
  97. if(isset($_POST['save']) && isset($_POST['cat'])) {
  98. $oSettings = new BxDolAdminSettings($iId);
  99. $mixedResult = $oSettings->saveChanges($_POST);
  100. }
  101. $oSettings = new BxDolAdminSettings($iId);
  102. $sResult = $oSettings->getForm();
  103. if($mixedResult !== true && !empty($mixedResult))
  104. $sResult = $mixedResult . $sResult;
  105. $aVars = array (
  106. 'content' => $sResult,
  107. );
  108. echo $this->_oTemplate->adminBlock ($this->_oTemplate->parseHtmlByName('default_padding', $aVars), _t('_bx_gsearch_administration'));
  109. $this->_oTemplate->addCssAdmin ('main.css');
  110. $this->_oTemplate->addCssAdmin ('forms_adv.css');
  111. $this->_oTemplate->pageCodeAdmin (_t('_bx_gsearch_administration'));
  112. }
  113. // ================================== service actions
  114. /**
  115. * Get search control html.
  116. * @return html with google search control
  117. */
  118. function serviceGetSearchControl () {
  119. $this->_oTemplate->addCss ('main.css');
  120. $this->_oTemplate->addJs ('http://www.google.com/jsapi');
  121. $a = parse_url ($GLOBALS['site']['url']);
  122. $aVars = array (
  123. 'is_image_search' => 'on' == getParam('bx_gsearch_block_images') ? 1 : 0,
  124. 'is_tabbed_search' => 'on' == getParam('bx_gsearch_block_tabbed') ? 1 : 0,
  125. 'domain' => $a['host'],
  126. 'keyword' => '',
  127. 'suffix' => 'simple',
  128. 'separate_search_form' => 0,
  129. );
  130. return $this->_oTemplate->parseHtmlByName('search', $aVars);
  131. }
  132. // ================================== other functions
  133. function isAdmin () {
  134. return $GLOBALS['logged']['admin'] || $GLOBALS['logged']['moderator'];
  135. }
  136. }
  137. ?>