PluginProbe
User Access Manager / 2.1.9
User Access Manager v2.1.9
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
user-access-manager / src / Controller / Backend / AboutController.php

AboutController.php in User Access Manager 2.1.9, at src/Controller/Backend/AboutController.php

100 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * AboutController.php
4 *
5 * The AboutController class file.
6 *
7 * PHP versions 5
8 *
9 * @author Alexander Schneider <alexanderschneider85@gmail.com>
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 */
15 namespace UserAccessManager\Controller\Backend;
16
17 use UserAccessManager\Controller\Controller;
18
19 /**
20 * Class AboutController
21 *
22 * @package UserAccessManager\Controller
23 */
24 class AboutController extends Controller
25 {
26 const SUPPORTER_FILE = 'supporters.json';
27 const SUPPORTER_FILE_URL = 'https://gm-alex.github.io/user-access-manager/supporters.json';
28
29 /**
30 * @var string
31 */
32 protected $template = 'AdminAbout.php';
33
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()
45 {
46 if ($this->supporters === null) {
47 $realPath = rtrim($this->wordpressConfig->getRealPath(), DIRECTORY_SEPARATOR);
48 $path = [$realPath, 'assets'];
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;
54
55 if ($fileContent !== false) {
56 file_put_contents($fileWithPath, $fileContent);
57 } elseif (is_file($fileWithPath) === true) {
58 $fileContent = file_get_contents($fileWithPath);
59 }
60
61 $this->supporters = (is_string($fileContent) === true) ? json_decode($fileContent, true) : [];
62 }
63
64 return $this->supporters;
65 }
66
67 /**
68 * Returns the people which earn a special thanks.
69 *
70 * @return array
71 */
72 public function getSpecialThanks()
73 {
74 $supporters = $this->getAllSupporters();
75 return isset($supporters['special-thanks']) === true ? $supporters['special-thanks'] : [];
76 }
77
78 /**
79 * Returns the people which earn a special thanks.
80 *
81 * @return array
82 */
83 public function getTopSupporters()
84 {
85 $supporters = $this->getAllSupporters();
86 return isset($supporters['top-supporters']) === true ? $supporters['top-supporters'] : [];
87 }
88
89 /**
90 * Returns the people which earn a special thanks.
91 *
92 * @return array
93 */
94 public function getSupporters()
95 {
96 $supporters = $this->getAllSupporters();
97 return isset($supporters['supporters']) === true ? $supporters['supporters'] : [];
98 }
99 }
100