-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MetaData: move copyright entries to KS (36692)
- Loading branch information
1 parent
3f548de
commit 610d126
Showing
12 changed files
with
787 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of ILIAS, a powerful learning management system | ||
* published by ILIAS open source e-Learning e.V. | ||
* | ||
* ILIAS is licensed with the GPL-3.0, | ||
* see https://www.gnu.org/licenses/gpl-3.0.en.html | ||
* You should have received a copy of said license along with the | ||
* source code, too. | ||
* | ||
* If this is not the case or you just want to try ILIAS, you'll find | ||
* us at: | ||
* https://www.ilias.de | ||
* https://github.com/ILIAS-eLearning | ||
* | ||
*********************************************************************/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ILIAS\MetaData\Copyright; | ||
|
||
use ILIAS\Data\URI; | ||
|
||
class CopyrightData implements CopyrightDataInterface | ||
{ | ||
protected string $full_name; | ||
protected ?URI $link; | ||
protected ?URI $image_link; | ||
protected string $alt_text; | ||
|
||
public function __construct( | ||
string $full_name, | ||
?URI $link, | ||
?URI $image_link, | ||
string $alt_text | ||
) { | ||
$this->full_name = $full_name; | ||
$this->link = $link; | ||
$this->alt_text = $alt_text; | ||
$this->image_link = $image_link; | ||
} | ||
|
||
public function fullName(): string | ||
{ | ||
return $this->full_name; | ||
} | ||
|
||
public function link(): ?URI | ||
{ | ||
return $this->link; | ||
} | ||
|
||
public function imageLink(): ?URI | ||
{ | ||
return $this->image_link; | ||
} | ||
|
||
public function altText(): string | ||
{ | ||
return $this->alt_text; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
Services/MetaData/classes/Copyright/CopyrightDataInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of ILIAS, a powerful learning management system | ||
* published by ILIAS open source e-Learning e.V. | ||
* | ||
* ILIAS is licensed with the GPL-3.0, | ||
* see https://www.gnu.org/licenses/gpl-3.0.en.html | ||
* You should have received a copy of said license along with the | ||
* source code, too. | ||
* | ||
* If this is not the case or you just want to try ILIAS, you'll find | ||
* us at: | ||
* https://www.ilias.de | ||
* https://github.com/ILIAS-eLearning | ||
* | ||
*********************************************************************/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ILIAS\MetaData\Copyright; | ||
|
||
use ILIAS\Data\URI; | ||
|
||
interface CopyrightDataInterface | ||
{ | ||
public function fullName(): string; | ||
|
||
public function link(): ?URI; | ||
|
||
public function imageLink(): ?URI; | ||
|
||
public function altText(): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of ILIAS, a powerful learning management system | ||
* published by ILIAS open source e-Learning e.V. | ||
* | ||
* ILIAS is licensed with the GPL-3.0, | ||
* see https://www.gnu.org/licenses/gpl-3.0.en.html | ||
* You should have received a copy of said license along with the | ||
* source code, too. | ||
* | ||
* If this is not the case or you just want to try ILIAS, you'll find | ||
* us at: | ||
* https://www.ilias.de | ||
* https://github.com/ILIAS-eLearning | ||
* | ||
*********************************************************************/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ILIAS\MetaData\Copyright; | ||
|
||
use ILIAS\Data\URI; | ||
|
||
class NullCopyrightData implements CopyrightDataInterface | ||
{ | ||
public function fullName(): string | ||
{ | ||
return ''; | ||
} | ||
|
||
public function link(): ?URI | ||
{ | ||
return null; | ||
} | ||
|
||
public function imageLink(): ?URI | ||
{ | ||
return null; | ||
} | ||
|
||
public function altText(): string | ||
{ | ||
return ''; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of ILIAS, a powerful learning management system | ||
* published by ILIAS open source e-Learning e.V. | ||
* | ||
* ILIAS is licensed with the GPL-3.0, | ||
* see https://www.gnu.org/licenses/gpl-3.0.en.html | ||
* You should have received a copy of said license along with the | ||
* source code, too. | ||
* | ||
* If this is not the case or you just want to try ILIAS, you'll find | ||
* us at: | ||
* https://www.ilias.de | ||
* https://github.com/ILIAS-eLearning | ||
* | ||
*********************************************************************/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ILIAS\MetaData\Copyright; | ||
|
||
use ILIAS\UI\Factory; | ||
use ILIAS\UI\Component\Image\Image; | ||
use ILIAS\UI\Component\Link\Link; | ||
use ILIAS\UI\Component\Legacy\Legacy; | ||
|
||
class Renderer implements RendererInterface | ||
{ | ||
protected Factory $factory; | ||
|
||
public function __construct( | ||
Factory $factory | ||
) { | ||
$this->factory = $factory; | ||
} | ||
|
||
/** | ||
* @return Image[]|Link[]|Legacy[] | ||
*/ | ||
public function toUIComponents(CopyrightDataInterface $copyright): array | ||
{ | ||
$res = []; | ||
$has_link = false; | ||
if (!is_null($image = $this->buildImage($copyright))) { | ||
$res[] = $image; | ||
} | ||
if (!is_null($link = $this->buildLink($copyright))) { | ||
$res[] = $link; | ||
$has_link = true; | ||
} | ||
if ($copyright->fullName() && !$has_link) { | ||
$res[] = $this->textInLegacy($copyright->fullName()); | ||
} | ||
return $res; | ||
} | ||
|
||
protected function buildImage(CopyrightDataInterface $copyright): ?Image | ||
{ | ||
if (!$copyright->imageLink()) { | ||
return null; | ||
} | ||
return $this->getImage( | ||
(string) $copyright->imageLink(), | ||
$copyright->altText(), | ||
(string) $copyright->link() | ||
); | ||
} | ||
|
||
protected function getImage(string $src, string $alt, string $link): Image | ||
{ | ||
$image = $this->standardImage($src, $alt); | ||
if ($link !== '') { | ||
$image = $image->withAction($link); | ||
} | ||
return $image; | ||
} | ||
|
||
protected function buildLink(CopyrightDataInterface $copyright): ?Link | ||
{ | ||
if (!$copyright->link()) { | ||
return null; | ||
} | ||
return $this->standardLink( | ||
$copyright->fullName() !== '' ? $copyright->fullName() : (string) $copyright->link(), | ||
(string) $copyright->link() | ||
); | ||
} | ||
|
||
protected function standardImage(string $src, string $alt): Image | ||
{ | ||
return $this->factory->image()->standard($src, $alt); | ||
} | ||
|
||
protected function standardLink(string $label, string $action): Link | ||
{ | ||
return $this->factory->link()->standard($label, $action); | ||
} | ||
|
||
protected function textInLegacy(string $text): Legacy | ||
{ | ||
return $this->factory->legacy($text); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of ILIAS, a powerful learning management system | ||
* published by ILIAS open source e-Learning e.V. | ||
* | ||
* ILIAS is licensed with the GPL-3.0, | ||
* see https://www.gnu.org/licenses/gpl-3.0.en.html | ||
* You should have received a copy of said license along with the | ||
* source code, too. | ||
* | ||
* If this is not the case or you just want to try ILIAS, you'll find | ||
* us at: | ||
* https://www.ilias.de | ||
* https://github.com/ILIAS-eLearning | ||
* | ||
*********************************************************************/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ILIAS\MetaData\Copyright; | ||
|
||
use ILIAS\UI\Component\Image\Image; | ||
use ILIAS\UI\Component\Link\Link; | ||
use ILIAS\UI\Component\Legacy\Legacy; | ||
|
||
interface RendererInterface | ||
{ | ||
/** | ||
* Returns a string in a legacy UI component if only a string can be returned. | ||
* @return Image[]|Link[]|Legacy[] | ||
*/ | ||
public function toUIComponents(CopyrightData $copyright): array; | ||
} |
Oops, something went wrong.