mirror of
https://github.com/processwire/processwire.git
synced 2025-08-14 02:34:24 +02:00
Update Pages Export/Import class to support export/import of page created and modified dates
This commit is contained in:
@@ -512,7 +512,9 @@ class PagesEditor extends Wire {
|
||||
} else if($isNew) {
|
||||
$sql = 'modified=NOW()';
|
||||
}
|
||||
if(!$isNew && $page->created > 0) $data['created'] = date('Y-m-d H:i:s', $page->created);
|
||||
if($page->created > 0) {
|
||||
$data['created'] = date('Y-m-d H:i:s', $page->created);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($data['modified_users_id'])) $page->modified_users_id = $data['modified_users_id'];
|
||||
@@ -531,8 +533,9 @@ class PagesEditor extends Wire {
|
||||
|
||||
$sql = trim($sql, ", ");
|
||||
|
||||
if($isNew) {
|
||||
$query = $database->prepare("INSERT INTO pages SET $sql, created=NOW()");
|
||||
if($isNew) {
|
||||
if(empty($data['created'])) $sql .= ', created=NOW()';
|
||||
$query = $database->prepare("INSERT INTO pages SET $sql");
|
||||
} else {
|
||||
$query = $database->prepare("UPDATE pages SET $sql WHERE id=:page_id");
|
||||
$query->bindValue(":page_id", (int) $page->id, \PDO::PARAM_INT);
|
||||
|
@@ -375,6 +375,8 @@ class PagesExportImport extends Wire {
|
||||
'status' => $page->status,
|
||||
'sort' => $page->sort,
|
||||
'sortfield' => $page->sortfield,
|
||||
'created' => $page->createdStr,
|
||||
'modified' => $page->modifiedStr,
|
||||
);
|
||||
|
||||
// verbose page settings
|
||||
@@ -382,11 +384,9 @@ class PagesExportImport extends Wire {
|
||||
$settings = array_merge($settings, array(
|
||||
'parent_id' => $page->parent_id,
|
||||
'templates_id' => $page->templates_id,
|
||||
'created' => $page->createdStr,
|
||||
'modified' => $page->modifiedStr,
|
||||
'published' => $page->publishedStr,
|
||||
'created_user' => $page->createdUser->name,
|
||||
'modified_user' => $page->modifiedUser->name,
|
||||
'published' => $page->publishedStr,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -557,7 +557,7 @@ class PagesExportImport extends Wire {
|
||||
'changeName' => true,
|
||||
'changeStatus' => true,
|
||||
'changeSort' => true,
|
||||
'saveOptions' => array('adjustName' => true), // options passed to Pages::save
|
||||
'saveOptions' => array('adjustName' => true, 'quiet' => true), // options passed to Pages::save
|
||||
'fieldNames' => array(), // import only these field names, when specified
|
||||
'replaceFields' => array(), // array of import-data field name to replacement page field name
|
||||
'replaceTemplates' => array(), // array of import-data template name to replacement page template name
|
||||
@@ -863,6 +863,12 @@ class PagesExportImport extends Wire {
|
||||
if($page->sort != $settings['sort']) $page->sort = $settings['sort'];
|
||||
if($page->sortfield != $settings['sortfield']) $page->sortfield = $settings['sortfield'];
|
||||
}
|
||||
|
||||
foreach(array('created', 'modified', 'published') as $dateType) {
|
||||
if(isset($settings[$dateType])) {
|
||||
$page->set($dateType, strtotime($settings[$dateType]));
|
||||
}
|
||||
}
|
||||
|
||||
if($languages && count($langProperties)) {
|
||||
foreach($langProperties as $property) {
|
||||
|
@@ -283,6 +283,7 @@ class ProcessPagesExportImport extends Process {
|
||||
// 'pages' => array( page import data ),
|
||||
// 'fields' => array( fields information ),
|
||||
// );
|
||||
set_time_limit(3600);
|
||||
|
||||
/** @var WireInput $input */
|
||||
$input = $this->wire('input');
|
||||
@@ -298,7 +299,7 @@ class ProcessPagesExportImport extends Process {
|
||||
$options = array(
|
||||
'update' => $importMode == 'all' || $importMode == 'update',
|
||||
'create' => $importMode == 'all' || $importMode == 'create',
|
||||
'saveOptions' => array('adjustName' => true),
|
||||
'saveOptions' => array('adjustName' => true, 'quiet' => true),
|
||||
'fieldNames' => $fieldNames,
|
||||
'replaceFields' => isset($a['_replaceFields']) ? $a['_replaceFields'] : array(),
|
||||
'commit' => $submitCommit,
|
||||
@@ -1023,6 +1024,8 @@ class ProcessPagesExportImport extends Process {
|
||||
// options_parent: array('parent', 'recursive')
|
||||
// export_fields: array(field names)
|
||||
// export_to: string(zip, json)
|
||||
|
||||
set_time_limit(3600);
|
||||
|
||||
/** @var Pages $pages */
|
||||
$pages = $this->wire('pages');
|
||||
|
Reference in New Issue
Block a user