version.php 8.9 KB

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