Subversion Repositories Applications.papyrus

Rev

Rev 2126 | Rev 2131 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2126 Rev 2127
Line 224... Line 224...
224
	$item['score'] = intval($item['weight'] / $max * 100);
224
	$item['score'] = intval($item['weight'] / $max * 100);
225
	$item['date_creation'] = isset($item['date_creation']) ? strftime("%d %B %Y", strtotime($item['date_creation'])) : '';
225
	$item['date_creation'] = isset($item['date_creation']) ? strftime("%d %B %Y", strtotime($item['date_creation'])) : '';
226
	unset($item['weight']);
226
	unset($item['weight']);
227
}
227
}
Line -... Line 228...
-
 
228
 
-
 
229
function _actuNewerFirst($a,$b) {
-
 
230
	return isset($a['date_creation']) && isset($b['date_creation']) ? strcmp($b['date_creation'], $a['date_creation']) : 0;
-
 
231
}
228
 
232
 
229
function sphinx_search($q = NULL, $page = 1) {
233
function sphinx_search($q = NULL, $page = 1) {
Line 230... Line 234...
230
	if(!$q) return array();
234
	if(!$q) return array();
231
 
235
 
Line 298... Line 302...
298
			  $res['nvjfl'][$v['id']]['id']);
302
			  $res['nvjfl'][$v['id']]['id']);
299
		// left: weight
303
		// left: weight
300
		$docs['nvjfl-' . $v['id']] = array_merge($v, $res['nvjfl'][$v['id']]);
304
		$docs['nvjfl-' . $v['id']] = array_merge($v, $res['nvjfl'][$v['id']]);
301
	}
305
	}
Line 302... Line -...
302
 
-
 
303
	$sorted = _sortArrayByArray($docs, $ids_par_poids);
-
 
304
 
306
 
305
	// sort
-
 
306
	/*
-
 
307
	// uncomment this:
307
	// sort
308
	print_r(array_keys($sorted); die;
-
 
309
 
-
 
310
	// then:
-
 
311
	ddiff
-
 
312
	<(mysql -h0 -P 9306 <<<"SELECT main_id FROM i_projet, i_spip, i_papyrus, i_bazar, i_coste, i_nvjfl WHERE MATCH('test') LIMIT 50;"|awk '{print $3}'|sed 1d) \
-
 
313
	<(POST http://localhost/site:reseau<<<"more_motif=test&"|awk -F'=>' '{print $2}'|sed -e 's/ //g' -e '/^$/d')
-
 
314
 
-
 
315
	// both should be equal.
-
 
316
	// [ SELECT main_id, group_id FROM i_projet, i_spip, i_papyrus, i_bazar WHERE MATCH('test') LIMIT 50; ]
-
 
Line 317... Line 308...
317
	*/
308
	$sorted = _sortArrayByArray($docs, $ids_par_poids);
318
 
309
 
-
 
310
	$max = current($sorted);
-
 
311
	$max = $max['weight'];
-
 
312
 
-
 
313
	if(isset($_GET['tri']) && $_GET['tri'] == 'date')
-
 
314
		usort($sorted, '_actuNewerFirst');
319
	$max = current($sorted);
315
 
Line 320... Line 316...
320
	$max = $max['weight'];
316
	// transforme les clefs pour s'adapter aux templates existants
321
	array_walk($sorted, '_weight2score', $max);
317
	array_walk($sorted, '_weight2score', $max);
322
 
318
 
Line 337... Line 333...
337
 
333
 
338
/*
334
/*
339
  Note: conversion côté client SQL:
335
  Note: conversion côté client SQL:
340
  mysql -h0 -P 9306 < <(iconv -f utf8 -t latin1 <<<"SELECT * FROM i_projet, i_spip, i_papyrus, i_bazar WHERE MATCH('journée');")
336
  mysql -h0 -P 9306 < <(iconv -f utf8 -t latin1 <<<"SELECT * FROM i_projet, i_spip, i_papyrus, i_bazar WHERE MATCH('journée');")
-
 
337
*/
-
 
338
 
-
 
339
/*
-
 
340
  // test sorting
-
 
341
  // uncomment this:
-
 
342
  print_r(array_keys($sorted); die;
-
 
343
 
-
 
344
  // then:
-
 
345
  ddiff
-
 
346
	<(mysql -h0 -P 9306 <<<"SELECT main_id FROM i_projet, i_spip, i_papyrus, i_bazar, i_coste, i_nvjfl WHERE MATCH('test') LIMIT 50;"|awk '{print $3}'|sed 1d) \
-
 
347
	<(POST http://localhost/site:reseau<<<"more_motif=test&"|awk -F'=>' '{print $2}'|sed -e 's/ //g' -e '/^$/d')
-
 
348
	
-
 
349
  // both should be equal.
-
 
350
  // [ SELECT main_id, group_id FROM i_projet, i_spip, i_papyrus, i_bazar WHERE MATCH('test') LIMIT 50; ]