| 1 | <?php
|
|---|
| 2 | /**
|
|---|
| 3 | * name: Video Inc
|
|---|
| 4 | * description: Embeds submitted video urls into post descriptions
|
|---|
| 5 | * version: 0.2
|
|---|
| 6 | * folder: video_inc
|
|---|
| 7 | * class: VideoInc
|
|---|
| 8 | * hooks: header_include, theme_index_top, sb_base_show_post_content_list, sb_base_show_post_content_post
|
|---|
| 9 | * requires: sb_base 0.1, media_select 0.2
|
|---|
| 10 | * author: Nick Ramsay
|
|---|
| 11 | * authorurl: http://hotarucms.org/member.php?1-Nick
|
|---|
| 12 | *
|
|---|
| 13 | * Uses http://autoembed.com/
|
|---|
| 14 | *
|
|---|
| 15 | * PHP version 5
|
|---|
| 16 | *
|
|---|
| 17 | * LICENSE: Hotaru CMS is free software: you can redistribute it and/or
|
|---|
| 18 | * modify it under the terms of the GNU General Public License as
|
|---|
| 19 | * published by the Free Software Foundation, either version 3 of
|
|---|
| 20 | * the License, or (at your option) any later version.
|
|---|
| 21 | *
|
|---|
| 22 | * Hotaru CMS is distributed in the hope that it will be useful, but WITHOUT
|
|---|
| 23 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|---|
| 24 | * FITNESS FOR A PARTICULAR PURPOSE.
|
|---|
| 25 | *
|
|---|
| 26 | * You should have received a copy of the GNU General Public License along
|
|---|
| 27 | * with Hotaru CMS. If not, see http://www.gnu.org/licenses/.
|
|---|
| 28 | *
|
|---|
| 29 | * @category Content Management System
|
|---|
| 30 | * @package HotaruCMS
|
|---|
| 31 | * @author Nick Ramsay <admin@hotarucms.org>
|
|---|
| 32 | * @copyright Copyright (c) 2009, Hotaru CMS
|
|---|
| 33 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
|
|---|
| 34 | * @link http://www.hotarucms.org/
|
|---|
| 35 | */
|
|---|
| 36 |
|
|---|
| 37 | class VideoInc
|
|---|
| 38 | {
|
|---|
| 39 | public function theme_index_top($h)
|
|---|
| 40 | {
|
|---|
| 41 | if ($h->pageName != 'video_inc') { return false; }
|
|---|
| 42 |
|
|---|
| 43 | $url = $h->cage->get->testUri('url');
|
|---|
| 44 |
|
|---|
| 45 | $embed = $this->getCode($url);
|
|---|
| 46 |
|
|---|
| 47 | if (!$embed) { return false; }
|
|---|
| 48 | echo "\n<div style='width: 100%; background-color: #000; text-align: center;'>\n" . $embed . "</div>\n";
|
|---|
| 49 | exit;
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 | public function sb_base_show_post_content_list($h)
|
|---|
| 54 | {
|
|---|
| 55 | if (!isset($h->post->vars['media']) || $h->post->vars['media'] != 'video') { return false; }
|
|---|
| 56 |
|
|---|
| 57 | include_once(PLUGINS . "video_inc/libs/AutoEmbed.class.php");
|
|---|
| 58 | $AE = new AutoEmbed();
|
|---|
| 59 |
|
|---|
| 60 | // If this url doesn't parse as a valid video link...
|
|---|
| 61 | if (!$AE->parseUrl($h->post->origUrl) ) { return false; }
|
|---|
| 62 |
|
|---|
| 63 | // get an associated static image (if there is one)
|
|---|
| 64 | $imageURL = $AE->getImageURL();
|
|---|
| 65 |
|
|---|
| 66 | $video_inc_url = BASEURL . "index.php?page=video_inc&url=" . urlencode($h->post->origUrl);
|
|---|
| 67 |
|
|---|
| 68 | // echo the image
|
|---|
| 69 | if ($imageURL) {
|
|---|
| 70 | echo "<div class='video_inc_list'>\n";
|
|---|
| 71 | if ($h->isActive('thickbox')) {
|
|---|
| 72 | echo "<a href='" . $video_inc_url . "&height=336&width=588' class='thickbox'>\n";
|
|---|
| 73 | echo "<img src='" . $imageURL . "'></a>\n";
|
|---|
| 74 | } else {
|
|---|
| 75 | echo "<img src='" . $imageURL . "'>\n";
|
|---|
| 76 | }
|
|---|
| 77 | echo "</div>\n";
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | public function sb_base_show_post_content_post($h)
|
|---|
| 83 | {
|
|---|
| 84 | if (!isset($h->post->vars['media']) || $h->post->vars['media'] != 'video') { return false; }
|
|---|
| 85 |
|
|---|
| 86 | $embed = $this->getCode($h->post->origUrl);
|
|---|
| 87 |
|
|---|
| 88 | if (!$embed) { return false; }
|
|---|
| 89 |
|
|---|
| 90 | // embed the video
|
|---|
| 91 | echo "\n<div class='video_inc_post'>\n" . $embed . "</div>\n";
|
|---|
| 92 | }
|
|---|
| 93 |
|
|---|
| 94 | public function getCode($url)
|
|---|
| 95 | {
|
|---|
| 96 | include_once(PLUGINS . "video_inc/libs/AutoEmbed.class.php");
|
|---|
| 97 | $AE = new AutoEmbed();
|
|---|
| 98 |
|
|---|
| 99 | // If this url doesn't parse as a valid video link...
|
|---|
| 100 | if (!$AE->parseUrl($url) ) { return false; }
|
|---|
| 101 |
|
|---|
| 102 | $AE->setWidth(533);
|
|---|
| 103 | $AE->setHeight(300);
|
|---|
| 104 | return $AE->getEmbedCode();
|
|---|
| 105 | }
|
|---|
| 106 | }
|
|---|
| 107 | ?> |
|---|