Merge pull request #7102 from nupplaphil/task/mod_pretheme
Move mod/pretheme to src/Module/ThemeDetails
This commit is contained in:
commit
b79201beaf
3 changed files with 34 additions and 25 deletions
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Theme;
|
||||
|
||||
function pretheme_init(App $a) {
|
||||
|
||||
if ($_REQUEST['theme']) {
|
||||
$theme = $_REQUEST['theme'];
|
||||
$info = Theme::getInfo($theme);
|
||||
if ($info) {
|
||||
// unfortunately there will be no translation for this string
|
||||
$desc = $info['description'];
|
||||
$version = $info['version'];
|
||||
$credits = $info['credits'];
|
||||
} else {
|
||||
$desc = '';
|
||||
$version = '';
|
||||
$credits = '';
|
||||
}
|
||||
echo json_encode(['img' => Theme::getScreenshot($theme), 'desc' => $desc, 'version' => $version, 'credits' => $credits]);
|
||||
}
|
||||
|
||||
exit();
|
||||
}
|
|
@ -155,6 +155,7 @@ class Router
|
|||
$collector->addRoute(['GET'], '/{type}/{name}', Module\Photo::class);
|
||||
$collector->addRoute(['GET'], '/{type}/{customize}/{name}', Module\Photo::class);
|
||||
});
|
||||
$this->routeCollector->addRoute(['GET'], '/pretheme', Module\ThemeDetails::class);
|
||||
$this->routeCollector->addGroup('/profile', function (RouteCollector $collector) {
|
||||
$collector->addRoute(['GET'], '/{nickname}', Module\Profile::class);
|
||||
$collector->addRoute(['GET'], '/{profile:\d+}/view', Module\Profile::class);
|
||||
|
|
33
src/Module/ThemeDetails.php
Normal file
33
src/Module/ThemeDetails.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Module;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Theme;
|
||||
|
||||
/**
|
||||
* Prints theme specific details as a JSON string
|
||||
*/
|
||||
class ThemeDetails extends BaseModule
|
||||
{
|
||||
public static function rawContent()
|
||||
{
|
||||
if (!empty($_REQUEST['theme'])) {
|
||||
$theme = $_REQUEST['theme'];
|
||||
$info = Theme::getInfo($theme);
|
||||
|
||||
// Unfortunately there will be no translation for this string
|
||||
$description = defaults($info, 'description', '');
|
||||
$version = defaults($info, 'version' , '');
|
||||
$credits = defaults($info, 'credits' , '');
|
||||
|
||||
echo json_encode([
|
||||
'img' => Theme::getScreenshot($theme),
|
||||
'desc' => $description,
|
||||
'version' => $version,
|
||||
'credits' => $credits,
|
||||
]);
|
||||
}
|
||||
exit();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue