Skip to content

Commit

Permalink
Merge branch 'release/4.7.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlaefer committed Mar 21, 2015
2 parents b9df105 + 35e306f commit 2f3291c
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 96 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -10,7 +10,7 @@ env:
- DB=pgsql

before_script:
- if [ ! -f composer.phar ]; then curl -s http://getcomposer.org/installer | php; fi; php composer.phar install -d app -o
- composer install -d app -o
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test;'; fi"
- sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'CREATE DATABASE cakephp_test;' -U postgres; fi"
- chmod -R 777 ./app/tmp
Expand Down
2 changes: 1 addition & 1 deletion app/Config/version.php
@@ -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');
4 changes: 0 additions & 4 deletions app/Plugin/Api/Controller/ApiEntriesController.php
Expand Up @@ -59,10 +59,6 @@ public function threadsGet() {
*/
public function entriesItemPost() {
$data['Entry'] = $this->request->data;
if (isset($data['Entry']['category_id'])) {
$data['Entry']['category'] = $data['Entry']['category_id'];
unset($data['Entry']['category_id']);
}
if (isset($data['Entry']['parent_id'])) {
$data['Entry']['pid'] = $data['Entry']['parent_id'];
unset($data['Entry']['parent_id']);
Expand Down
19 changes: 19 additions & 0 deletions app/Plugin/Api/Test/Case/Controller/ApiEntriesControllerTest.php
Expand Up @@ -133,6 +133,25 @@ public function testEntriesItemPostEmptySubject() {
);
}

public function testEntriesItemPostSuccess() {
$this->generate('Api.ApiEntries');
$this->_loginUser(3);
$result = $this->testAction(
$this->_apiRoot . 'entries.json',
[
'return' => 'view',
'method' => 'POST',
'data' => [
'subject' => 'subject',
'parent_id' => 0,
'category_id' => 2
]
]
);
$statusCode = $this->controller->response->statusCode();
$this->assertEquals(200, $statusCode);
}

public function testEntriesItemPutOnlyAuthenticatedUsers() {
$this->generate('ApiEntries', ['methods' => 'entriesItemPut']);
$this->testAction($this->_apiRoot . 'entries/1', ['method' => 'PUT']);
Expand Down
94 changes: 45 additions & 49 deletions app/Plugin/Embedly/View/Helper/EmbedlyHelper.php
@@ -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;
}

?>
}
2 changes: 1 addition & 1 deletion app/composer.json
Expand Up @@ -30,7 +30,7 @@
"php": ">=5.4.0",
"ext-mcrypt": "*",
"markstory/geshi": "0.3.*",
"pear-pear.cakephp.org/CakePHP": "2.6.2",
"pear-pear.cakephp.org/CakePHP": "2.6.3",
"kzykhys/ciconia": "~1.0.3",
"jbbcode/jbbcode": "~1.3",
"aura/di": "~2.1"
Expand Down

0 comments on commit 2f3291c

Please sign in to comment.