Changeset 758 for trunk/GoogleSearch

Show
Ignore:
Timestamp:
06/23/08 22:37:23 (17 months ago)
Author:
mpaschal
Message:

Merge changes to GoogleSearch? plugin as shipped in extras/
BugzID: 69005

Location:
trunk/GoogleSearch/plugins/GoogleSearch
Files:
4 added
7 modified

Legend:

Unmodified
Added
Removed
  • trunk/GoogleSearch/plugins/GoogleSearch/GoogleSearch.pl

    r155 r758  
     1# Movable Type (r) Open Source (C) 2005-2008 Six Apart, Ltd. 
     2# This program is distributed under the terms of the 
     3# GNU General Public License, version 2. 
     4# 
     5# $Id: GoogleSearch.pl 1174 2008-01-08 21:02:50Z bchoate $ 
     6 
    17# GoogleSearch plugin for Movable Type 
    28# Author: Six Apart (http://www.sixapart.com) 
    3 # Released under the Artistic License 
    4 # 
    5 # $Id: GoogleSearch.pl 32163 2006-06-23 14:05:22Z ytakayama $ 
     9# Released under the Artistic and GPLv2 License 
    610 
    711package MT::Plugin::GoogleSearch; 
  • trunk/GoogleSearch/plugins/GoogleSearch/lib/GoogleSearch/L10N.pm

    r44 r758  
     1# Movable Type (r) Open Source (C) 2001-2008 Six Apart, Ltd. 
     2# This program is distributed under the terms of the 
     3# GNU General Public License, version 2. 
     4# 
     5# $Id: L10N.pm 1174 2008-01-08 21:02:50Z bchoate $ 
     6 
    17# GoogleSearch plugin for Movable Type 
    28# Author: Six Apart (http://www.sixapart.com) 
    3 # Released under the Artistic License 
    4 # 
    5 # $Id: L10N.pm 30952 2006-06-13 09:20:43Z jallen $ 
     9# Released under the Artistic and GPLv2 License 
    610 
    711package GoogleSearch::L10N; 
  • trunk/GoogleSearch/plugins/GoogleSearch/lib/GoogleSearch/L10N/en_us.pm

    r44 r758  
     1# Movable Type (r) Open Source (C) 2001-2008 Six Apart, Ltd. 
     2# This program is distributed under the terms of the 
     3# GNU General Public License, version 2. 
     4# 
     5# $Id: en_us.pm 1174 2008-01-08 21:02:50Z bchoate $ 
     6 
    17# GoogleSearch plugin for Movable Type 
    28# Author: Six Apart (http://www.sixapart.com) 
    3 # Released under the Artistic License 
    4 # 
    5 # $Id: en_us.pm 30952 2006-06-13 09:20:43Z jallen $ 
     9# Released under the Artistic and GPLv2 License 
    610 
    711package GoogleSearch::L10N::en_us; 
  • trunk/GoogleSearch/plugins/GoogleSearch/lib/GoogleSearch/L10N/ja.pm

    r44 r758  
     1# Movable Type (r) Open Source (C) 2001-2008 Six Apart, Ltd. 
     2# This program is distributed under the terms of the 
     3# GNU General Public License, version 2. 
     4# 
     5# $Id: ja.pm 1174 2008-01-08 21:02:50Z bchoate $ 
     6 
    17# GoogleSearch plugin for Movable Type 
    28# Author: Six Apart (http://www.sixapart.com) 
    3 # Released under the Artistic License 
    4 # 
    5 # $Id: ja.pm 30952 2006-06-13 09:20:43Z jallen $ 
     9# Released under the Artistic and GPLv2 License 
    610 
    711package GoogleSearch::L10N::ja; 
  • trunk/GoogleSearch/plugins/GoogleSearch/php/block.mtgooglesearch.php

    r757 r758  
    11<?php 
    2 function smarty_block_MTGoogleSearch($args, $content, &$ctx, &$repeat) { 
     2# Movable Type (r) Open Source (C) 2001-2008 Six Apart, Ltd. 
     3# This program is distributed under the terms of the 
     4# GNU General Public License, version 2. 
     5# 
     6# $Id$ 
     7 
     8function smarty_block_mtgooglesearch($args, $content, &$ctx, &$repeat) { 
    39    $localvars = array('google_result_item', 'google_results', '_result_count'); 
    410    if (!isset($content)) { 
     
    2430            $query = $entry['entry_title']; 
    2531        } elseif ($args['excerpt']) { 
    26             $query = smarty_function_MTEntryExcerpt(array(), $ctx); 
     32            $query = smarty_function_mtentryexcerpt(array(), $ctx); 
    2733        } elseif ($args['keywords']) { 
    2834            $query = $entry['entry_keywords']; 
     35        } elseif ($args['tags']) { 
     36            $query = ""; 
     37            $tags = $ctx->mt->db->fetch_entry_tags(array('entry_id' => $entry['entry_id'], 'blog_id' => $blog->id)); 
     38            if (isset($tags)) { 
     39                foreach($tags as $tag) { 
     40                    $query .= '"'.$tag['tag_name'].'" '; 
     41                } 
     42            } 
    2943        } else { 
    3044            $query = $args['query']; 
    3145        } 
    3246 
     47        if ($query == '') { 
     48            $query = $entry['entry_title']; 
     49        } 
     50 
    3351        global $mt; 
    34         $lang = $mt->config['DefaultLanguage']; 
     52        $lang = $mt->config('DefaultLanguage'); 
    3553        if ($lang == 'ja') { 
    36             $charset = $mt->config['PublishCharset']; 
     54            $charset = $mt->config('PublishCharset'); 
    3755            $query = mb_convert_encoding($query, 'utf-8', $charset); 
    3856        } 
     
    5270            } 
    5371            else { 
    54                 return $ctx->error('You need a Google API key to use &lt;MTGoogleSearch>'); 
     72                return $ctx->error('You need a Google API key to use &lt;mtgooglesearch>'); 
    5573            } 
    5674        } 
    5775 
    58         $wsdl = new SOAP_WSDL($mt->config['PHPDir'].DIRECTORY_SEPARATOR."plugins".DIRECTORY_SEPARATOR."GoogleSearch.wsdl"); 
     76        $wsdl = new SOAP_WSDL(dirname(__FILE__).DIRECTORY_SEPARATOR."GoogleSearch.wsdl"); 
    5977        $proxy = $wsdl->getProxy(); 
    6078        $result = $proxy->doGoogleSearch( 
     
    7896        } else { 
    7997            // We have proper search results 
    80             foreach ($result->resultElements as $index => $item) { 
    81                 $summary = $item->summary; 
    82                 $url = $item->URL; 
    83                 $snippet = $item->snippet; 
    84                 $title = $item->title; 
     98            if ($result->resultElements) { 
     99                foreach ($result->resultElements as $index => $item) { 
     100                    $summary = $item->summary; 
     101                    $url = $item->URL; 
     102                    $snippet = $item->snippet; 
     103                    $title = $item->title; 
    85104                 
    86                 $set = array( 
    87                     'summary' => $summary, 
    88                     'URL' => $url, 
    89                     'snippet' => $snippet, 
    90                     'title' => $title 
    91                 ); 
     105                    $set = array( 
     106                        'summary' => $summary, 
     107                        'URL' => $url, 
     108                        'snippet' => $snippet, 
     109                        'title' => $title 
     110                    ); 
    92111                 
    93                 $google_results[] = $set; 
     112                    $google_results[] = $set; 
     113                } 
    94114            } 
    95115            $ctx->stash('google_results', $google_results); 
  • trunk/GoogleSearch/plugins/GoogleSearch/php/function.mtgooglesearchresult.php

    r757 r758  
    11<?php 
    2 function smarty_function_MTGoogleSearchResult($args, &$ctx) { 
     2# Movable Type (r) Open Source (C) 2001-2008 Six Apart, Ltd. 
     3# This program is distributed under the terms of the 
     4# GNU General Public License, version 2. 
     5# 
     6# $Id$ 
     7 
     8function smarty_function_mtgooglesearchresult($args, &$ctx) { 
    39    $result = $ctx->stash('google_result_item'); 
    410    $prop = $args['property']; 
     
    814 
    915    global $mt; 
    10     $lang = $mt->config['DefaultLanguage']; 
     16    $lang = $mt->config('DefaultLanguage'); 
    1117    if ($lang == 'ja') { 
    12         $charset = $mt->config['PublishCharset']; 
     18        $charset = $mt->config('PublishCharset'); 
    1319        $s = mb_convert_encoding($result[$prop], $charset, 'utf-8'); 
    1420    }else{ 
  • trunk/GoogleSearch/plugins/GoogleSearch/tmpl/config.tmpl

    r93 r758  
    1 <div class="setting"> 
    2     <div class="label"> 
    3         <label for="google_api_key"><MT_TRANS phrase="Google API Key:"></label> 
    4     </div> 
    5     <div class="field"> 
     1    <mtapp:setting 
     2        id="google_api_key" 
     3        label="<__trans phrase="Google API Key">" 
     4        hint="<__trans phrase="If you wish to use any of the Google API functionality, you will need a Google API key. Paste it in here.">"> 
    65        <input type="text" name="google_api_key" id="google_api_key" value="<TMPL_VAR NAME=GOOGLE_API_KEY ESCAPE=HTML>" /> 
    7         <p><MT_TRANS phrase="If you wish to use any of the Google API functionality, you will need a Google API key. Paste it in here."></p> 
    8     </div>  
    9 </div> 
     6    </mtapp:setting>