A tumblelog CMS built on AJAX, PHP and MySQL.

feedreplacement.php 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /*
  3. Plugin Name: FeedReplacement
  4. Plugin URI: http://www.gelatocms.com/plugins/feedreplacement/
  5. Description:
  6. Author: Victor Bracco
  7. Author URI: http://www.vbracco.com.ar/
  8. Version: 0.3
  9. */
  10. class feedreplacement extends plugins {
  11. function feedreplacement() {
  12. global $user, $conf, $tumble;
  13. //agregar al los panel de options un input mas
  14. $this->addAction('add_options_panel', 'feedreplacement_setOptionsPanel');
  15. //crea o verifica que la opcion que usa de la tabla de opciones esta creada
  16. $this->addAction('gelato_init', 'feedreplacement_check');
  17. //reemplaza el link del feed de gelato por el link de feedburner
  18. //$this->addAction('add_post', 'dameCinco');
  19. //lo mismo pero con el que esta en el header
  20. $this->addAction('gelato_includes', 'feedreplacement_includeFeed');
  21. //guarda la opcion si viene por POST
  22. if ($user->isAdmin()) {
  23. if(isset($_POST["feedreplacement_url"])){
  24. if (!$tumble->saveOption($_POST["feedreplacement_url"], "feedreplacement_url")) {
  25. header("Location: ".$conf->urlGelato."/admin/options.php?error=1&des=".$conf->merror);
  26. die();
  27. }
  28. }
  29. }
  30. }
  31. function feedreplacement_setOptionsPanel() {
  32. global $conf;
  33. echo '<li><label class="help" for="feedreplacement_url">'.__("Replacement Feed:").'</label>
  34. <input type="text" name="feedreplacement_url" id="feedreplacement_url" value="'.$conf->get_option('feedreplacement_url').'" class="txt help" title="'.__("Introduce your new feed url into this input").'"/></li>';
  35. }
  36. function feedreplacement_check(){
  37. global $db,$conf;
  38. $sqlStr = "SELECT COUNT(*) as exist FROM `".$conf->tablePrefix."options` WHERE name='feedreplacement_url' LIMIT 1";
  39. if ($db->ejecutarConsulta($sqlStr)) {
  40. $row=$db->obtenerRegistro();
  41. if($row["exist"]==0){
  42. $sql = "INSERT INTO `".$conf->tablePrefix."options` VALUES ('feedreplacement_url', '');";
  43. $db->ejecutarConsulta($sql);
  44. }
  45. }
  46. }
  47. function feedreplacement_includeFeed(){
  48. global $conf,$gelato_includes;
  49. $feedreplacement_url = $conf->get_option('feedreplacement_url');
  50. if($feedreplacement_url!=""){
  51. $feed = ($conf->urlFriendly?"/rss/":"/rss.php");
  52. $url = $conf->urlGelato.$feed;
  53. $gelato_includes = str_replace($url,$feedreplacement_url,$gelato_includes);
  54. }
  55. }
  56. }
  57. ?>