diff --git a/serendipity_event_oembed/OEmbedDatabase.php b/serendipity_event_oembed/OEmbedDatabase.php index 858dc444..d5eda746 100644 --- a/serendipity_event_oembed/OEmbedDatabase.php +++ b/serendipity_event_oembed/OEmbedDatabase.php @@ -42,6 +42,11 @@ class OEmbedDatabase { } return null; } + function clear_cache() { + global $serendipity; + $q = "delete from {$serendipity['dbPrefix']}" . PLUGIN_OEMBED_DATABASEVNAME; + serendipity_db_schema_import($q); + } function install(&$obj) { global $serendipity; @@ -80,6 +85,7 @@ class OEmbedDatabase { } function cleanup_html( $str ) { + $str = trim($str); // Clear unicode stuff $str=str_ireplace("\u003C","<",$str); $str=str_ireplace("\u003E",">",$str); diff --git a/serendipity_event_oembed/lang_en.inc.php b/serendipity_event_oembed/lang_en.inc.php index 1f787309..04f0f325 100755 --- a/serendipity_event_oembed/lang_en.inc.php +++ b/serendipity_event_oembed/lang_en.inc.php @@ -8,6 +8,10 @@ @define('PLUGIN_EVENT_OEMBED_NAME', 'oEmbed Plugin'); @define('PLUGIN_EVENT_OEMBED_DESC', 'oEmbed is a format for allowing an embedded representation of a URL on your blog. It allows blog articles to display embedded content (such as tweets, photos or videos) when a user posts a link to that resource, without having to parse the resource directly.'); +/* +@define('PLUGIN_EVENT_OEMBED_EXPAND_TWEETBACKS', 'Expand tweetbacks'); +@define('PLUGIN_EVENT_OEMBED_EXPAND_TWEETBACKS_DESC', 'If enabled the plugin will detect tweetbacks and set their content to the oEmbed content delivered from twitter.'); +*/ @define('PLUGIN_EVENT_OEMBED_INFO', '
'.
'This plugin expands URLs to pages of known services to a representation of that URL. It shows i.e. the video for a youtube URL or the image instead of a flickr URL.
' .
diff --git a/serendipity_event_oembed/oembed.tpl b/serendipity_event_oembed/oembed.tpl
index 41a1b167..b40818bd 100644
--- a/serendipity_event_oembed/oembed.tpl
+++ b/serendipity_event_oembed/oembed.tpl
@@ -5,12 +5,12 @@
{elseif $oembed.type=='video'}
{$oembed.html}
{elseif $oembed.type=='image'}
-
+
{elseif $oembed.type=='photo'}
-
+
{elseif $oembed.type=='link'}
{$oembed.author_name}
{else}
-{$oembedurl}
+{$oembedurl}
{/if}
\ No newline at end of file
diff --git a/serendipity_event_oembed/oembed/EmbedProvider.class.php b/serendipity_event_oembed/oembed/EmbedProvider.class.php
index ad94760c..5187d849 100644
--- a/serendipity_event_oembed/oembed/EmbedProvider.class.php
+++ b/serendipity_event_oembed/oembed/EmbedProvider.class.php
@@ -2,11 +2,15 @@
abstract class EmbedProvider {
public $url;
public $endpoint;
+ public $maxwidth;
+ public $maxheight;
public abstract function match($url);
public abstract function provide($url,$format="json");
// public abstract function register();
- public function __construct($url,$endpoint){
+ public function __construct($url,$endpoint, $maxwidth=null, $maxheight=null){
$this->url = $url;
$this->endpoint = $endpoint;
+ $this->maxwidth = $maxwidth;
+ $this->maxheight = $maxheight;
}
}
diff --git a/serendipity_event_oembed/oembed/OEmbedProvider.class.php b/serendipity_event_oembed/oembed/OEmbedProvider.class.php
index af7ce783..b78125b7 100644
--- a/serendipity_event_oembed/oembed/OEmbedProvider.class.php
+++ b/serendipity_event_oembed/oembed/OEmbedProvider.class.php
@@ -3,12 +3,14 @@ class OEmbedProvider extends EmbedProvider{
private $urlRegExp;
private $jsonEndpoint;
private $xmlEndpoint;
+ private $dimensionsSupported = true;
private $onlyJson = false;
- public function __construct($url,$endpoint, $onlyJson=false){
- parent::__construct($url,$endpoint);
+ public function __construct($url,$endpoint, $onlyJson=false, $maxwidth=null, $maxheight=null, $dimensionsSupported=true){
+ parent::__construct($url,$endpoint,$maxwidth,$maxheight);
$this->onlyJson = $onlyJson;
+ $this->dimensionsSupported = $dimensionsSupported;
$this->urlRegExp=preg_replace(array("/\*/","/\//","/\.\*\./"),array(".*","\/",".*"),$url);
$this->urlRegExp="/".$this->urlRegExp."/";
if (preg_match("/\{format\}/",$endpoint)){
@@ -20,6 +22,16 @@ class OEmbedProvider extends EmbedProvider{
$this->jsonEndpoint=$endpoint."?url={url}&format=json";
$this->xmlEndpoint=$endpoint."?url={url}&format=xml";
}
+ if ($this->dimensionsSupported) {
+ if (!empty($this->maxwidth)) {
+ $this->jsonEndpoint.= '&maxwidth=' . $this->maxwidth;
+ $this->xmlEndpoint.= '&maxwidth=' . $this->maxwidth;
+ }
+ if (!empty($this->maxheight)) {
+ $this->jsonEndpoint.= '&maxwidth=' . $this->maxheight;
+ $this->xmlEndpoint.= '&maxwidth=' . $this->maxheight;
+ }
+ }
}
public function getUrlRegExp(){ return $this->urlRegExp; }
diff --git a/serendipity_event_oembed/oembed/ProviderManager.class.php b/serendipity_event_oembed/oembed/ProviderManager.class.php
index a2df7618..92691a08 100644
--- a/serendipity_event_oembed/oembed/ProviderManager.class.php
+++ b/serendipity_event_oembed/oembed/ProviderManager.class.php
@@ -2,13 +2,14 @@
class ProviderManager{
private $providers;
private static $_instance;
- private function __construct(){
+ private function __construct($maxwidth=null, $maxheight=null){
$this->providers=array();
$xml = simplexml_load_file(PLUGIN_OEMBED_PROVIDER_XML_FILE);// PROVIDER_XML comes from config.php
foreach($xml->provider as $provider){
if(!isset($provider->class) && isset($provider->endpoint)){
$onlyJson = isset($provider->jsononly);
- $this->register(new OEmbedProvider($provider->url,$provider->endpoint, $onlyJson));
+ $dimensionsSupported = !isset($provider->nodimensionsupport);
+ $this->register(new OEmbedProvider($provider->url,$provider->endpoint, $onlyJson, $maxwidth, $maxheight, $dimensionsSupported));
} else {
$classname="".$provider->class; // force to be string :)
$reflection = new ReflectionClass($classname);
@@ -16,9 +17,9 @@ class ProviderManager{
}
}
}
- static function getInstance(){
+ static function getInstance($maxwidth=null, $maxheight=null){
if(!isset($_instance) || $_instance==null){
- $_instance = new ProviderManager();
+ $_instance = new ProviderManager($maxwidth, $maxheight);
}
return $_instance;
}
diff --git a/serendipity_event_oembed/oembed/YouTubeProvider.class.php b/serendipity_event_oembed/oembed/YouTubeProvider.class.php
index 2bf03ec4..d7797a0b 100644
--- a/serendipity_event_oembed/oembed/YouTubeProvider.class.php
+++ b/serendipity_event_oembed/oembed/YouTubeProvider.class.php
@@ -74,7 +74,7 @@ class YouTubeProvider extends EmbedProvider {
}
- public function __construct($config){
- parent::__construct("http://youtube.com","");
+ public function __construct($config,$maxwidth=null, $maxheight=null){
+ parent::__construct("http://youtube.com","", $maxwidth, $maxheight);
}
}
diff --git a/serendipity_event_oembed/oembed/providers.xml b/serendipity_event_oembed/oembed/providers.xml
index 629a871a..04e8eb4e 100644
--- a/serendipity_event_oembed/oembed/providers.xml
+++ b/serendipity_event_oembed/oembed/providers.xml
@@ -13,7 +13,7 @@
-->
";
+ echo "
";
}
$this->check_tweetbacks_save_comment($article_id, $entry, $comment_type, true);
$comment_saved = true;