[xoops-cvslog 3194] CVS update: xoops2jp/html/modules/base/service

Back to archive index

Minahito minah****@users*****
2006年 5月 27日 (土) 22:09:41 JST


Index: xoops2jp/html/modules/base/service/LegacySearchService.class.php
diff -u xoops2jp/html/modules/base/service/LegacySearchService.class.php:1.1.2.3 xoops2jp/html/modules/base/service/LegacySearchService.class.php:1.1.2.4
--- xoops2jp/html/modules/base/service/LegacySearchService.class.php:1.1.2.3	Tue Mar 28 22:30:34 2006
+++ xoops2jp/html/modules/base/service/LegacySearchService.class.php	Sat May 27 22:09:41 2006
@@ -13,13 +13,21 @@
 	 * @param $parameters['uid'] Target user's id
 	 * @param $parameters['current_uid'] Current user's id
 	 * @param $parameters['maxhit'] Max hit count of each modules. The default value is 5.
+	 * @param $parameters['mid'] If this is specified, search only one module.
 	 */
 	function doGetItems(&$parameters)
 	{
 		$ret = array();
-		$uid = $parameters['uid'];
+		$uid = isset($parameters['uid']) ? intval($parameters['uid']) : 0;
+		$queries = isset($parameters['queries']) ? $parameters['queries'] : null;
+
+		$andor = isset($parameters['andor']) ? $parameters['andor'] : null;
+		if ($andor == null) {
+			$andor == "AND";
+		}
 		
 		$maxhit = isset($parameters['maxhit']) ? intval($parameters['maxhit']) : 5;
+		$start = isset($parameters['offset']) ? intval($parameters['offset']) : null;
 		
 		$userHandler =& xoops_gethandler('user');
 		$currentUser =& $userHandler->get($parameters['current_uid']);
@@ -31,10 +39,19 @@
 		// At first, get active module IDs.
 		//
 		$moduleHandler =& xoops_gethandler('module');
-		$criteria =& new CriteriaCompo(new Criteria('hassearch', 1));
-		$criteria->add(new Criteria('isactive', 1));
 		
-		$mids =& array_keys($moduleHandler->getList($criteria));
+		$mids = array();
+		if (isset($parameters['mids']) && is_array($parameters['mids'])) {
+			$mids = $parameters['mids'];
+		}
+		elseif (isset($parameters['mid'])) {
+			$mids[] = intval($parameters['mid']);
+		}
+		else {
+			$criteria =& new CriteriaCompo(new Criteria('hassearch', 1));
+			$criteria->add(new Criteria('isactive', 1));
+			$mids =& array_keys($moduleHandler->getList($criteria));
+		}
 
 		//
 		// Next, fetch from $mids[], and check read permission.
@@ -47,8 +64,13 @@
 		foreach ($mids as $mid) {
 			if ($gpermHandler->checkRight('module_read', $mid, $groups)) {
 				$module =& $moduleHandler->get($mid);
-				$results =& $module->search('', '', $maxhit, 0, $uid);
+				if (!is_object($module)) {
+					continue;
+				}
+				
+				$results =& $module->search($queries, $andor, $maxhit, $start, $uid);
 				
+				$ret[$i]['mid'] = $mid;
 				$ret[$i]['name'] = $module->get('name');
 				
 				if (is_array($results) && count($results) > 0) {
@@ -63,6 +85,7 @@
 						
 						$item['link'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/' . $result['link'];
 						$item['title'] = $result['title'];
+						$item['uid'] = $result['uid'];
 						
 						//
 						// TODO If this service will come to web service, we should
@@ -73,15 +96,7 @@
 						$ret[$i]['results'][] = $item;
 					}
 					
-					if (count($results) == 5) {
-						$link = @sprintf("%s/search.php?action=showallbyuser&mid=%d&uid=%d",
-							XOOPS_URL,
-							$module->get('mid'),
-							$uid
-						);
-						
-						$ret[$i]['showall_link'] =	$link;
-					}
+					$ret[$i]['has_more'] = (count($results) == $maxhit);
 				}
 				else {
 					$ret[$i]['results'] = array();


xoops-cvslog メーリングリストの案内
Back to archive index