The official, canonical postActiv repository. http://www.postactiv.com

version.php 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <?php
  2. // !TODO: I WRITE HTML, REFACTOR FOR SMARTY
  3. /* ============================================================================
  4. * Title: Version
  5. * Show version information for this software and plugins
  6. *
  7. * postActiv:
  8. * the micro-blogging software
  9. *
  10. * Copyright:
  11. * Copyright (C) 2016-2018, Maiyannah Bishop
  12. *
  13. * Derived from code copyright various sources:
  14. * o GNU Social (C) 2013-2016, Free Software Foundation, Inc
  15. * o StatusNet (C) 2008-2012, StatusNet, Inc
  16. * ----------------------------------------------------------------------------
  17. * License:
  18. * This program is free software: you can redistribute it and/or modify
  19. * it under the terms of the GNU Affero General Public License as published by
  20. * the Free Software Foundation, either version 3 of the License, or
  21. * (at your option) any later version.
  22. *
  23. * This program is distributed in the hope that it will be useful,
  24. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26. * GNU Affero General Public License for more details.
  27. *
  28. * You should have received a copy of the GNU Affero General Public License
  29. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  30. *
  31. * <https://www.gnu.org/licenses/agpl.html>
  32. * ----------------------------------------------------------------------------
  33. * About:
  34. * Show version information for this software and plugins
  35. *
  36. * A page that shows version information for this site. Helpful for
  37. * debugging, for giving credit to authors, and for linking to more
  38. * complete documentation for admins.
  39. *
  40. * PHP version:
  41. * Tested with PHP 7.0
  42. * ----------------------------------------------------------------------------
  43. * File Authors:
  44. * o Evan Prodromou
  45. * o Sarven Capadisli
  46. * o Siebrand Mazeland <s.mazeland@xs4all.nl>
  47. * o Craig Andrews <candrews@integralblue.com>
  48. * o Zach Copley
  49. * o Mikael Nordfeldth <mmn@hethane.se>
  50. * o Maiyannah Bishop <maiyannah.bishop@postactiv.com>
  51. *
  52. * Web:
  53. * o postActiv <http://www.postactiv.com>
  54. * o GNU social <https://www.gnu.org/s/social/>
  55. * ============================================================================
  56. */
  57. // This file is formatted so that it provides useful documentation output in
  58. // NaturalDocs. Please be considerate of this before changing formatting.
  59. if (!defined('POSTACTIV')) { exit(1); }
  60. // ============================================================================
  61. // Class: VersionAction
  62. // Version info page
  63. //
  64. // Variables:
  65. // o pluginVersions - array to hold plugin information
  66. // o contributors - HARDCODED array of contributors
  67. class VersionAction extends Action
  68. {
  69. var $pluginVersions = array();
  70. // -------------------------------------------------------------------------
  71. // Function: isReadOnly
  72. // Return true since we're read-only.
  73. //
  74. // Param:
  75. // o array $args - other arguments
  76. //
  77. // Returns:
  78. // o boolean is read only action?
  79. function isReadOnly($args) {
  80. return true;
  81. }
  82. // -------------------------------------------------------------------------
  83. // Function: title
  84. // Returns the page title
  85. //
  86. // @return string page title
  87. function title() {
  88. // TRANS: Title for version page. %1$s is the engine name, %2$s is the engine version.
  89. return sprintf(_('%1$s %2$s'), GNUSOCIAL_ENGINE, GNUSOCIAL_VERSION);
  90. }
  91. // -------------------------------------------------------------------------
  92. // Function: prepare
  93. // Prepare to run
  94. //
  95. // Fire off an event to let plugins report their
  96. // versions.
  97. //
  98. // Parameters:
  99. // o array $args - array misc. arguments
  100. //
  101. // Returns:
  102. // o boolean success
  103. protected function prepare(array $args=array()) {
  104. try {
  105. parent::prepare($args);
  106. Event::handle('PluginVersion', array(&$this->pluginVersions));
  107. return true;
  108. } catch (exception $e) {
  109. return false;
  110. }
  111. }
  112. // -------------------------------------------------------------------------
  113. // Function: handle
  114. // Shows a page with the version information in the
  115. // content area.
  116. //
  117. // Parameters:
  118. // o array $args - ignored.
  119. //
  120. // Returns:
  121. // o void
  122. protected function handle() {
  123. parent::handle();
  124. $this->showPage();
  125. }
  126. // -------------------------------------------------------------------------
  127. // Function: showContentBlock
  128. // Override to add h-entry, and content-inner classes
  129. //
  130. // Returns:
  131. // o void
  132. function showContentBlock() {
  133. $this->elementStart('div', array('id' => 'content', 'class' => 'h-entry'));
  134. $this->showPageTitle();
  135. $this->showPageNoticeBlock();
  136. $this->elementStart('div', array('id' => 'content_inner',
  137. 'class' => 'e-content'));
  138. // show the actual content (forms, lists, whatever)
  139. $this->showContent();
  140. $this->elementEnd('div');
  141. $this->elementEnd('div');
  142. }
  143. /*
  144. * Overrride to add entry-title class
  145. *
  146. * @return void
  147. */
  148. function showPageTitle() {
  149. $this->element('h1', array('class' => 'entry-title'), $this->title());
  150. }
  151. // -------------------------------------------------------------------------
  152. // Function: showContent
  153. // Show version information
  154. //
  155. // TODO: This will need templated, when Smarty is implemented
  156. //
  157. // @return void
  158. function showContent() {
  159. $this->elementStart('p');
  160. // TRANS: Content part of engine version page.
  161. // TRANS: %1$s is the engine name (GNU social) and %2$s is the GNU social version.
  162. $this->raw(sprintf(_('This site is powered by %1$s version %2$s, '.
  163. 'Copyright 2008-2013 StatusNet, Inc. '.
  164. 'and contributors.'),
  165. XMLStringer::estring('a', array('href' => GNUSOCIAL_ENGINE_URL),
  166. // TRANS: Engine name.
  167. GNUSOCIAL_ENGINE),
  168. GNUSOCIAL_VERSION));
  169. $this->elementEnd('p');
  170. // TRANS: Header for engine software contributors section on the version page.
  171. $this->element('h2', null, _('Contributors'));
  172. sort($this->contributors);
  173. $this->element('p', null, implode(', ', $this->contributors));
  174. // TRANS: Header for engine software license section on the version page.
  175. $this->element('h2', null, _('License'));
  176. $this->element('p', null,
  177. // TRANS: Content part of engine software version page. %1s is engine name
  178. sprintf(_('%1$s is free software: you can redistribute it and/or modify '.
  179. 'it under the terms of the GNU Affero General Public License as published by '.
  180. 'the Free Software Foundation, either version 3 of the License, or '.
  181. '(at your option) any later version.'), GNUSOCIAL_ENGINE));
  182. $this->element('p', null,
  183. // TRANS: Content part of engine software version page.
  184. _('This program is distributed in the hope that it will be useful, '.
  185. 'but WITHOUT ANY WARRANTY; without even the implied warranty of '.
  186. 'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the '.
  187. 'GNU Affero General Public License for more details.'));
  188. $this->elementStart('p');
  189. // TRANS: Content part of engine version page.
  190. // TRANS: %s is a link to the AGPL license with link description "http://www.gnu.org/licenses/agpl.html".
  191. $this->raw(sprintf(_('You should have received a copy of the GNU Affero General Public License '.
  192. 'along with this program. If not, see %s.'),
  193. XMLStringer::estring('a', array('href' => 'http://www.gnu.org/licenses/agpl.html'),
  194. 'http://www.gnu.org/licenses/agpl.html')));
  195. $this->elementEnd('p');
  196. // XXX: Theme information?
  197. if (count($this->pluginVersions)) {
  198. // TRANS: Header for engine plugins section on the version page.
  199. $this->element('h2', null, _('Plugins'));
  200. $this->elementStart('table', array('id' => 'plugins_enabled'));
  201. $this->elementStart('thead');
  202. $this->elementStart('tr');
  203. // TRANS: Column header for plugins table on version page.
  204. $this->element('th', array('id' => 'plugin_name'), _m('HEADER','Name'));
  205. // TRANS: Column header for plugins table on version page.
  206. $this->element('th', array('id' => 'plugin_version'), _m('HEADER','Version'));
  207. // TRANS: Column header for plugins table on version page.
  208. $this->element('th', array('id' => 'plugin_authors'), _m('HEADER','Author(s)'));
  209. // TRANS: Column header for plugins table on version page.
  210. $this->element('th', array('id' => 'plugin_description'), _m('HEADER','Description'));
  211. $this->elementEnd('tr');
  212. $this->elementEnd('thead');
  213. $this->elementStart('tbody');
  214. foreach ($this->pluginVersions as $plugin) {
  215. $this->elementStart('tr');
  216. if (array_key_exists('homepage', $plugin)) {
  217. $this->elementStart('th');
  218. $this->element('a', array('href' => $plugin['homepage']),
  219. $plugin['name']);
  220. $this->elementEnd('th');
  221. } else {
  222. $this->element('th', null, $plugin['name']);
  223. }
  224. $this->element('td', null, $plugin['version']);
  225. if (array_key_exists('author', $plugin)) {
  226. $this->element('td', null, $plugin['author']);
  227. }
  228. if (array_key_exists('rawdescription', $plugin)) {
  229. $this->elementStart('td');
  230. $this->raw($plugin['rawdescription']);
  231. $this->elementEnd('td');
  232. } else if (array_key_exists('description', $plugin)) {
  233. $this->element('td', null, $plugin['description']);
  234. }
  235. $this->elementEnd('tr');
  236. }
  237. $this->elementEnd('tbody');
  238. $this->elementEnd('table');
  239. }
  240. }
  241. var $contributors = array('Evan Prodromou (StatusNet)',
  242. 'Zach Copley (StatusNet)',
  243. 'Earle Martin (StatusNet)',
  244. 'Marie-Claude Doyon (StatusNet)',
  245. 'Sarven Capadisli (StatusNet)',
  246. 'Robin Millette (StatusNet)',
  247. 'Ciaran Gultnieks',
  248. 'Michael Landers',
  249. 'Ori Avtalion',
  250. 'Garret Buell',
  251. 'Mike Cochrane',
  252. 'Matthew Gregg',
  253. 'Florian Biree',
  254. 'Erik Stambaugh',
  255. 'drry',
  256. 'Gina Haeussge',
  257. 'Tryggvi Björgvinsson',
  258. 'Adrian Lang',
  259. 'Meitar Moscovitz',
  260. 'Sean Murphy',
  261. 'Leslie Michael Orchard',
  262. 'Eric Helgeson',
  263. 'Ken Sedgwick',
  264. 'Brian Hendrickson',
  265. 'Tobias Diekershoff',
  266. 'Dan Moore',
  267. 'Fil',
  268. 'Jeff Mitchell',
  269. 'Brenda Wallace',
  270. 'Jeffery To',
  271. 'Federico Marani',
  272. 'Craig Andrews',
  273. 'mEDI',
  274. 'Brett Taylor',
  275. 'Brigitte Schuster',
  276. 'Brion Vibber (StatusNet)',
  277. 'Siebrand Mazeland',
  278. 'Samantha Doherty (StatusNet)',
  279. 'Mikael Nordfeldth (FSF)');
  280. }
  281. // END OF FILE
  282. // ============================================================================
  283. ?>