Importing webpage elements from manually entered cloud file path work. All detected elements are automatically imported.
This commit is contained in:
parent
75fb065526
commit
d6b28cdc57
@ -269,9 +269,28 @@ class Webpages extends \Zotlabs\Web\Controller {
|
|||||||
notice( t('Invalid folder path.') . EOL);
|
notice( t('Invalid folder path.') . EOL);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
info( t('Valid folder path.') . EOL);
|
require_once('include/import.php');
|
||||||
|
$elements = [];
|
||||||
|
$elements['pages'] = scan_webpage_elements($_POST['path'], 'page', true);
|
||||||
|
$elements['layouts'] = scan_webpage_elements($_POST['path'], 'layout', true);
|
||||||
|
$elements['blocks'] = scan_webpage_elements($_POST['path'], 'block', true);
|
||||||
|
logger('elements: ' . json_encode($elements));
|
||||||
|
if(!(empty($elements['pages']) && empty($elements['blocks']) && empty($elements['layouts']))) {
|
||||||
|
info( t('Webpages elements detected.') . EOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Import layout first so that pages that reference new layouts will find
|
||||||
|
// the mid of layout items in the database
|
||||||
|
foreach($elements['layouts'] as &$layout) {
|
||||||
|
$layout = import_webpage_element($layout, $channel, 'layout');
|
||||||
|
}
|
||||||
|
foreach($elements['pages'] as &$page) {
|
||||||
|
$page = import_webpage_element($page, $channel, 'page');
|
||||||
|
}
|
||||||
|
foreach($elements['blocks'] as &$block) {
|
||||||
|
$block = import_webpage_element($block, $channel, 'block');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -1972,7 +1972,7 @@ function get_filename_by_cloudname($cloudname, $channel, $storepath) {
|
|||||||
foreach($items as $item) {
|
foreach($items as $item) {
|
||||||
$filename = find_filename_by_hash($channel['channel_id'], $item);
|
$filename = find_filename_by_hash($channel['channel_id'], $item);
|
||||||
if($filename === $cloudname) {
|
if($filename === $cloudname) {
|
||||||
return $filename;
|
return $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -1223,15 +1223,15 @@ function scan_webpage_elements($path, $type, $cloud = false) {
|
|||||||
$dirtoscan = $path;
|
$dirtoscan = $path;
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'page':
|
case 'page':
|
||||||
$dirtoscan .= '/pages/';
|
$dirtoscan .= 'pages/';
|
||||||
$json_filename = 'page.json';
|
$json_filename = 'page.json';
|
||||||
break;
|
break;
|
||||||
case 'layout':
|
case 'layout':
|
||||||
$dirtoscan .= '/layouts/';
|
$dirtoscan .= 'layouts/';
|
||||||
$json_filename = 'layout.json';
|
$json_filename = 'layout.json';
|
||||||
break;
|
break;
|
||||||
case 'block':
|
case 'block':
|
||||||
$dirtoscan .= '/blocks/';
|
$dirtoscan .= 'blocks/';
|
||||||
$json_filename = 'block.json';
|
$json_filename = 'block.json';
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
@ -1251,7 +1251,7 @@ function scan_webpage_elements($path, $type, $cloud = false) {
|
|||||||
$folder = $dirtoscan . '/' . $element;
|
$folder = $dirtoscan . '/' . $element;
|
||||||
if (is_dir($folder)) {
|
if (is_dir($folder)) {
|
||||||
if($cloud) {
|
if($cloud) {
|
||||||
$jsonfilepath = get_filename_by_cloudname($json_filename, $channel, $folder);
|
$jsonfilepath = $folder . '/' . get_filename_by_cloudname($json_filename, $channel, $folder);
|
||||||
} else {
|
} else {
|
||||||
$jsonfilepath = $folder . '/' . $json_filename;
|
$jsonfilepath = $folder . '/' . $json_filename;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user