2014-09-25 19:11:41 +02:00
|
|
|
<?php
|
|
|
|
namespace Szurubooru\FormData;
|
|
|
|
|
|
|
|
class PostEditFormData implements \Szurubooru\IValidatable
|
|
|
|
{
|
|
|
|
public $content;
|
|
|
|
public $thumbnail;
|
|
|
|
public $safety;
|
|
|
|
public $source;
|
|
|
|
public $tags;
|
2014-09-25 23:53:47 +02:00
|
|
|
public $relations;
|
2014-09-25 19:11:41 +02:00
|
|
|
|
2014-09-25 22:19:15 +02:00
|
|
|
public $seenEditTime;
|
|
|
|
|
2014-09-25 19:11:41 +02:00
|
|
|
public function __construct($inputReader = null)
|
|
|
|
{
|
|
|
|
if ($inputReader !== null)
|
|
|
|
{
|
|
|
|
$this->content = $inputReader->decodeBase64($inputReader->content);
|
|
|
|
$this->thumbnail = $inputReader->decodebase64($inputReader->thumbnail);
|
|
|
|
$this->safety = \Szurubooru\Helpers\EnumHelper::postSafetyFromString($inputReader->safety);
|
|
|
|
$this->source = $inputReader->source;
|
|
|
|
$this->tags = preg_split('/[\s+]/', $inputReader->tags);
|
2014-09-25 23:53:47 +02:00
|
|
|
$this->relations = array_filter(preg_split('/[\s+]/', $inputReader->relations));
|
2014-09-25 22:19:15 +02:00
|
|
|
$this->seenEditTime = $inputReader->seenEditTime;
|
2014-09-25 19:11:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function validate(\Szurubooru\Validator $validator)
|
|
|
|
{
|
|
|
|
$validator->validatePostTags($this->tags);
|
|
|
|
|
|
|
|
if ($this->source !== null)
|
|
|
|
$validator->validatePostSource($this->source);
|
2014-09-25 23:53:47 +02:00
|
|
|
|
|
|
|
if ($this->relations)
|
|
|
|
{
|
|
|
|
foreach ($this->relations as $relatedPostId)
|
|
|
|
$validator->validateNumber($relatedPostId);
|
|
|
|
}
|
2014-09-25 19:11:41 +02:00
|
|
|
}
|
|
|
|
}
|