mirror of
https://github.com/getgrav/grav.git
synced 2026-07-21 06:50:38 +02:00
PSR Fixes
This commit is contained in:
@@ -98,13 +98,11 @@ class Media extends Getters
|
||||
|
||||
// Build missing alternatives
|
||||
if (!empty($types['alternative'])) {
|
||||
|
||||
$alternatives = $types['alternative'];
|
||||
|
||||
$max = max(array_keys($alternatives));
|
||||
|
||||
for ($i=2; $i < $max; $i++) {
|
||||
|
||||
if (isset($alternatives[$i])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class ImageMedium extends Medium
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $quality = 85;
|
||||
protected $quality = DEFAULT_IMG_QUALITY;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
@@ -76,7 +76,7 @@ class ImageMedium extends Medium
|
||||
/**
|
||||
* Add meta file for the medium.
|
||||
*
|
||||
* @param $format
|
||||
* @param $filepath
|
||||
* @return $this
|
||||
*/
|
||||
public function addMetaFile($filepath)
|
||||
@@ -92,13 +92,16 @@ class ImageMedium extends Medium
|
||||
/**
|
||||
* Return PATH to image.
|
||||
*
|
||||
* @return string path to image
|
||||
* @param bool $reset
|
||||
* @return string path to image
|
||||
*/
|
||||
public function path($reset = true)
|
||||
{
|
||||
$output = $this->saveImage();
|
||||
|
||||
if ($reset) $this->reset();
|
||||
if ($reset) {
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
@@ -113,7 +116,9 @@ class ImageMedium extends Medium
|
||||
{
|
||||
$output = preg_replace('|^' . GRAV_ROOT . '|', '', $this->saveImage());
|
||||
|
||||
if ($reset) $this->reset();
|
||||
if ($reset) {
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
return self::$grav['base_url'] . $output . $this->urlHash();
|
||||
}
|
||||
@@ -178,7 +183,7 @@ class ImageMedium extends Medium
|
||||
}
|
||||
|
||||
$this->format = 'guess';
|
||||
$this->quality = 85;
|
||||
$this->quality = DEFAULT_IMG_QUALITY;
|
||||
|
||||
$this->debug_watermarked = false;
|
||||
|
||||
@@ -262,7 +267,8 @@ class ImageMedium extends Medium
|
||||
* @param string $sizes
|
||||
* @return $this
|
||||
*/
|
||||
public function sizes($sizes = null) {
|
||||
public function sizes($sizes = null)
|
||||
{
|
||||
|
||||
if ($sizes) {
|
||||
$this->attributes['sizes'] = $sizes;
|
||||
@@ -312,7 +318,8 @@ class ImageMedium extends Medium
|
||||
|
||||
call_user_func_array([$medium, $method], $args_copy);
|
||||
}
|
||||
} catch (\BadFunctionCallException $e) { }
|
||||
} catch (\BadFunctionCallException $e) {
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -320,7 +327,6 @@ class ImageMedium extends Medium
|
||||
/**
|
||||
* Gets medium image, resets image manipulation operations.
|
||||
*
|
||||
* @param string $variable
|
||||
* @return $this
|
||||
*/
|
||||
protected function image()
|
||||
|
||||
@@ -12,6 +12,7 @@ class Link implements RenderableInterface
|
||||
* @var array
|
||||
*/
|
||||
protected $attributes = [];
|
||||
protected $source;
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Grav\Common\Page\Medium;
|
||||
use Grav\Common\File\CompiledYamlFile;
|
||||
use Grav\Common\GravTrait;
|
||||
use Grav\Common\Data\Data;
|
||||
use Grav\Common\Data\Blueprint;
|
||||
|
||||
/**
|
||||
* The Medium is a general class for multimedia objects in Grav pages, specific implementations will derive from
|
||||
@@ -32,6 +33,8 @@ class Medium extends Data implements RenderableInterface
|
||||
*/
|
||||
protected $thumbnailTypes = [ 'page', 'default' ];
|
||||
|
||||
protected $thumbnailType = null;
|
||||
|
||||
/**
|
||||
* @var Medium[]
|
||||
*/
|
||||
@@ -105,7 +108,9 @@ class Medium extends Data implements RenderableInterface
|
||||
*/
|
||||
public function path($reset = true)
|
||||
{
|
||||
if ($reset) $this->reset();
|
||||
if ($reset) {
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
return $this->get('filepath');
|
||||
}
|
||||
@@ -120,7 +125,9 @@ class Medium extends Data implements RenderableInterface
|
||||
{
|
||||
$output = preg_replace('|^' . GRAV_ROOT . '|', '', $this->get('filepath'));
|
||||
|
||||
if ($reset) $this->reset();
|
||||
if ($reset) {
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
return self::$grav['base_url'] . $output . $this->urlHash();
|
||||
}
|
||||
@@ -158,8 +165,6 @@ class Medium extends Data implements RenderableInterface
|
||||
*/
|
||||
public function parsedownElement($title = null, $alt = null, $class = null, $reset = true)
|
||||
{
|
||||
$element;
|
||||
|
||||
$attributes = $this->attributes;
|
||||
|
||||
$style = '';
|
||||
@@ -249,8 +254,10 @@ class Medium extends Data implements RenderableInterface
|
||||
*/
|
||||
public function display($mode = 'source')
|
||||
{
|
||||
if ($this->mode === $mode)
|
||||
if ($this->mode === $mode) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
$this->mode = $mode;
|
||||
|
||||
@@ -266,8 +273,9 @@ class Medium extends Data implements RenderableInterface
|
||||
*/
|
||||
public function thumbnail($type = 'auto')
|
||||
{
|
||||
if ($type !== 'auto' && !in_array($type, $this->thumbnailTypes))
|
||||
if ($type !== 'auto' && !in_array($type, $this->thumbnailTypes)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
if ($this->thumbnailType !== $type) {
|
||||
$this->_thumbnail = null;
|
||||
|
||||
@@ -113,8 +113,9 @@ class MediumFactory
|
||||
*/
|
||||
public static function scaledFromMedium($medium, $from, $to)
|
||||
{
|
||||
if (! $medium instanceof ImageMedium)
|
||||
if (! $medium instanceof ImageMedium) {
|
||||
return $medium;
|
||||
}
|
||||
|
||||
if ($to > $from) {
|
||||
return $medium;
|
||||
|
||||
@@ -960,7 +960,6 @@ class Page
|
||||
|
||||
// Build an array of meta objects..
|
||||
foreach ((array)$page_header->metadata as $key => $value) {
|
||||
|
||||
// If this is a property type metadata: "og", "twitter", "facebook" etc
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $property => $prop_value) {
|
||||
|
||||
@@ -523,7 +523,6 @@ class Pages
|
||||
|
||||
/** @var \DirectoryIterator $file */
|
||||
foreach ($iterator as $file) {
|
||||
|
||||
if ($file->isDot()) {
|
||||
continue;
|
||||
}
|
||||
@@ -531,14 +530,12 @@ class Pages
|
||||
$name = $file->getFilename();
|
||||
|
||||
if ($file->isFile()) {
|
||||
|
||||
// Update the last modified if it's newer than already found
|
||||
if ($file->getBasename() !== '.DS_Store' && ($modified = $file->getMTime()) > $last_modified) {
|
||||
$last_modified = $modified;
|
||||
}
|
||||
|
||||
if (Utils::endsWith($name, CONTENT_EXT)) {
|
||||
|
||||
$page->init($file);
|
||||
$content_exists = true;
|
||||
|
||||
@@ -547,7 +544,6 @@ class Pages
|
||||
}
|
||||
}
|
||||
} elseif ($file->isDir()) {
|
||||
|
||||
if (!$page->path()) {
|
||||
$page->path($file->getPath());
|
||||
}
|
||||
@@ -593,7 +589,6 @@ class Pages
|
||||
// Build routes and taxonomy map.
|
||||
/** @var $page Page */
|
||||
foreach ($this->instances as $page) {
|
||||
|
||||
$parent = $page->parent();
|
||||
|
||||
if ($parent) {
|
||||
@@ -643,7 +638,6 @@ class Pages
|
||||
}
|
||||
|
||||
foreach ($pages as $key => $info) {
|
||||
|
||||
$child = isset($this->instances[$key]) ? $this->instances[$key] : null;
|
||||
if (!$child) {
|
||||
throw new \RuntimeException("Page does not exist: {$key}");
|
||||
|
||||
Reference in New Issue
Block a user