forked from ILIAS-eLearning/ILIAS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Component: build public resources (WIP)
- Loading branch information
Showing
596 changed files
with
596 additions
and
54,371 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
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
File renamed without changes.
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
0
public/calendar.php → ...nts/ILIAS/Calendar/resources/calendar.php
100755 → 100644
File renamed without changes.
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
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
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
67 changes: 67 additions & 0 deletions
67
components/ILIAS/Component/src/Resource/ComponentResource.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,67 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* 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 | ||
* | ||
*********************************************************************/ | ||
|
||
namespace ILIAS\Component\Resource; | ||
|
||
/** | ||
* An public asset is a file or folder that should be served via the web. | ||
*/ | ||
class ComponentResource implements PublicAsset | ||
{ | ||
public const REGEXP_SOURCE = '%^((\w+(/\w+)*\.\w{2,4})|(\.htaccess))$%'; | ||
public const REGEXP_TARGET = '%^((\w+(/\w+)*)|[.])$%'; | ||
|
||
public function __construct( | ||
// the component this belongs to | ||
protected \ILIAS\Component\Component $component, | ||
// path relative to the components resource directory | ||
protected string $source, | ||
// path relative to the ILIAS public directory, filename of resource will be appended | ||
// use one dot for toplevel | ||
protected string $target, | ||
) { | ||
if (!preg_match(self::REGEXP_SOURCE, $this->source)) { | ||
throw new \InvalidArgumentException( | ||
"'{$this->source}' is not a valid source path for a public asset." | ||
); | ||
} | ||
if (!preg_match(self::REGEXP_TARGET, $this->target)) { | ||
throw new \InvalidArgumentException( | ||
"'{$this->target}' is not a valid target path for a public asset." | ||
); | ||
} | ||
} | ||
|
||
public function getSource(): string | ||
{ | ||
list($vendor, $component) = explode("\\", get_class($this->component)); | ||
|
||
return "components/$vendor/$component/resources/{$this->source}"; | ||
} | ||
|
||
public function getTarget(): string | ||
{ | ||
$source = explode("/", $this->source); | ||
if ($this->target === ".") { | ||
return array_pop($source); | ||
} | ||
return $this->target . "/" . array_pop($source); | ||
} | ||
} |
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,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* 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 | ||
* | ||
*********************************************************************/ | ||
|
||
namespace ILIAS\Component\Resource; | ||
|
||
/** | ||
* An endpoint is a PHP file that produces output via HTTP. These will be located | ||
* on the toplevel of the public folder. Fall back to ComponentResource if something | ||
* else is needed. | ||
*/ | ||
class Endpoint extends ComponentResource | ||
{ | ||
public function __construct( | ||
// the component this belongs to | ||
\ILIAS\Component\Component $component, | ||
// path relative to the components resource directory | ||
string $source | ||
) { | ||
parent::__construct($component, $source, "."); | ||
} | ||
} |
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
Oops, something went wrong.