From: Aaron Schulz Date: Thu, 16 Jan 2014 20:25:41 +0000 (-0800) Subject: Removed ZhClient; unused by core and extensions X-Git-Tag: 1.31.0-rc.0~17235^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/password.php?a=commitdiff_plain;h=9f38f56fb5aff2c39981bb8c51d2e99c42d65215;p=lhc%2Fweb%2Fwiklou.git Removed ZhClient; unused by core and extensions Change-Id: Ieda34368b8e1c4a09dc244f47f7e09d943849b1e --- diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index e1f8a14b4d..fd74da7f9b 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -246,7 +246,6 @@ $wgAutoloadLocalClasses = array( 'XmlJsCode' => 'includes/Xml.php', 'XMLReader2' => 'includes/Import.php', 'XmlSelect' => 'includes/Xml.php', - 'ZhClient' => 'includes/ZhClient.php', # includes/actions 'CachedAction' => 'includes/actions/CachedAction.php', diff --git a/includes/ZhClient.php b/includes/ZhClient.php deleted file mode 100644 index c5955aeca7..0000000000 --- a/includes/ZhClient.php +++ /dev/null @@ -1,164 +0,0 @@ -mHost = $host; - $this->mPort = $port; - $this->mConnected = $this->connect(); - } - - /** - * Check if connection to zhdaemon is successful - * - * @return bool - */ - function isconnected() { - return $this->mConnected; - } - - /** - * Establish connection - * - * @access private - * - * @return bool - */ - function connect() { - wfSuppressWarnings(); - $errno = $errstr = ''; - $this->mFP = fsockopen( $this->mHost, $this->mPort, $errno, $errstr, 30 ); - wfRestoreWarnings(); - return !$this->mFP; - } - - /** - * Query the daemon and return the result - * - * @access private - * - * @return string - */ - function query( $request ) { - if ( !$this->mConnected ) { - return false; - } - - fwrite( $this->mFP, $request ); - - $result = fgets( $this->mFP, 1024 ); - - list( $status, $len ) = explode( ' ', $result ); - if ( $status == 'ERROR' ) { - // $len is actually the error code... - print "zhdaemon error $len
\n"; - return false; - } - $bytesread = 0; - $data = ''; - while ( !feof( $this->mFP ) && $bytesread < $len ) { - $str = fread( $this->mFP, $len - $bytesread ); - $bytesread += strlen( $str ); - $data .= $str; - } - // data should be of length $len. otherwise something is wrong - return strlen( $data ) == $len; - } - - /** - * Convert the input to a different language variant - * - * @param string $text input text - * @param string $tolang language variant - * @return string the converted text - */ - function convert( $text, $tolang ) { - $len = strlen( $text ); - $q = "CONV $tolang $len\n$text"; - $result = $this->query( $q ); - if ( !$result ) { - $result = $text; - } - return $result; - } - - /** - * Convert the input to all possible variants - * - * @param string $text input text - * @return array langcode => converted_string - */ - function convertToAllVariants( $text ) { - $len = strlen( $text ); - $q = "CONV ALL $len\n$text"; - $result = $this->query( $q ); - if ( !$result ) { - return false; - } - list( $infoline, $data ) = explode( '|', $result, 2 ); - $info = explode( ';', $infoline ); - $ret = array(); - $i = 0; - foreach ( $info as $variant ) { - list( $code, $len ) = explode( ' ', $variant ); - $ret[strtolower( $code )] = substr( $data, $i, $len ); - $i += $len; - } - return $ret; - } - - /** - * Perform word segmentation - * - * @param string $text input text - * @return string segmented text - */ - function segment( $text ) { - $len = strlen( $text ); - $q = "SEG $len\n$text"; - $result = $this->query( $q ); - if ( !$result ) { // fallback to character based segmentation - $result = $this->segment( $text ); - } - return $result; - } - - /** - * Close the connection - */ - function close() { - fclose( $this->mFP ); - } -}