logo       

CVS: phpwiki/lib loadsave.php,1.135,1.136: msg#00144

web.wiki.phpwiki.checkins

Subject: CVS: phpwiki/lib loadsave.php,1.135,1.136

Update of /cvsroot/phpwiki/phpwiki/lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30807/lib

Modified Files:
loadsave.php
Log Message:
remove body tags in html dumps, add css and images to zipdumps, simplify
printing

Index: loadsave.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/loadsave.php,v
retrieving revision 1.135
retrieving revision 1.136
diff -u -2 -b -p -d -r1.135 -r1.136
--- loadsave.php 26 Dec 2004 17:17:25 -0000 1.135
+++ loadsave.php 25 Jan 2005 07:07:24 -0000 1.136
@@ -3,5 +3,5 @@ rcs_id('$Id$');

/*
- Copyright 1999, 2000, 2001, 2002, 2004 $ThePhpWikiProgrammingTeam
+ Copyright 1999,2000,2001,2002,2004,2005 $ThePhpWikiProgrammingTeam

This file is part of PhpWiki.
@@ -22,5 +22,4 @@ rcs_id('$Id$');
*/

-
require_once("lib/ziplib.php");
require_once("lib/Template.php");
@@ -316,5 +315,5 @@ function DumpToDir (&$request)

