From b1c86ddb0bfbb96f2b084b5b059f45babf115b82 Mon Sep 17 00:00:00 2001 From: vbracco Date: Fri, 31 Oct 2008 17:04:57 +0000 Subject: [PATCH] Add FeedReplacement Plugin and some triggers. --- admin/options.php | 3 ++ admin/settings.php | 5 ++- entry.php | 2 +- index.php | 6 ++-- plugins/cinco.php | 2 +- plugins/feedreplacement.php | 68 +++++++++++++++++++++++++++++++++++++ plugins/hola.php | 2 +- 7 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 plugins/feedreplacement.php diff --git a/admin/options.php b/admin/options.php index 0ee7a19..1c4c238 100644 --- a/admin/options.php +++ b/admin/options.php @@ -233,6 +233,9 @@ if ($user->isAdmin()) { +call('add_options_panel'); +?>

diff --git a/admin/settings.php b/admin/settings.php index bcaab44..07feacc 100644 --- a/admin/settings.php +++ b/admin/settings.php @@ -109,7 +109,10 @@ if ($user->isAdmin()) { } ?> - + +call('add_settings_panel'); +?>

diff --git a/entry.php b/entry.php index 8951cc2..4dbbb02 100644 --- a/entry.php +++ b/entry.php @@ -97,7 +97,7 @@ if($installed){ //print_r($plugEngine->actions); //die(); - $trigger->call('add_post'); + $trigger->call('gelato_init'); $feeds = new feeds(); $feeds->updateFeeds(); diff --git a/index.php b/index.php index 717aa34..c72e614 100644 --- a/index.php +++ b/index.php @@ -56,7 +56,8 @@ $theme = new themes; $gelato_includes .= "\turlGelato."/admin/css/lightbox.css\" />\n"; $gelato_includes .= "\t\n"; $gelato_includes .= "\t"; - + + $page_title = $conf->title; $page_title_divisor = " » "; // it should be set in configuration $page_title_len = 50; // it should be set in configuration @@ -75,7 +76,8 @@ $theme = new themes; $page_title .= $page_title_divisor.stripslashes($page_title_data); } } - + + $trigger->call('gelato_includes'); $theme->set('Gelato_includes',$gelato_includes); $theme->set('Title',$conf->title); $theme->set('Page_Title',$page_title); diff --git a/plugins/cinco.php b/plugins/cinco.php index ebd0193..73314fb 100644 --- a/plugins/cinco.php +++ b/plugins/cinco.php @@ -3,7 +3,7 @@ class cinco extends plugins { function cinco() { - $this->addAction('add_post', 'dameCinco'); + //$this->addAction('gelato_init', 'dameCinco'); } function dameCinco() { diff --git a/plugins/feedreplacement.php b/plugins/feedreplacement.php new file mode 100644 index 0000000..76bc1c1 --- /dev/null +++ b/plugins/feedreplacement.php @@ -0,0 +1,68 @@ +addAction('add_options_panel', 'feedreplacement_setOptionsPanel'); + + //crea o verifica que la opcion que usa de la tabla de opciones esta creada + $this->addAction('gelato_init', 'feedreplacement_check'); + + //reemplaza el link del feed de gelato por el link de feedburner + $this->addAction('gelato_includes', 'feedreplacement_includeFeed'); + + //lo mismo pero con el que esta en el header + //$this->addAction('add_post', 'dameCinco'); + + //guarda la opcion si viene por POST + if ($user->isAdmin()) { + if(isset($_POST["feedreplacement_url"])){ + if (!$tumble->saveOption($_POST["feedreplacement_url"], "feedreplacement_url")) { + header("Location: ".$conf->urlGelato."/admin/options.php?error=1&des=".$conf->merror); + die(); + } + } + } + } + + function feedreplacement_setOptionsPanel() { + global $conf; + echo '

  • +
  • '; + } + + function feedreplacement_check(){ + global $db,$conf; + $sqlStr = "SELECT COUNT(*) as exist FROM `".$conf->tablePrefix."options` WHERE name='feedreplacement_url' LIMIT 1"; + if ($db->ejecutarConsulta($sqlStr)) { + $row=$db->obtenerRegistro(); + if($row["exist"]==0){ + $sql = "INSERT INTO `".$conf->tablePrefix."options` VALUES ('feedreplacement_url', '');"; + $db->ejecutarConsulta($sql); + } + } + } + + function feedreplacement_includeFeed(){ + global $conf,$gelato_includes; + $feedreplacement_url = $conf->get_option('feedreplacement_url'); + if($feedreplacement_url!=""){ + $feed = ($conf->urlFriendly?"/rss/":"/rss.php"); + $url = $conf->urlGelato.$feed; + $gelato_includes = str_replace($url,$feedreplacement_url,$gelato_includes); + } + } + +} + +?> \ No newline at end of file diff --git a/plugins/hola.php b/plugins/hola.php index 1c9ca03..cc94824 100644 --- a/plugins/hola.php +++ b/plugins/hola.php @@ -3,7 +3,7 @@ class hola extends plugins { function hola() { - $this->addAction('add_post', 'saluda'); + //$this->addAction('gelato_init', 'saluda'); } function saluda() {