Skip to content

Commit

Permalink
Move misc pages to Community namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
carlbennett committed Dec 2, 2024
1 parent 003fc59 commit 9c881cc
Show file tree
Hide file tree
Showing 46 changed files with 444 additions and 398 deletions.
34 changes: 34 additions & 0 deletions src/Controllers/Community/Credits.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace BNETDocs\Controllers\Community;

use \BNETDocs\Libraries\Community\Credits as CreditsLib;

class Credits extends \BNETDocs\Controllers\Base
{
/**
* Constructs a Controller, typically to initialize properties.
*/
public function __construct()
{
$this->model = new \BNETDocs\Models\Community\Credits();
}

/**
* Invoked by the Router class to handle the request.
*
* @param array|null $args The optional route arguments and any captured URI arguments.
* @return boolean Whether the Router should invoke the configured View.
*/
public function invoke(?array $args): bool
{
$this->model->_responseCode = \BNETDocs\Libraries\Core\HttpCode::HTTP_OK;
$this->model->top_contributors_by_comments = CreditsLib::getTopContributorsByComments();
$this->model->top_contributors_by_documents = CreditsLib::getTopContributorsByDocuments();
$this->model->top_contributors_by_news_posts = CreditsLib::getTopContributorsByNewsPosts();
$this->model->top_contributors_by_packets = CreditsLib::getTopContributorsByPackets();
$this->model->top_contributors_by_servers = CreditsLib::getTopContributorsByServers();
$this->model->total_users = CreditsLib::getTotalUsers();
return true;
}
}
34 changes: 34 additions & 0 deletions src/Controllers/Community/Discord.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace BNETDocs\Controllers\Community;

use \BNETDocs\Libraries\Core\HttpCode;

class Discord extends \BNETDocs\Controllers\Base
{
/**
* Constructs a Controller, typically to initialize properties.
*/
public function __construct()
{
$this->model = new \BNETDocs\Models\Community\Discord();
}

/**
* Invoked by the Router class to handle the request.
*
* @param array|null $args The optional route arguments and any captured URI arguments.
* @return boolean Whether the Router should invoke the configured View.
*/
public function invoke(?array $args): bool
{
$config = &\CarlBennett\MVC\Libraries\Common::$config->discord;

$this->model->discord_server_id = $config->server_id;
$this->model->discord_url = \sprintf('https://discord.gg/%s', $config->invite_code);
$this->model->enabled = $config->enabled;

$this->model->_responseCode = ($this->model->enabled ? HttpCode::HTTP_OK : HttpCode::HTTP_SERVICE_UNAVAILABLE);
return true;
}
}
27 changes: 27 additions & 0 deletions src/Controllers/Community/Donate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace BNETDocs\Controllers\Community;

class Donate extends \BNETDocs\Controllers\Base
{
/**
* Constructs a Controller, typically to initialize properties.
*/
public function __construct()
{
$this->model = new \BNETDocs\Models\Community\Donate();
}

/**
* Invoked by the Router class to handle the request.
*
* @param array|null $args The optional route arguments and any captured URI arguments.
* @return boolean Whether the Router should invoke the configured View.
*/
public function invoke(?array $args): bool
{
$this->model->donations = \CarlBennett\MVC\Libraries\Common::$config->bnetdocs->donations;
$this->model->_responseCode = \BNETDocs\Libraries\Core\HttpCode::HTTP_OK;
return true;
}
}
54 changes: 54 additions & 0 deletions src/Controllers/Community/Legal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace BNETDocs\Controllers\Community;

use \BNETDocs\Libraries\Core\DateTimeImmutable;
use \DateTimeZone;

class Legal extends \BNETDocs\Controllers\Base
{
public const LICENSE_FILE = '../LICENSE.txt';

/**
* Constructs a Controller, typically to initialize properties.
*/
public function __construct()
{
$this->model = new \BNETDocs\Models\Community\Legal();
}

/**
* Invoked by the Router class to handle the request.
*
* @param array|null $args The optional route arguments and any captured URI arguments.
* @return boolean Whether the Router should invoke the configured View.
*/
public function invoke(?array $args): bool
{
$privacy_contact = &\CarlBennett\MVC\Libraries\Common::$config->bnetdocs->privacy->contact;
$this->model->email_domain = $privacy_contact->email_domain;
$this->model->email_mailbox = $privacy_contact->email_mailbox;

$this->model->license = \file_get_contents(self::LICENSE_FILE);
$this->model->license_version = \BNETDocs\Libraries\Core\VersionInfo::$version['bnetdocs'][3] ?? null;

if (!\is_null($this->model->license_version))
{
$this->model->license_version = \explode(' ', $this->model->license_version);
$this->model->license_version[1] = new DateTimeImmutable(
$this->model->license_version[1], new DateTimeZone('Etc/UTC')
);
}
else
{
$this->model->license_version = [];
$this->model->license_version[0] = null;
$this->model->license_version[1] = new DateTimeImmutable(
'@' . \filemtime(self::LICENSE_FILE), new DateTimeZone('Etc/UTC')
);
}

$this->model->_responseCode = \BNETDocs\Libraries\Core\HttpCode::HTTP_OK;
return true;
}
}
31 changes: 31 additions & 0 deletions src/Controllers/Community/PrivacyPolicy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace BNETDocs\Controllers\Community;

class PrivacyPolicy extends \BNETDocs\Controllers\Base
{
/**
* Constructs a Controller, typically to initialize properties.
*/
public function __construct()
{
$this->model = new \BNETDocs\Models\Community\PrivacyPolicy();
}

/**
* Invoked by the Router class to handle the request.
*
* @param array|null $args The optional route arguments and any captured URI arguments.
* @return boolean Whether the Router should invoke the configured View.
*/
public function invoke(?array $args): bool
{
$privacy = &\CarlBennett\MVC\Libraries\Common::$config->bnetdocs->privacy;
$this->model->data_location = $privacy->data_location;
$this->model->email_domain = $privacy->contact->email_domain;
$this->model->email_mailbox = $privacy->contact->email_mailbox;
$this->model->organization = $privacy->organization;
$this->model->_responseCode = \BNETDocs\Libraries\Core\HttpCode::HTTP_OK;
return true;
}
}
26 changes: 26 additions & 0 deletions src/Controllers/Community/Welcome.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace BNETDocs\Controllers\Community;

class Welcome extends \BNETDocs\Controllers\Base
{
/**
* Constructs a Controller, typically to initialize properties.
*/
public function __construct()
{
$this->model = new \BNETDocs\Models\Community\Welcome();
}

/**
* Invoked by the Router class to handle the request.
*
* @param array|null $args The optional route arguments and any captured URI arguments.
* @return boolean Whether the Router should invoke the configured View.
*/
public function invoke(?array $args): bool
{
$this->model->_responseCode = \BNETDocs\Libraries\Core\HttpCode::HTTP_OK;
return true;
}
}
34 changes: 0 additions & 34 deletions src/Controllers/Credits.php

This file was deleted.

34 changes: 0 additions & 34 deletions src/Controllers/Discord.php

This file was deleted.

27 changes: 0 additions & 27 deletions src/Controllers/Donate.php

This file was deleted.

54 changes: 0 additions & 54 deletions src/Controllers/Legal.php

This file was deleted.

31 changes: 0 additions & 31 deletions src/Controllers/PrivacyPolicy.php

This file was deleted.

Loading

0 comments on commit 9c881cc

Please sign in to comment.