version.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <?php
  2. // This file is part of GNU social - https://www.gnu.org/software/social
  3. //
  4. // GNU social is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Affero General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // GNU social is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Affero General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Affero General Public License
  15. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  16. defined('GNUSOCIAL') || die();
  17. /**
  18. * Version info page
  19. *
  20. * A page that shows version information for this site. Helpful for
  21. * debugging, for giving credit to authors, and for linking to more
  22. * complete documentation for admins.
  23. *
  24. * @category Info
  25. * @package GNUsocial
  26. * @author Evan Prodromou <evan@status.net>
  27. * @author Craig Andrews <candrews@integralblue.com>
  28. * @copyright 2009-2011 Free Software Foundation, Inc http://www.fsf.org
  29. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
  30. * @link http://status.net/
  31. */
  32. class VersionAction extends Action
  33. {
  34. public $pluginVersions = [];
  35. /**
  36. * Return true since we're read-only.
  37. *
  38. * @param array $args other arguments
  39. *
  40. * @return bool is read only action?
  41. */
  42. public function isReadOnly($args)
  43. {
  44. return true;
  45. }
  46. /**
  47. * Returns the page title
  48. *
  49. * @return string page title
  50. */
  51. public function title()
  52. {
  53. // TRANS: Title for version page. %1$s is the engine name, %2$s is the engine version.
  54. return sprintf(_('%1$s %2$s'), GNUSOCIAL_ENGINE, GNUSOCIAL_VERSION);
  55. }
  56. /**
  57. * Prepare to run
  58. *
  59. * Fire off an event to let plugins report their
  60. * versions.
  61. *
  62. * @param array $args array misc. arguments
  63. *
  64. * @return bool true
  65. * @throws ClientException
  66. */
  67. protected function prepare(array $args = [])
  68. {
  69. parent::prepare($args);
  70. Event::handle('ModuleVersion', [&$this->pluginVersions]);
  71. // Filter out core modules
  72. $plugins = array_filter($this->pluginVersions, function ($plugin) {
  73. return !in_array($plugin['name'], array_keys(common_config('plugins', 'core')));
  74. });
  75. $this->pluginVersions = $plugins;
  76. return true;
  77. }
  78. /**
  79. * Execute the action
  80. *
  81. * Shows a page with the version information in the
  82. * content area.
  83. *
  84. * @return void
  85. * @throws ClientException
  86. * @throws ReflectionException
  87. * @throws ServerException
  88. */
  89. protected function handle()
  90. {
  91. parent::handle();
  92. $this->showPage();
  93. }
  94. /*
  95. * Override to add h-entry, and content-inner classes
  96. *
  97. * @return void
  98. */
  99. public function showContentBlock()
  100. {
  101. $this->elementStart('div', ['id' => 'content', 'class' => 'h-entry']);
  102. $this->showPageTitle();
  103. $this->showPageNoticeBlock();
  104. $this->elementStart('div', ['id' => 'content_inner',
  105. 'class' => 'e-content']);
  106. // show the actual content (forms, lists, whatever)
  107. $this->showContent();
  108. $this->elementEnd('div');
  109. $this->elementEnd('div');
  110. }
  111. /*
  112. * Overrride to add entry-title class
  113. *
  114. * @return void
  115. */
  116. public function showPageTitle()
  117. {
  118. $this->element('h1', ['class' => 'entry-title'], $this->title());
  119. }
  120. /**
  121. * Show version information
  122. *
  123. * @return void
  124. * @throws Exception
  125. */
  126. public function showContent()
  127. {
  128. $this->elementStart('p');
  129. // TRANS: Content part of engine version page.
  130. // TRANS: %1$s is the engine name (GNU social) and %2$s is the GNU social version.
  131. $this->raw(sprintf(
  132. _('This site is powered by %1$s version %2$s, ' .
  133. 'Copyright 2010 Free Software Foundation, Inc.'),
  134. XMLStringer::estring(
  135. 'a',
  136. ['href' => GNUSOCIAL_ENGINE_URL],
  137. // TRANS: Engine name.
  138. GNUSOCIAL_ENGINE
  139. ),
  140. GNUSOCIAL_VERSION
  141. ));
  142. $this->elementEnd('p');
  143. // TRANS: Header for engine software contributors section on the version page.
  144. $this->element('h2', null, _('Contributors'));
  145. $this->elementStart('p');
  146. $this->raw(sprintf(
  147. 'See %s for a full list of contributors.',
  148. XMLStringer::estring(
  149. 'a',
  150. ['href' => 'https://notabug.org/diogo/gnu-social/src/nightly/CREDITS.md'],
  151. 'https://notabug.org/diogo/gnu-social/src/nightly/CREDITS.md'
  152. )
  153. ));
  154. $this->elementEnd('p');
  155. // TRANS: Header for engine software license section on the version page.
  156. $this->element('h2', null, _('License'));
  157. $this->element(
  158. 'p',
  159. null,
  160. // TRANS: Content part of engine software version page. %1s is engine name
  161. sprintf(_('%1$s is free software: you can redistribute it and/or modify ' .
  162. 'it under the terms of the GNU Affero General Public License as published by ' .
  163. 'the Free Software Foundation, either version 3 of the License, or ' .
  164. '(at your option) any later version.'), GNUSOCIAL_ENGINE)
  165. );
  166. $this->element(
  167. 'p',
  168. null,
  169. // TRANS: Content part of engine software version page.
  170. _('This program is distributed in the hope that it will be useful, ' .
  171. 'but WITHOUT ANY WARRANTY; without even the implied warranty of ' .
  172. 'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ' .
  173. 'GNU Affero General Public License for more details.')
  174. );
  175. $this->elementStart('p');
  176. // TRANS: Content part of engine version page.
  177. // TRANS: %s is a link to the AGPL license with link description "http://www.gnu.org/licenses/agpl.html".
  178. $this->raw(sprintf(
  179. _('You should have received a copy of the GNU Affero General Public License ' .
  180. 'along with this program. If not, see %s.'),
  181. XMLStringer::estring(
  182. 'a',
  183. ['href' => 'https://www.gnu.org/licenses/agpl.html'],
  184. 'https://www.gnu.org/licenses/agpl.html'
  185. )
  186. ));
  187. $this->elementEnd('p');
  188. // XXX: Theme information?
  189. if (count($this->pluginVersions)) {
  190. // TRANS: Header for engine plugins section on the version page.
  191. $this->element('h2', null, _('Plugins'));
  192. $this->elementStart('table', ['id' => 'plugins_enabled']);
  193. $this->elementStart('thead');
  194. $this->elementStart('tr');
  195. // TRANS: Column header for plugins table on version page.
  196. $this->element('th', ['id' => 'plugin_name'], _m('HEADER', 'Name'));
  197. // TRANS: Column header for plugins table on version page.
  198. $this->element('th', ['id' => 'plugin_version'], _m('HEADER', 'Version'));
  199. // TRANS: Column header for plugins table on version page.
  200. $this->element('th', ['id' => 'plugin_authors'], _m('HEADER', 'Author(s)'));
  201. // TRANS: Column header for plugins table on version page.
  202. $this->element('th', ['id' => 'plugin_description'], _m('HEADER', 'Description'));
  203. $this->elementEnd('tr');
  204. $this->elementEnd('thead');
  205. $this->elementStart('tbody');
  206. foreach ($this->pluginVersions as $plugin) {
  207. $this->elementStart('tr');
  208. if (array_key_exists('homepage', $plugin)) {
  209. $this->elementStart('th');
  210. $this->element(
  211. 'a',
  212. ['href' => $plugin['homepage']],
  213. $plugin['name']
  214. );
  215. $this->elementEnd('th');
  216. } else {
  217. $this->element('th', null, $plugin['name']);
  218. }
  219. $this->element('td', null, $plugin['version']);
  220. if (array_key_exists('author', $plugin)) {
  221. $this->element('td', null, $plugin['author']);
  222. }
  223. if (array_key_exists('rawdescription', $plugin)) {
  224. $this->elementStart('td');
  225. $this->raw($plugin['rawdescription']);
  226. $this->elementEnd('td');
  227. } elseif (array_key_exists('description', $plugin)) {
  228. $this->element('td', null, $plugin['description']);
  229. }
  230. $this->elementEnd('tr');
  231. }
  232. $this->elementEnd('tbody');
  233. $this->elementEnd('table');
  234. }
  235. }
  236. }