Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
118 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?php | ||
Configure::write('Saito.v', '4.7.3'); | ||
Configure::write('Saito.v', '4.7.4'); | ||
|
||
Configure::write('Saito.saitoHomepage', 'http://saito.siezi.com'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,60 @@ | ||
<?php | ||
|
||
App::uses('AppHelper', 'View/Helper'); | ||
App::import('vendor', 'Embedly.Embedly'); | ||
App::uses('AppHelper', 'View/Helper'); | ||
App::import('vendor', 'Embedly.Embedly'); | ||
|
||
class EmbedlyHelper extends AppHelper { | ||
class EmbedlyHelper extends AppHelper { | ||
|
||
public $helpers = array( 'Html' ); | ||
public $helpers = array('Html'); | ||
|
||
protected static $_apiKey = NULL; | ||
protected static $_apiKey = null; | ||
|
||
public function setApiKey($apiKey) { | ||
self::$_apiKey = $apiKey; | ||
} | ||
public function setApiKey($apiKey) { | ||
self::$_apiKey = $apiKey; | ||
} | ||
|
||
public function embedly($string) { | ||
public function embedly($string) { | ||
|
||
if ( self::$_apiKey == FALSE ) : | ||
return __('Embed.ly API-key not set.'); | ||
endif; | ||
if (self::$_apiKey == false) : | ||
return __('Embed.ly API-key not set.'); | ||
endif; | ||
|
||
$out = FALSE; | ||
$out = false; | ||
|
||
$api = new Embedly\Embedly( | ||
array( | ||
'user_agent' => 'Mozilla/5.0 (compatible; cakephp/1.0)', | ||
'key' => self::$_apiKey, | ||
)); | ||
$properties = [ | ||
'user_agent' => 'Mozilla/5.0 (compatible; cakephp/1.0)', | ||
'key' => self::$_apiKey, | ||
]; | ||
$api = new Embedly\Embedly($properties); | ||
|
||
try { | ||
$request = ['urls' => [$string]]; | ||
|
||
try { | ||
$obj = current($api->oembed($request)); | ||
} catch (Exception $e) { | ||
return 'Embedding failded: ' . $e->getMessage(); | ||
$obj = current($api->oembed($request)); | ||
} catch (Exception $e) { | ||
return 'Embedding failded: ' . $e->getMessage(); | ||
} | ||
|
||
if (isset($obj->html) && $obj->type !== 'link') { | ||
// use the html code from embedly if possible | ||
$out = $obj->html; | ||
} elseif (isset($obj->title) && isset($obj->url)) { | ||
// else just link to target | ||
$title = ''; | ||
$escape = true; | ||
if (isset($obj->thumbnail_url)) { | ||
// use thumbnail for link if available | ||
$title .= $this->Html->image( | ||
$obj->thumbnail_url, | ||
['class' => 'embedly-image'] | ||
); | ||
$title .= $this->Html->tag('br'); | ||
$escape = false; | ||
} | ||
$title .= $obj->title; | ||
$out = $this->Html->link($title, $obj->url, ['escape' => $escape]); | ||
} | ||
|
||
if ( isset($obj->html) ): | ||
// use the html code from embedly if possible | ||
$out = $obj->html; | ||
elseif ( isset($obj->title) && isset($obj->url) ): | ||
// else just link to target | ||
$title = ''; | ||
$escape = TRUE; | ||
if ( isset($obj->thumbnail_url) ) : | ||
// use thumbnail for link if available | ||
$title .= $this->Html->image($obj->thumbnail_url, array( | ||
'class' => 'embedly-image' | ||
)); | ||
$title .= $this->Html->tag('br'); | ||
$escape = FALSE; | ||
endif; | ||
$title .= $obj->title; | ||
$out = $this->Html->link( | ||
$title, $obj->url, array( 'escape' => $escape ) | ||
); | ||
endif; | ||
|
||
return $out; | ||
} | ||
|
||
} | ||
return $out; | ||
} | ||
|
||
?> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.