Browse Source

Google Video support and w3c validation

pecesama 18 years ago
parent
commit
c7c2889598
3 changed files with 59 additions and 26 deletions
  1. 8 0
      classes/functions.php
  2. 50 25
      classes/gelato.class.php
  3. 1 1
      themes/tumblr/template_header.htm

+ 8 - 0
classes/functions.php View File

@@ -98,9 +98,17 @@
98 98
 		return $params2[0];
99 99
 	}
100 100
 	
101
+	function isGoogleVideo($videoUrl) {
102
+		if (beginsWith($videoUrl, "http://video.google.com/videoplay?docid="))
103
+			return true;
104
+		else
105
+			return false;
106
+	}
107
+	
101 108
 	function isVideo($url) {
102 109
 		if (isYoutubeVideo($url)) { return true; }
103 110
 		elseif (isVimeoVideo($url)) { return true; }
111
+		elseif (isGoogleVideo($url)) { return true; }
104 112
 		else { return false; }
105 113
 	}
106 114
 	

+ 50 - 25
classes/gelato.class.php View File

@@ -26,23 +26,7 @@ class gelato extends Conexion_Mysql {
26 26
 		} else {
27 27
 			return false;
28 28
 		}		
29
-	}
30
-	
31
-	function saveMP3($remoteFileName) {
32
-		if (getMP3File($remoteFileName)) {
33
-			return true;
34
-		} else {
35
-			return false;
36
-		}
37
-	}
38
-	
39
-	function savePhoto($remoteFileName) {		
40
-		if (getPhotoFile($remoteFileName)) {
41
-			return true;
42
-		} else {
43
-			return false;
44
-		}
45
-	}
29
+	}	
46 30
 	
47 31
 	function getPosts($limit="10", $from="0") {
48 32
 		$sqlStr = "select * from ".$this->conf->tablePrefix."data ORDER BY date DESC LIMIT $from,$limit";
@@ -55,6 +39,12 @@ class gelato extends Conexion_Mysql {
55 39
 		return mysql_fetch_array($this->mid_consulta);
56 40
 	}
57 41
 	
42
+	function getPostsNumber() {
43
+		$this->ejecutarConsulta("select count(*) as total from ".$this->conf->tablePrefix."data");
44
+		$row = mysql_fetch_assoc($this->mid_consulta);
45
+		return $row['total'];
46
+	}
47
+	
58 48
 	function getType($id) {
59 49
 		if ($this->ejecutarConsulta("select type from ".$this->conf->tablePrefix."data WHERE id_post=".$id)) {	
60 50
 			if ($this->contarRegistros()>0) {	
@@ -97,6 +87,22 @@ class gelato extends Conexion_Mysql {
97 87
 		return $formatedText;
98 88
 	}
99 89
 	
90
+	function saveMP3($remoteFileName) {
91
+		if (getMP3File($remoteFileName)) {
92
+			return true;
93
+		} else {
94
+			return false;
95
+		}
96
+	}
97
+	
98
+	function savePhoto($remoteFileName) {		
99
+		if (getPhotoFile($remoteFileName)) {
100
+			return true;
101
+		} else {
102
+			return false;
103
+		}
104
+	}
105
+	
100 106
 	function getVideoPlayer($url) {
101 107
 		if (isYoutubeVideo($url)) {
102 108
 			$id_video = getYoutubeVideoUrl($url);
@@ -104,8 +110,33 @@ class gelato extends Conexion_Mysql {
104 110
 		} elseif (isVimeoVideo($url)) {
105 111
 			$id_video = getVimeoVideoUrl($url);
106 112
 			return "\t\t\t<object type=\"application/x-shockwave-flash\" style=\"width:500px;height:393px\" data=\"http://www.vimeo.com/moogaloop.swf?clip_id=".$id_video."\"><param name=\"movie\" value=\"http://www.vimeo.com/moogaloop.swf?clip_id=".$id_video."\" /></object>\n";
113
+		} elseif (isGoogleVideo($url)) {
114
+			$html = trim(file_get_contents($url));
115
+			$start_code = strpos($html, "var flashObj =\n    \"");
116
+			$end_code = strpos($html, "\";\n  flashObj = flashObj.replace");
117
+			$start_code = $start_code + strlen("var flashObj =\n    \"");
118
+			$video_code = substr($html, $start_code, $end_code - $start_code);	
119
+			$video_code = str_replace("\u003c", "<", $video_code);
120
+			$video_code = str_replace("\u003d", "=", $video_code);
121
+			$video_code = str_replace("\\\"", "\"", $video_code);
122
+			$video_code = str_replace("width:100%;height:100%;", "width:500px;height:393px", $video_code);
123
+			$video_code = str_replace("/googleplayer.swf", "http://video.google.com/googleplayer.swf", $video_code);
124
+			$video_code = str_replace("embed", "object", $video_code);
125
+			$video_code = str_replace("src=", "data=", $video_code);
126
+			$video_code = str_replace('align="middle"', "", $video_code);
127
+			$video_code = str_replace('allowScriptAccess="always"', "", $video_code);
128
+			$video_code = str_replace('quality="best"', "", $video_code);
129
+			$video_code = str_replace('bgcolor="#ffffff"', "", $video_code);
130
+			$video_code = str_replace('scale="noScale"', "", $video_code);
131
+			$video_code = str_replace('salign="TL"', "", $video_code);	
132
+			$video_code = str_replace('FlashVars="playerMode=normal&autoPlay=true&docid=-2519555829449987448&clickUrl="', "", $video_code);
133
+			$video_code = str_replace('          \\', " /", $video_code);
134
+			$video_code = str_replace('\></object\>', ' ></object>', $video_code);
135
+			$video_code = str_replace("id=\"VideoPlayback\"", "", $video_code);
136
+			$video_code = str_replace("&", "&amp;", $video_code);
137
+			return $video_code;
107 138
 		} else {
108
-			return "This URL is not a supported video (YouTube or Vimeo)";
139
+			return "This URL is not a supported video (YouTube, Vimeo or Google Video)";
109 140
 		}		
110 141
 	}
111 142
 	
@@ -116,12 +147,6 @@ class gelato extends Conexion_Mysql {
116 147
 		} else {
117 148
 			return "This URL is not a supported video (YouTube or Vimeo)";
118 149
 		}		
119
-	}
120
-	
121
-	function getPostsNumber() {
122
-		$this->ejecutarConsulta("select count(*) as total from ".$this->conf->tablePrefix."data");
123
-		$row = mysql_fetch_assoc($this->mid_consulta);
124
-		return $row['total'];
125
-	}
150
+	}	
126 151
 } 
127 152
 ?>

+ 1 - 1
themes/tumblr/template_header.htm View File

@@ -16,7 +16,7 @@
16 16
 </head>
17 17
 <body>
18 18
     <div id="container">
19
-        <a href="{URL_Tumble}/rss.php"><img src="{URL_Tumble}/themes/tumblr/img/rss.gif" id="rss" alt="RSS"></a>
19
+        <a href="{URL_Tumble}/rss.php"><img src="{URL_Tumble}/themes/tumblr/img/rss.gif" id="rss" alt="RSS" title="RSS" /></a>
20 20
 
21 21
         <h1><a href="{URL_Tumble}/">{Title}</a></h1>        
22 22