mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-25 05:22:59 +00:00
Bugfix: Include uploaded files when exporting
This commit is contained in:
parent
c120902cda
commit
d51c3f163f
5 changed files with 28 additions and 15 deletions
|
@ -26,6 +26,7 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
|
|||
- Standardise line endings to `\n` (linux)
|
||||
- Enhanced setup instructions in README.
|
||||
- Long lines in code blocks now wrap correctly.
|
||||
- The `export` action now correctly includes uploaded files alongside their descriptions
|
||||
|
||||
## v0.17.1
|
||||
|
||||
|
|
|
@ -411,7 +411,7 @@ if($settings->sessionprefix == "auto")
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
/** The version of Pepperminty Wiki currently running. */
|
||||
$version = "v0.18-dev";
|
||||
$commit = "dc860acfd3db082023b34fd769be7885c521b4cd";
|
||||
$commit = "c120902cda82e3efcd32d071ad8993c06fdc79ac";
|
||||
/// Environment ///
|
||||
/** Holds information about the current request environment. */
|
||||
$env = new stdClass();
|
||||
|
@ -457,6 +457,8 @@ $paths->idindex = "idindex.json";
|
|||
$paths->statsindex = "statsindex.json";
|
||||
/** The interwiki index cache */
|
||||
$paths->interwiki_index = "interwiki_index.json";
|
||||
/** The cache directory, minus the trailing slash. Contains cached rendered versions of pages. If things don't update, try deleting this folder. */
|
||||
$paths->cache_directory = "._cache";
|
||||
|
||||
// Prepend the storage data directory to all the defined paths.
|
||||
foreach ($paths as &$path) {
|
||||
|
@ -468,6 +470,10 @@ $paths->settings_file = $settingsFilename;
|
|||
/** The prefix to add to uploaded files */
|
||||
$paths->upload_file_prefix = "Files/";
|
||||
|
||||
// Create the cache directory if it doesn't exist
|
||||
if(!is_dir($paths->cache_directory))
|
||||
mkdir($paths->cache_directory, 0700);
|
||||
|
||||
session_start();
|
||||
// Make sure that the login cookie lasts beyond the end of the user's session
|
||||
setcookie(session_name(), session_id(), time() + $settings->sessionlifetime, "", "", false, true);
|
||||
|
@ -2136,13 +2142,12 @@ function add_parser($name, $parser_code)
|
|||
/**
|
||||
* Parses the specified page source using the parser specified in the settings
|
||||
* into HTML.
|
||||
* The specified parser may (though it's unilkely) render it to other things.
|
||||
* The specified parser may (though it's unlikely) render it to other things.
|
||||
* @package core
|
||||
* @param string $source The source to render.
|
||||
* @return string The source rendered to HTML.
|
||||
*/
|
||||
function parse_page_source($source)
|
||||
{
|
||||
function parse_page_source($source) {
|
||||
global $settings, $parsers;
|
||||
if(!isset($parsers[$settings->parser]))
|
||||
exit(page_renderer::render_main("Parsing error - $settings->sitename", "<p>Parsing some page source data failed. This is most likely because $settings->sitename has the parser setting set incorrectly. Please contact <a href='mailto:" . hide_email($settings->admindetails_email) . "'>" . $settings->admindetails_name . "</a>, your $settings->sitename Administrator."));
|
||||
|
@ -7665,7 +7670,7 @@ function generate_page_hash($page_data) {
|
|||
|
||||
register_module([
|
||||
"name" => "Export",
|
||||
"version" => "0.4",
|
||||
"version" => "0.5",
|
||||
"author" => "Starbeamrainbowlabs",
|
||||
"description" => "Adds a page that you can use to export your wiki as a .zip file. Uses \$settings->export_only_allow_admins, which controls whether only admins are allowed to export the wiki.",
|
||||
"id" => "page-export",
|
||||
|
@ -7710,9 +7715,10 @@ register_module([
|
|||
exit(page_renderer::render("Export error - $settings->sitename", "Pepperminty Wiki was unable to open a temporary file to store the exported data in. Please contact $settings->sitename's administrator (" . $settings->admindetails_name . " at " . hide_email($settings->admindetails_email) . ") for assistance."));
|
||||
}
|
||||
|
||||
foreach($pageindex as $entry)
|
||||
{
|
||||
foreach($pageindex as $entry) {
|
||||
$zip->addFile("$env->storage_prefix$entry->filename", $entry->filename);
|
||||
if(isset($entry->uploadedfilepath))
|
||||
$zip->addFile($entry->uploadedfilepath);
|
||||
}
|
||||
|
||||
if($zip->close() !== true)
|
||||
|
|
11
core.php
11
core.php
|
@ -56,6 +56,8 @@ $paths->idindex = "idindex.json";
|
|||
$paths->statsindex = "statsindex.json";
|
||||
/** The interwiki index cache */
|
||||
$paths->interwiki_index = "interwiki_index.json";
|
||||
/** The cache directory, minus the trailing slash. Contains cached rendered versions of pages. If things don't update, try deleting this folder. */
|
||||
$paths->cache_directory = "._cache";
|
||||
|
||||
// Prepend the storage data directory to all the defined paths.
|
||||
foreach ($paths as &$path) {
|
||||
|
@ -67,6 +69,10 @@ $paths->settings_file = $settingsFilename;
|
|||
/** The prefix to add to uploaded files */
|
||||
$paths->upload_file_prefix = "Files/";
|
||||
|
||||
// Create the cache directory if it doesn't exist
|
||||
if(!is_dir($paths->cache_directory))
|
||||
mkdir($paths->cache_directory, 0700);
|
||||
|
||||
session_start();
|
||||
// Make sure that the login cookie lasts beyond the end of the user's session
|
||||
setcookie(session_name(), session_id(), time() + $settings->sessionlifetime, "", "", false, true);
|
||||
|
@ -1735,13 +1741,12 @@ function add_parser($name, $parser_code)
|
|||
/**
|
||||
* Parses the specified page source using the parser specified in the settings
|
||||
* into HTML.
|
||||
* The specified parser may (though it's unilkely) render it to other things.
|
||||
* The specified parser may (though it's unlikely) render it to other things.
|
||||
* @package core
|
||||
* @param string $source The source to render.
|
||||
* @return string The source rendered to HTML.
|
||||
*/
|
||||
function parse_page_source($source)
|
||||
{
|
||||
function parse_page_source($source) {
|
||||
global $settings, $parsers;
|
||||
if(!isset($parsers[$settings->parser]))
|
||||
exit(page_renderer::render_main("Parsing error - $settings->sitename", "<p>Parsing some page source data failed. This is most likely because $settings->sitename has the parser setting set incorrectly. Please contact <a href='mailto:" . hide_email($settings->admindetails_email) . "'>" . $settings->admindetails_name . "</a>, your $settings->sitename Administrator."));
|
||||
|
|
|
@ -190,11 +190,11 @@
|
|||
},
|
||||
{
|
||||
"name": "Export",
|
||||
"version": "0.4",
|
||||
"version": "0.5",
|
||||
"author": "Starbeamrainbowlabs",
|
||||
"description": "Adds a page that you can use to export your wiki as a .zip file. Uses $settings->export_only_allow_admins, which controls whether only admins are allowed to export the wiki.",
|
||||
"id": "page-export",
|
||||
"lastupdate": 1472230366,
|
||||
"lastupdate": 1548970758,
|
||||
"optional": false
|
||||
},
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
register_module([
|
||||
"name" => "Export",
|
||||
"version" => "0.4",
|
||||
"version" => "0.5",
|
||||
"author" => "Starbeamrainbowlabs",
|
||||
"description" => "Adds a page that you can use to export your wiki as a .zip file. Uses \$settings->export_only_allow_admins, which controls whether only admins are allowed to export the wiki.",
|
||||
"id" => "page-export",
|
||||
|
@ -46,9 +46,10 @@ register_module([
|
|||
exit(page_renderer::render("Export error - $settings->sitename", "Pepperminty Wiki was unable to open a temporary file to store the exported data in. Please contact $settings->sitename's administrator (" . $settings->admindetails_name . " at " . hide_email($settings->admindetails_email) . ") for assistance."));
|
||||
}
|
||||
|
||||
foreach($pageindex as $entry)
|
||||
{
|
||||
foreach($pageindex as $entry) {
|
||||
$zip->addFile("$env->storage_prefix$entry->filename", $entry->filename);
|
||||
if(isset($entry->uploadedfilepath))
|
||||
$zip->addFile($entry->uploadedfilepath);
|
||||
}
|
||||
|
||||
if($zip->close() !== true)
|
||||
|
|
Loading…
Reference in a new issue