mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 11:33:17 +00:00
Use Guzzle\Http\Url for medias
This commit is contained in:
@@ -202,7 +202,7 @@ class Edit implements ControllerProviderInterface
|
||||
$thumbnail = $record->get_thumbnail();
|
||||
|
||||
$elements[$indice]['subdefs']['thumbnail'] = array(
|
||||
'url' => $thumbnail->get_url()
|
||||
'url' => (string) $thumbnail->get_url()
|
||||
, 'w' => $thumbnail->get_width()
|
||||
, 'h' => $thumbnail->get_height()
|
||||
);
|
||||
|
@@ -272,7 +272,7 @@ class Records implements ControllerProviderInterface
|
||||
|
||||
$renewed = array();
|
||||
foreach ($records as $record) {
|
||||
$renewed[$record->get_serialize_key()] = $record->get_preview()->renew_url();
|
||||
$renewed[$record->get_serialize_key()] = (string) $record->get_preview()->renew_url();
|
||||
};
|
||||
|
||||
return $app->json($renewed);
|
||||
|
@@ -1728,6 +1728,9 @@ class API_V1_adapter extends API_V1_Abstract
|
||||
*/
|
||||
protected function list_permalink(media_Permalink_Adapter $permalink, registryInterface $registry)
|
||||
{
|
||||
$downloadUrl = $permalink->get_url();
|
||||
$downloadUrl->getQuery()->set('download', '1');
|
||||
|
||||
return array(
|
||||
'created_on' => $permalink->get_created_on()->format(DATE_ATOM),
|
||||
'id' => $permalink->get_id(),
|
||||
@@ -1735,8 +1738,8 @@ class API_V1_adapter extends API_V1_Abstract
|
||||
'label' => $permalink->get_label(),
|
||||
'updated_on' => $permalink->get_last_modified()->format(DATE_ATOM),
|
||||
'page_url' => $permalink->get_page(),
|
||||
'download_url' => $permalink->get_url() . '&download',
|
||||
'url' => $permalink->get_url()
|
||||
'download_url' => (string) $downloadUrl,
|
||||
'url' => (string) $permalink->get_url()
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -294,7 +294,7 @@ abstract class Feed_XML_Abstract
|
||||
if ($preview_permalink) {
|
||||
$preview = $this->addTag($document, $group, 'media:content');
|
||||
|
||||
$preview->setAttribute('url', $preview_permalink->get_url());
|
||||
$preview->setAttribute('url', (string) $preview_permalink->get_url());
|
||||
$preview->setAttribute('fileSize', $preview_sd->get_size());
|
||||
$preview->setAttribute('type', $preview_sd->get_mime());
|
||||
$preview->setAttribute('medium', $medium);
|
||||
@@ -312,7 +312,7 @@ abstract class Feed_XML_Abstract
|
||||
if ($thumbnail_permalink) {
|
||||
$thumbnail = $this->addTag($document, $group, 'media:thumbnail');
|
||||
|
||||
$thumbnail->setAttribute('url', $thumbnail_permalink->get_url());
|
||||
$thumbnail->setAttribute('url', (string) $thumbnail_permalink->get_url());
|
||||
|
||||
if ($thumbnail_sd->get_width())
|
||||
$thumbnail->setAttribute('width', $thumbnail_sd->get_width());
|
||||
@@ -321,7 +321,7 @@ abstract class Feed_XML_Abstract
|
||||
|
||||
$thumbnail = $this->addTag($document, $group, 'media:content');
|
||||
|
||||
$thumbnail->setAttribute('url', $thumbnail_permalink->get_url());
|
||||
$thumbnail->setAttribute('url', (string) $thumbnail_permalink->get_url());
|
||||
$thumbnail->setAttribute('fileSize', $thumbnail_sd->get_size());
|
||||
$thumbnail->setAttribute('type', $thumbnail_sd->get_mime());
|
||||
$thumbnail->setAttribute('medium', $medium);
|
||||
|
@@ -394,7 +394,7 @@ class Feed_XML_Cooliris extends Feed_XML_Abstract implements Feed_XML_Interface
|
||||
if ($preview_permalink) {
|
||||
$preview = $this->addTag($document, $item, 'media:content');
|
||||
|
||||
$preview->setAttribute('url', $preview_permalink->get_url());
|
||||
$preview->setAttribute('url', (string) $preview_permalink->get_url());
|
||||
$preview->setAttribute('fileSize', $preview_sd->get_size());
|
||||
$preview->setAttribute('type', $preview_sd->get_mime());
|
||||
$preview->setAttribute('medium', $medium);
|
||||
@@ -412,7 +412,7 @@ class Feed_XML_Cooliris extends Feed_XML_Abstract implements Feed_XML_Interface
|
||||
if ($thumbnail_permalink) {
|
||||
$thumbnail = $this->addTag($document, $item, 'media:thumbnail');
|
||||
|
||||
$thumbnail->setAttribute('url', $thumbnail_permalink->get_url());
|
||||
$thumbnail->setAttribute('url', (string) $thumbnail_permalink->get_url());
|
||||
|
||||
if ($thumbnail_sd->get_width())
|
||||
$thumbnail->setAttribute('width', $thumbnail_sd->get_width());
|
||||
@@ -421,7 +421,7 @@ class Feed_XML_Cooliris extends Feed_XML_Abstract implements Feed_XML_Interface
|
||||
|
||||
$thumbnail = $this->addTag($document, $item, 'media:content');
|
||||
|
||||
$thumbnail->setAttribute('url', $thumbnail_permalink->get_url());
|
||||
$thumbnail->setAttribute('url', (string) $thumbnail_permalink->get_url());
|
||||
$thumbnail->setAttribute('fileSize', $thumbnail_sd->get_size());
|
||||
$thumbnail->setAttribute('type', $thumbnail_sd->get_mime());
|
||||
$thumbnail->setAttribute('medium', $medium);
|
||||
|
@@ -11,6 +11,7 @@
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||
use Guzzle\Http\Url;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -142,19 +143,19 @@ class media_Permalink_Adapter implements media_Permalink_Interface, cache_cachea
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
* @return Url
|
||||
*/
|
||||
public function get_url()
|
||||
{
|
||||
$label = $this->get_label() . '.' . pathinfo($this->media_subdef->get_file(), PATHINFO_EXTENSION);
|
||||
|
||||
return $this->app->url('permalinks_permalink', array(
|
||||
return Url::factory($this->app->url('permalinks_permalink', array(
|
||||
'sbas_id' => $this->media_subdef->get_sbas_id(),
|
||||
'record_id' => $this->media_subdef->get_record_id(),
|
||||
'subdef' => $this->media_subdef->get_name(),
|
||||
'label' => $label,
|
||||
'token' => $this->get_token(),
|
||||
));
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -9,6 +9,8 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Guzzle\Http\Url;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package subdefs
|
||||
@@ -19,7 +21,7 @@ abstract class media_abstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
* @var Url
|
||||
*/
|
||||
protected $url;
|
||||
|
||||
@@ -45,7 +47,7 @@ abstract class media_abstract
|
||||
* @param int $height
|
||||
* @return media
|
||||
*/
|
||||
public function __construct($url, $width, $height)
|
||||
public function __construct(Url $url, $width, $height)
|
||||
{
|
||||
$this->url = $url;
|
||||
$this->height = (int) $height;
|
||||
@@ -65,7 +67,7 @@ abstract class media_abstract
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
* @return Url
|
||||
*/
|
||||
public function get_url()
|
||||
{
|
||||
|
@@ -13,6 +13,7 @@ use Alchemy\Phrasea\Application;
|
||||
use MediaAlchemyst\Alchemyst;
|
||||
use MediaVorus\MediaVorus;
|
||||
use MediaVorus\Media\MediaInterface;
|
||||
use Guzzle\Http\Url;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -231,7 +232,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
|
||||
, 'height' => $this->height
|
||||
, 'etag' => $this->etag
|
||||
, 'path' => $this->path
|
||||
, 'url' => $this->url . ($this->is_physically_present ? '?etag=' . $this->etag : '')
|
||||
, 'url' => $this->url
|
||||
, 'file' => $this->file
|
||||
, 'physically_present' => $this->is_physically_present
|
||||
, 'is_substituted' => $this->is_substituted
|
||||
@@ -280,7 +281,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
|
||||
$this->height = 256;
|
||||
$this->path = $this->app['root.path'] . '/www/skins/icons/substitution/';
|
||||
$this->file = 'regroup_thumb.png';
|
||||
$this->url = '/skins/icons/substitution/regroup_thumb.png';
|
||||
$this->url = Url::factory('/skins/icons/substitution/regroup_thumb.png');
|
||||
} else {
|
||||
$mime = $this->record->get_mime();
|
||||
$mime = trim($mime) != '' ? str_replace('/', '_', $mime) : 'application_octet-stream';
|
||||
@@ -290,7 +291,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
|
||||
$this->height = 256;
|
||||
$this->path = $this->app['root.path'] . '/www/skins/icons/substitution/';
|
||||
$this->file = str_replace('+', '%20', $mime) . '.png';
|
||||
$this->url = '/skins/icons/substitution/' . $this->file;
|
||||
$this->url = Url::factory('/skins/icons/substitution/' . $this->file);
|
||||
}
|
||||
|
||||
$this->is_physically_present = false;
|
||||
@@ -298,7 +299,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
|
||||
if ( ! file_exists($this->path . $this->file)) {
|
||||
$this->path = $this->app['root.path'] . '/www/skins/icons/';
|
||||
$this->file = 'substitution.png';
|
||||
$this->url = '/skins/icons/' . $this->file;
|
||||
$this->url = Url::factory('/skins/icons/' . $this->file);
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -367,9 +368,11 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
|
||||
public function get_url()
|
||||
{
|
||||
$url = parent::get_url();
|
||||
$etag = $this->getEtag();
|
||||
if (null !== $this->getEtag()) {
|
||||
$url->getQuery()->set('etag', $this->getEtag());
|
||||
}
|
||||
|
||||
return $url . ($etag ? '?etag=' . $etag : '');
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -747,9 +750,9 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
|
||||
}
|
||||
}
|
||||
|
||||
$this->url = "/datafiles/" . $this->record->get_sbas_id()
|
||||
$this->url = Url::factory("/datafiles/" . $this->record->get_sbas_id()
|
||||
. "/" . $this->record->get_record_id() . "/"
|
||||
. $this->get_name() . "/";
|
||||
. $this->get_name() . "/");
|
||||
|
||||
return;
|
||||
}
|
||||
|
@@ -520,7 +520,7 @@ class module_report_nav extends module_report
|
||||
$this->result[] = array(
|
||||
'photo' =>
|
||||
"<img style='width:" . $x->get_width() . "px;height:" . $x->get_height() . "px;'
|
||||
src='" . $x->get_url() . "'>"
|
||||
src='" . (string) $x->get_url() . "'>"
|
||||
, 'record_id' => $record->get_record_id()
|
||||
, 'date' => $this->app['date-formatter']->getPrettyString($document->get_creation_date())
|
||||
, 'type' => $document->get_mime()
|
||||
|
@@ -9,6 +9,8 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Guzzle\Http\Url;
|
||||
|
||||
class p4file
|
||||
{
|
||||
|
||||
@@ -52,7 +54,7 @@ class p4file
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
return Url::factory($ret);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -11,6 +11,7 @@
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Alchemy\Phrasea\SearchEngine\SearchEngineInterface;
|
||||
use Guzzle\Http\Url;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -479,7 +480,7 @@ class record_preview extends record_adapter
|
||||
|
||||
$width = 350;
|
||||
$height = 150;
|
||||
$url = 'http://chart.apis.google.com/chart?' .
|
||||
$url = Url::factory('http://chart.apis.google.com/chart?' .
|
||||
'chs=' . $width . 'x' . $height .
|
||||
'&chd=t:' . implode(',', $views) .
|
||||
'&cht=lc' .
|
||||
@@ -492,7 +493,7 @@ class record_preview extends record_adapter
|
||||
. date_format(new DateTime(), 'd M') . '|1:|0|'
|
||||
. round($top / 2, 2) . '|' . $top
|
||||
. '|2:|min|average|max' .
|
||||
'&chxp=2,' . $min . ',' . $average . ',' . $max;
|
||||
'&chxp=2,' . $min . ',' . $average . ',' . $max);
|
||||
|
||||
$this->view_popularity = new media_adapter($url, $width, $height);
|
||||
|
||||
@@ -559,12 +560,12 @@ class record_preview extends record_adapter
|
||||
$width = 550;
|
||||
$height = 100;
|
||||
|
||||
$url = 'http://chart.apis.google.com/chart?'
|
||||
$url = Url::factory('http://chart.apis.google.com/chart?'
|
||||
. 'cht=p3&chf=bg,s,00000000&chd=t:'
|
||||
. implode(',', $referrers)
|
||||
. '&chs=' . $width . 'x' . $height
|
||||
. '&chl='
|
||||
. urlencode(implode('|', array_keys($referrers))) . '';
|
||||
. urlencode(implode('|', array_keys($referrers))));
|
||||
|
||||
$this->refferer_popularity = new media_adapter($url, $width, $height);
|
||||
|
||||
@@ -635,7 +636,7 @@ class record_preview extends record_adapter
|
||||
|
||||
$width = 250;
|
||||
$height = 150;
|
||||
$url = 'http://chart.apis.google.com/chart?' .
|
||||
$url = Url::factory('http://chart.apis.google.com/chart?' .
|
||||
'chs=' . $width . 'x' . $height .
|
||||
'&chd=t:' . implode(',', $dwnls) .
|
||||
'&cht=lc' .
|
||||
@@ -645,7 +646,7 @@ class record_preview extends record_adapter
|
||||
'&chxl=0:|' . date_format(new DateTime('-30 days'), 'd M') . '|'
|
||||
. date_format(new DateTime('-15 days'), 'd M') . '|'
|
||||
. date_format(new DateTime(), 'd M') . '|1:|0|'
|
||||
. round($top / 2) . '|' . $top . '';
|
||||
. round($top / 2) . '|' . $top);
|
||||
|
||||
$ret = new media_adapter($url, $width, $height);
|
||||
$this->download_popularity = $ret;
|
||||
|
@@ -2244,7 +2244,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
|
||||
|
||||
$this->assertArrayHasKey("download_url", $permalink);
|
||||
$this->assertInternalType(\PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $permalink['download_url']);
|
||||
$this->assertEquals($subdef->get_permalink()->get_url() . '&download', $permalink['download_url']);
|
||||
$this->assertEquals((string) $subdef->get_permalink()->get_url() . '&download=1', $permalink['download_url']);
|
||||
$this->checkUrlCode200($permalink['download_url']);
|
||||
$this->assertPermalinkHeaders($permalink['download_url'], $subdef, "download_url");
|
||||
}
|
||||
|
@@ -561,7 +561,7 @@ class RssFeedTest extends \PhraseanetWebTestCaseAbstract
|
||||
foreach ($current_attributes as $attribute => $value) {
|
||||
switch ($attribute) {
|
||||
case "url":
|
||||
$this->assertEquals($permalink->get_url(), $value);
|
||||
$this->assertEquals((string) $permalink->get_url(), $value);
|
||||
break;
|
||||
case "fileSize":
|
||||
$this->assertEquals($ressource->get_size(), $value);
|
||||
|
@@ -56,7 +56,7 @@ class media_Permalink_AdapterTest extends PhraseanetPHPUnitAbstract
|
||||
. '.' . pathinfo(self::$DI['record_1']->get_subdef('document')->get_file(), PATHINFO_EXTENSION)
|
||||
. '?token=' . static::$object->get_token();
|
||||
|
||||
$this->assertEquals($url, static::$object->get_url());
|
||||
$this->assertEquals($url, (string) static::$object->get_url());
|
||||
}
|
||||
|
||||
public function testGet_Previewurl()
|
||||
@@ -72,7 +72,7 @@ class media_Permalink_AdapterTest extends PhraseanetPHPUnitAbstract
|
||||
. '.' . pathinfo(self::$DI['record_1']->get_subdef('preview')->get_file(), PATHINFO_EXTENSION)
|
||||
. '?token=' . $previewPermalink->get_token();
|
||||
|
||||
$this->assertEquals($url, $previewPermalink->get_url());
|
||||
$this->assertEquals($url, (string) $previewPermalink->get_url());
|
||||
}
|
||||
|
||||
public function testGet_page()
|
||||
|
@@ -91,8 +91,10 @@ class media_subdefTest extends \PhraseanetPHPUnitAbstract
|
||||
*/
|
||||
public function testGet_url()
|
||||
{
|
||||
$this->assertEquals('/skins/icons/substitution/image_jpeg.png', self::$objectNotPresent->get_url());
|
||||
$this->assertRegExp('#\/datafiles\/' . self::$objectPresent->get_sbas_id() . '\/' . self::$objectPresent->get_record_id() . '\/preview\/\?etag=[0-9a-f]{32}#', self::$objectPresent->get_url());
|
||||
$this->assertInstanceOf('Guzzle\Http\Url', self::$objectNotPresent->get_url());
|
||||
$this->assertInstanceOf('Guzzle\Http\Url', self::$objectPresent->get_url());
|
||||
$this->assertEquals('/skins/icons/substitution/image_jpeg.png', (string) self::$objectNotPresent->get_url());
|
||||
$this->assertRegExp('#\/datafiles\/' . self::$objectPresent->get_sbas_id() . '\/' . self::$objectPresent->get_record_id() . '\/preview\/\?etag=[0-9a-f]{32}#', (string) self::$objectPresent->get_url());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -253,8 +255,8 @@ class media_subdefTest extends \PhraseanetPHPUnitAbstract
|
||||
*/
|
||||
public function testRenew_url()
|
||||
{
|
||||
$this->assertInternalType('string', self::$objectPresent->renew_url());
|
||||
$this->assertInternalType('string', self::$objectNotPresent->renew_url());
|
||||
$this->assertInstanceOf('Guzzle\Http\Url', self::$objectPresent->renew_url());
|
||||
$this->assertInstanceOf('Guzzle\Http\Url', self::$objectNotPresent->renew_url());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user