function translate($text, $from = '', $to = 'en') { $url = 'http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=' . rawurlencode($text) . '&langpair=' . rawurlencode($from . '|' . $to); $response = file_get_contents1($url, null, "http://" . $_SERVER['HTTP_HOST'] . "/\r\n"); $obj = json_decode($response); if (is_object($obj)) { return self::_unescapeUTF8EscapeSeq($obj->{'responseData'}->{'translatedText'}); } else { return self::translate_api($text, $from, $to = 'en'); } }
/** * @brief Outputs the image to the OutputPage object. * * @param title to generate md5 for filename */ function htmlForImage($title, $type) { global $graphCache, $wgScriptPath; $script = "SemanticProjectGraph.php"; $html = ''; $docRoot = __DIR__ . '/' . $graphCache; $md5 = md5($title); $fileMap = "{$docRoot}{$md5}.map"; if (file_exists($fileMap)) { $map = file_get_contents1($fileMap); $URLpng = "{$wgScriptPath}/extensions/SemanticProjectGraph/{$script}?png={$md5}"; $html = "<DIV><IMG src=\"{$URLpng}\" usemap=\"#map1\" alt=\"{$title}\"><MAP name=\"map1\">{$map}</MAP>"; $html .= "</DIV>"; return $html; } else { return null; } }