list.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. <?php
  2. /**
  3. * DokuWiki Plugin extension (Helper Component)
  4. *
  5. * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
  6. * @author Michael Hamann <michael@content-space.de>
  7. */
  8. /**
  9. * Class helper_plugin_extension_list takes care of creating a HTML list of extensions
  10. */
  11. class helper_plugin_extension_list extends DokuWiki_Plugin
  12. {
  13. protected $form = '';
  14. /** @var helper_plugin_extension_gui */
  15. protected $gui;
  16. /**
  17. * Constructor
  18. *
  19. * loads additional helpers
  20. */
  21. public function __construct()
  22. {
  23. $this->gui = plugin_load('helper', 'extension_gui');
  24. }
  25. /**
  26. * Initialize the extension table form
  27. */
  28. public function startForm()
  29. {
  30. $this->form .= '<ul class="extensionList">';
  31. }
  32. /**
  33. * Build single row of extension table
  34. *
  35. * @param helper_plugin_extension_extension $extension The extension that shall be added
  36. * @param bool $showinfo Show the info area
  37. */
  38. public function addRow(helper_plugin_extension_extension $extension, $showinfo = false)
  39. {
  40. $this->startRow($extension);
  41. $this->populateColumn('legend', $this->makeLegend($extension, $showinfo));
  42. $this->populateColumn('actions', $this->makeActions($extension));
  43. $this->endRow();
  44. }
  45. /**
  46. * Adds a header to the form
  47. *
  48. * @param string $id The id of the header
  49. * @param string $header The content of the header
  50. * @param int $level The level of the header
  51. */
  52. public function addHeader($id, $header, $level = 2)
  53. {
  54. $this->form .='<h'.$level.' id="'.$id.'">'.hsc($header).'</h'.$level.'>'.DOKU_LF;
  55. }
  56. /**
  57. * Adds a paragraph to the form
  58. *
  59. * @param string $data The content
  60. */
  61. public function addParagraph($data)
  62. {
  63. $this->form .= '<p>'.hsc($data).'</p>'.DOKU_LF;
  64. }
  65. /**
  66. * Add hidden fields to the form with the given data
  67. *
  68. * @param array $data key-value list of fields and their values to add
  69. */
  70. public function addHidden(array $data)
  71. {
  72. $this->form .= '<div class="no">';
  73. foreach ($data as $key => $value) {
  74. $this->form .= '<input type="hidden" name="'.hsc($key).'" value="'.hsc($value).'" />';
  75. }
  76. $this->form .= '</div>'.DOKU_LF;
  77. }
  78. /**
  79. * Add closing tags
  80. */
  81. public function endForm()
  82. {
  83. $this->form .= '</ul>';
  84. }
  85. /**
  86. * Show message when no results are found
  87. */
  88. public function nothingFound()
  89. {
  90. global $lang;
  91. $this->form .= '<li class="notfound">'.$lang['nothingfound'].'</li>';
  92. }
  93. /**
  94. * Print the form
  95. *
  96. * @param bool $returnonly whether to return html or print
  97. */
  98. public function render($returnonly = false)
  99. {
  100. if ($returnonly) return $this->form;
  101. echo $this->form;
  102. }
  103. /**
  104. * Start the HTML for the row for the extension
  105. *
  106. * @param helper_plugin_extension_extension $extension The extension
  107. */
  108. private function startRow(helper_plugin_extension_extension $extension)
  109. {
  110. $this->form .= '<li id="extensionplugin__'.hsc($extension->getID()).
  111. '" class="'.$this->makeClass($extension).'">';
  112. }
  113. /**
  114. * Add a column with the given class and content
  115. * @param string $class The class name
  116. * @param string $html The content
  117. */
  118. private function populateColumn($class, $html)
  119. {
  120. $this->form .= '<div class="'.$class.' col">'.$html.'</div>'.DOKU_LF;
  121. }
  122. /**
  123. * End the row
  124. */
  125. private function endRow()
  126. {
  127. $this->form .= '</li>'.DOKU_LF;
  128. }
  129. /**
  130. * Generate the link to the plugin homepage
  131. *
  132. * @param helper_plugin_extension_extension $extension The extension
  133. * @return string The HTML code
  134. */
  135. public function makeHomepageLink(helper_plugin_extension_extension $extension)
  136. {
  137. global $conf;
  138. $url = $extension->getURL();
  139. if (strtolower(parse_url($url, PHP_URL_HOST)) == 'www.dokuwiki.org') {
  140. $linktype = 'interwiki';
  141. } else {
  142. $linktype = 'extern';
  143. }
  144. $param = array(
  145. 'href' => $url,
  146. 'title' => $url,
  147. 'class' => ($linktype == 'extern') ? 'urlextern' : 'interwiki iw_doku',
  148. 'target' => $conf['target'][$linktype],
  149. 'rel' => ($linktype == 'extern') ? 'noopener' : '',
  150. );
  151. if ($linktype == 'extern' && $conf['relnofollow']) {
  152. $param['rel'] = implode(' ', [$param['rel'], 'ugc nofollow']);
  153. }
  154. $html = ' <a '. buildAttributes($param, true).'>'.
  155. $this->getLang('homepage_link').'</a>';
  156. return $html;
  157. }
  158. /**
  159. * Generate the class name for the row of the extension
  160. *
  161. * @param helper_plugin_extension_extension $extension The extension object
  162. * @return string The class name
  163. */
  164. public function makeClass(helper_plugin_extension_extension $extension)
  165. {
  166. $class = ($extension->isTemplate()) ? 'template' : 'plugin';
  167. if ($extension->isInstalled()) {
  168. $class.=' installed';
  169. $class.= ($extension->isEnabled()) ? ' enabled':' disabled';
  170. if ($extension->updateAvailable()) $class .= ' updatable';
  171. }
  172. if (!$extension->canModify()) $class.= ' notselect';
  173. if ($extension->isProtected()) $class.= ' protected';
  174. //if($this->showinfo) $class.= ' showinfo';
  175. return $class;
  176. }
  177. /**
  178. * Generate a link to the author of the extension
  179. *
  180. * @param helper_plugin_extension_extension $extension The extension object
  181. * @return string The HTML code of the link
  182. */
  183. public function makeAuthor(helper_plugin_extension_extension $extension)
  184. {
  185. if ($extension->getAuthor()) {
  186. $mailid = $extension->getEmailID();
  187. if ($mailid) {
  188. $url = $this->gui->tabURL('search', array('q' => 'authorid:'.$mailid));
  189. $html = '<a href="'.$url.'" class="author" title="'.$this->getLang('author_hint').'" >'.
  190. '<img src="//www.gravatar.com/avatar/'.$mailid.
  191. '?s=20&amp;d=mm" width="20" height="20" alt="" /> '.
  192. hsc($extension->getAuthor()).'</a>';
  193. } else {
  194. $html = '<span class="author">'.hsc($extension->getAuthor()).'</span>';
  195. }
  196. $html = '<bdi>'.$html.'</bdi>';
  197. } else {
  198. $html = '<em class="author">'.$this->getLang('unknown_author').'</em>'.DOKU_LF;
  199. }
  200. return $html;
  201. }
  202. /**
  203. * Get the link and image tag for the screenshot/thumbnail
  204. *
  205. * @param helper_plugin_extension_extension $extension The extension object
  206. * @return string The HTML code
  207. */
  208. public function makeScreenshot(helper_plugin_extension_extension $extension)
  209. {
  210. $screen = $extension->getScreenshotURL();
  211. $thumb = $extension->getThumbnailURL();
  212. if ($screen) {
  213. // use protocol independent URLs for images coming from us #595
  214. $screen = str_replace('http://www.dokuwiki.org', '//www.dokuwiki.org', $screen);
  215. $thumb = str_replace('http://www.dokuwiki.org', '//www.dokuwiki.org', $thumb);
  216. $title = sprintf($this->getLang('screenshot'), hsc($extension->getDisplayName()));
  217. $img = '<a href="'.hsc($screen).'" target="_blank" class="extension_screenshot">'.
  218. '<img alt="'.$title.'" width="120" height="70" src="'.hsc($thumb).'" />'.
  219. '</a>';
  220. } elseif ($extension->isTemplate()) {
  221. $img = '<img alt="" width="120" height="70" src="'.DOKU_BASE.
  222. 'lib/plugins/extension/images/template.png" />';
  223. } else {
  224. $img = '<img alt="" width="120" height="70" src="'.DOKU_BASE.
  225. 'lib/plugins/extension/images/plugin.png" />';
  226. }
  227. $html = '<div class="screenshot" >'.$img.'<span></span></div>'.DOKU_LF;
  228. return $html;
  229. }
  230. /**
  231. * Extension main description
  232. *
  233. * @param helper_plugin_extension_extension $extension The extension object
  234. * @param bool $showinfo Show the info section
  235. * @return string The HTML code
  236. */
  237. public function makeLegend(helper_plugin_extension_extension $extension, $showinfo = false)
  238. {
  239. $html = '<div>';
  240. $html .= '<h2>';
  241. $html .= sprintf(
  242. $this->getLang('extensionby'),
  243. '<bdi>'.hsc($extension->getDisplayName()).'</bdi>',
  244. $this->makeAuthor($extension)
  245. );
  246. $html .= '</h2>'.DOKU_LF;
  247. $html .= $this->makeScreenshot($extension);
  248. $popularity = $extension->getPopularity();
  249. if ($popularity !== false && !$extension->isBundled()) {
  250. $popularityText = sprintf($this->getLang('popularity'), round($popularity*100, 2));
  251. $html .= '<div class="popularity" title="'.$popularityText.'">'.
  252. '<div style="width: '.($popularity * 100).'%;">'.
  253. '<span class="a11y">'.$popularityText.'</span>'.
  254. '</div></div>'.DOKU_LF;
  255. }
  256. if ($extension->getDescription()) {
  257. $html .= '<p><bdi>';
  258. $html .= hsc($extension->getDescription()).' ';
  259. $html .= '</bdi></p>'.DOKU_LF;
  260. }
  261. $html .= $this->makeLinkbar($extension);
  262. if ($showinfo) {
  263. $url = $this->gui->tabURL('');
  264. $class = 'close';
  265. } else {
  266. $url = $this->gui->tabURL('', array('info' => $extension->getID()));
  267. $class = '';
  268. }
  269. $html .= ' <a href="'.$url.'#extensionplugin__'.$extension->getID().
  270. '" class="info '.$class.'" title="'.$this->getLang('btn_info').
  271. '" data-extid="'.$extension->getID().'">'.$this->getLang('btn_info').'</a>';
  272. if ($showinfo) {
  273. $html .= $this->makeInfo($extension);
  274. }
  275. $html .= $this->makeNoticeArea($extension);
  276. $html .= '</div>'.DOKU_LF;
  277. return $html;
  278. }
  279. /**
  280. * Generate the link bar HTML code
  281. *
  282. * @param helper_plugin_extension_extension $extension The extension instance
  283. * @return string The HTML code
  284. */
  285. public function makeLinkbar(helper_plugin_extension_extension $extension)
  286. {
  287. global $conf;
  288. $html = '<div class="linkbar">';
  289. $html .= $this->makeHomepageLink($extension);
  290. $bugtrackerURL = $extension->getBugtrackerURL();
  291. if ($bugtrackerURL) {
  292. if (strtolower(parse_url($bugtrackerURL, PHP_URL_HOST)) == 'www.dokuwiki.org') {
  293. $linktype = 'interwiki';
  294. } else {
  295. $linktype = 'extern';
  296. }
  297. $param = array(
  298. 'href' => $bugtrackerURL,
  299. 'title' => $bugtrackerURL,
  300. 'class' => 'bugs',
  301. 'target' => $conf['target'][$linktype],
  302. 'rel' => ($linktype == 'extern') ? 'noopener' : '',
  303. );
  304. if ($conf['relnofollow']) {
  305. $param['rel'] = implode(' ', [$param['rel'], 'ugc nofollow']);
  306. }
  307. $html .= ' <a '.buildAttributes($param, true).'>'.
  308. $this->getLang('bugs_features').'</a>';
  309. }
  310. if ($extension->getTags()) {
  311. $first = true;
  312. $html .= ' <span class="tags">'.$this->getLang('tags').' ';
  313. foreach ($extension->getTags() as $tag) {
  314. if (!$first) {
  315. $html .= ', ';
  316. } else {
  317. $first = false;
  318. }
  319. $url = $this->gui->tabURL('search', ['q' => 'tag:'.$tag]);
  320. $html .= '<bdi><a href="'.$url.'">'.hsc($tag).'</a></bdi>';
  321. }
  322. $html .= '</span>';
  323. }
  324. $html .= '</div>'.DOKU_LF;
  325. return $html;
  326. }
  327. /**
  328. * Notice area
  329. *
  330. * @param helper_plugin_extension_extension $extension The extension
  331. * @return string The HTML code
  332. */
  333. public function makeNoticeArea(helper_plugin_extension_extension $extension)
  334. {
  335. $html = '';
  336. $missing_dependencies = $extension->getMissingDependencies();
  337. if (!empty($missing_dependencies)) {
  338. $html .= '<div class="msg error">' .
  339. sprintf(
  340. $this->getLang('missing_dependency'),
  341. '<bdi>' . implode(', ', $missing_dependencies) . '</bdi>'
  342. ) .
  343. '</div>';
  344. }
  345. if ($extension->isInWrongFolder()) {
  346. $html .= '<div class="msg error">' .
  347. sprintf(
  348. $this->getLang('wrong_folder'),
  349. '<bdi>' . hsc($extension->getInstallName()) . '</bdi>',
  350. '<bdi>' . hsc($extension->getBase()) . '</bdi>'
  351. ) .
  352. '</div>';
  353. }
  354. if (($securityissue = $extension->getSecurityIssue()) !== false) {
  355. $html .= '<div class="msg error">'.
  356. sprintf($this->getLang('security_issue'), '<bdi>'.hsc($securityissue).'</bdi>').
  357. '</div>';
  358. }
  359. if (($securitywarning = $extension->getSecurityWarning()) !== false) {
  360. $html .= '<div class="msg notify">'.
  361. sprintf($this->getLang('security_warning'), '<bdi>'.hsc($securitywarning).'</bdi>').
  362. '</div>';
  363. }
  364. if ($extension->updateAvailable()) {
  365. $html .= '<div class="msg notify">'.
  366. sprintf($this->getLang('update_available'), hsc($extension->getLastUpdate())).
  367. '</div>';
  368. }
  369. if ($extension->hasDownloadURLChanged()) {
  370. $html .= '<div class="msg notify">' .
  371. sprintf(
  372. $this->getLang('url_change'),
  373. '<bdi>' . hsc($extension->getDownloadURL()) . '</bdi>',
  374. '<bdi>' . hsc($extension->getLastDownloadURL()) . '</bdi>'
  375. ) .
  376. '</div>';
  377. }
  378. return $html.DOKU_LF;
  379. }
  380. /**
  381. * Create a link from the given URL
  382. *
  383. * Shortens the URL for display
  384. *
  385. * @param string $url
  386. * @return string HTML link
  387. */
  388. public function shortlink($url)
  389. {
  390. $link = parse_url($url);
  391. $base = $link['host'];
  392. if (!empty($link['port'])) $base .= $base.':'.$link['port'];
  393. $long = $link['path'];
  394. if (!empty($link['query'])) $long .= $link['query'];
  395. $name = shorten($base, $long, 55);
  396. $html = '<a href="'.hsc($url).'" class="urlextern">'.hsc($name).'</a>';
  397. return $html;
  398. }
  399. /**
  400. * Plugin/template details
  401. *
  402. * @param helper_plugin_extension_extension $extension The extension
  403. * @return string The HTML code
  404. */
  405. public function makeInfo(helper_plugin_extension_extension $extension)
  406. {
  407. $default = $this->getLang('unknown');
  408. $html = '<dl class="details">';
  409. $html .= '<dt>'.$this->getLang('status').'</dt>';
  410. $html .= '<dd>'.$this->makeStatus($extension).'</dd>';
  411. if ($extension->getDonationURL()) {
  412. $html .= '<dt>'.$this->getLang('donate').'</dt>';
  413. $html .= '<dd>';
  414. $html .= '<a href="'.$extension->getDonationURL().'" class="donate">'.
  415. $this->getLang('donate_action').'</a>';
  416. $html .= '</dd>';
  417. }
  418. if (!$extension->isBundled()) {
  419. $html .= '<dt>'.$this->getLang('downloadurl').'</dt>';
  420. $html .= '<dd><bdi>';
  421. $html .= ($extension->getDownloadURL()
  422. ? $this->shortlink($extension->getDownloadURL())
  423. : $default);
  424. $html .= '</bdi></dd>';
  425. $html .= '<dt>'.$this->getLang('repository').'</dt>';
  426. $html .= '<dd><bdi>';
  427. $html .= ($extension->getSourcerepoURL()
  428. ? $this->shortlink($extension->getSourcerepoURL())
  429. : $default);
  430. $html .= '</bdi></dd>';
  431. }
  432. if ($extension->isInstalled()) {
  433. if ($extension->getInstalledVersion()) {
  434. $html .= '<dt>'.$this->getLang('installed_version').'</dt>';
  435. $html .= '<dd>';
  436. $html .= hsc($extension->getInstalledVersion());
  437. $html .= '</dd>';
  438. }
  439. if (!$extension->isBundled()) {
  440. $html .= '<dt>'.$this->getLang('install_date').'</dt>';
  441. $html .= '<dd>';
  442. $html .= ($extension->getUpdateDate()
  443. ? hsc($extension->getUpdateDate())
  444. : $this->getLang('unknown'));
  445. $html .= '</dd>';
  446. }
  447. }
  448. if (!$extension->isInstalled() || $extension->updateAvailable()) {
  449. $html .= '<dt>'.$this->getLang('available_version').'</dt>';
  450. $html .= '<dd>';
  451. $html .= ($extension->getLastUpdate()
  452. ? hsc($extension->getLastUpdate())
  453. : $this->getLang('unknown'));
  454. $html .= '</dd>';
  455. }
  456. $html .= '<dt>'.$this->getLang('provides').'</dt>';
  457. $html .= '<dd><bdi>';
  458. $html .= ($extension->getTypes()
  459. ? hsc(implode(', ', $extension->getTypes()))
  460. : $default);
  461. $html .= '</bdi></dd>';
  462. if (!$extension->isBundled() && $extension->getCompatibleVersions()) {
  463. $html .= '<dt>'.$this->getLang('compatible').'</dt>';
  464. $html .= '<dd>';
  465. foreach ($extension->getCompatibleVersions() as $date => $version) {
  466. $html .= '<bdi>'.$version['label'].' ('.$date.')</bdi>, ';
  467. }
  468. $html = rtrim($html, ', ');
  469. $html .= '</dd>';
  470. }
  471. if ($extension->getDependencies()) {
  472. $html .= '<dt>'.$this->getLang('depends').'</dt>';
  473. $html .= '<dd>';
  474. $html .= $this->makeLinkList($extension->getDependencies());
  475. $html .= '</dd>';
  476. }
  477. if ($extension->getSimilarExtensions()) {
  478. $html .= '<dt>'.$this->getLang('similar').'</dt>';
  479. $html .= '<dd>';
  480. $html .= $this->makeLinkList($extension->getSimilarExtensions());
  481. $html .= '</dd>';
  482. }
  483. if ($extension->getConflicts()) {
  484. $html .= '<dt>'.$this->getLang('conflicts').'</dt>';
  485. $html .= '<dd>';
  486. $html .= $this->makeLinkList($extension->getConflicts());
  487. $html .= '</dd>';
  488. }
  489. $html .= '</dl>'.DOKU_LF;
  490. return $html;
  491. }
  492. /**
  493. * Generate a list of links for extensions
  494. *
  495. * @param array $ext The extensions
  496. * @return string The HTML code
  497. */
  498. public function makeLinkList($ext)
  499. {
  500. $html = '';
  501. foreach ($ext as $link) {
  502. $html .= '<bdi><a href="'.
  503. $this->gui->tabURL('search', array('q'=>'ext:'.$link)).'">'.
  504. hsc($link).'</a></bdi>, ';
  505. }
  506. return rtrim($html, ', ');
  507. }
  508. /**
  509. * Display the action buttons if they are possible
  510. *
  511. * @param helper_plugin_extension_extension $extension The extension
  512. * @return string The HTML code
  513. */
  514. public function makeActions(helper_plugin_extension_extension $extension)
  515. {
  516. global $conf;
  517. $html = '';
  518. $errors = '';
  519. if ($extension->isInstalled()) {
  520. if (($canmod = $extension->canModify()) === true) {
  521. if (!$extension->isProtected()) {
  522. $html .= $this->makeAction('uninstall', $extension);
  523. }
  524. if ($extension->getDownloadURL()) {
  525. if ($extension->updateAvailable()) {
  526. $html .= $this->makeAction('update', $extension);
  527. } else {
  528. $html .= $this->makeAction('reinstall', $extension);
  529. }
  530. }
  531. } else {
  532. $errors .= '<p class="permerror">'.$this->getLang($canmod).'</p>';
  533. }
  534. if (!$extension->isProtected() && !$extension->isTemplate()) { // no enable/disable for templates
  535. if ($extension->isEnabled()) {
  536. $html .= $this->makeAction('disable', $extension);
  537. } else {
  538. $html .= $this->makeAction('enable', $extension);
  539. }
  540. }
  541. if ($extension->isGitControlled()) {
  542. $errors .= '<p class="permerror">'.$this->getLang('git').'</p>';
  543. }
  544. if ($extension->isEnabled() &&
  545. in_array('Auth', $extension->getTypes()) &&
  546. $conf['authtype'] != $extension->getID()
  547. ) {
  548. $errors .= '<p class="permerror">'.$this->getLang('auth').'</p>';
  549. }
  550. } else {
  551. if (($canmod = $extension->canModify()) === true) {
  552. if ($extension->getDownloadURL()) {
  553. $html .= $this->makeAction('install', $extension);
  554. }
  555. } else {
  556. $errors .= '<div class="permerror">'.$this->getLang($canmod).'</div>';
  557. }
  558. }
  559. if (!$extension->isInstalled() && $extension->getDownloadURL()) {
  560. $html .= ' <span class="version">'.$this->getLang('available_version').' ';
  561. $html .= ($extension->getLastUpdate()
  562. ? hsc($extension->getLastUpdate())
  563. : $this->getLang('unknown')).'</span>';
  564. }
  565. return $html.' '.$errors.DOKU_LF;
  566. }
  567. /**
  568. * Display an action button for an extension
  569. *
  570. * @param string $action The action
  571. * @param helper_plugin_extension_extension $extension The extension
  572. * @return string The HTML code
  573. */
  574. public function makeAction($action, $extension)
  575. {
  576. $title = '';
  577. switch ($action) {
  578. case 'install':
  579. case 'reinstall':
  580. $title = 'title="'.hsc($extension->getDownloadURL()).'"';
  581. break;
  582. }
  583. $classes = 'button '.$action;
  584. $name = 'fn['.$action.']['.hsc($extension->getID()).']';
  585. $html = '<button class="'.$classes.'" name="'.$name.'" type="submit" '.$title.'>'.
  586. $this->getLang('btn_'.$action).'</button> ';
  587. return $html;
  588. }
  589. /**
  590. * Plugin/template status
  591. *
  592. * @param helper_plugin_extension_extension $extension The extension
  593. * @return string The description of all relevant statusses
  594. */
  595. public function makeStatus(helper_plugin_extension_extension $extension)
  596. {
  597. $status = array();
  598. if ($extension->isInstalled()) {
  599. $status[] = $this->getLang('status_installed');
  600. if ($extension->isProtected()) {
  601. $status[] = $this->getLang('status_protected');
  602. } else {
  603. $status[] = $extension->isEnabled()
  604. ? $this->getLang('status_enabled')
  605. : $this->getLang('status_disabled');
  606. }
  607. } else {
  608. $status[] = $this->getLang('status_not_installed');
  609. }
  610. if (!$extension->canModify()) $status[] = $this->getLang('status_unmodifiable');
  611. if ($extension->isBundled()) $status[] = $this->getLang('status_bundled');
  612. $status[] = $extension->isTemplate()
  613. ? $this->getLang('status_template')
  614. : $this->getLang('status_plugin');
  615. return implode(', ', $status);
  616. }
  617. }