1<?php
2/**
3 * DokuWiki Plugin Bookcreator (Helper Component)
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  Gerrit Uitslag <klapinklapin@gmail.com>
7 */
8
9/**
10 * Class helper_plugin_bookcreator
11 */
12class helper_plugin_bookcreator extends DokuWiki_Plugin {
13
14    /**
15     * Create a item for list of available saved selections
16     *
17     * @param array $item with at least the entries:
18     *   - string 'id'    pageid
19     *   - int    'mtime' unixtime modification date
20     * @param bool $isbookmanager   if in bookmanager, show delete button(if allowed) and date
21     * @return string
22     */
23    public function createListitem($item, $isbookmanager = false) {
24        $itemtitle = p_get_first_heading($item['id']);
25        $nons      = noNS($item['id']);
26        $url       = wl($this->getConf('save_namespace').":".$nons);
27
28        $out = "<li class='level1 bkctrsavsel__$nons' data-page-id='$nons'>";
29        if(($isbookmanager) && (auth_quickaclcheck($item['id']) >= AUTH_DELETE)) {
30            $out .= "<a class='action delete' href='#deletesavedselection' title='{$this->getLang('delselection')}'>"
31                 . inlineSVG(__DIR__ . '/images/notebook-remove-outline.svg')
32                 . "</a>&nbsp;";
33        }
34        $out .= "<a class='action load' href='#loadsavedselection' title='{$this->getLang('loadselection')}'>"
35             . inlineSVG(__DIR__ . '/images/notebook-edit-outline.svg')
36             . "</a>&nbsp;"
37             . "<a href='$url' title='{$this->getLang('showselection')}'>".inlineSVG(__DIR__ . '/images/notebook-outline.svg')." $itemtitle</a>";
38        if($isbookmanager) {
39            $out .= ' ('.dformat($item['mtime']).')';
40        }
41        $out .= '</li>';
42
43        return $out;
44    }
45}
46