Files
Phraseanet/lib/classes/media/abstract.php
Romain Neutron 1713c23c59 Merge branch '3.8'
Conflicts:
	bin/console
	lib/Alchemy/Phrasea/Controller/Api/V1.php
	lib/Alchemy/Phrasea/Controller/Prod/Edit.php
	lib/Alchemy/Phrasea/Core/Version.php
	lib/classes/API/V1/Interface.php
	lib/classes/API/V1/adapter.php
	lib/classes/Feed/XML/Abstract.php
	lib/classes/Feed/XML/Cooliris.php
	lib/classes/User/Adapter.php
	lib/classes/media/Permalink/Adapter.php
	lib/classes/media/abstract.php
	lib/classes/media/subdef.php
	lib/classes/p4file.php
	lib/classes/record/preview.php
	lib/conf.d/_GV_template.inc
	tests/Alchemy/Tests/Phrasea/Controller/Api/ApiTestCase.php
	tests/Alchemy/Tests/Phrasea/Core/Provider/FileServeServiceProviderTest.php
	tests/classes/media/Permalink/media_Permalink_AdapterTest.php
2014-03-03 17:00:17 +01:00

120 lines
1.8 KiB
PHP

<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Guzzle\Http\Url;
abstract class media_abstract
{
/**
*
* @var Url
*/
protected $url;
/**
*
* @var int
*/
protected $height;
/**
*
* @var int
*/
protected $width;
const PORTRAIT = 'PORTRAIT';
const PAYSAGE = 'LANDSCAPE';
/**
*
* @param string $url
* @param int $width
* @param int $height
* @return media
*/
public function __construct(Url $url, $width, $height)
{
$this->url = $url;
$this->height = (int) $height;
$this->width = (int) $width;
return $this;
}
/**
*
* @return Url
*/
public function get_url()
{
return $this->url;
}
/**
*
* @return int
*/
public function get_width()
{
return $this->width;
}
/**
*
* @return int
*/
public function get_height()
{
return $this->height;
}
/**
*
* @return string
*/
public function get_type()
{
return 'image';
}
/**
*
* @return string
*/
public function get_orientation()
{
if ($this->width > $this->height) {
return self::PAYSAGE;
} else {
return self::PORTRAIT;
}
}
/**
*
* @return boolean
*/
public function is_paysage()
{
return $this->get_orientation() == self::PAYSAGE;
}
/**
*
* @return boolean
*/
public function is_portrait()
{
return $this->get_orientation() == self::PORTRAIT;
}
}