Changeset 647 for plugins/suggestr/trunk/suggestr.plugin.php
- Timestamp:
- 06/27/08 20:44:04 (5 months ago)
- Files:
-
- 1 modified
-
plugins/suggestr/trunk/suggestr.plugin.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
plugins/suggestr/trunk/suggestr.plugin.php
r634 r647 23 23 24 24 public function action_ajax_tag_suggest( $handler ) { 25 $count= 10;26 25 $text= $handler->handler_vars['text']; 27 $tags= array('lol', 'cool', 'lorem', 'ipsum', 'mipsum', 'ripwik', 'tiktk', 'likarick', 'dialect',); 28 $message= _t('No tag suggestions could be found'); 26 $tags= array(); 27 28 $tags = $this->fetch_yahoo_tags($text); 29 29 30 30 $tags = serialize($tags); … … 32 32 $tags = unserialize($tags); 33 33 34 $message= sprintf( '%d tag ' . _n( _t( 'suggestion'), _t( 'suggestions' ), $count ) . ' could be found.', $count ); 34 $count = count($tags); 35 36 if($count == 0) { 37 $message= _t('No tag suggestions could be found'); 38 } else { 39 $message= sprintf( '%d tag ' . _n( _t( 'suggestion'), _t( 'suggestions' ), $count ) . ' could be found.', $count ); 40 } 35 41 36 42 echo json_encode(array('count' => $count, 'tags' => $tags, 'message' => $message)); 43 } 44 45 public function fetch_yahoo_tags( $text ) { 46 $appID = 'UZuNQnrV34En.c9itu77sQrdjp.FQU81t8azZeE5YmWjRkP9wVlPg.CPIc8eLZT68GI-'; 47 $context = $text; 48 49 $request = new RemoteRequest('http://search.yahooapis.com/ContentAnalysisService/V1/termExtraction', 'POST'); 50 $request->set_params(array( 51 'appid' => $appID, 52 'context' => $context 53 )); 54 $request->execute(); 55 56 $response = $request->get_response_body(); 57 58 $xml = new SimpleXMLElement($response); 59 60 $tags= array(); 61 62 foreach($xml->Result as $tag) { 63 $tags[] = strval($tag); 64 } 65 66 return $tags; 67 37 68 } 38 69
