xref: /plugin/dw2pdf/action.php (revision f765508ec270ca401de763caf93dc9e70b35a286)
1ee19bac3SLuigi Micco<?php
2ee19bac3SLuigi Micco /**
3ee19bac3SLuigi Micco  * dw2Pdf Plugin: Conversion from dokuwiki content to pdf.
4ee19bac3SLuigi Micco  *
5ee19bac3SLuigi Micco  * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6ee19bac3SLuigi Micco  * @author     Luigi Micco <l.micco@tiscali.it>
75db42babSAndreas Gohr  * @author     Andreas Gohr <andi@splitbrain.org>
8ee19bac3SLuigi Micco  */
9ee19bac3SLuigi Micco
10ee19bac3SLuigi Micco// must be run within Dokuwiki
11ee19bac3SLuigi Miccoif (!defined('DOKU_INC')) die();
12ee19bac3SLuigi Micco
131ef68647SAndreas Gohrclass action_plugin_dw2pdf extends DokuWiki_Action_Plugin {
14ee19bac3SLuigi Micco
151c14c879SAndreas Gohr    private $tpl;
161c14c879SAndreas Gohr
171c14c879SAndreas Gohr    /**
181c14c879SAndreas Gohr     * Constructor. Sets the correct template
191c14c879SAndreas Gohr     */
206be736bfSGerrit Uitslag    public function __construct(){
21737417c6SKlap-in        $tpl = false;
221c14c879SAndreas Gohr        if(isset($_REQUEST['tpl'])){
231c14c879SAndreas Gohr            $tpl = trim(preg_replace('/[^A-Za-z0-9_\-]+/','',$_REQUEST['tpl']));
241c14c879SAndreas Gohr        }
251c14c879SAndreas Gohr        if(!$tpl) $tpl = $this->getConf('template');
261c14c879SAndreas Gohr        if(!$tpl) $tpl = 'default';
271c14c879SAndreas Gohr        if(!is_dir(DOKU_PLUGIN.'dw2pdf/tpl/'.$tpl)) $tpl = 'default';
281c14c879SAndreas Gohr
291c14c879SAndreas Gohr        $this->tpl = $tpl;
301c14c879SAndreas Gohr    }
311c14c879SAndreas Gohr
32ee19bac3SLuigi Micco    /**
33ee19bac3SLuigi Micco     * Register the events
34ee19bac3SLuigi Micco     */
356be736bfSGerrit Uitslag    public function register(Doku_Event_Handler $controller) {
36ee19bac3SLuigi Micco        $controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'convert', array());
376be736bfSGerrit Uitslag        $controller->register_hook('TEMPLATE_PAGETOOLS_DISPLAY', 'BEFORE', $this, 'addbutton', array());
38ee19bac3SLuigi Micco    }
39ee19bac3SLuigi Micco
401c14c879SAndreas Gohr    /**
411c14c879SAndreas Gohr     * Do the HTML to PDF conversion work
42737417c6SKlap-in     *
43737417c6SKlap-in     * @param Doku_Event $event
44737417c6SKlap-in     * @param array      $param
45737417c6SKlap-in     * @return bool
461c14c879SAndreas Gohr     */
476be736bfSGerrit Uitslag    public function convert(&$event, $param) {
48ee19bac3SLuigi Micco        global $ACT;
49ee19bac3SLuigi Micco        global $REV;
50ee19bac3SLuigi Micco        global $ID;
516ea88a05SAndreas Gohr        global $INPUT;
52ee19bac3SLuigi Micco
531ef68647SAndreas Gohr        // our event?
541ef68647SAndreas Gohr        if (( $ACT != 'export_pdfbook' ) && ( $ACT != 'export_pdf' )) return false;
55ee19bac3SLuigi Micco
561ef68647SAndreas Gohr        // check user's rights
571ef68647SAndreas Gohr        if ( auth_quickaclcheck($ID) < AUTH_READ ) return false;
581ef68647SAndreas Gohr
5987c86ddaSAndreas Gohr        // one or multiple pages?
6087c86ddaSAndreas Gohr        $list  = array();
6128e636eaSGerrit Uitslag
6287c86ddaSAndreas Gohr        if($ACT == 'export_pdf') {
6387c86ddaSAndreas Gohr            $list[0] = $ID;
64737417c6SKlap-in            $title = p_get_first_heading($ID);
65737417c6SKlap-in        } elseif(isset($_COOKIE['list-pagelist']) && !empty($_COOKIE['list-pagelist'])) {
66737417c6SKlap-in            //is in Bookmanager of bookcreator plugin title given
67737417c6SKlap-in            if(!$title = $_GET['pdfbook_title']) {  //TODO when title is changed, the cached file contains the old title
68737417c6SKlap-in                /** @var $bookcreator action_plugin_bookcreator */
6928e636eaSGerrit Uitslag                $bookcreator = plugin_load('action', 'bookcreator');
70737417c6SKlap-in                msg($bookcreator->getLang('needtitle'), -1);
71737417c6SKlap-in
72737417c6SKlap-in                $event->data               = 'show';
73737417c6SKlap-in                $_SERVER['REQUEST_METHOD'] = 'POST'; //clears url
74737417c6SKlap-in                return false;
7587c86ddaSAndreas Gohr            }
76737417c6SKlap-in            $list = explode("|", $_COOKIE['list-pagelist']);
77737417c6SKlap-in        } else {
78737417c6SKlap-in            /** @var $bookcreator action_plugin_bookcreator */
7928e636eaSGerrit Uitslag            $bookcreator = plugin_load('action', 'bookcreator');
80737417c6SKlap-in            msg($bookcreator->getLang('empty'), -1);
81737417c6SKlap-in
82737417c6SKlap-in            $event->data               = 'show';
83737417c6SKlap-in            $_SERVER['REQUEST_METHOD'] = 'POST'; //clears url
84737417c6SKlap-in            return false;
85737417c6SKlap-in        }
86737417c6SKlap-in
87737417c6SKlap-in        // it's ours, no one else's
88737417c6SKlap-in        $event->preventDefault();
8987c86ddaSAndreas Gohr
906ea88a05SAndreas Gohr        // decide on the paper setup from param or config
916ea88a05SAndreas Gohr        $pagesize    = $INPUT->str('pagesize', $this->getConf('pagesize'), true);
926ea88a05SAndreas Gohr        $orientation = $INPUT->str('orientation', $this->getConf('orientation'), true);
936ea88a05SAndreas Gohr
9487c86ddaSAndreas Gohr        // prepare cache
956ea88a05SAndreas Gohr        $cache = new cache(join(',',$list).$REV.$this->tpl.$pagesize.$orientation,'.dw2.pdf');
9687c86ddaSAndreas Gohr        $depends['files']   = array_map('wikiFN',$list);
9787c86ddaSAndreas Gohr        $depends['files'][] = __FILE__;
9887c86ddaSAndreas Gohr        $depends['files'][] = dirname(__FILE__).'/renderer.php';
9987c86ddaSAndreas Gohr        $depends['files'][] = dirname(__FILE__).'/mpdf/mpdf.php';
100df59f400SAndreas Gohr        $depends['files']   = array_merge($depends['files'], getConfigFiles('main'));
10187c86ddaSAndreas Gohr
102d01d2a42SAndreas Gohr        // hard work only when no cache available
10387c86ddaSAndreas Gohr        if(!$this->getConf('usecache') || !$cache->useCache($depends)){
1041ef68647SAndreas Gohr            // initialize PDF library
105cde5a1b3SAndreas Gohr            require_once(dirname(__FILE__)."/DokuPDF.class.php");
1066ea88a05SAndreas Gohr
1076ea88a05SAndreas Gohr            $mpdf = new DokuPDF($pagesize, $orientation);
108ee19bac3SLuigi Micco
109d62df65bSAndreas Gohr            // let mpdf fix local links
110d62df65bSAndreas Gohr            $self = parse_url(DOKU_URL);
111d62df65bSAndreas Gohr            $url  = $self['scheme'].'://'.$self['host'];
112737417c6SKlap-in            if($self['port']) $url .= ':'.$self['port'];
113d62df65bSAndreas Gohr            $mpdf->setBasePath($url);
114d62df65bSAndreas Gohr
11556d13144SAndreas Gohr            // Set the title
11656d13144SAndreas Gohr            $mpdf->SetTitle($title);
11756d13144SAndreas Gohr
1181ef68647SAndreas Gohr            // some default settings
119daa70883SAndreas Gohr            $mpdf->mirrorMargins = 1;
120daa70883SAndreas Gohr            $mpdf->useOddEven    = 1;
121daa70883SAndreas Gohr            $mpdf->setAutoTopMargin = 'stretch';
122daa70883SAndreas Gohr            $mpdf->setAutoBottomMargin = 'stretch';
1232eedf77dSAndreas Gohr
12456d13144SAndreas Gohr            // load the template
1251c14c879SAndreas Gohr            $template = $this->load_template($title);
126ee19bac3SLuigi Micco
1271ef68647SAndreas Gohr            // prepare HTML header styles
128ee19bac3SLuigi Micco            $html  = '<html><head>';
129737417c6SKlap-in            $html .= '<style type="text/css">';
1301c14c879SAndreas Gohr            $html .= $this->load_css();
131daa70883SAndreas Gohr            $html .= '@page { size:auto; '.$template['page'].'}';
1322eedf77dSAndreas Gohr            $html .= '@page :first {'.$template['first'].'}';
1331ef68647SAndreas Gohr            $html .= '</style>';
1341ef68647SAndreas Gohr            $html .= '</head><body>';
1352eedf77dSAndreas Gohr            $html .= $template['html'];
1361c14c879SAndreas Gohr            $html .= '<div class="dokuwiki">';
1372eedf77dSAndreas Gohr
1381ef68647SAndreas Gohr            // loop over all pages
1391ef68647SAndreas Gohr            $cnt = count($list);
1401ef68647SAndreas Gohr            for($n=0; $n<$cnt; $n++){
141ee19bac3SLuigi Micco                $page = $list[$n];
142ee19bac3SLuigi Micco
143a876b55bSAndreas Gohr                $html .= p_cached_output(wikiFN($page,$REV),'dw2pdf',$page);
144a180c973SKlap-in                $html .= $this->page_depend_replacements($template['cite'], cleanID($page));
1451ef68647SAndreas Gohr                if ($n < ($cnt - 1)){
1461ef68647SAndreas Gohr                    $html .= '<pagebreak />';
1471ef68647SAndreas Gohr                }
148ee19bac3SLuigi Micco            }
149ee19bac3SLuigi Micco
1501c14c879SAndreas Gohr            $html .= '</div>';
151*f765508eSGerrit Uitslag
152*f765508eSGerrit Uitslag            //Return html for debugging
153*f765508eSGerrit Uitslag            if($_GET['debughtml'] == 'html') die($html);
154*f765508eSGerrit Uitslag
155ee19bac3SLuigi Micco            $mpdf->WriteHTML($html);
156a06728a6SAndreas Gohr
15787c86ddaSAndreas Gohr            // write to cache file
15887c86ddaSAndreas Gohr            $mpdf->Output($cache->cache, 'F');
15987c86ddaSAndreas Gohr        }
16087c86ddaSAndreas Gohr
16187c86ddaSAndreas Gohr        // deliver the file
16287c86ddaSAndreas Gohr        header('Content-Type: application/pdf');
163b853b723SAndreas Gohr        header('Cache-Control: must-revalidate, no-transform, post-check=0, pre-check=0');
16487c86ddaSAndreas Gohr        header('Pragma: public');
16587c86ddaSAndreas Gohr        http_conditionalRequest(filemtime($cache->cache));
16687c86ddaSAndreas Gohr
1679a3c8d9fSAndreas Gohr        $filename = rawurlencode(cleanID(strtr($title, ':/;"','    ')));
16887c86ddaSAndreas Gohr        if($this->getConf('output') == 'file'){
1699a3c8d9fSAndreas Gohr            header('Content-Disposition: attachment; filename="'.$filename.'.pdf";');
17087c86ddaSAndreas Gohr        }else{
1719a3c8d9fSAndreas Gohr            header('Content-Disposition: inline; filename="'.$filename.'.pdf";');
17287c86ddaSAndreas Gohr        }
173ee19bac3SLuigi Micco
174e993da11SGerrit Uitslag        //try to send file, and exit if done
175e993da11SGerrit Uitslag        http_sendfile($cache->cache);
17687c86ddaSAndreas Gohr
17787c86ddaSAndreas Gohr        $fp = @fopen($cache->cache,"rb");
17887c86ddaSAndreas Gohr        if($fp){
17987c86ddaSAndreas Gohr            http_rangeRequest($fp,filesize($cache->cache),'application/pdf');
18087c86ddaSAndreas Gohr        }else{
18187c86ddaSAndreas Gohr            header("HTTP/1.0 500 Internal Server Error");
18287c86ddaSAndreas Gohr            print "Could not read file - bad permissions?";
18387c86ddaSAndreas Gohr        }
1841ef68647SAndreas Gohr        exit();
1851ef68647SAndreas Gohr    }
1861ef68647SAndreas Gohr
1876be736bfSGerrit Uitslag    /**
1886be736bfSGerrit Uitslag     * Add 'export pdf'-button to pagetools
1896be736bfSGerrit Uitslag     *
1906be736bfSGerrit Uitslag     * @param Doku_Event $event
1916be736bfSGerrit Uitslag     * @param mixed      $param not defined
1926be736bfSGerrit Uitslag     */
1936be736bfSGerrit Uitslag    public function addbutton(&$event, $param) {
1946be736bfSGerrit Uitslag        global $ID, $REV, $conf;
1956be736bfSGerrit Uitslag
1966be736bfSGerrit Uitslag        if($this->getConf('showexportbutton') && $event->data['view'] == 'main') {
1976be736bfSGerrit Uitslag            $params = array('do' => 'export_pdf');
1986be736bfSGerrit Uitslag            if($REV) $params['rev'] = $REV;
1996be736bfSGerrit Uitslag
2006be736bfSGerrit Uitslag            switch($conf['template']) {
2016be736bfSGerrit Uitslag                case 'dokuwiki':
2023cc6f95eSGerrit Uitslag                case 'arago':
203fc56eef8SGerrit Uitslag                case 'wikilu': // a private template
2046be736bfSGerrit Uitslag                    $event->data['items']['export_pdf'] =
2056be736bfSGerrit Uitslag                        '<li>'
2066be736bfSGerrit Uitslag                        .'<a href='.wl($ID, $params).'  class="action export_pdf" rel="nofollow" title="'.$this->getLang('export_pdf_button').'">'
2076be736bfSGerrit Uitslag                        .'<span>'.$this->getLang('export_pdf_button').'</span>'
2086be736bfSGerrit Uitslag                        .'</a>'
2096be736bfSGerrit Uitslag                        .'</li>';
2106be736bfSGerrit Uitslag                    break;
2116be736bfSGerrit Uitslag            }
2126be736bfSGerrit Uitslag        }
2136be736bfSGerrit Uitslag    }
214d01d2a42SAndreas Gohr
215d01d2a42SAndreas Gohr    /**
2162eedf77dSAndreas Gohr     * Load the various template files and prepare the HTML/CSS for insertion
2171ef68647SAndreas Gohr     */
2181c14c879SAndreas Gohr    protected function load_template($title){
2191ef68647SAndreas Gohr        global $ID;
2201ef68647SAndreas Gohr        global $conf;
2211c14c879SAndreas Gohr        $tpl = $this->tpl;
2221ef68647SAndreas Gohr
2232eedf77dSAndreas Gohr        // this is what we'll return
2242eedf77dSAndreas Gohr        $output = array(
2252eedf77dSAndreas Gohr            'html'  => '',
2262eedf77dSAndreas Gohr            'page'  => '',
2272eedf77dSAndreas Gohr            'first' => '',
2282eedf77dSAndreas Gohr            'cite'  => '',
2292eedf77dSAndreas Gohr        );
2302eedf77dSAndreas Gohr
2312eedf77dSAndreas Gohr        // prepare header/footer elements
2322eedf77dSAndreas Gohr        $html = '';
2332eedf77dSAndreas Gohr        foreach(array('header','footer') as $t){
2349e6e41f4SAndreas Gohr            foreach(array('','_odd','_even','_first') as $h){
2352eedf77dSAndreas Gohr                if(file_exists(DOKU_PLUGIN.'dw2pdf/tpl/'.$tpl.'/'.$t.$h.'.html')){
2362eedf77dSAndreas Gohr                    $html .= '<htmlpage'.$t.' name="'.$t.$h.'">'.DOKU_LF;
2372eedf77dSAndreas Gohr                    $html .= file_get_contents(DOKU_PLUGIN.'dw2pdf/tpl/'.$tpl.'/'.$t.$h.'.html').DOKU_LF;
2382eedf77dSAndreas Gohr                    $html .= '</htmlpage'.$t.'>'.DOKU_LF;
2392eedf77dSAndreas Gohr
2402eedf77dSAndreas Gohr                    // register the needed pseudo CSS
2419e6e41f4SAndreas Gohr                    if($h == '_first'){
2422eedf77dSAndreas Gohr                        $output['first'] .= $t.': html_'.$t.$h.';'.DOKU_LF;
2432eedf77dSAndreas Gohr                    }elseif($h == '_even'){
2442eedf77dSAndreas Gohr                        $output['page'] .= 'even-'.$t.'-name: html_'.$t.$h.';'.DOKU_LF;
245daa70883SAndreas Gohr                    }elseif($h == '_odd'){
2462eedf77dSAndreas Gohr                        $output['page'] .= 'odd-'.$t.'-name: html_'.$t.$h.';'.DOKU_LF;
247daa70883SAndreas Gohr                    }else{
248daa70883SAndreas Gohr                        $output['page'] .= $t.': html_'.$t.$h.';'.DOKU_LF;
2492eedf77dSAndreas Gohr                    }
2502eedf77dSAndreas Gohr                }
2512eedf77dSAndreas Gohr            }
2522eedf77dSAndreas Gohr        }
2532eedf77dSAndreas Gohr
2541ef68647SAndreas Gohr        // prepare replacements
2551ef68647SAndreas Gohr        $replace = array(
2561ef68647SAndreas Gohr                '@PAGE@'    => '{PAGENO}',
2571ef68647SAndreas Gohr                '@PAGES@'   => '{nb}',
2582eedf77dSAndreas Gohr                '@TITLE@'   => hsc($title),
2591ef68647SAndreas Gohr                '@WIKI@'    => $conf['title'],
2601ef68647SAndreas Gohr                '@WIKIURL@' => DOKU_URL,
2611ef68647SAndreas Gohr                '@DATE@'    => dformat(time()),
2625d6fbaeaSAndreas Gohr                '@BASE@'    => DOKU_BASE,
263a180c973SKlap-in                '@TPLBASE@' => DOKU_BASE.'lib/plugins/dw2pdf/tpl/'.$tpl.'/'
2641ef68647SAndreas Gohr        );
2651ef68647SAndreas Gohr
2662eedf77dSAndreas Gohr        // set HTML element
267a180c973SKlap-in        $html = str_replace(array_keys($replace), array_values($replace), $html);
268a180c973SKlap-in        //TODO For bookcreator $ID (= bookmanager page) makes no sense
269a180c973SKlap-in        $output['html'] = $this->page_depend_replacements($html, $ID);
2701ef68647SAndreas Gohr
2712eedf77dSAndreas Gohr        // citation box
2722eedf77dSAndreas Gohr        if(file_exists(DOKU_PLUGIN.'dw2pdf/tpl/'.$tpl.'/citation.html')){
2732eedf77dSAndreas Gohr            $output['cite'] = file_get_contents(DOKU_PLUGIN.'dw2pdf/tpl/'.$tpl.'/citation.html');
2742eedf77dSAndreas Gohr            $output['cite'] = str_replace(array_keys($replace), array_values($replace), $output['cite']);
2752eedf77dSAndreas Gohr        }
2761ef68647SAndreas Gohr
2772eedf77dSAndreas Gohr        return $output;
2781ef68647SAndreas Gohr    }
2791ef68647SAndreas Gohr
2801ef68647SAndreas Gohr    /**
281a180c973SKlap-in     * @param string $raw code with placeholders
282a180c973SKlap-in     * @param string $id  pageid
283a180c973SKlap-in     * @return string
284a180c973SKlap-in     */
285a180c973SKlap-in    protected function page_depend_replacements($raw, $id){
286a180c973SKlap-in        global $REV;
287a180c973SKlap-in
288a180c973SKlap-in        // generate qr code for this page using google infographics api
289a180c973SKlap-in        $qr_code = '';
290a180c973SKlap-in        if ($this->getConf('qrcodesize')) {
291a180c973SKlap-in            $url = urlencode(wl($id,'','&',true));
292a180c973SKlap-in            $qr_code = '<img src="https://chart.googleapis.com/chart?chs='.
293a180c973SKlap-in                $this->getConf('qrcodesize').'&cht=qr&chl='.$url.'" />';
294a180c973SKlap-in        }
295a180c973SKlap-in        // prepare replacements
296a180c973SKlap-in        $replace['@ID@']      = $id;
297a180c973SKlap-in        $replace['@UPDATE@']  = dformat(filemtime(wikiFN($id, $REV)));
298a180c973SKlap-in        $replace['@PAGEURL@'] = wl($id, ($REV) ? array('rev'=> $REV) : false, true, "&");
299a180c973SKlap-in        $replace['@QRCODE@']  = $qr_code;
300a180c973SKlap-in
301a180c973SKlap-in        return str_replace(array_keys($replace), array_values($replace), $raw);
302a180c973SKlap-in    }
303a180c973SKlap-in
304a180c973SKlap-in    /**
3051c14c879SAndreas Gohr     * Load all the style sheets and apply the needed replacements
3061ef68647SAndreas Gohr     */
3071c14c879SAndreas Gohr    protected function load_css(){
308737417c6SKlap-in        global $conf;
3091c14c879SAndreas Gohr        //reusue the CSS dispatcher functions without triggering the main function
3101c14c879SAndreas Gohr        define('SIMPLE_TEST',1);
3111c14c879SAndreas Gohr        require_once(DOKU_INC.'lib/exe/css.php');
312ee19bac3SLuigi Micco
3131c14c879SAndreas Gohr        // prepare CSS files
3141c14c879SAndreas Gohr        $files = array_merge(
3151c14c879SAndreas Gohr                    array(
3161c14c879SAndreas Gohr                        DOKU_INC.'lib/styles/screen.css'
3171c14c879SAndreas Gohr                            => DOKU_BASE.'lib/styles/',
3181c14c879SAndreas Gohr                        DOKU_INC.'lib/styles/print.css'
3191c14c879SAndreas Gohr                            => DOKU_BASE.'lib/styles/',
3201c14c879SAndreas Gohr                    ),
3211c14c879SAndreas Gohr                    css_pluginstyles('all'),
32258e6409eSAndreas Gohr                    $this->css_pluginPDFstyles(),
3231c14c879SAndreas Gohr                    array(
3241c14c879SAndreas Gohr                        DOKU_PLUGIN.'dw2pdf/conf/style.css'
3251c14c879SAndreas Gohr                            => DOKU_BASE.'lib/plugins/dw2pdf/conf/',
3261c14c879SAndreas Gohr                        DOKU_PLUGIN.'dw2pdf/tpl/'.$this->tpl.'/style.css'
3271c14c879SAndreas Gohr                            => DOKU_BASE.'lib/plugins/dw2pdf/tpl/'.$this->tpl.'/',
3281c14c879SAndreas Gohr                        DOKU_PLUGIN.'dw2pdf/conf/style.local.css'
3291c14c879SAndreas Gohr                            => DOKU_BASE.'lib/plugins/dw2pdf/conf/',
3301c14c879SAndreas Gohr                    )
3311c14c879SAndreas Gohr                 );
3321c14c879SAndreas Gohr        $css = '';
3331c14c879SAndreas Gohr        foreach($files as $file => $location){
33428e636eaSGerrit Uitslag            $display = str_replace(fullpath(DOKU_INC), '', fullpath($file));
33528e636eaSGerrit Uitslag            $css .= "\n/* XXXXXXXXX $display XXXXXXXXX */\n";
3361c14c879SAndreas Gohr            $css .= css_loadfile($file, $location);
3371ef68647SAndreas Gohr        }
3381ef68647SAndreas Gohr
33928e636eaSGerrit Uitslag        if(function_exists('css_parseless')) {
3401c14c879SAndreas Gohr            // apply pattern replacements
34128e636eaSGerrit Uitslag            $styleini = css_styleini($conf['template']);
34228e636eaSGerrit Uitslag            $css = css_applystyle($css, $styleini['replacements']);
34328e636eaSGerrit Uitslag
34428e636eaSGerrit Uitslag            // parse less
34528e636eaSGerrit Uitslag            $css = css_parseless($css);
34628e636eaSGerrit Uitslag        } else {
34728e636eaSGerrit Uitslag            // @deprecated 2013-12-19: fix backward compatibility
3481c14c879SAndreas Gohr            $css = css_applystyle($css,DOKU_INC.'lib/tpl/'.$conf['template'].'/');
34928e636eaSGerrit Uitslag        }
3501ef68647SAndreas Gohr
3511c14c879SAndreas Gohr        return $css;
352ee19bac3SLuigi Micco    }
3531c14c879SAndreas Gohr
35458e6409eSAndreas Gohr    /**
35558e6409eSAndreas Gohr     * Returns a list of possible Plugin PDF Styles
35658e6409eSAndreas Gohr     *
35758e6409eSAndreas Gohr     * Checks for a pdf.css, falls back to print.css
35858e6409eSAndreas Gohr     *
35958e6409eSAndreas Gohr     * @author Andreas Gohr <andi@splitbrain.org>
36058e6409eSAndreas Gohr     */
3616be736bfSGerrit Uitslag    protected function css_pluginPDFstyles(){
36258e6409eSAndreas Gohr        $list = array();
36358e6409eSAndreas Gohr        $plugins = plugin_list();
364f54b51f7SAndreas Gohr
365f54b51f7SAndreas Gohr        $usestyle = explode(',',$this->getConf('usestyles'));
36658e6409eSAndreas Gohr        foreach ($plugins as $p){
367f54b51f7SAndreas Gohr            if(in_array($p,$usestyle)){
368f54b51f7SAndreas Gohr                $list[DOKU_PLUGIN."$p/screen.css"] = DOKU_BASE."lib/plugins/$p/";
369f54b51f7SAndreas Gohr                $list[DOKU_PLUGIN."$p/style.css"] = DOKU_BASE."lib/plugins/$p/";
370f54b51f7SAndreas Gohr            }
371f54b51f7SAndreas Gohr
37258e6409eSAndreas Gohr            if(file_exists(DOKU_PLUGIN."$p/pdf.css")){
37358e6409eSAndreas Gohr                $list[DOKU_PLUGIN."$p/pdf.css"] = DOKU_BASE."lib/plugins/$p/";
37458e6409eSAndreas Gohr            }else{
37558e6409eSAndreas Gohr                $list[DOKU_PLUGIN."$p/print.css"] = DOKU_BASE."lib/plugins/$p/";
37658e6409eSAndreas Gohr            }
37758e6409eSAndreas Gohr        }
37858e6409eSAndreas Gohr        return $list;
37958e6409eSAndreas Gohr    }
380ee19bac3SLuigi Micco}
381