| 1 |
<?php
|
| 2 |
|
| 3 |
/**
|
| 4 |
* gather stats about how many fields could be searched on
|
| 5 |
* */
|
| 6 |
function _semantic_search_cacheStatsFromForm(&$form){
|
| 7 |
return $form;
|
| 8 |
}
|
| 9 |
|
| 10 |
/**
|
| 11 |
* used to display timing throughout a query
|
| 12 |
* */
|
| 13 |
function __nsp($name){
|
| 14 |
global $__n_start;
|
| 15 |
global $__n_last;
|
| 16 |
if (empty($__n_start )) $__n_start = this_microtime();
|
| 17 |
if ($__n_last !== 0 && empty($__n_last )) $__n_last = $__n_start;
|
| 18 |
$now = this_microtime();
|
| 19 |
$total = $now - $__n_start;
|
| 20 |
$diff = $now - $__n_last;
|
| 21 |
drupal_set_message("$diff for <b>$name</b> from last $total from start");
|
| 22 |
$__n_last = $now;
|
| 23 |
|
| 24 |
}
|
| 25 |
|
| 26 |
function this_microtime()
|
| 27 |
{
|
| 28 |
list($usec, $sec) = explode(" ", microtime());
|
| 29 |
return ((float)$usec + (float)$sec);
|
| 30 |
}
|
| 31 |
|
| 32 |
/// RANDOM helper functions
|
| 33 |
if (!function_exists('dbg')) {
|
| 34 |
/**
|
| 35 |
* A debug method.
|
| 36 |
* Use to print contents of an array and gives an indication
|
| 37 |
* of where dbg() was called
|
| 38 |
*
|
| 39 |
* @todo
|
| 40 |
* - add support for object debugging
|
| 41 |
* - have default $lable parameter be the name of $param passed in
|
| 42 |
*
|
| 43 |
* @param mixed $array the item to debug
|
| 44 |
* @param string $label optional html to label the $array
|
| 45 |
* @param string $bt whethor or not to enable back trace
|
| 46 |
*
|
| 47 |
* */
|
| 48 |
function dbg($array, $label = 'Debug Output', $bt = false) {
|
| 49 |
$t = '';
|
| 50 |
$backtrace_string = '';
|
| 51 |
if ($bt) {
|
| 52 |
$backtraces = debug_backtrace();
|
| 53 |
$backtrace_string = '';
|
| 54 |
$first_run = true;
|
| 55 |
|
| 56 |
foreach ($backtraces as $backtrace) {
|
| 57 |
$backtrace_string .= '<strong>line ' . $backtrace['line'] . '</strong> calls function <strong>';
|
| 58 |
$backtrace_string .= $backtrace['function'] . '()</strong> in ';
|
| 59 |
$backtrace_string .= '<span style="font-size: 9pt;">' . $backtrace['file'] . '</span><br />';
|
| 60 |
}
|
| 61 |
}
|
| 62 |
|
| 63 |
$t .= '<div style="pmsg"><strong>' . $label . '</strong><br />';
|
| 64 |
$t .= '<div class="arrayDebug" ><pre>';
|
| 65 |
$t .= print_r($array, 1);
|
| 66 |
$t .= '</pre></div>';
|
| 67 |
$t .= "<em>";
|
| 68 |
$t .= $backtrace_string;
|
| 69 |
$t .= '</em></div>';
|
| 70 |
|
| 71 |
drupal_set_message($t);
|
| 72 |
}
|
| 73 |
} //end if function exists
|
| 74 |
|
| 75 |
/**
|
| 76 |
* general string cleaner
|
| 77 |
* */
|
| 78 |
function _semantic_search_str_clean(&$value){
|
| 79 |
return $value;
|
| 80 |
//return _semantic_search_iso_str_encode($value);
|
| 81 |
}
|
| 82 |
|
| 83 |
/**
|
| 84 |
* from sadikkeskin at hotmail dot com
|
| 85 |
* http://us3.php.net/manual/en/function.utf8-encode.php
|
| 86 |
* */
|
| 87 |
function _semantic_search_iso_str_encode($string,$to="iso-8859-9",$from="utf8") {
|
| 88 |
if($to=="iso-8859-9" && $from=="utf8"){
|
| 89 |
$str_array = array(
|
| 90 |
chr(196).chr(177) => chr(253),
|
| 91 |
chr(196).chr(176) => chr(221),
|
| 92 |
chr(195).chr(182) => chr(246),
|
| 93 |
chr(195).chr(150) => chr(214),
|
| 94 |
chr(195).chr(167) => chr(231),
|
| 95 |
chr(195).chr(135) => chr(199),
|
| 96 |
chr(197).chr(159) => chr(254),
|
| 97 |
chr(197).chr(158) => chr(222),
|
| 98 |
chr(196).chr(159) => chr(240),
|
| 99 |
chr(196).chr(158) => chr(208),
|
| 100 |
chr(195).chr(188) => chr(252),
|
| 101 |
chr(195).chr(156) => chr(220)
|
| 102 |
);
|
| 103 |
return str_replace(array_keys($str_array), array_values($str_array), $string);
|
| 104 |
|
| 105 |
}
|
| 106 |
return $string;
|
| 107 |
}
|
| 108 |
|
| 109 |
/*
|
| 110 |
PHP URL encoding/decoding functions for Javascript interaction V1.0
|
| 111 |
(C) 2006 www.captain.at - all rights reserved
|
| 112 |
License: GPL
|
| 113 |
|
| 114 |
status: REMOVED
|
| 115 |
*/
|