Example #1
0
 function EditToolbar()
 {
     global $WikiTheme;
     $this->tokens = array();
     //FIXME: enable Undo button for all other buttons also, not only the search/replace button
     if (JS_SEARCHREPLACE) {
         $this->tokens['JS_SEARCHREPLACE'] = 1;
         $undo_btn = $WikiTheme->getImageURL("ed_undo.png");
         $undo_d_btn = $WikiTheme->getImageURL("ed_undo_d.png");
         // JS_SEARCHREPLACE from walterzorn.de
         $js = Javascript("\nuri_undo_btn   = '" . $undo_btn . "'\nmsg_undo_alt   = '" . _("Undo") . "'\nuri_undo_d_btn = '" . $undo_d_btn . "'\nmsg_undo_d_alt = '" . _("Undo disabled") . "'\nmsg_do_undo    = '" . _("Operation undone") . "'\nmsg_replfound  = '" . _("Substring \"\\1\" found \\2 times. Replace with \"\\3\"?") . "'\nmsg_replnot    = '" . _("String \"%s\" not found.") . "'\nmsg_repl_title     = '" . _("Search & Replace") . "'\nmsg_repl_search    = '" . _("Search for") . "'\nmsg_repl_replace_with = '" . _("Replace with") . "'\nmsg_repl_ok        = '" . _("OK") . "'\nmsg_repl_close     = '" . _("Close") . "'\n");
         if (empty($WikiTheme->_headers_printed)) {
             $WikiTheme->addMoreHeaders($js);
             $WikiTheme->addMoreAttr('body', "SearchReplace", " onload='define_f()'");
         } else {
             // from an actionpage: WikiBlog, AddComment, WikiForum
             printXML($js);
         }
     } else {
         $WikiTheme->addMoreAttr('body', "editfocus", "document.getElementById('edit-content]').editarea.focus()");
     }
     if (ENABLE_EDIT_TOOLBAR) {
         $js = JavaScript('', array('src' => $WikiTheme->_findData("toolbar.js")));
         if (empty($WikiTheme->_headers_printed)) {
             $WikiTheme->addMoreHeaders($js);
         } else {
             // from an actionpage: WikiBlog, AddComment, WikiForum
             printXML($js);
             printXML(JavaScript('define_f()'));
         }
     }
     require_once "lib/WikiPluginCached.php";
     $cache = WikiPluginCached::newCache();
     $dbi = $GLOBALS['request']->getDbh();
     // regenerate if number of pages changes (categories, pages, templates)
     $key = $dbi->numPages();
     $key .= '+categories+plugin' . (isBrowserSafari() ? '+safari' : '');
     if (TOOLBAR_PAGELINK_PULLDOWN) {
         $key .= "+pages";
     }
     if (TOOLBAR_TEMPLATE_PULLDOWN) {
         $key .= "+templates_" . $dbi->getTimestamp();
     }
     $id = $cache->generateId($key);
     $content = $cache->get($id, 'toolbarcache');
     if (!empty($content)) {
         $this->tokens['EDIT_TOOLBAR'] =& $content;
     } else {
         $content = $this->_generate();
         // regenerate buttons every 1 hr/6 hrs
         $cache->save($id, $content, DEBUG ? '+3600' : '+21600', 'toolbarcache');
         $this->tokens['EDIT_TOOLBAR'] =& $content;
     }
 }
Example #2
0
 function EditToolbar()
 {
     global $WikiTheme;
     $this->tokens = array();
     //FIXME: enable Undo button for all other buttons also, not only the search/replace button
     if (JS_SEARCHREPLACE) {
         $this->tokens['JS_SEARCHREPLACE'] = 1;
         $undo_btn = $WikiTheme->getImageURL("ed_undo.png");
         $undo_d_btn = $WikiTheme->getImageURL("ed_undo_d.png");
         // JS_SEARCHREPLACE from walterzorn.de
         $WikiTheme->addMoreHeaders(Javascript("\nvar f, sr_undo, replacewin, undo_buffer=new Array(), undo_buffer_index=0;\n\nfunction define_f() {\n   f=document.getElementById('editpage');\n   f.editarea=document.getElementById('edit[content]');\n   sr_undo=document.getElementById('sr_undo');\n   undo_enable(false);\n   f.editarea.focus();\n}\nfunction undo_enable(bool) {\n   if (bool) {\n     sr_undo.src='" . $undo_btn . "';\n     sr_undo.alt='" . _("Undo") . "';\n     sr_undo.disabled = false;\n   } else {\n     sr_undo.src='" . $undo_d_btn . "';\n     sr_undo.alt='" . _("Undo disabled") . "';\n     sr_undo.disabled = true;\n     if(sr_undo.blur) sr_undo.blur();\n  }\n}\nfunction replace() {\n   replacewin = window.open('','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,height=90,width=450');\n   replacewin.window.document.write('<html><head><title>" . _("Search & Replace") . "</title><style type=\"text/css\"><'+'!'+'-- body, input {font-family:Tahoma,Arial,Helvetica,sans-serif;font-size:10pt;font-weight:bold;} td {font-size:9pt}  --'+'></style></head><body bgcolor=\"#dddddd\" onload=\"if(document.forms[0].ein.focus) document.forms[0].ein.focus(); return false;\"><form><center><table><tr><td align=\"right\">'+'" . _("Search") . ":</td><td align=\"left\"><input type=\"text\" name=\"ein\" size=\"45\" maxlength=\"500\"></td></tr><tr><td align=\"right\">'+' " . _("Replace with") . ":</td><td align=\"left\"><input type=\"text\" name=\"aus\" size=\"45\" maxlength=\"500\"></td></tr><tr><td colspan=\"2\" align=\"center\"><input type=\"button\" value=\" " . _("OK") . " \" onclick=\"if(self.opener)self.opener.do_replace(); return false;\">&nbsp;&nbsp;&nbsp;<input type=\"button\" value=\"" . _("Close") . "\" onclick=\"self.close(); return false;\"></td></tr></table></center></form></body></html>');\n   replacewin.window.document.close();\n   return false;\n}\nfunction do_replace() {\n   var txt=undo_buffer[undo_buffer_index]=f.editarea.value, ein=new RegExp(replacewin.document.forms[0].ein.value,'g'), aus=replacewin.document.forms[0].aus.value;\n   if (ein==''||ein==null) {\n      if (replacewin) replacewin.window.document.forms[0].ein.focus();\n      return;\n   }\n   var z_repl=txt.match(ein)? txt.match(ein).length : 0;\n   txt=txt.replace(ein,aus);\n   ein=ein.toString().substring(1,ein.toString().length-2);\n   result(z_repl, '" . sprintf(_("Substring \"%s\" found %s times. Replace with \"%s\"?"), "'+ein+'", "'+z_repl+'", "'+aus+'") . "', txt, '" . sprintf(_("String \"%s\" not found."), "'+ein+'") . "');\n   replacewin.window.focus();\n   replacewin.window.document.forms[0].ein.focus();\n   return false;\n}\nfunction result(zahl,frage,txt,alert_txt) {\n   if (zahl>0) {\n      if(window.confirm(frage)==true) {\n         f.editarea.value=txt;\n         undo_save();\n         undo_enable(true);\n      }\n   } else alert(alert_txt);\n}\nfunction do_undo() {\n   if(undo_buffer_index==0) return;\n   else if(undo_buffer_index>0) {\n      f.editarea.value=undo_buffer[undo_buffer_index-1];\n      undo_buffer[undo_buffer_index]=null;\n      undo_buffer_index--;\n      if(undo_buffer_index==0) {\n         alert('" . _("Operation undone") . "');\n         undo_enable(false);\n      }\n   }\n}\n//save a snapshot in the undo buffer\nfunction undo_save() {\n   undo_buffer[undo_buffer_index]=f.editarea.value;\n   undo_buffer_index++;\n   undo_enable(true);\n}\n"));
         $WikiTheme->addMoreAttr('body', "SearchReplace", " onload='define_f()'");
     } else {
         $WikiTheme->addMoreAttr('body', "editfocus", "document.getElementById('edit[content]').editarea.focus()");
     }
     if (ENABLE_EDIT_TOOLBAR) {
         $WikiTheme->addMoreHeaders(JavaScript('', array('src' => $WikiTheme->_findData("toolbar.js"))));
     }
     include_once "lib/WikiPluginCached.php";
     $cache = WikiPluginCached::newCache();
     $dbi = $GLOBALS['request']->getDbh();
     // regenerate if number of pages changes (categories, pages, templates)
     $key = $dbi->numPages();
     $key .= '+categories+plugin';
     if (TOOLBAR_PAGELINK_PULLDOWN) {
         $key .= "+pages";
     }
     if (TOOLBAR_TEMPLATE_PULLDOWN) {
         $key .= "+templates_" . $dbi->getTimestamp();
     }
     $id = $cache->generateId($key);
     $content = $cache->get($id, 'toolbarcache');
     if (!empty($content)) {
         $this->tokens['EDIT_TOOLBAR'] =& $content;
     } else {
         $content = $this->_generate();
         // regenerate buttons every 3600 seconds
         $cache->save($id, $content, '+3600', 'toolbarcache');
         $this->tokens['EDIT_TOOLBAR'] =& $content;
     }
 }