if (in_array($pagename, $excludeList)) {
- if (!isa($request,'MockRequest')) {
+ if (!isa($request, 'MockRequest')) {
PrintXML(_("Skipped."));
flush();
@@ -342,5 +341,5 @@ function DumpToDir (&$request)
$num = fwrite($fd, $data, strlen($data));
$msg->pushContent(HTML::small(fmt("%s bytes written", $num)));
- if (!isa($request,'MockRequest')) {
+ if (!isa($request, 'MockRequest')) {
PrintXML($msg);
flush();
@@ -353,4 +352,13 @@ function DumpToDir (&$request)
}

+function _copyMsg($page, $smallmsg) {
+ if (!isa($GLOBALS['request'], 'MockRequest')) {
+ if ($page) $msg = HTML(HTML::br(), HTML($page),
HTML::small($smallmsg));
+ else $msg = HTML::small($smallmsg);
+ PrintXML($msg);
+ flush();
+ }
+}
+
/**
* Dump all pages as XHTML to a directory, as pagename.html.
@@ -405,4 +413,6 @@ function DumpHtmlToDir (&$request)
$WikiTheme->HTML_DUMP_SUFFIX = HTML_DUMP_SUFFIX;
$WikiTheme->DUMP_MODE = 'HTML';
+ $_bodyAttr = $WikiTheme->_MoreAttr['body'];
+ unset($WikiTheme->_MoreAttr['body']);

// check if the dumped file will be accessible from outside
@@ -423,5 +433,5 @@ function DumpHtmlToDir (&$request)

$request_args = $request->args;
- $timeout = (! $request->getArg('start_debug')) ? 30 : 240;
+ $timeout = (! $request->getArg('start_debug')) ? 20 : 240;

while ($page = $pages->next()) {
@@ -464,5 +474,5 @@ function DumpHtmlToDir (&$request)
}
$msg->pushContent(HTML::small(fmt("%s bytes written", $num), "\n"));
- if (!isa($request,'MockRequest')) {
+ if (!isa($request, 'MockRequest')) {
PrintXML($msg);
}
@@ -493,15 +503,13 @@ function DumpHtmlToDir (&$request)
@mkdir("$directory/images");
foreach ($WikiTheme->dumped_images as $img_file) {
- if (($from = $WikiTheme->_findFile($img_file, true)) and
basename($from)) {
+ if ($img_file and ($from = $WikiTheme->_findFile($img_file, true))
and basename($from)) {
$target = "$directory/images/".basename($img_file);
if (copy($WikiTheme->_path . $from, $target)) {
- $msg = HTML(HTML::br(), HTML($from), HTML::small(fmt("...
copied to %s", $target)));
- if (!isa($request,'MockRequest'))
- PrintXML($msg);
+ _copyMsg($from, fmt("... copied to %s", $target));
+ } else {
+ _copyMsg($from, fmt("... not copied to %s", $target));
}
} else {
- $msg = HTML(HTML::br(), HTML($img_file), HTML::small(fmt("...
not found", $target)));
- if (!isa($request,'MockRequest'))
- PrintXML($msg);
+ _copyMsg($from, _("... not found"));
}
}
@@ -511,15 +519,13 @@ function DumpHtmlToDir (&$request)
@mkdir("$directory/images/buttons");
foreach ($WikiTheme->dumped_buttons as $text => $img_file) {
- if (($from = $WikiTheme->_findFile($img_file, true)) and
basename($from)) {
+ if ($img_file and ($from = $WikiTheme->_findFile($img_file, true))
and basename($from)) {
$target = "$directory/images/buttons/".basename($img_file);
if (copy($WikiTheme->_path . $from, $target)) {
- $msg = HTML(HTML::br(), HTML($from), HTML::small(fmt("...
copied to %s", $target)));
- if (!isa($request,'MockRequest'))
- PrintXML($msg);
+ _copyMsg($from, fmt("... copied to %s", $target));
+ } else {
+ _copyMsg($from, fmt("... not copied to %s", $target));
}
} else {
- $msg = HTML(HTML::br(), HTML($img_file), HTML::small(fmt("...
not found", $target)));
- if (!isa($request,'MockRequest'))
- PrintXML($msg);
+ _copyMsg($from, _("... not found"));
}
}
@@ -527,15 +533,13 @@ function DumpHtmlToDir (&$request)
if (!empty($WikiTheme->dumped_css) and is_array($WikiTheme->dumped_css)) {
foreach ($WikiTheme->dumped_css as $css_file) {
- if (($from = $WikiTheme->_findFile(basename($css_file), true)) and
basename($from)) {
+ if ($css_file and ($from =
$WikiTheme->_findFile(basename($css_file), true)) and basename($from)) {
$target = "$directory/" . basename($css_file);
if (copy($WikiTheme->_path . $from, $target)) {
- $msg = HTML(HTML::br(), HTML($from), HTML::small(fmt("...
copied to %s", $target)));
- if (!isa($request,'MockRequest'))
- PrintXML($msg);
+ _copyMsg($from, fmt("... copied to %s", $target));
+ } else {
+ _copyMsg($from, fmt("... not copied to %s", $target));
}
} else {
- $msg = HTML(HTML::br(), HTML($css_file), HTML::small(fmt("...
not found", $target)));
- if (!isa($request,'MockRequest'))
- PrintXML($msg);
+ _copyMsg($from, _("... not found"));
}
}
@@ -543,4 +547,5 @@ function DumpHtmlToDir (&$request)
$WikiTheme->HTML_DUMP_SUFFIX = '';
$WikiTheme->DUMP_MODE = false;
+ $WikiTheme->_MoreAttr['body'] = $_bodyAttr;

$request->setArg('pagename',$thispage); // Template::_basepage fix
@@ -582,4 +587,6 @@ function MakeWikiZipHtml (&$request)
$WikiTheme->HTML_DUMP_SUFFIX = HTML_DUMP_SUFFIX;
$WikiTheme->DUMP_MODE = 'ZIPHTML';
+ $_bodyAttr = $WikiTheme->_MoreAttr['body'];
+ unset($WikiTheme->_MoreAttr['body']);

/* ignore fatals in plugins */
@@ -590,5 +597,5 @@ function MakeWikiZipHtml (&$request)

$request_args = $request->args;
- $timeout = (! $request->getArg('start_debug')) ? 30 : 240;
+ $timeout = (! $request->getArg('start_debug')) ? 20 : 240;

while ($page = $pages->next()) {
@@ -621,5 +628,5 @@ function MakeWikiZipHtml (&$request)
$data = GeneratePageasXML($template, $pagename);

- $zip->addRegularFile( $filename, $data, $attrib);
+ $zip->addRegularFile( $filename, $data, $attrib );

if (USECACHE) {
@@ -639,5 +646,43 @@ function MakeWikiZipHtml (&$request)
$pages->free();

- // FIXME: Deal with css and images here.
+ $attrib = false;
+ // Deal with css and images here.
+ if (!empty($WikiTheme->dumped_images) and
is_array($WikiTheme->dumped_images)) {
+ // dirs are created automatically
+ //if ($WikiTheme->dumped_images) $zip->addRegularFile("images", "",
$attrib);
+ foreach ($WikiTheme->dumped_images as $img_file) {
+ if (($from = $WikiTheme->_findFile($img_file, true)) and
basename($from)) {
+ $target = "images/".basename($img_file);
+ if (check_php_version(4,3))
+ $zip->addRegularFile($target,
file_get_contents($WikiTheme->_path . $from), $attrib);
+ else
+ $zip->addRegularFile($target, join('',
file($WikiTheme->_path . $from)), $attrib);
+ }
+ }
+ }
+ if (!empty($WikiTheme->dumped_buttons) and
is_array($WikiTheme->dumped_buttons)) {
+ //if ($WikiTheme->dumped_buttons)
$zip->addRegularFile("images/buttons", "", $attrib);
+ foreach ($WikiTheme->dumped_buttons as $text => $img_file) {
+ if (($from = $WikiTheme->_findFile($img_file, true)) and
basename($from)) {
+ $target = "images/buttons/".basename($img_file);
+ if (check_php_version(4,3))
+ $zip->addRegularFile($target,
file_get_contents($WikiTheme->_path . $from), $attrib);
+ else
+ $zip->addRegularFile($target, join('',
file($WikiTheme->_path . $from)), $attrib);
+ }
+ }
+ }
+ if (!empty($WikiTheme->dumped_css) and is_array($WikiTheme->dumped_css)) {
+ foreach ($WikiTheme->dumped_css as $css_file) {
+ if (($from = $WikiTheme->_findFile(basename($css_file), true)) and
basename($from)) {
+ $target = basename($css_file);
+ if (check_php_version(4,3))
+ $zip->addRegularFile($target,
file_get_contents($WikiTheme->_path . $from), $attrib);
+ else
+ $zip->addRegularFile($target, join('',
file($WikiTheme->_path . $from)), $attrib);
+ }
+ }
+ }
+
$zip->finish();
if (check_php_version(4,1)) {
@@ -645,6 +690,7 @@ function MakeWikiZipHtml (&$request)
$ErrorManager->popErrorHandler();
}
- $WikiTheme->$HTML_DUMP_SUFFIX = '';
+ $WikiTheme->HTML_DUMP_SUFFIX = '';
$WikiTheme->DUMP_MODE = false;
+ $WikiTheme->_MoreAttr['body'] = $_bodyAttr;
}

@@ -877,5 +923,5 @@ function _tryinsertInterWikiMap($content

// if loading from virgin setup do echo, otherwise trigger_error
E_USER_NOTICE
- if (!isa($GLOBALS['request'],'MockRequest'))
+ if (!isa($GLOBALS['request'], 'MockRequest'))
echo sprintf(_("Loading InterWikiMap from external file %s."),
$mapfile),"<br />";

@@ -1260,4 +1306,7 @@ function LoadPostFile (&$request)
/**
$Log$
+ Revision 1.136 2005/01/25 07:07:24 rurban
+ remove body tags in html dumps, add css and images to zipdumps, simplify
printing
+
Revision 1.135 2004/12/26 17:17:25 rurban
announce dumps - mult.requests to avoid request::finish, e.g. LinkDatabase,
PdfOut, ...



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise