|
@@ -0,0 +1,68 @@
|
|
1
|
+<?php
|
|
2
|
+/*
|
|
3
|
+Plugin Name: Feed Replacement
|
|
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
|
+
|
|
12
|
+ function feedreplacement() {
|
|
13
|
+ global $user, $conf, $tumble;
|
|
14
|
+
|
|
15
|
+ //agregar al los panel de options un input mas
|
|
16
|
+ $this->addAction('add_options_panel', 'feedreplacement_setOptionsPanel');
|
|
17
|
+
|
|
18
|
+ //crea o verifica que la opcion que usa de la tabla de opciones esta creada
|
|
19
|
+ $this->addAction('gelato_init', 'feedreplacement_check');
|
|
20
|
+
|
|
21
|
+ //reemplaza el link del feed de gelato por el link de feedburner
|
|
22
|
+ $this->addAction('gelato_includes', 'feedreplacement_includeFeed');
|
|
23
|
+
|
|
24
|
+ //lo mismo pero con el que esta en el header
|
|
25
|
+ //$this->addAction('add_post', 'dameCinco');
|
|
26
|
+
|
|
27
|
+ //guarda la opcion si viene por POST
|
|
28
|
+ if ($user->isAdmin()) {
|
|
29
|
+ if(isset($_POST["feedreplacement_url"])){
|
|
30
|
+ if (!$tumble->saveOption($_POST["feedreplacement_url"], "feedreplacement_url")) {
|
|
31
|
+ header("Location: ".$conf->urlGelato."/admin/options.php?error=1&des=".$conf->merror);
|
|
32
|
+ die();
|
|
33
|
+ }
|
|
34
|
+ }
|
|
35
|
+ }
|
|
36
|
+ }
|
|
37
|
+
|
|
38
|
+ function feedreplacement_setOptionsPanel() {
|
|
39
|
+ global $conf;
|
|
40
|
+ echo '<li><label class="help" for="feedreplacement_url">'.__("Replacement Feed:").'</label>
|
|
41
|
+ <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>';
|
|
42
|
+ }
|
|
43
|
+
|
|
44
|
+ function feedreplacement_check(){
|
|
45
|
+ global $db,$conf;
|
|
46
|
+ $sqlStr = "SELECT COUNT(*) as exist FROM `".$conf->tablePrefix."options` WHERE name='feedreplacement_url' LIMIT 1";
|
|
47
|
+ if ($db->ejecutarConsulta($sqlStr)) {
|
|
48
|
+ $row=$db->obtenerRegistro();
|
|
49
|
+ if($row["exist"]==0){
|
|
50
|
+ $sql = "INSERT INTO `".$conf->tablePrefix."options` VALUES ('feedreplacement_url', '');";
|
|
51
|
+ $db->ejecutarConsulta($sql);
|
|
52
|
+ }
|
|
53
|
+ }
|
|
54
|
+ }
|
|
55
|
+
|
|
56
|
+ function feedreplacement_includeFeed(){
|
|
57
|
+ global $conf,$gelato_includes;
|
|
58
|
+ $feedreplacement_url = $conf->get_option('feedreplacement_url');
|
|
59
|
+ if($feedreplacement_url!=""){
|
|
60
|
+ $feed = ($conf->urlFriendly?"/rss/":"/rss.php");
|
|
61
|
+ $url = $conf->urlGelato.$feed;
|
|
62
|
+ $gelato_includes = str_replace($url,$feedreplacement_url,$gelato_includes);
|
|
63
|
+ }
|
|
64
|
+ }
|
|
65
|
+
|
|
66
|
+}
|
|
67
|
+
|
|
68
|
+?>
|