diff --git a/lib/Alchemy/Phrasea/Border/Attribute/Story.php b/lib/Alchemy/Phrasea/Border/Attribute/Story.php index 9c24bd0a8d..80a5a8ece0 100644 --- a/lib/Alchemy/Phrasea/Border/Attribute/Story.php +++ b/lib/Alchemy/Phrasea/Border/Attribute/Story.php @@ -31,7 +31,7 @@ class Story implements AttributeInterface */ public function __construct(\record_adapter $story) { - if ( ! $story->is_grouping()) { + if ( ! $story->isStory()) { throw new \InvalidArgumentException('Unable to fetch a story from string'); } @@ -87,7 +87,7 @@ class Story implements AttributeInterface throw new \InvalidArgumentException('Unable to fetch a story from string'); } - if ( ! $story->is_grouping()) { + if ( ! $story->isStory()) { throw new \InvalidArgumentException('Unable to fetch a story from string'); } diff --git a/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php b/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php index 9318e013bc..21fbe3e8f0 100644 --- a/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php +++ b/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php @@ -1034,7 +1034,7 @@ class V1Controller extends Controller } - if ($record->is_grouping()) { + if ($record->isStory()) { $ret['results']['stories'][] = $this->listStory($request, $record); } else { $ret['results']['records'][] = $this->listRecord($request, $record); @@ -1190,7 +1190,7 @@ class V1Controller extends Controller */ public function listStory(Request $request, \record_adapter $story) { - if (!$story->is_grouping()) { + if (!$story->isStory()) { return Result::createError($request, 404, 'Story not found')->createResponse(); } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/PropertyController.php b/lib/Alchemy/Phrasea/Controller/Prod/PropertyController.php index a6bdf3c5dd..f3d9a1e2c0 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/PropertyController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/PropertyController.php @@ -127,7 +127,7 @@ class PropertyController extends Controller } //update children if current record is a story - if (isset($applyStatusToChildren[$sbasId]) && $record->is_grouping()) { + if (isset($applyStatusToChildren[$sbasId]) && $record->isStory()) { foreach ($record->get_children() as $child) { if (null !== $updatedStatus = $this->updateRecordStatus($child, $postStatus)) { $updated[$record->get_serialize_key()] = $updatedStatus; diff --git a/lib/Alchemy/Phrasea/Controller/Prod/StoryController.php b/lib/Alchemy/Phrasea/Controller/Prod/StoryController.php index bd1cceadc4..4185a1e520 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/StoryController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/StoryController.php @@ -170,7 +170,7 @@ class StoryController extends Controller { $story = new \record_adapter($this->app, $sbas_id, $record_id); - if (!$story->is_grouping()) { + if (!$story->isStory()) { throw new \Exception('This is not a story'); } @@ -184,7 +184,7 @@ class StoryController extends Controller try { $story = new \record_adapter($this->app, $sbas_id, $record_id); - if (!$story->is_grouping()) { + if (!$story->isStory()) { throw new \Exception('This is not a story'); } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php b/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php index 42e9539944..1917d3f581 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php @@ -40,7 +40,7 @@ class ToolsController extends Controller if (count($records) == 1) { $record = $records->first(); - if (!$record->is_grouping()) { + if (!$record->isStory()) { try { $metadata = $this->getExifToolReader() ->files($record->get_subdef('document')->get_pathfile()) diff --git a/lib/Alchemy/Phrasea/Controller/Prod/WorkzoneController.php b/lib/Alchemy/Phrasea/Controller/Prod/WorkzoneController.php index e1b18f8743..b1de4e2bf5 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/WorkzoneController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/WorkzoneController.php @@ -96,7 +96,7 @@ class WorkzoneController extends Controller $element = explode('_', $element); $story = new \record_adapter($this->app, $element[0], $element[1]); - if (!$story->is_grouping()) { + if (!$story->isStory()) { throw new \Exception('You can only attach stories'); } diff --git a/lib/Alchemy/Phrasea/Controller/RecordsRequest.php b/lib/Alchemy/Phrasea/Controller/RecordsRequest.php index 0d3257c290..6c223c13a7 100644 --- a/lib/Alchemy/Phrasea/Controller/RecordsRequest.php +++ b/lib/Alchemy/Phrasea/Controller/RecordsRequest.php @@ -42,12 +42,12 @@ class RecordsRequest extends ArrayCollection parent::__construct($elements); $this->received = $received; $this->basket = $basket; - $this->isSingleStory = ($flatten !== self::FLATTEN_YES && 1 === count($this) && $this->first()->is_grouping()); + $this->isSingleStory = ($flatten !== self::FLATTEN_YES && 1 === count($this) && $this->first()->isStory()); if (self::FLATTEN_NO !== $flatten) { $to_remove = []; foreach ($this as $key => $record) { - if ($record->is_grouping()) { + if ($record->isStory()) { if (self::FLATTEN_YES === $flatten) { $to_remove[] = $key; } @@ -143,7 +143,7 @@ class RecordsRequest extends ArrayCollection { return new ArrayCollection( array_filter($this->toArray(), function (\record_adapter $record) { - return $record->is_grouping(); + return $record->isStory(); }) ); } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/RecordEditSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/RecordEditSubscriber.php index be89f0349e..856b45f1e2 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/RecordEditSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/RecordEditSubscriber.php @@ -42,7 +42,7 @@ class RecordEditSubscriber implements EventSubscriberInterface private function updateRecord($record, $field) { - if (false === $record->is_grouping()) { + if (false === $record->isStory()) { foreach ($record->get_grouping_parents() as $story) { $this->updateEditField($story, $field); } diff --git a/lib/Alchemy/Phrasea/Media/SubdefSubstituer.php b/lib/Alchemy/Phrasea/Media/SubdefSubstituer.php index 4f2b248f24..c41815b9ee 100644 --- a/lib/Alchemy/Phrasea/Media/SubdefSubstituer.php +++ b/lib/Alchemy/Phrasea/Media/SubdefSubstituer.php @@ -54,7 +54,7 @@ class SubdefSubstituer $subdefFile = $pathhd . $filehd; $meta_writable = true; } else { - $type = $record->is_grouping() ? 'image' : $record->get_type(); + $type = $record->isStory() ? 'image' : $record->get_type(); $subdef_def = $record->get_databox()->get_subdef_structure()->get_subdef($type, $name); if ($record->has_subdef($name) && $record->get_subdef($name)->is_physically_present()) { diff --git a/lib/Alchemy/Phrasea/Model/Serializer/ESRecordSerializer.php b/lib/Alchemy/Phrasea/Model/Serializer/ESRecordSerializer.php index 77c894be7d..2384591497 100644 --- a/lib/Alchemy/Phrasea/Model/Serializer/ESRecordSerializer.php +++ b/lib/Alchemy/Phrasea/Model/Serializer/ESRecordSerializer.php @@ -69,7 +69,7 @@ class ESRecordSerializer extends AbstractSerializer 'sha256' => $record->get_sha256(), 'technical_informations' => $technicalInformation, 'phrasea_type' => $record->get_type(), - 'type' => $record->is_grouping() ? 'story' : 'record', + 'type' => $record->isStory() ? 'story' : 'record', 'uuid' => $record->getUuid(), 'caption' => $caption, 'status' => $status, diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/RecordMoverJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/RecordMoverJob.php index 13b79f4727..71922028ba 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/RecordMoverJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/RecordMoverJob.php @@ -106,7 +106,7 @@ class RecordMoverJob extends AbstractJob break; case 'DELETE': - if ($row['deletechildren'] && $rec->is_grouping()) { + if ($row['deletechildren'] && $rec->isStory()) { /** @var record_adapter $child */ foreach ($rec->get_children() as $child) { $child->delete(); @@ -175,7 +175,7 @@ class RecordMoverJob extends AbstractJob break; case 'DELETE': $tmp['deletechildren'] = false; - if ($sxtask['deletechildren'] && $rec->is_grouping()) { + if ($sxtask['deletechildren'] && $rec->isStory()) { $tmp['deletechildren'] = true; } $ret[] = $tmp; diff --git a/lib/classes/media/subdef.php b/lib/classes/media/subdef.php index 7264be71ae..3658b02061 100644 --- a/lib/classes/media/subdef.php +++ b/lib/classes/media/subdef.php @@ -274,7 +274,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface */ protected function find_substitute_file() { - if ($this->record->is_grouping()) { + if ($this->record->isStory()) { $this->mime = 'image/png'; $this->width = 256; $this->height = 256; diff --git a/lib/classes/record/adapter.php b/lib/classes/record/adapter.php index 5092025ba0..332be2274b 100644 --- a/lib/classes/record/adapter.php +++ b/lib/classes/record/adapter.php @@ -60,7 +60,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface private $subdefs; private $type; private $sha256; - private $grouping; + private $isStory; private $duration; /** @var databox */ private $databox; @@ -232,10 +232,16 @@ class record_adapter implements RecordInterface, cache_cacheableInterface * Return true if the record is a grouping * * @return bool + * @deprecated use {@link self::isStory} instead */ public function is_grouping() { - return $this->grouping; + return $this->isStory(); + } + + public function isStory() + { + return $this->isStory; } /** @@ -506,7 +512,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface $searchDevices = array_merge((array) $devices, (array) databox_subdef::DEVICE_ALL); - $type = $this->is_grouping() ? 'image' : $this->get_type(); + $type = $this->isStory() ? 'image' : $this->get_type(); foreach ($this->databox->get_subdef_structure() as $group => $databoxSubdefs) { @@ -828,7 +834,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface $meta_writable = true; } else { - $type = $this->is_grouping() ? 'image' : $this->get_type(); + $type = $this->isStory() ? 'image' : $this->get_type(); $subdef_def = $this->get_databox()->get_subdef_structure()->get_subdef($type, $name); @@ -1605,7 +1611,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface */ public function get_children() { - if (!$this->is_grouping()) { + if (!$this->isStory()) { throw new Exception('This record is not a grouping'); } @@ -1697,7 +1703,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface public function appendChild(\record_adapter $record) { - if (!$this->is_grouping()) { + if (!$this->isStory()) { throw new \Exception('Only stories can append children'); } @@ -1746,7 +1752,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface public function removeChild(\record_adapter $record) { - if (!$this->is_grouping()) { + if (!$this->isStory()) { throw new \Exception('Only stories can append children'); } @@ -1792,12 +1798,6 @@ class record_adapter implements RecordInterface, cache_cacheableInterface return $this->get_databox()->get_sbas_id(); } - /** {@inheritdoc} */ - public function isStory() - { - return $this->is_grouping(); - } - /** {@inheritdoc} */ public function getMimeType() { @@ -1886,7 +1886,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface $this->sha256 = $data['sha256']; $this->original_name = $data['original_name']; $this->type = $data['type']; - $this->grouping = $data['grouping']; + $this->isStory = $data['grouping']; $this->uuid = $data['uuid']; $this->updated = $data['modification_date']; $this->created = $data['creation_date']; @@ -1903,7 +1903,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface 'sha256' => $this->sha256, 'original_name' => $this->original_name, 'type' => $this->type, - 'grouping' => $this->grouping, + 'grouping' => $this->isStory, 'uuid' => $this->uuid, 'modification_date' => $this->updated, 'creation_date' => $this->created, @@ -1925,7 +1925,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface $this->updated = new DateTime($row['moddate']); $this->uuid = $row['uuid']; - $this->grouping = ($row['parent_record_id'] == '1'); + $this->isStory = ($row['parent_record_id'] == '1'); $this->type = $row['type']; $this->original_name = $row['originalname']; $this->sha256 = $row['sha256']; diff --git a/lib/classes/set/abstract.php b/lib/classes/set/abstract.php index 17ab3a0688..ac2f61c55f 100644 --- a/lib/classes/set/abstract.php +++ b/lib/classes/set/abstract.php @@ -119,7 +119,7 @@ abstract class set_abstract implements IteratorAggregate { $n = 0; foreach ($this->elements as $record) { - if ($record->is_grouping()) + if ($record->isStory()) $n ++; } diff --git a/lib/classes/set/export.php b/lib/classes/set/export.php index 3f82b508fc..6d0958833b 100644 --- a/lib/classes/set/export.php +++ b/lib/classes/set/export.php @@ -100,7 +100,7 @@ class set_export extends set_abstract continue; } - if ($record->is_grouping()) { + if ($record->isStory()) { foreach ($record->get_children() as $child_basrec) { $base_id = $child_basrec->get_base_id(); $record_id = $child_basrec->get_record_id(); diff --git a/lib/classes/set/selection.php b/lib/classes/set/selection.php index 87e3b1f964..20bdd40199 100644 --- a/lib/classes/set/selection.php +++ b/lib/classes/set/selection.php @@ -128,7 +128,7 @@ class set_selection extends set_abstract } catch (\Exception $e) { continue; } - if ($record->is_grouping() && $flatten_groupings === true) { + if ($record->isStory() && $flatten_groupings === true) { foreach ($record->get_children() as $rec) { $this->add_element($rec); } diff --git a/templates/web/client/answers.html.twig b/templates/web/client/answers.html.twig index f70c21f41e..87f94128ae 100644 --- a/templates/web/client/answers.html.twig +++ b/templates/web/client/answers.html.twig @@ -158,7 +158,7 @@ {% endif %} {% endif %} - {% if record.is_grouping %} + {% if record.isStory %} {% set on_click_html = "openPreview('REG',0, '" ~ record.get_serialize_key() ~ "');" %} {% else %} {% set on_click_html = "openPreview('RESULT','" ~ record.getNumber() ~ "');" %} diff --git a/templates/web/prod/actions/Property/type.html.twig b/templates/web/prod/actions/Property/type.html.twig index dfa7b17cec..c415e96bf8 100644 --- a/templates/web/prod/actions/Property/type.html.twig +++ b/templates/web/prod/actions/Property/type.html.twig @@ -32,7 +32,7 @@

diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/UploadTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/UploadTest.php index 864bd41bc1..db8959ee7d 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/UploadTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/UploadTest.php @@ -338,7 +338,7 @@ class UploadTest extends \PhraseanetAuthenticatedWebTestCase $id = explode('_', $datas['id']); $record = new \record_adapter(self::$DI['app'], $id[0], $id[1]); - $this->assertFalse($record->is_grouping()); + $this->assertFalse($record->isStory()); $this->assertEquals([], $datas['reasons']); } @@ -375,7 +375,7 @@ class UploadTest extends \PhraseanetAuthenticatedWebTestCase $id = explode('_', $datas['id']); $record = new \record_adapter(self::$DI['app'], $id[0], $id[1]); - $this->assertFalse($record->is_grouping()); + $this->assertFalse($record->isStory()); $this->assertEquals(1, substr(strrev($record->get_status()), 4, 1)); $this->assertEquals([], $datas['reasons']); } diff --git a/tests/classes/record/adapterTest.php b/tests/classes/record/adapterTest.php index 52587f51bc..0f2c853c24 100644 --- a/tests/classes/record/adapterTest.php +++ b/tests/classes/record/adapterTest.php @@ -152,8 +152,8 @@ class record_adapterTest extends \PhraseanetAuthenticatedTestCase public function testIs_grouping() { - $this->assertFalse($this->getRecord1()->is_grouping()); - $this->assertTrue($this->getRecordStory1()->is_grouping()); + $this->assertFalse($this->getRecord1()->isStory()); + $this->assertTrue($this->getRecordStory1()->isStory()); } public function testGet_base_id()