Example #3
0
function ConvertAndDisplayPdf(&$request)
{
    global $WikiTheme;
    if (empty($request->_is_buffering_output)) {
        $request->buffer_output(false);
    }
    $pagename = $request->getArg('pagename');
    $dest = $request->getArg('dest');
    // Disable CACHE
    $WikiTheme->DUMP_MODE = true;
    include_once "lib/display.php";
    // TODO: urldecode pagename to get rid of %20 in filename.pdf
    displayPage($request, new Template('htmldump', $request));
    $html = ob_get_contents();
    $WikiTheme->DUMP_MODE = false;
    // check hook for external converters
    if (defined('USE_EXTERNAL_HTML2PDF') and USE_EXTERNAL_HTML2PDF) {
        // See http://phpwiki.sourceforge.net/phpwiki/PhpWikiToDocBookAndPDF
        // htmldoc or ghostscript + html2ps or docbook (dbdoclet, xsltproc, fop)
        Header('Content-Type: application/pdf');
        $request->discardOutput();
        $request->buffer_output(false);
        require_once "lib/WikiPluginCached.php";
        $cache = new WikiPluginCached();
        $cache->newCache();
        $tmpfile = $cache->tempnam('pdf.html');
        $fp = fopen($tmpfile, "wb");
        fwrite($fp, $html);
        fclose($fp);
        passthru(sprintf(USE_EXTERNAL_HTML2PDF, $tmpfile));
        unlink($tmpfile);
    }
    // clean the hints errors
    global $ErrorManager;
    $ErrorManager->destroyPostponedErrors();
    if (!empty($errormsg)) {
        $request->discardOutput();
    }
}
Example #4
0
function ConvertAndDisplayPdf(&$request)
{
    if (empty($request->_is_buffering_output)) {
        $request->buffer_output(false);
    }
    $pagename = $request->getArg('pagename');
    $dest = $request->getArg('dest');
    //TODO: inline cached content: /getimg.php? => image.png
    // Disable CACHE
    include_once "lib/display.php";
    displayPage($request);
    $html = ob_get_contents();
    // check hook for external converters
    if (defined('USE_EXTERNAL_HTML2PDF') and USE_EXTERNAL_HTML2PDF) {
        // See http://phpwiki.sourceforge.net/phpwiki/PhpWikiToDocBookAndPDF
        // htmldoc or ghostscript + html2ps or docbook (dbdoclet, xsltproc, fop)
        $request->discardOutput();
        $request->buffer_output(false);
        require_once "lib/WikiPluginCached.php";
        $cache = new WikiPluginCached();
        $cache->newCache();
        $tmpfile = $cache->tempnam();
        $fp = fopen($tmpfile, "wb");
        fwrite($fp, $html);
        fclose($fp);
        Header('Content-Type: application/pdf');
        passthru(sprintf(USE_EXTERNAL_HTML2PDF, $tmpfile));
        unlink($tmpfile);
    } else {
        // use fpdf:
        if ($GLOBALS['LANG'] == 'ja') {
            include_once "lib/fpdf/japanese.php";
            $pdf = new PDF_Japanese();
        } elseif ($GLOBALS['LANG'] == 'zh') {
            include_once "lib/fpdf/chinese.php";
            $pdf = new PDF_Chinese();
        } else {
            $pdf = new PDF();
        }
        $pdf->Open();
        $pdf->AddPage();
        $pdf->ConvertFromHTML($html);
        $request->discardOutput();
        $request->buffer_output(false);
        $pdf->Output($pagename . ".pdf", $dest ? $dest : 'I');
    }
    if (!empty($errormsg)) {
        $request->discardOutput();
    }
}
Example #5
0
 function discspace()
 {
     global $DBParams, $request;
     include_once "lib/WikiPluginCached.php";
     $cache = WikiPluginCached::newCache();
     $id = $cache->generateId('SystemInfo::discspace');
     $cachedir = 'plugincache';
     $content = $cache->get($id, $cachedir);
     if (empty($content)) {
         $dir = defined('PHPWIKI_DIR') ? PHPWIKI_DIR : '.';
         //TODO: windows only (no cygwin)
         $appsize = `du -s {$dir} | cut -f1`;
         if (in_array($DBParams['dbtype'], array('SQL', 'ADODB'))) {
             //TODO: where is the data is actually stored? see phpMyAdmin
             $pagesize = 0;
         } elseif ($DBParams['dbtype'] == 'dba') {
             $pagesize = 0;
             $dbdir = $DBParams['directory'];
             if ($DBParams['dba_handler'] == 'db3') {
                 $pagesize = filesize($DBParams['directory'] . "/wiki_pagedb.db3") / 1024;
             }
             // if issubdirof($dbdir, $dir) $appsize -= $pagesize;
         } else {
             // flatfile, cvs
             $dbdir = $DBParams['directory'];
             $pagesize = `du -s {$dbdir}`;
             // if issubdirof($dbdir, $dir) $appsize -= $pagesize;
         }
         $content = array('appsize' => $appsize, 'pagesize' => $pagesize);
         // regenerate cache every 30 minutes
         $cache->save($id, $content, '+1800', $cachedir);
     } else {
         $appsize = $content['appsize'];
         $pagesize = $content['pagesize'];
     }
     $s = sprintf(_("Application size: %d Kb"), $appsize);
     if ($pagesize) {
         $s .= ", " . sprintf(_("Pagedata size: %d Kb", $pagesize));
     }
     return $s;
 }