PageRenderTime 66ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/platforms.class.php

https://github.com/fiftyandfifty/teleportd-wordpress-plugin
PHP | 585 lines | 562 code | 21 blank | 2 comment | 16 complexity | 07f227a92774fe308bd563cf299c6ed0 MD5 | raw file
  1. <?php
  2. class PLATFORM_BASE {
  3. var $pic_sha;
  4. var $pic_mysqldate;
  5. var $pic_handle;
  6. var $pic_handle_platform;
  7. var $pic_handle_avatar;
  8. var $pic_username;
  9. var $pic_thumb;
  10. var $pic_full;
  11. var $pic_loc;
  12. var $pic_platform;
  13. var $pic_strs;
  14. var $pic_tags;
  15. var $pic_full_title;
  16. var $pic_clean_title;
  17. var $pic_post_content;
  18. var $vid_embed;
  19. var $next_page;
  20. function unset_variables(){
  21. unset($this->pic_thumb);
  22. unset($this->pic_full);
  23. unset($this->pic_tags);
  24. unset($this->pic_loc);
  25. }
  26. function strip_urls($url) {
  27. $U = explode(' ',$url);
  28. $W =array();
  29. foreach ($U as $k => $u) {
  30. if (stristr($u,'http') || (count(explode('.',$u)) > 1)) {
  31. unset($U[$k]);
  32. return $this->strip_urls( implode(' ',$U));
  33. }
  34. }
  35. return implode(' ',$U);
  36. }
  37. function get_cron_intervals(){
  38. return array(
  39. 'manual' => 'manual',
  40. 'hourly' => 'hourly',
  41. 'twicedaily' => 'twicedaily',
  42. 'daily' => 'daily'
  43. );
  44. }
  45. }
  46. class PLATFORM_TWITTER Extends PLATFORM_BASE {
  47. function parse_response($response_object, $plugin_options){
  48. $this->unset_variables();
  49. if( is_array($response_object->entities->media) ){
  50. $this->pic_thumb = $response_object->entities->media[0]->media_url . ":thumb";
  51. $this->pic_full = $response_object->entities->media[0]->media_url;
  52. }
  53. else{
  54. $no_pic = $response_object->text;
  55. }
  56. if( $plugin_options['only_with_pics'] == 'Yes' && $no_pic ){
  57. if($this->debug){print "Skip no pic \n";}
  58. return false;
  59. }
  60. // remove hash tags from title and create tags with them
  61. $pattern = "/\#([a-z1-9^\S])+/";
  62. preg_match_all($pattern, $response_object->text, $hashtags_in_title);
  63. $clean_title = $this->strip_urls(preg_replace($pattern, "", $response_object->text));
  64. $this->pic_strs = str_replace("#", "", $hashtags_in_title[0]);
  65. $this->pic_mysqldate = date( 'Y-m-d H:i:s', strtotime($response_object->created_at) );
  66. $this->pic_handle = $response_object->from_user;
  67. $this->pic_username = $response_object->from_user_name;
  68. $this->pic_sha = $response_object->id_str;
  69. $this->pic_handle_avatar = $response_object->profile_image_url;
  70. $this->pic_handle_platform = 'twitter';
  71. $this->pic_platform = 'twitter';
  72. if( $response_object->geo != '' ){
  73. $this->pic_loc = implode(",", $response_object->geo);
  74. }
  75. if($response_object->hashtags[0]){
  76. $this->pic_tags = array();
  77. foreach($response_object->entities->hashtags as $tag){
  78. array_push($this->pic_tags, $tag->text);
  79. }
  80. }
  81. $this->pic_full_title = $response_object->text;
  82. $this->pic_clean_title = $no_pic ? $no_pic : (trim($clean_title) ? $clean_title : $this->pic_handle . ' using ' . $this->pic_handle_platform);
  83. return true;
  84. }
  85. function clean_response($response_object){
  86. return $response_object->results;
  87. }
  88. function get_next_page($response_object, $last_page){
  89. if(stristr($last_page, "page=")){
  90. $split = split("&", $last_page);
  91. foreach($split as $num => $url_piece){
  92. if(substr($url_piece, 0, 4) == 'page'){
  93. $split2 = split("=", $url_piece);
  94. $newurl .= 'page=' . ($split2[1] + 1) . '&';
  95. }else{
  96. $newurl .= $url_piece . '&';
  97. }
  98. }
  99. }
  100. else{
  101. $newurl = $last_page . '&page=2';
  102. }
  103. $this->next_page = $newurl;
  104. }
  105. function admin_form($cache_settings, $cache_num, $api_options){
  106. ?>
  107. <div class="widgets-holder-wrap">
  108. <div class="sidebar-name">
  109. <div class="sidebar-name-arrow"><br></div>
  110. <h3><?php print ($cache_settings[search_name] ? $cache_settings[search_name] : $cache_settings['api_selected']) ?> <span id="removing-widget">Deactivate <span></span></span></h3>
  111. </div>
  112. <div class="widget-holder">
  113. <table id="all-plugins-table" class="widefat">
  114. <tbody class="plugins">
  115. <tr>
  116. <td>
  117. <label for="">API: </label>
  118. <select name="teleportd_cache[<?php print $cache_num ?>][api_selected]" class="disable_onchange" >
  119. <?php foreach( $api_options as $api => $array): ?>
  120. <option value="<?php print $api ?>" <?php selected( $cache_settings[api_selected], $api ); ?>><?php print $api ?></option>
  121. <?php endforeach; ?>
  122. </select>
  123. <label for="">API Key (not needed) </label>
  124. <!-- a class="button-secondary" id="test_api" href="javascript:test_api(<?php print $cache_num ?>);">Test API</a> <div id="test_response"></div -->
  125. </td>
  126. <th scope="row">
  127. </th>
  128. </tr>
  129. <tr class="active">
  130. <td class="desc">
  131. <p><input type="text" name="teleportd_cache[<?php print $cache_num ?>][search_name]" value="<?php print ($cache_settings[search_name] ? $cache_settings[search_name] : $cache_settings['api_selected']) ?>" class="regular-text disable_onchange" /></p>
  132. </td>
  133. <th scope="row">
  134. <label for="">Search Name</label><br/>
  135. <code>Name this search combination, and we'll create a category for them</code>
  136. </th>
  137. </tr>
  138. <tr class="active">
  139. <td class="desc">
  140. <select name="teleportd_cache[<?php print $cache_num ?>][only_with_pics]" class="disable_onchange" >
  141. <option value="No" <?php selected( $cache_settings[only_with_pics], 'No' ); ?>>No</option>
  142. <option value="Yes" <?php selected( $cache_settings[only_with_pics], 'Yes' ); ?>>Yes</option>
  143. </select>
  144. </td>
  145. <th scope="row">
  146. <label for="">Only Grab Tweets with Pics</label><br/>
  147. <code>Skip text-only tweets</code>
  148. </th>
  149. </tr>
  150. <tr class="active">
  151. <td class="desc">
  152. <select name="teleportd_cache[<?php print $cache_num ?>][skip_retweets]" class="disable_onchange" >
  153. <option value="No" <?php selected( $cache_settings[skip_retweets], 'No' ); ?>>No</option>
  154. <option value="Yes" <?php selected( $cache_settings[skip_retweets], 'Yes' ); ?>>Yes</option>
  155. </select>
  156. </td>
  157. <th scope="row">
  158. <label for="">Skip Retweets</label><br/>
  159. <code>Skip duplicate tweets that are (we 'RT' in the subject)</code>
  160. </th>
  161. </tr>
  162. <tr class="active">
  163. <td class="desc">
  164. <p><input type="text" name="teleportd_cache[<?php print $cache_num ?>][string]" value="<?php print $cache_settings[string] ?>" class="regular-text disable_onchange" /></p>
  165. </td>
  166. <th scope="row">
  167. <label for="">Search String</label><br/>
  168. <code>Textual search based on tweet contents.</code><br />
  169. <code>Supports: single word, multi word, tag (#***), mentions (@***), negate (-***)</code>
  170. <code><a href="https://dev.twitter.com/docs/using-search" target="_blank">more search options</a>
  171. </th>
  172. </tr>
  173. <tr class="active">
  174. <td class="desc">
  175. <p><input type="text" name="teleportd_cache[<?php print $cache_num ?>][period]" value="<?php print $cache_settings[period] ?>" class="regular-text disable_onchange" /></p>
  176. </td>
  177. <th scope="row">
  178. <label for="">Until</label><br/>
  179. <code>Returns tweets generated before the given date.</code><br />
  180. <code>Date should be formatted as YYYY-MM-DD</code>
  181. </th>
  182. </tr>
  183. <tr class="active">
  184. <td class="desc">
  185. <p><input type="text" name="teleportd_cache[<?php print $cache_num ?>][location]" value="<?php print $cache_settings[location] ?>" class="regular-text disable_onchange" /></p>
  186. </td>
  187. <th scope="row">
  188. <label for="">Location</label><br/>
  189. <code>[37.781157, -122.398720, 1mi]</code><br />
  190. <code><a href="http://itouchmap.com/latlong.html" target="_blank">Find a Lat/Lon</a>
  191. </th>
  192. </tr>
  193. <tr>
  194. <td class="desc">
  195. <?php $cron_intervals = $this->get_cron_intervals(); ?>
  196. <select name="teleportd_cache[<?php print $cache_num ?>][cron_interval]" >
  197. <?php foreach( $cron_intervals as $type): ?>
  198. <option value="<?php print $type ?>" <?php selected( $cache_settings[cron_interval], $type ); ?>><?php print $type ?></option>
  199. <?php endforeach; ?>
  200. </select>
  201. </td>
  202. <th scope="row">
  203. <label for="">Cron Interval</label>
  204. </th>
  205. </tr>
  206. </tbody>
  207. <tfoot>
  208. <tr>
  209. <th class="manage-column" scope="col">
  210. <p><a class="button-secondary" id="run_manually" href="javascript:run_manually(<?php print $cache_num ?>);">Run This Query Manually</a> <input type=checkbox value=true class=debug> <small>debug to javascript console</small> <div id="run_manually_response"></div></p>
  211. </th>
  212. <th class="manage-column" scope="col"> <div class="remove-div"><a href="javascript:delete_an_api(<?php print $cache_num ?>);" class="widget-control-remove">Remove</a></div> </th>
  213. </tr>
  214. </tfoot>
  215. </table>
  216. </div><!-- .widget-holder -->
  217. </div><!-- .widgets-holder-wrap -->
  218. <div style="width:100%;height:10px"></div>
  219. <?php
  220. }
  221. }
  222. class PLATFORM_TELEPORTD Extends PLATFORM_BASE {
  223. function parse_response($response_object, $plugin_options){
  224. $this->unset_variables();
  225. $this->pic_sha = $response_object->sha;
  226. $this->pic_mysqldate = date( 'Y-m-d H:i:s', $response_object->date );
  227. $this->pic_handle = $response_object->user->handle;
  228. $this->pic_handle_platform = $response_object->user->src;
  229. $this->pic_handle_avatar = $response_object->user->pic;
  230. $this->pic_username = $response_object->user->name;
  231. if( $response_object->thumb ){
  232. $this->pic_thumb = $response_object->thumb;
  233. }
  234. if( $response_object->full ){
  235. $this->pic_full = $response_object->full;
  236. }
  237. $this->pic_loc = implode(",", $response_object->loc);
  238. $this->pic_platform = $response_object->src;
  239. $this->pic_strs = $response_object->qidx->strs;
  240. $this->pic_tags = $response_object->qidx->tags;
  241. $this->pic_full_title = implode(" ", $response_object->qidx->strs) . " " . implode(" $", $response_object->qidx->tags);
  242. $this->pic_clean_title = trim($clean_title) != '' ? $clean_title : $this->pic_handle . ' using ' . $this->pic_handle_platform;
  243. return true;
  244. }
  245. function clean_response($response_object){
  246. return $response_object->results;
  247. }
  248. function get_next_page($response_object, $last_page){
  249. $this->next_page = '';
  250. }
  251. function admin_form($cache_settings, $cache_num, $api_options){
  252. ?>
  253. <div class="widgets-holder-wrap">
  254. <div class="sidebar-name">
  255. <div class="sidebar-name-arrow"><br></div>
  256. <h3><?php print ($cache_settings[search_name] ? $cache_settings[search_name] : $cache_settings['api_selected']) ?> <span id="removing-widget">Deactivate <span></span></span></h3>
  257. </div>
  258. <div class="widget-holder">
  259. <table id="all-plugins-table" class="widefat">
  260. <tbody class="plugins">
  261. <tr>
  262. <td>
  263. <label for="">API: </label>
  264. <select name="teleportd_cache[<?php print $cache_num ?>][api_selected]" class="disable_onchange" >
  265. <?php foreach( $api_options as $api => $array): ?>
  266. <option value="<?php print $api ?>" <?php selected( $cache_settings[api_selected], $api ); ?>><?php print $api ?></option>
  267. <?php endforeach; ?>
  268. </select>
  269. <label for="">API Key: </label>
  270. <input type="text" name="teleportd_cache[<?php print $cache_num ?>][api_authentication]" value="<?php print $cache_settings[api_authentication] ?>" class="regular-text disable_onchange" id="teleportd_api" />
  271. <!-- a class="button-secondary" id="test_api" href="javascript:test_api(<?php print $cache_num ?>);">Test API</a> <div id="test_response"></div -->
  272. </td>
  273. <th scope="row">
  274. </th>
  275. </tr>
  276. <tr class="active">
  277. <td class="desc">
  278. <p><input type="text" name="teleportd_cache[<?php print $cache_num ?>][search_name]" value="<?php print ($cache_settings[search_name] ? $cache_settings[search_name] : $cache_settings['api_selected']) ?>" class="regular-text disable_onchange" /></p>
  279. </td>
  280. <th scope="row">
  281. <label for="">Search Name</label><br/>
  282. <code>Name this search combination, and we'll create a category for them</code>
  283. </th>
  284. </tr>
  285. <tr class="active">
  286. <td class="desc">
  287. <p><input type="text" name="teleportd_cache[<?php print $cache_num ?>][string]" value="<?php print $cache_settings[string] ?>" class="regular-text disable_onchange" /></p>
  288. </td>
  289. <th scope="row">
  290. <label for="">String</label><br/>
  291. <code>Textual search based on picture comments.</code><br />
  292. <code>Supports: single word, multi word, tag (#***), user (usr:***), source (src:***)</code>
  293. </th>
  294. </tr>
  295. <tr class="active">
  296. <td class="desc">
  297. <p><input type="text" name="teleportd_cache[<?php print $cache_num ?>][period]" value="<?php print $cache_settings[period] ?>" class="regular-text disable_onchange" /></p>
  298. </td>
  299. <th scope="row">
  300. <label for="">Period</label><br/>
  301. <code>Filter results based on time. Array representation of begin, end.</code><br />
  302. <code>Historical data: 20 days</code>
  303. <code>unit: POSIX time</code>
  304. </th>
  305. </tr>
  306. <tr class="active">
  307. <td class="desc">
  308. <p><input type="text" name="teleportd_cache[<?php print $cache_num ?>][location]" value="<?php print $cache_settings[location] ?>" class="regular-text disable_onchange" /></p>
  309. </td>
  310. <th scope="row">
  311. <label for="">Location</label><br/>
  312. <code>[34.19, -119.49, 5.0, 3.0]</code><br />
  313. <code><a href="http://itouchmap.com/latlong.html" target="_blank">Find a Lat/Lon</a>
  314. </th>
  315. </tr>
  316. <tr>
  317. <td class="desc">
  318. <?php $cron_intervals = $this->get_cron_intervals(); ?>
  319. <select name="teleportd_cache[<?php print $cache_num ?>][cron_interval]" >
  320. <?php foreach( $cron_intervals as $type): ?>
  321. <option value="<?php print $type ?>" <?php selected( $cache_settings[cron_interval], $type ); ?>><?php print $type ?></option>
  322. <?php endforeach; ?>
  323. </select>
  324. </td>
  325. <th scope="row">
  326. <label for="">Cron Interval</label>
  327. </th>
  328. </tr>
  329. </tbody>
  330. <tfoot>
  331. <tr>
  332. <th class="manage-column" scope="col">
  333. <p><a class="button-secondary" id="run_manually" href="javascript:run_manually(<?php print $cache_num ?>);">Run This Query Manually</a> <input type=checkbox value=true class=debug> <small>debug to javascript console</small> <div id="run_manually_response"></div></p>
  334. </th>
  335. <th class="manage-column" scope="col"> <div class="remove-div"><a href="javascript:delete_an_api(<?php print $cache_num ?>);" class="widget-control-remove">Remove</a></div> </th>
  336. </tr>
  337. </tfoot>
  338. </table>
  339. </div><!-- .widget-holder -->
  340. </div><!-- .widgets-holder-wrap -->
  341. <div style="width:100%;height:10px"></div>
  342. <?php
  343. }
  344. }
  345. class PLATFORM_INSTAGRAM Extends PLATFORM_BASE {
  346. function parse_response($response_object, $plugin_options){
  347. $this->unset_variables();
  348. // remove hash tags from title and create tags with them
  349. $pattern = "/\#([a-z1-9^\S])+/";
  350. preg_match_all($pattern, $response_object->caption->text, $hashtags_in_title);
  351. $clean_title = preg_replace($pattern, "", $response_object->caption->text);
  352. $this->pic_tags = $response_object->tags;
  353. $this->pic_loc = $response_object->location->latitude . "," . $response_object->location->longitude;
  354. $this->pic_strs = str_replace("#", "", $hashtags_in_title[0]);
  355. $this->pic_mysqldate = date( 'Y-m-d H:i:s', $response_object->created_time );
  356. $this->pic_thumb = $response_object->images->thumbnail->url;
  357. $this->pic_full = $response_object->images->standard_resolution->url;
  358. $this->pic_sha = $response_object->id;
  359. $this->pic_handle_avatar = $response_object->user->profile_picture;
  360. $this->pic_handle = $response_object->user->username;
  361. $this->pic_handle_platform = 'instagram';
  362. $this->pic_username = $response_object->user->full_name;
  363. $this->pic_platform = 'instagram';
  364. $this->pic_full_title = $response_object->caption->text;
  365. $this->pic_clean_title = trim($clean_title) != '' ? $clean_title : $this->pic_handle . ' using ' . $this->pic_handle_platform;
  366. return true;
  367. }
  368. function clean_response($response_object){
  369. return $response_object->data;
  370. }
  371. function get_next_page($response_object, $last_page){
  372. $this->next_page = $response_object->pagination->next_url;
  373. }
  374. function admin_form($cache_settings, $cache_num, $api_options){
  375. ?>
  376. <div class="widgets-holder-wrap">
  377. <div class="sidebar-name">
  378. <div class="sidebar-name-arrow"><br></div>
  379. <h3><?php print ($cache_settings[search_name] ? $cache_settings[search_name] : $cache_settings['api_selected']) ?> <span id="removing-widget">Deactivate <span></span></span></h3>
  380. </div>
  381. <div class="widget-holder">
  382. <table id="all-plugins-table" class="widefat">
  383. <tbody class="plugins">
  384. <tr>
  385. <td>
  386. <label for="">API: </label>
  387. <select name="teleportd_cache[<?php print $cache_num ?>][api_selected]" class="disable_onchange" >
  388. <?php foreach( $api_options as $api => $array): ?>
  389. <option value="<?php print $api ?>" <?php selected( $cache_settings[api_selected], $api ); ?>><?php print $api ?></option>
  390. <?php endforeach; ?>
  391. </select>
  392. <label for="">Client ID: </label>
  393. <input type="text" name="teleportd_cache[<?php print $cache_num ?>][api_authentication]" value="<?php print $cache_settings[api_authentication] ?>" class="regular-text disable_onchange" id="teleportd_api" />
  394. <!-- a class="button-secondary" id="test_api" href="javascript:test_api(<?php print $cache_num ?>);">Test API</a> <div id="test_response"></div -->
  395. </td>
  396. <th scope="row">
  397. </th>
  398. </tr>
  399. <tr class="active">
  400. <td class="desc">
  401. <p><input type="text" name="teleportd_cache[<?php print $cache_num ?>][search_name]" value="<?php print ($cache_settings[search_name] ? $cache_settings[search_name] : $cache_settings['api_selected']) ?>" class="regular-text disable_onchange" /></p>
  402. </td>
  403. <th scope="row">
  404. <label for="">Search Name</label><br/>
  405. <code>Name this search combination, and we'll create a category for them</code>
  406. </th>
  407. </tr>
  408. <tr class="active">
  409. <td class="desc">
  410. <p><input type="text" name="teleportd_cache[<?php print $cache_num ?>][string]" value="<?php print $cache_settings[string] ?>" class="regular-text disable_onchange" /></p>
  411. </td>
  412. <th scope="row">
  413. <label for="">Tag</label><br/>
  414. <code>Textual search based on picture comments.</code><br />
  415. <code>Supports: single word (#***)</code>
  416. </th>
  417. </tr>
  418. <tr>
  419. <td class="desc">
  420. <?php $cron_intervals = $this->get_cron_intervals(); ?>
  421. <select name="teleportd_cache[<?php print $cache_num ?>][cron_interval]" >
  422. <?php foreach( $cron_intervals as $type): ?>
  423. <option value="<?php print $type ?>" <?php selected( $cache_settings[cron_interval], $type ); ?>><?php print $type ?></option>
  424. <?php endforeach; ?>
  425. </select>
  426. </td>
  427. <th scope="row">
  428. <label for="">Cron Interval</label>
  429. </th>
  430. </tr>
  431. </tbody>
  432. <tfoot>
  433. <tr>
  434. <th class="manage-column" scope="col">
  435. <p><a class="button-secondary" id="run_manually" href="javascript:run_manually(<?php print $cache_num ?>);">Run This Query Manually</a> <input type=checkbox value=true class=debug> <small>debug to javascript console</small> <div id="run_manually_response"></div></p>
  436. </th>
  437. <th class="manage-column" scope="col"> <div class="remove-div"><a href="javascript:delete_an_api(<?php print $cache_num ?>);" class="widget-control-remove">Remove</a></div> </th>
  438. </tr>
  439. </tfoot>
  440. </table>
  441. </div><!-- .widget-holder -->
  442. </div><!-- .widgets-holder-wrap -->
  443. <div style="width:100%;height:10px"></div>
  444. <?php
  445. }
  446. }
  447. class PLATFORM_YOUTUBE Extends PLATFORM_BASE {
  448. function parse_response($response_object, $plugin_options){
  449. $this->unset_variables();
  450. $date_split = split("T", $response_object->uploaded);
  451. $this->pic_mysqldate = date( $date_split[0] . substr(0, 8, $date_split[1]) );
  452. $this->pic_tags = $response_object->tags;
  453. // $this->pic_loc = $response_object->location->latitude . "," . $response_object->location->longitude;
  454. // $this->pic_strs = str_replace("#", "", $hashtags_in_title[0]);
  455. $this->pic_thumb = $response_object->thumbnail->sqDefault;
  456. $this->pic_full = $response_object->thumbnail->hqDefault;
  457. $this->pic_sha = $response_object->id;
  458. // $this->pic_handle_avatar = $response_object->user->profile_picture;
  459. $this->pic_handle = $response_object->uploader;
  460. $this->pic_handle_platform = 'youtube';
  461. $this->pic_username = $response_object->uploader;
  462. $this->pic_platform = 'youtube';
  463. $this->pic_full_title = $response_object->title;
  464. $this->pic_clean_title = $response_object->title;
  465. $this->pic_post_content = $response_object->description;
  466. $this->vid_embed = $response_object->player->default;
  467. return true;
  468. }
  469. function clean_response($response_object){
  470. return $response_object->data->items;
  471. }
  472. function get_next_page($response_object, $last_page){
  473. if(stristr($last_page, "start-index=")){
  474. $split = split("&", $last_page);
  475. foreach($split as $num => $url_piece){
  476. if(substr($url_piece, 0, 11) == 'start-index'){
  477. $split2 = split("=", $url_piece);
  478. //TODO sniff for the max-index, dont hardcode 50 here
  479. $newurl .= 'start-index=' . ($split2[1] + 50) . '&';
  480. }else{
  481. $newurl .= $url_piece . '&';
  482. }
  483. }
  484. }
  485. else{
  486. $newurl = $last_page . '&start-index=51';
  487. }
  488. $this->next_page = $newurl;
  489. }
  490. function admin_form($cache_settings, $cache_num, $api_options){
  491. ?>
  492. <div class="widgets-holder-wrap">
  493. <div class="sidebar-name">
  494. <div class="sidebar-name-arrow"><br></div>
  495. <h3><?php print ($cache_settings[search_name] ? $cache_settings[search_name] : $cache_settings['api_selected']) ?> <span id="removing-widget">Deactivate <span></span></span></h3>
  496. </div>
  497. <div class="widget-holder">
  498. <table id="all-plugins-table" class="widefat">
  499. <tbody class="plugins">
  500. <tr>
  501. <td>
  502. <label for="">API: </label>
  503. <select name="teleportd_cache[<?php print $cache_num ?>][api_selected]" class="disable_onchange" >
  504. <?php foreach( $api_options as $api => $array): ?>
  505. <option value="<?php print $api ?>" <?php selected( $cache_settings[api_selected], $api ); ?>><?php print $api ?></option>
  506. <?php endforeach; ?>
  507. </select>
  508. <!-- a class="button-secondary" id="test_api" href="javascript:test_api(<?php print $cache_num ?>);">Test API</a> <div id="test_response"></div -->
  509. </td>
  510. <th scope="row">
  511. </th>
  512. </tr>
  513. <tr class="active">
  514. <td class="desc">
  515. <p><input type="text" name="teleportd_cache[<?php print $cache_num ?>][search_name]" value="<?php print ($cache_settings[search_name] ? $cache_settings[search_name] : $cache_settings['api_selected']) ?>" class="regular-text disable_onchange" /></p>
  516. </td>
  517. <th scope="row">
  518. <label for="">Search Name</label><br/>
  519. <code>Name this search combination, and we'll create a category for them</code>
  520. </th>
  521. </tr>
  522. <tr class="active">
  523. <td class="desc">
  524. <p><input type="text" name="teleportd_cache[<?php print $cache_num ?>][string]" value="<?php print $cache_settings[string] ?>" class="regular-text disable_onchange" /></p>
  525. </td>
  526. <th scope="row">
  527. <label for="">Search Term</label><br/>
  528. <code>Textual search based on video tags & title.</code><br />
  529. </th>
  530. </tr>
  531. <tr>
  532. <td class="desc">
  533. <?php $cron_intervals = $this->get_cron_intervals(); ?>
  534. <select name="teleportd_cache[<?php print $cache_num ?>][cron_interval]" >
  535. <?php foreach( $cron_intervals as $type): ?>
  536. <option value="<?php print $type ?>" <?php selected( $cache_settings[cron_interval], $type ); ?>><?php print $type ?></option>
  537. <?php endforeach; ?>
  538. </select>
  539. </td>
  540. <th scope="row">
  541. <label for="">Cron Interval</label>
  542. </th>
  543. </tr>
  544. </tbody>
  545. <tfoot>
  546. <tr>
  547. <th class="manage-column" scope="col">
  548. <p><a class="button-secondary" id="run_manually" href="javascript:run_manually(<?php print $cache_num ?>);">Run This Query Manually</a> <input type=checkbox value=true class=debug> <small>debug to javascript console</small> <div id="run_manually_response"></div></p>
  549. </th>
  550. <th class="manage-column" scope="col"> <div class="remove-div"><a href="javascript:delete_an_api(<?php print $cache_num ?>);" class="widget-control-remove">Remove</a></div> </th>
  551. </tr>
  552. </tfoot>
  553. </table>
  554. </div><!-- .widget-holder -->
  555. </div><!-- .widgets-holder-wrap -->
  556. <div style="width:100%;height:10px"></div>
  557. <?php
  558. }
  559. }