PageRenderTime 56ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/webui/google-api/contrib/apiCustomsearchService.php

https://bitbucket.org/sailsdigital/piler-remi
PHP | 488 lines | 408 code | 18 blank | 62 comment | 2 complexity | 4ac15ed9873fabaec58b44067be7bfc7 MD5 | raw file
Possible License(s): GPL-3.0
  1. <?php
  2. /*
  3. * Copyright (c) 2010 Google Inc.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  6. * use this file except in compliance with the License. You may obtain a copy of
  7. * the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  13. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  14. * License for the specific language governing permissions and limitations under
  15. * the License.
  16. */
  17. require_once 'service/apiModel.php';
  18. require_once 'service/apiService.php';
  19. require_once 'service/apiServiceRequest.php';
  20. /**
  21. * The "cse" collection of methods.
  22. * Typical usage is:
  23. * <code>
  24. * $customsearchService = new apiCustomsearchService(...);
  25. * $cse = $customsearchService->cse;
  26. * </code>
  27. */
  28. class CseServiceResource extends apiServiceResource {
  29. /**
  30. * Returns metadata about the search performed, metadata about the custom search engine used for the
  31. * search, and the search results. (cse.list)
  32. *
  33. * @param string $q Query
  34. * @param array $optParams Optional parameters. Valid optional parameters are listed below.
  35. *
  36. * @opt_param string sort The sort expression to apply to the results
  37. * @opt_param string num Number of search results to return
  38. * @opt_param string googlehost The local Google domain to use to perform the search.
  39. * @opt_param string safe Search safety level
  40. * @opt_param string filter Controls turning on or off the duplicate content filter.
  41. * @opt_param string start The index of the first result to return
  42. * @opt_param string cx The custom search engine ID to scope this search query
  43. * @opt_param string lr The language restriction for the search results
  44. * @opt_param string cr Country restrict(s).
  45. * @opt_param string gl Geolocation of end user.
  46. * @opt_param string cref The URL of a linked custom search engine
  47. * @return Search
  48. */
  49. public function listCse($q, $optParams = array()) {
  50. $params = array('q' => $q);
  51. $params = array_merge($params, $optParams);
  52. $data = $this->__call('list', array($params));
  53. if ($this->useObjects()) {
  54. return new Search($data);
  55. } else {
  56. return $data;
  57. }
  58. }
  59. }
  60. /**
  61. * Service definition for Customsearch (v1).
  62. *
  63. * <p>
  64. * Lets you search over a website or collection of websites
  65. * </p>
  66. *
  67. * <p>
  68. * For more information about this service, see the
  69. * <a href="http://code.google.com/apis/customsearch/v1/using_rest.html" target="_blank">API Documentation</a>
  70. * </p>
  71. *
  72. * @author Google, Inc.
  73. */
  74. class apiCustomsearchService extends apiService {
  75. public $cse;
  76. /**
  77. * Constructs the internal representation of the Customsearch service.
  78. *
  79. * @param apiClient apiClient
  80. */
  81. public function __construct(apiClient $apiClient) {
  82. $this->rpcPath = '/rpc';
  83. $this->restBasePath = '/customsearch/';
  84. $this->version = 'v1';
  85. $this->serviceName = 'customsearch';
  86. $apiClient->addService($this->serviceName, $this->version);
  87. $this->cse = new CseServiceResource($this, $this->serviceName, 'cse', json_decode('{"methods": {"list": {"parameters": {"sort": {"type": "string", "location": "query"}, "filter": {"enum": ["0", "1"], "type": "string", "location": "query"}, "cx": {"type": "string", "location": "query"}, "googlehost": {"type": "string", "location": "query"}, "safe": {"default": "off", "enum": ["high", "medium", "off"], "location": "query", "type": "string"}, "q": {"required": true, "type": "string", "location": "query"}, "start": {"type": "string", "location": "query"}, "num": {"default": "10", "type": "string", "location": "query"}, "lr": {"enum": ["lang_ar", "lang_bg", "lang_ca", "lang_cs", "lang_da", "lang_de", "lang_el", "lang_en", "lang_es", "lang_et", "lang_fi", "lang_fr", "lang_hr", "lang_hu", "lang_id", "lang_is", "lang_it", "lang_iw", "lang_ja", "lang_ko", "lang_lt", "lang_lv", "lang_nl", "lang_no", "lang_pl", "lang_pt", "lang_ro", "lang_ru", "lang_sk", "lang_sl", "lang_sr", "lang_sv", "lang_tr", "lang_zh-CN", "lang_zh-TW"], "type": "string", "location": "query"}, "cr": {"type": "string", "location": "query"}, "gl": {"type": "string", "location": "query"}, "cref": {"type": "string", "location": "query"}}, "id": "search.cse.list", "httpMethod": "GET", "path": "v1", "response": {"$ref": "Search"}}}}', true));
  88. }
  89. }
  90. class Context extends apiModel {
  91. protected $__facetsType = 'ContextFacets';
  92. protected $__facetsDataType = 'array';
  93. public $facets;
  94. public $title;
  95. public function setFacets(/* array(ContextFacets) */ $facets) {
  96. $this->assertIsArray($facets, 'ContextFacets', __METHOD__);
  97. $this->facets = $facets;
  98. }
  99. public function getFacets() {
  100. return $this->facets;
  101. }
  102. public function setTitle($title) {
  103. $this->title = $title;
  104. }
  105. public function getTitle() {
  106. return $this->title;
  107. }
  108. }
  109. class ContextFacets extends apiModel {
  110. public $anchor;
  111. public $label;
  112. public function setAnchor($anchor) {
  113. $this->anchor = $anchor;
  114. }
  115. public function getAnchor() {
  116. return $this->anchor;
  117. }
  118. public function setLabel($label) {
  119. $this->label = $label;
  120. }
  121. public function getLabel() {
  122. return $this->label;
  123. }
  124. }
  125. class Promotion extends apiModel {
  126. public $link;
  127. public $displayLink;
  128. protected $__imageType = 'PromotionImage';
  129. protected $__imageDataType = '';
  130. public $image;
  131. protected $__bodyLinesType = 'PromotionBodyLines';
  132. protected $__bodyLinesDataType = 'array';
  133. public $bodyLines;
  134. public $title;
  135. public function setLink($link) {
  136. $this->link = $link;
  137. }
  138. public function getLink() {
  139. return $this->link;
  140. }
  141. public function setDisplayLink($displayLink) {
  142. $this->displayLink = $displayLink;
  143. }
  144. public function getDisplayLink() {
  145. return $this->displayLink;
  146. }
  147. public function setImage(PromotionImage $image) {
  148. $this->image = $image;
  149. }
  150. public function getImage() {
  151. return $this->image;
  152. }
  153. public function setBodyLines(/* array(PromotionBodyLines) */ $bodyLines) {
  154. $this->assertIsArray($bodyLines, 'PromotionBodyLines', __METHOD__);
  155. $this->bodyLines = $bodyLines;
  156. }
  157. public function getBodyLines() {
  158. return $this->bodyLines;
  159. }
  160. public function setTitle($title) {
  161. $this->title = $title;
  162. }
  163. public function getTitle() {
  164. return $this->title;
  165. }
  166. }
  167. class PromotionBodyLines extends apiModel {
  168. public $url;
  169. public $link;
  170. public $title;
  171. public function setUrl($url) {
  172. $this->url = $url;
  173. }
  174. public function getUrl() {
  175. return $this->url;
  176. }
  177. public function setLink($link) {
  178. $this->link = $link;
  179. }
  180. public function getLink() {
  181. return $this->link;
  182. }
  183. public function setTitle($title) {
  184. $this->title = $title;
  185. }
  186. public function getTitle() {
  187. return $this->title;
  188. }
  189. }
  190. class PromotionImage extends apiModel {
  191. public $source;
  192. public $width;
  193. public $height;
  194. public function setSource($source) {
  195. $this->source = $source;
  196. }
  197. public function getSource() {
  198. return $this->source;
  199. }
  200. public function setWidth($width) {
  201. $this->width = $width;
  202. }
  203. public function getWidth() {
  204. return $this->width;
  205. }
  206. public function setHeight($height) {
  207. $this->height = $height;
  208. }
  209. public function getHeight() {
  210. return $this->height;
  211. }
  212. }
  213. class Query extends apiModel {
  214. public $count;
  215. public $sort;
  216. public $outputEncoding;
  217. public $language;
  218. public $title;
  219. public $googleHost;
  220. public $safe;
  221. public $searchTerms;
  222. public $filter;
  223. public $startIndex;
  224. public $cx;
  225. public $startPage;
  226. public $inputEncoding;
  227. public $cr;
  228. public $gl;
  229. public $totalResults;
  230. public $cref;
  231. public function setCount($count) {
  232. $this->count = $count;
  233. }
  234. public function getCount() {
  235. return $this->count;
  236. }
  237. public function setSort($sort) {
  238. $this->sort = $sort;
  239. }
  240. public function getSort() {
  241. return $this->sort;
  242. }
  243. public function setOutputEncoding($outputEncoding) {
  244. $this->outputEncoding = $outputEncoding;
  245. }
  246. public function getOutputEncoding() {
  247. return $this->outputEncoding;
  248. }
  249. public function setLanguage($language) {
  250. $this->language = $language;
  251. }
  252. public function getLanguage() {
  253. return $this->language;
  254. }
  255. public function setTitle($title) {
  256. $this->title = $title;
  257. }
  258. public function getTitle() {
  259. return $this->title;
  260. }
  261. public function setGoogleHost($googleHost) {
  262. $this->googleHost = $googleHost;
  263. }
  264. public function getGoogleHost() {
  265. return $this->googleHost;
  266. }
  267. public function setSafe($safe) {
  268. $this->safe = $safe;
  269. }
  270. public function getSafe() {
  271. return $this->safe;
  272. }
  273. public function setSearchTerms($searchTerms) {
  274. $this->searchTerms = $searchTerms;
  275. }
  276. public function getSearchTerms() {
  277. return $this->searchTerms;
  278. }
  279. public function setFilter($filter) {
  280. $this->filter = $filter;
  281. }
  282. public function getFilter() {
  283. return $this->filter;
  284. }
  285. public function setStartIndex($startIndex) {
  286. $this->startIndex = $startIndex;
  287. }
  288. public function getStartIndex() {
  289. return $this->startIndex;
  290. }
  291. public function setCx($cx) {
  292. $this->cx = $cx;
  293. }
  294. public function getCx() {
  295. return $this->cx;
  296. }
  297. public function setStartPage($startPage) {
  298. $this->startPage = $startPage;
  299. }
  300. public function getStartPage() {
  301. return $this->startPage;
  302. }
  303. public function setInputEncoding($inputEncoding) {
  304. $this->inputEncoding = $inputEncoding;
  305. }
  306. public function getInputEncoding() {
  307. return $this->inputEncoding;
  308. }
  309. public function setCr($cr) {
  310. $this->cr = $cr;
  311. }
  312. public function getCr() {
  313. return $this->cr;
  314. }
  315. public function setGl($gl) {
  316. $this->gl = $gl;
  317. }
  318. public function getGl() {
  319. return $this->gl;
  320. }
  321. public function setTotalResults($totalResults) {
  322. $this->totalResults = $totalResults;
  323. }
  324. public function getTotalResults() {
  325. return $this->totalResults;
  326. }
  327. public function setCref($cref) {
  328. $this->cref = $cref;
  329. }
  330. public function getCref() {
  331. return $this->cref;
  332. }
  333. }
  334. class Result extends apiModel {
  335. public $kind;
  336. public $title;
  337. public $displayLink;
  338. public $cacheId;
  339. public $pagemap;
  340. public $snippet;
  341. public $htmlSnippet;
  342. public $link;
  343. public $htmlTitle;
  344. public function setKind($kind) {
  345. $this->kind = $kind;
  346. }
  347. public function getKind() {
  348. return $this->kind;
  349. }
  350. public function setTitle($title) {
  351. $this->title = $title;
  352. }
  353. public function getTitle() {
  354. return $this->title;
  355. }
  356. public function setDisplayLink($displayLink) {
  357. $this->displayLink = $displayLink;
  358. }
  359. public function getDisplayLink() {
  360. return $this->displayLink;
  361. }
  362. public function setCacheId($cacheId) {
  363. $this->cacheId = $cacheId;
  364. }
  365. public function getCacheId() {
  366. return $this->cacheId;
  367. }
  368. public function setPagemap($pagemap) {
  369. $this->pagemap = $pagemap;
  370. }
  371. public function getPagemap() {
  372. return $this->pagemap;
  373. }
  374. public function setSnippet($snippet) {
  375. $this->snippet = $snippet;
  376. }
  377. public function getSnippet() {
  378. return $this->snippet;
  379. }
  380. public function setHtmlSnippet($htmlSnippet) {
  381. $this->htmlSnippet = $htmlSnippet;
  382. }
  383. public function getHtmlSnippet() {
  384. return $this->htmlSnippet;
  385. }
  386. public function setLink($link) {
  387. $this->link = $link;
  388. }
  389. public function getLink() {
  390. return $this->link;
  391. }
  392. public function setHtmlTitle($htmlTitle) {
  393. $this->htmlTitle = $htmlTitle;
  394. }
  395. public function getHtmlTitle() {
  396. return $this->htmlTitle;
  397. }
  398. }
  399. class Search extends apiModel {
  400. protected $__promotionsType = 'Promotion';
  401. protected $__promotionsDataType = 'array';
  402. public $promotions;
  403. public $kind;
  404. protected $__urlType = 'SearchUrl';
  405. protected $__urlDataType = '';
  406. public $url;
  407. protected $__itemsType = 'Result';
  408. protected $__itemsDataType = 'array';
  409. public $items;
  410. protected $__contextType = 'Context';
  411. protected $__contextDataType = '';
  412. public $context;
  413. protected $__queriesType = 'Query';
  414. protected $__queriesDataType = 'map';
  415. public $queries;
  416. public function setPromotions(/* array(Promotion) */ $promotions) {
  417. $this->assertIsArray($promotions, 'Promotion', __METHOD__);
  418. $this->promotions = $promotions;
  419. }
  420. public function getPromotions() {
  421. return $this->promotions;
  422. }
  423. public function setKind($kind) {
  424. $this->kind = $kind;
  425. }
  426. public function getKind() {
  427. return $this->kind;
  428. }
  429. public function setUrl(SearchUrl $url) {
  430. $this->url = $url;
  431. }
  432. public function getUrl() {
  433. return $this->url;
  434. }
  435. public function setItems(/* array(Result) */ $items) {
  436. $this->assertIsArray($items, 'Result', __METHOD__);
  437. $this->items = $items;
  438. }
  439. public function getItems() {
  440. return $this->items;
  441. }
  442. public function setContext(Context $context) {
  443. $this->context = $context;
  444. }
  445. public function getContext() {
  446. return $this->context;
  447. }
  448. public function setQueries(Query $queries) {
  449. $this->queries = $queries;
  450. }
  451. public function getQueries() {
  452. return $this->queries;
  453. }
  454. }
  455. class SearchUrl extends apiModel {
  456. public $type;
  457. public $template;
  458. public function setType($type) {
  459. $this->type = $type;
  460. }
  461. public function getType() {
  462. return $this->type;
  463. }
  464. public function setTemplate($template) {
  465. $this->template = $template;
  466. }
  467. public function getTemplate() {
  468. return $this->template;
  469. }
  470. }