Skip to content

Commit

Permalink
apply snake_case: according to change requests
Browse files Browse the repository at this point in the history
  • Loading branch information
ferishili committed Nov 7, 2023
1 parent 0919944 commit 38a7894
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ public function __construct(xoctPublicationUsageGUI $a_parent_obj, $a_parent_cmd
public function fillRow($a_set)
{
/**
* @var $PublicationUsageGroup PublicationUsageGroup
* @var $publication_usage_group PublicationUsageGroup
*/
$xoctPublicationUsageGroup = PublicationUsageGroup::find($a_set['id']);
$this->tpl->setVariable('NAME', $xoctPublicationUsageGroup->getName());
$this->tpl->setVariable('DISPLAY_NAME', $xoctPublicationUsageGroup->getDisplayName());
$this->tpl->setVariable('DESCRIPTION', $xoctPublicationUsageGroup->getDescription());
$$publication_usage_group = PublicationUsageGroup::find($a_set['id']);
$this->tpl->setVariable('NAME', $$publication_usage_group->getName());
$this->tpl->setVariable('DISPLAY_NAME', $$publication_usage_group->getDisplayName());
$this->tpl->setVariable('DESCRIPTION', $$publication_usage_group->getDescription());

$this->addActionMenu($xoctPublicationUsageGroup);
$this->addActionMenu($$publication_usage_group);
}


Expand All @@ -82,18 +82,18 @@ protected function initColumns()


/**
* @param PublicationUsageGroup $xoctPublicationUsageGroup
* @param PublicationUsageGroup $publication_usage_group
*
* @throws DICException
*/
protected function addActionMenu(PublicationUsageGroup $xoctPublicationUsageGroup)
protected function addActionMenu(PublicationUsageGroup $publication_usage_group)
{
$current_selection_list = new ilAdvancedSelectionListGUI();
$current_selection_list->setListTitle($this->plugin->txt('common_actions'));
$current_selection_list->setId(self::TBL_ID . '_actions_' . $xoctPublicationUsageGroup->getId());
$current_selection_list->setId(self::TBL_ID . '_actions_' . $publication_usage_group->getId());
$current_selection_list->setUseImages(false);

$this->ctrl->setParameter($this->parent_obj, 'id', $xoctPublicationUsageGroup->getId());
$this->ctrl->setParameter($this->parent_obj, 'id', $publication_usage_group->getId());
$current_selection_list->addItem(
$this->parent_obj->txt(xoctPublicationUsageGUI::CMD_EDIT),
xoctPublicationUsageGUI::CMD_EDIT_GROUP,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,42 +61,42 @@ public function __construct(xoctPublicationUsageGUI $a_parent_obj, $a_parent_cmd
public function fillRow($a_set)
{
/**
* @var $PublicationSubUsage PublicationSubUsage
* @var $publication_sub_usage PublicationSubUsage
*/
$PublicationSubUsage = PublicationSubUsage::find($a_set['id']);
$this->tpl->setVariable('PARENT_USAGE_ID', $PublicationSubUsage->getParentUsageId());
$this->tpl->setVariable('TITLE', $PublicationSubUsage->getTitle());
$this->tpl->setVariable('DISPLAY_NAME', $PublicationSubUsage->getDisplayName());
$this->tpl->setVariable('DESCRIPTION', $PublicationSubUsage->getDescription());
$this->tpl->setVariable('CHANNEL', $PublicationSubUsage->getChannel());
$this->tpl->setVariable('MD_TYPE', $this->parent_obj->txt('md_type_' . $PublicationSubUsage->getMdType()));
if ($PublicationSubUsage->getMdType() === PublicationUsage::MD_TYPE_PUBLICATION_ITSELF) {
$publication_sub_usage = PublicationSubUsage::find($a_set['id']);
$this->tpl->setVariable('PARENT_USAGE_ID', $publication_sub_usage->getParentUsageId());
$this->tpl->setVariable('TITLE', $publication_sub_usage->getTitle());
$this->tpl->setVariable('DISPLAY_NAME', $publication_sub_usage->getDisplayName());
$this->tpl->setVariable('DESCRIPTION', $publication_sub_usage->getDescription());
$this->tpl->setVariable('CHANNEL', $publication_sub_usage->getChannel());
$this->tpl->setVariable('MD_TYPE', $this->parent_obj->txt('md_type_' . $publication_sub_usage->getMdType()));
if ($publication_sub_usage->getMdType() === PublicationUsage::MD_TYPE_PUBLICATION_ITSELF) {
$this->tpl->setVariable('FLAVOR', '&nbsp');
$this->tpl->setVariable('TAG', '&nbsp');
} elseif ($PublicationSubUsage->getSearchKey() == xoctPublicationUsageFormGUI::F_FLAVOR) {
$this->tpl->setVariable('FLAVOR', $PublicationSubUsage->getFlavor());
} elseif ($publication_sub_usage->getSearchKey() == xoctPublicationUsageFormGUI::F_FLAVOR) {
$this->tpl->setVariable('FLAVOR', $publication_sub_usage->getFlavor());
$this->tpl->setVariable('TAG', '&nbsp');
} else {
$this->tpl->setVariable('TAG', $PublicationSubUsage->getTag());
$this->tpl->setVariable('TAG', $publication_sub_usage->getTag());
$this->tpl->setVariable('FLAVOR', '&nbsp');
}
$group_name = '';
if (!is_null($PublicationSubUsage->getGroupId())) {
$PublicationUsageGroup = PublicationUsageGroup::find($PublicationSubUsage->getGroupId());
$group_name = $PublicationUsageGroup ? $PublicationUsageGroup->getName() : $group_name;
if (!is_null($publication_sub_usage->getGroupId())) {
$publication_usage_group = PublicationUsageGroup::find($publication_sub_usage->getGroupId());
$group_name = $publication_usage_group ? $publication_usage_group->getName() : $group_name;
}
$this->tpl->setVariable('GROUP_NAME', $group_name);

$extras = [];
if ($PublicationSubUsage->getParentUsageId() == PublicationUsage::USAGE_DOWNLOAD ||
$PublicationSubUsage->getParentUsageId() == PublicationUsage::USAGE_DOWNLOAD_FALLBACK) {
if ($PublicationSubUsage->isExternalDownloadSource()) {
if ($publication_sub_usage->getParentUsageId() == PublicationUsage::USAGE_DOWNLOAD ||
$publication_sub_usage->getParentUsageId() == PublicationUsage::USAGE_DOWNLOAD_FALLBACK) {
if ($publication_sub_usage->isExternalDownloadSource()) {
$extras[] = $this->parent_obj->txt('ext_dl_source');
}
}
$this->tpl->setVariable('EXTRA_CONFIG', implode('<br>', $extras));

$this->addActionMenu($PublicationSubUsage);
$this->addActionMenu($publication_sub_usage);
}


Expand All @@ -118,18 +118,18 @@ protected function initColumns()


/**
* @param PublicationSubUsage $PublicationSubUsage
* @param PublicationSubUsage $publication_sub_usage
*
* @throws DICException
*/
protected function addActionMenu(PublicationSubUsage $PublicationSubUsage)
protected function addActionMenu(PublicationSubUsage $publication_sub_usage)
{
$current_selection_list = new ilAdvancedSelectionListGUI();
$current_selection_list->setListTitle($this->plugin->txt('common_actions'));
$current_selection_list->setId(self::TBL_ID . '_actions_' . $PublicationSubUsage->getId());
$current_selection_list->setId(self::TBL_ID . '_actions_' . $publication_sub_usage->getId());
$current_selection_list->setUseImages(false);

$this->ctrl->setParameter($this->parent_obj, 'id', $PublicationSubUsage->getId());
$this->ctrl->setParameter($this->parent_obj, 'id', $publication_sub_usage->getId());
$current_selection_list->addItem(
$this->parent_obj->txt(xoctPublicationUsageGUI::CMD_EDIT),
xoctPublicationUsageGUI::CMD_EDIT_SUB,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,42 +68,42 @@ public function __construct(xoctPublicationUsageGUI $a_parent_obj, $a_parent_cmd
protected function fillRow($a_set)
{
/**
* @var $PublicationUsage PublicationUsage
* @var $publication_usage PublicationUsage
*/
$PublicationUsage = $this->repository->getUsage($a_set['usage_id']);
$this->tpl->setVariable('USAGE_ID', $PublicationUsage->getUsageId());
$this->tpl->setVariable('TITLE', $PublicationUsage->getTitle());
$this->tpl->setVariable('DISPLAY_NAME', $PublicationUsage->getDisplayName());
$this->tpl->setVariable('DESCRIPTION', $PublicationUsage->getDescription());
$this->tpl->setVariable('CHANNEL', $PublicationUsage->getChannel());
$this->tpl->setVariable('MD_TYPE', $this->parent_obj->txt('md_type_' . $PublicationUsage->getMdType()));
if ($PublicationUsage->getMdType() === PublicationUsage::MD_TYPE_PUBLICATION_ITSELF) {
$publication_usage = $this->repository->getUsage($a_set['usage_id']);
$this->tpl->setVariable('USAGE_ID', $publication_usage->getUsageId());
$this->tpl->setVariable('TITLE', $publication_usage->getTitle());
$this->tpl->setVariable('DISPLAY_NAME', $publication_usage->getDisplayName());
$this->tpl->setVariable('DESCRIPTION', $publication_usage->getDescription());
$this->tpl->setVariable('CHANNEL', $publication_usage->getChannel());
$this->tpl->setVariable('MD_TYPE', $this->parent_obj->txt('md_type_' . $publication_usage->getMdType()));
if ($publication_usage->getMdType() === PublicationUsage::MD_TYPE_PUBLICATION_ITSELF) {
$this->tpl->setVariable('FLAVOR', '&nbsp');
$this->tpl->setVariable('TAG', '&nbsp');
} elseif ($PublicationUsage->getSearchKey() == xoctPublicationUsageFormGUI::F_FLAVOR) {
$this->tpl->setVariable('FLAVOR', $PublicationUsage->getFlavor());
} elseif ($publication_usage->getSearchKey() == xoctPublicationUsageFormGUI::F_FLAVOR) {
$this->tpl->setVariable('FLAVOR', $publication_usage->getFlavor());
$this->tpl->setVariable('TAG', '&nbsp');
} else {
$this->tpl->setVariable('TAG', $PublicationUsage->getTag());
$this->tpl->setVariable('TAG', $publication_usage->getTag());
$this->tpl->setVariable('FLAVOR', '&nbsp');
}
$group_name = '';
if (!is_null($PublicationUsage->getGroupId())) {
$PublicationUsageGroup = PublicationUsageGroup::find($PublicationUsage->getGroupId());
$group_name = $PublicationUsageGroup ? $PublicationUsageGroup->getName() : $group_name;
if (!is_null($publication_usage->getGroupId())) {
$$publication_usage_group = PublicationUsageGroup::find($publication_usage->getGroupId());
$group_name = $$publication_usage_group ? $$publication_usage_group->getName() : $group_name;
}
$this->tpl->setVariable('GROUP_NAME', $group_name);

$extras = [];
if ($PublicationUsage->getUsageId() == PublicationUsage::USAGE_DOWNLOAD ||
$PublicationUsage->getUsageId() == PublicationUsage::USAGE_DOWNLOAD_FALLBACK) {
if ($PublicationUsage->isExternalDownloadSource()) {
if ($publication_usage->getUsageId() == PublicationUsage::USAGE_DOWNLOAD ||
$publication_usage->getUsageId() == PublicationUsage::USAGE_DOWNLOAD_FALLBACK) {
if ($publication_usage->isExternalDownloadSource()) {
$extras[] = $this->parent_obj->txt('ext_dl_source');
}
}
$this->tpl->setVariable('EXTRA_CONFIG', implode('<br>', $extras));

$this->addActionMenu($PublicationUsage);
$this->addActionMenu($publication_usage);
}

protected function initColumns()
Expand Down
16 changes: 8 additions & 8 deletions src/Model/Publication/Config/PublicationUsageDefault.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ public static function getDefaultUsage(string $usage)
if (is_null($defaults)) {
return null;
}
$PublicationUsage = new PublicationUsage();
$PublicationUsage->setUsageId($usage);
$PublicationUsage->setChannel($defaults['channel']);
$PublicationUsage->setMdType($defaults['md_type']);
$PublicationUsage->setSearchKey($defaults['search_key']);
$PublicationUsage->setFlavor($defaults['flavor']);
$PublicationUsage->setTag($defaults['tag']);
return $PublicationUsage;
$publication_usage = new PublicationUsage();
$publication_usage->setUsageId($usage);
$publication_usage->setChannel($defaults['channel']);
$publication_usage->setMdType($defaults['md_type']);
$publication_usage->setSearchKey($defaults['search_key']);
$publication_usage->setFlavor($defaults['flavor']);
$publication_usage->setTag($defaults['tag']);
return $publication_usage;
}
}
44 changes: 22 additions & 22 deletions src/Model/Publication/PublicationSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -469,27 +469,27 @@ public function getThumbnailUrl()
}

/**
* @param $PublicationUsage
* @param $publication_usage
*
* @return Publication[]|Media[]|Attachment[]
* @throws xoctException
*/
public function getPublicationMetadataForUsage($PublicationUsage): array
public function getPublicationMetadataForUsage($publication_usage): array
{
if (!$PublicationUsage instanceof PublicationUsage) {
if (!$publication_usage instanceof PublicationUsage) {
return [];
}
$usage_type = property_exists($PublicationUsage, 'is_sub') ? PublicationUsage::USAGE_TYPE_SUB : PublicationUsage::USAGE_TYPE_ORG;
$usage_id = property_exists($PublicationUsage, 'sub_id') ? $PublicationUsage->sub_id : $PublicationUsage->getUsageId();
$usage_type = property_exists($publication_usage, 'is_sub') ? PublicationUsage::USAGE_TYPE_SUB : PublicationUsage::USAGE_TYPE_ORG;
$usage_id = property_exists($publication_usage, 'sub_id') ? $publication_usage->sub_id : $publication_usage->getUsageId();
/**
* @var $PublicationUsage PublicationUsage
* @var $publication_usage PublicationUsage
* @var $attachment Attachment
* @var $medium Media
*/
$media = [];
$attachments = [];
foreach ($this->getPublications() as $publication) {
if ($publication->getChannel() === $PublicationUsage->getChannel()) {
if ($publication->getChannel() === $publication_usage->getChannel()) {
$media += $publication->getMedia();
$attachments += $publication->getAttachments();
}
Expand All @@ -506,21 +506,21 @@ public function getPublicationMetadataForUsage($PublicationUsage): array
return $medium;
}, $media);
$return = [];
switch ($PublicationUsage->getMdType()) {
switch ($publication_usage->getMdType()) {
case PublicationUsage::MD_TYPE_ATTACHMENT:
foreach ($attachments as $attachment) {
switch ($PublicationUsage->getSearchKey()) {
switch ($publication_usage->getSearchKey()) {
case PublicationUsage::SEARCH_KEY_FLAVOR:
if ($this->checkFlavor($attachment->getFlavor(), $PublicationUsage->getFlavor())) {
$result = $this->checkMediaTypes($attachment, $PublicationUsage);
if ($this->checkFlavor($attachment->getFlavor(), $publication_usage->getFlavor())) {
$result = $this->checkMediaTypes($attachment, $publication_usage);
if (!empty($result)) {
$return[] = clone $result;
}
}
break;
case PublicationUsage::SEARCH_KEY_TAG:
if (in_array($PublicationUsage->getTag(), $attachment->getTags())) {
$result = $this->checkMediaTypes($attachment, $PublicationUsage);
if (in_array($publication_usage->getTag(), $attachment->getTags())) {
$result = $this->checkMediaTypes($attachment, $publication_usage);
if (!empty($result)) {
$return[] = clone $result;
}
Expand All @@ -531,18 +531,18 @@ public function getPublicationMetadataForUsage($PublicationUsage): array
break;
case PublicationUsage::MD_TYPE_MEDIA:
foreach ($media as $medium) {
switch ($PublicationUsage->getSearchKey()) {
switch ($publication_usage->getSearchKey()) {
case PublicationUsage::SEARCH_KEY_FLAVOR:
if ($this->checkFlavor($medium->getFlavor(), $PublicationUsage->getFlavor())) {
$result = $this->checkMediaTypes($medium, $PublicationUsage);
if ($this->checkFlavor($medium->getFlavor(), $publication_usage->getFlavor())) {
$result = $this->checkMediaTypes($medium, $publication_usage);
if (!empty($result)) {
$return[] = clone $result;
}
}
break;
case PublicationUsage::SEARCH_KEY_TAG:
if (in_array($PublicationUsage->getTag(), $medium->getTags())) {
$result = $this->checkMediaTypes($medium, $PublicationUsage);
if (in_array($publication_usage->getTag(), $medium->getTags())) {
$result = $this->checkMediaTypes($medium, $publication_usage);
if (!empty($result)) {
$return[] = clone $result;
}
Expand All @@ -553,7 +553,7 @@ public function getPublicationMetadataForUsage($PublicationUsage): array
break;
case PublicationUsage::MD_TYPE_PUBLICATION_ITSELF:
foreach ($this->getPublications() as $publication) {
if ($publication->getChannel() == $PublicationUsage->getChannel()) {
if ($publication->getChannel() == $publication_usage->getChannel()) {
$publication->usage_type = $usage_type;
$publication->usage_id = $usage_id;
$return[] = clone $publication;
Expand Down Expand Up @@ -623,13 +623,13 @@ public function setReference(SerializableClosure $reference): void
/**
* Returns the publication if the media type matches the usage media type, null otherwise.
* @param publicationMetadata $publicationType
* @param PublicationUsage $publicationUsage
* @param PublicationUsage $publication_usage
*
* @return publicationMetadata|null
*/
private function checkMediaTypes(publicationMetadata $publicationType, PublicationUsage $publicationUsage): ?publicationMetadata
private function checkMediaTypes(publicationMetadata $publicationType, PublicationUsage $publication_usage): ?publicationMetadata
{
$media_types = $publicationUsage->getArrayMediaTypes();
$media_types = $publication_usage->getArrayMediaTypes();
if (empty($media_types)) {
return $publicationType;
}
Expand Down

0 comments on commit 38a7894

Please sign in to comment.