version.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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. $this->pluginVersions = PluginList::getActivePluginVersions();
  71. return true;
  72. }
  73. /**
  74. * Execute the action
  75. *
  76. * Shows a page with the version information in the
  77. * content area.
  78. *
  79. * @return void
  80. * @throws ClientException
  81. * @throws ReflectionException
  82. * @throws ServerException
  83. */
  84. protected function handle()
  85. {
  86. parent::handle();
  87. $this->showPage();
  88. }
  89. /*
  90. * Override to add h-entry, and content-inner classes
  91. *
  92. * @return void
  93. */
  94. public function showContentBlock()
  95. {
  96. $this->elementStart('div', ['id' => 'content', 'class' => 'h-entry']);
  97. $this->showPageTitle();
  98. $this->showPageNoticeBlock();
  99. $this->elementStart('div', ['id' => 'content_inner',
  100. 'class' => 'e-content']);
  101. // show the actual content (forms, lists, whatever)
  102. $this->showContent();
  103. $this->elementEnd('div');
  104. $this->elementEnd('div');
  105. }
  106. /*
  107. * Overrride to add entry-title class
  108. *
  109. * @return void
  110. */
  111. public function showPageTitle()
  112. {
  113. $this->element('h1', ['class' => 'entry-title'], $this->title());
  114. }
  115. /**
  116. * Show version information
  117. *
  118. * @return void
  119. * @throws Exception
  120. */
  121. public function showContent()
  122. {
  123. $this->elementStart('p');
  124. // TRANS: Content part of engine version page.
  125. // TRANS: %1$s is the engine name (GNU social) and %2$s is the GNU social version.
  126. $this->raw(sprintf(
  127. _('This site is powered by %1$s version %2$s, ' .
  128. 'Copyright 2010 Free Software Foundation, Inc.'),
  129. XMLStringer::estring(
  130. 'a',
  131. ['href' => GNUSOCIAL_ENGINE_URL],
  132. // TRANS: Engine name.
  133. GNUSOCIAL_ENGINE
  134. ),
  135. GNUSOCIAL_VERSION
  136. ));
  137. $this->elementEnd('p');
  138. // TRANS: Header for engine software contributors section on the version page.
  139. $this->element('h2', null, _('Contributors'));
  140. $this->elementStart('p');
  141. $this->raw(sprintf(
  142. 'See %s for a full list of contributors.',
  143. XMLStringer::estring(
  144. 'a',
  145. ['href' => 'https://notabug.org/diogo/gnu-social/src/nightly/CREDITS.md'],
  146. 'https://notabug.org/diogo/gnu-social/src/nightly/CREDITS.md'
  147. )
  148. ));
  149. $this->elementEnd('p');
  150. // TRANS: Header for engine software license section on the version page.
  151. $this->element('h2', null, _('License'));
  152. $this->element(
  153. 'p',
  154. null,
  155. // TRANS: Content part of engine software version page. %1s is engine name
  156. sprintf(_('%1$s is free software: you can redistribute it and/or modify ' .
  157. 'it under the terms of the GNU Affero General Public License as published by ' .
  158. 'the Free Software Foundation, either version 3 of the License, or ' .
  159. '(at your option) any later version.'), GNUSOCIAL_ENGINE)
  160. );
  161. $this->element(
  162. 'p',
  163. null,
  164. // TRANS: Content part of engine software version page.
  165. _('This program is distributed in the hope that it will be useful, ' .
  166. 'but WITHOUT ANY WARRANTY; without even the implied warranty of ' .
  167. 'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ' .
  168. 'GNU Affero General Public License for more details.')
  169. );
  170. $this->elementStart('p');
  171. // TRANS: Content part of engine version page.
  172. // TRANS: %s is a link to the AGPL license with link description "http://www.gnu.org/licenses/agpl.html".
  173. $this->raw(sprintf(
  174. _('You should have received a copy of the GNU Affero General Public License ' .
  175. 'along with this program. If not, see %s.'),
  176. XMLStringer::estring(
  177. 'a',
  178. ['href' => 'https://www.gnu.org/licenses/agpl.html'],
  179. 'https://www.gnu.org/licenses/agpl.html'
  180. )
  181. ));
  182. $this->elementEnd('p');
  183. // XXX: Theme information?
  184. if (count($this->pluginVersions)) {
  185. // TRANS: Header for engine plugins section on the version page.
  186. $this->element('h2', null, _('Plugins'));
  187. $this->elementStart('table', ['id' => 'plugins_enabled']);
  188. $this->elementStart('thead');
  189. $this->elementStart('tr');
  190. // TRANS: Column header for plugins table on version page.
  191. $this->element('th', ['id' => 'plugin_name'], _m('HEADER', 'Name'));
  192. // TRANS: Column header for plugins table on version page.
  193. $this->element('th', ['id' => 'plugin_version'], _m('HEADER', 'Version'));
  194. // TRANS: Column header for plugins table on version page.
  195. $this->element('th', ['id' => 'plugin_authors'], _m('HEADER', 'Author(s)'));
  196. // TRANS: Column header for plugins table on version page.
  197. $this->element('th', ['id' => 'plugin_description'], _m('HEADER', 'Description'));
  198. $this->elementEnd('tr');
  199. $this->elementEnd('thead');
  200. $this->elementStart('tbody');
  201. foreach ($this->pluginVersions as $plugin) {
  202. $this->elementStart('tr');
  203. if (array_key_exists('homepage', $plugin)) {
  204. $this->elementStart('th');
  205. $this->element(
  206. 'a',
  207. ['href' => $plugin['homepage']],
  208. $plugin['name']
  209. );
  210. $this->elementEnd('th');
  211. } else {
  212. $this->element('th', null, $plugin['name']);
  213. }
  214. $this->element('td', null, $plugin['version']);
  215. if (array_key_exists('author', $plugin)) {
  216. $this->element('td', null, $plugin['author']);
  217. }
  218. if (array_key_exists('rawdescription', $plugin)) {
  219. $this->elementStart('td');
  220. $this->raw($plugin['rawdescription']);
  221. $this->elementEnd('td');
  222. } elseif (array_key_exists('description', $plugin)) {
  223. $this->element('td', null, $plugin['description']);
  224. }
  225. $this->elementEnd('tr');
  226. }
  227. $this->elementEnd('tbody');
  228. $this->elementEnd('table');
  229. }
  230. }
  231. }