]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Added vimeo support to ECML.
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Wed, 14 Apr 2010 22:43:47 +0000 (22:43 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Wed, 14 Apr 2010 22:43:47 +0000 (22:43 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@5736 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/ecml/start.php
mod/ecml/views/default/ecml/keywords/vimeo.php [new file with mode: 0644]

index 6bf1a565de72c1bd1d63eabdae5a553783969744..51082e9c660e0e717672f5edb29934332696c1b4 100644 (file)
@@ -128,7 +128,7 @@ function ecml_parse_view($hook, $entity_type, $return_value, $params) {
  * @return unknown_type
  */
 function ecml_keyword_hook($hook, $entity_type, $return_value, $params) {
-       $keywords = array('youtube', 'slideshare');
+       $keywords = array('youtube', 'slideshare', 'vimeo');
 
        foreach ($keywords as $keyword) {
                $return_value[$keyword] = array(
diff --git a/mod/ecml/views/default/ecml/keywords/vimeo.php b/mod/ecml/views/default/ecml/keywords/vimeo.php
new file mode 100644 (file)
index 0000000..6ca1294
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+/**
+ * ECML vimeo support
+ *
+ * @package ECML
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008-2010
+ * @link http://elgg.org/
+ */
+
+$src = (isset($vars['src'])) ? $vars['src'] : FALSE;
+$width = (isset($vars['width'])) ? $vars['width'] : 480;
+$height = (isset($vars['height'])) ? $vars['height'] : 385;
+
+// need to extract the video id.
+// the src arg can take a full url or an id.
+// assume if no youtube.com that it's an id.
+if (strpos($src, 'vimeo.com') === FALSE) {
+       $vid = $src;
+} else {
+       // we love vimeo.
+       list($address, $vid) = explode('vimeo.com/', $src);
+}
+
+if ($vid) {
+       $movie_url = "http://vimeo.com/moogaloop.swf?";
+       $query = array('clip_id' => $vid, 'server' => 'vimeo.com');
+
+       $params = array(
+               'show_title' => 1,
+               'show_byline' => 1,
+               'show_portrait' => 0,
+               'color' => '',
+               'fullscreen' => 1
+       );
+
+       foreach ($params as $param => $default) {
+               $query[$param] = (isset($vars[$param])) ? $vars[$param] : $default;
+       }
+
+       $query_str = http_build_query($query);
+       $movie_url .= $query_str;
+
+       echo "
+<object width=\"$width\" height=\"$height\">
+       <param name=\"allowfullscreen\" value=\"true\" />
+       <param name=\"allowscriptaccess\" value=\"always\" />
+       <param name=\"movie\" value=\"$movie_url\" />
+       <embed src=\"$movie_url\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" allowscriptaccess=\"always\" width=\"$width\" height=\"$height\">
+       </embed>
+</object>
+       ";
+}
\ No newline at end of file