Assembla home | Assembla project page
 

Changeset 261

Show
Ignore:
Timestamp:
07/04/08 20:32:54 (5 months ago)
Author:
tobias382
Message:

Fixes #33 Modified the Convert plugin to account for bad input and properly format results returned that use scientific notation

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Phergie/Plugin/Convert.php

    r248 r261  
    5353        $xpath = new DomXPath($doc); 
    5454        $result = $xpath->query('//h2/font/b'); 
    55         $text = $result->item(0)->nodeValue; 
    56  
    57         if (empty($text)) { 
    58             $this->doNotice($target, 'Computation error, nothing was returned, perhaps division by zero?'); 
     55        if ($result->length) { 
     56            $children = $result->item(0)->childNodes; 
     57            $text = str_replace(array(chr(195), chr(151)), array('x', ''), $children->item(0)->nodeValue); 
     58            $text .= '^' . $children->item(1)->nodeValue . $children->item(2)->nodeValue; 
     59            $this->doPrivmsg($this->event->getSource(), $target . ': ' . $text); 
    5960        } else { 
    60             $this->doPrivmsg($this->event->getSource(), $target . ': ' . $text); 
     61            $this->doNotice($target, 'Computation error, nothing was returned'); 
    6162        } 
    6263    }