PluginProbe
User Access Manager / 2.1.11
User Access Manager v2.1.11
2.3.20 2.3.19 2.3.18 2.3.17 2.3.16 2.3.15 2.3.14 2.3.13 trunk 0.6 0.6.1 0.6.2 0.7 0.7 Beta 0.7.0.1 0.8 0.8.0.1 0.8.0.2 0.9 0.9.1 0.9.1.1 0.9.1.2 0.9.1.3 0.9.1.4 1.0 All 136 releases
← All changes | src/Controller/Backend/AboutController.php +59 -17 2.3.17 → 2.1.11 View file →
@@ -1,35 +1,62 @@
1 1 <?php
2 -
3 -declare(strict_types=1);
4 -
2 +/**
3 + * AboutController.php
4 + *
5 + * The AboutController class file.
6 + *
7 + * PHP versions 5
8 + *
9 + * @author Alexander Schneider <[email protected]>
10 + * @copyright 2008-2017 Alexander Schneider
11 + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2
12 + * @version SVN: $id$
13 + * @link http://wordpress.org/extend/plugins/user-access-manager/
14 + */
5 15 namespace UserAccessManager\Controller\Backend;
6 16
7 17 use UserAccessManager\Controller\Controller;
8 18
19 +/**
20 + * Class AboutController
21 + *
22 + * @package UserAccessManager\Controller
23 + */
9 24 class AboutController extends Controller
10 25 {
11 26 const SUPPORTER_FILE = 'supporters.json';
12 27 const SUPPORTER_FILE_URL = 'https://gm-alex.github.io/user-access-manager/supporters.json';
13 28
14 - protected ?string $template = 'AdminAbout.php';
15 - private ?array $supporters = null;
29 + /**
30 + * @var string
31 + */
32 + protected $template = 'AdminAbout.php';
16 33
17 - private function getAllSupporters(): ?array
34 + /**
35 + * @var null|array
36 + */
37 + private $supporters = null;
38 +
39 + /**
40 + * Returns all the supporters.
41 + *
42 + * @return array
43 + */
44 + private function getAllSupporters()
18 45 {
19 46 if ($this->supporters === null) {
20 47 $realPath = rtrim($this->wordpressConfig->getRealPath(), DIRECTORY_SEPARATOR);
21 48 $path = [$realPath, 'assets'];
22 - $path = implode(DIRECTORY_SEPARATOR, $path) . DIRECTORY_SEPARATOR;
23 - $fileWithPath = $path . self::SUPPORTER_FILE;
24 - $needsUpdate = $this->php->isFile($fileWithPath) === false
25 - || $this->php->fileMTime($fileWithPath) < $this->wordpress->currentTime('timestamp') - 24 * 60 * 60;
26 - $fileContent = ($needsUpdate === true) ? $this->php->fileGetContents(self::SUPPORTER_FILE_URL) : false;
49 + $path = implode(DIRECTORY_SEPARATOR, $path).DIRECTORY_SEPARATOR;
50 + $fileWithPath = $path.self::SUPPORTER_FILE;
51 + $needsUpdate = is_file($fileWithPath) === false
52 + || filemtime($fileWithPath) < $this->wordpress->currentTime('timestamp') - 24 * 60 * 60;
53 + $fileContent = ($needsUpdate === true) ? @file_get_contents(self::SUPPORTER_FILE_URL) : false;
27 54
28 55 if ($fileContent !== false) {
29 - $this->php->filePutContents($fileWithPath, $fileContent);
30 - } elseif ($this->php->isFile($fileWithPath) === true) {
31 - $fileContent = $this->php->fileGetContents($fileWithPath);
56 + file_put_contents($fileWithPath, $fileContent);
57 + } elseif (is_file($fileWithPath) === true) {
58 + $fileContent = file_get_contents($fileWithPath);
32 59 }
33 60
34 61 $this->supporters = (is_string($fileContent) === true) ? json_decode($fileContent, true) : [];
35 62 }
@@ -36,21 +63,36 @@
36 63
37 64 return $this->supporters;
38 65 }
39 66
40 - public function getSpecialThanks(): array
67 + /**
68 + * Returns the people which earn a special thanks.
69 + *
70 + * @return array
71 + */
72 + public function getSpecialThanks()
41 73 {
42 74 $supporters = $this->getAllSupporters();
43 75 return isset($supporters['special-thanks']) === true ? $supporters['special-thanks'] : [];
44 76 }
45 77
46 - public function getTopSupporters(): array
78 + /**
79 + * Returns the people which earn a special thanks.
80 + *
81 + * @return array
82 + */
83 + public function getTopSupporters()
47 84 {
48 85 $supporters = $this->getAllSupporters();
49 86 return isset($supporters['top-supporters']) === true ? $supporters['top-supporters'] : [];
50 87 }
51 88
52 - public function getSupporters(): array
89 + /**
90 + * Returns the people which earn a special thanks.
91 + *
92 + * @return array
93 + */
94 + public function getSupporters()
53 95 {
54 96 $supporters = $this->getAllSupporters();
55 97 return isset($supporters['supporters']) === true ? $supporters['supporters'] : [];
56 98 }