aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Webpages.php
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Module/Webpages.php')
-rw-r--r--Zotlabs/Module/Webpages.php113
1 files changed, 91 insertions, 22 deletions
diff --git a/Zotlabs/Module/Webpages.php b/Zotlabs/Module/Webpages.php
index ab03b0a37..ee9633243 100644
--- a/Zotlabs/Module/Webpages.php
+++ b/Zotlabs/Module/Webpages.php
@@ -45,7 +45,29 @@ class Webpages extends \Zotlabs\Web\Controller {
$observer = \App::get_observer();
$channel = \App::get_channel();
-
+
+ switch ($_SESSION['action']) {
+ case 'import':
+ $_SESSION['action'] = null;
+ $o .= replace_macros(get_markup_template('webpage_import.tpl'), array(
+ '$title' => t('Import Webpage Elements'),
+ '$action' => 'import',
+ '$pages' => $_SESSION['pages'],
+ '$layouts' => $_SESSION['layouts'],
+ '$blocks' => $_SESSION['blocks'],
+ ));
+ //logger('webpage_import.tpl: ' . $o);
+ return $o;
+
+ case 'importselected':
+ $_SESSION['action'] = null;
+ break;
+ default :
+ $_SESSION['action'] = null;
+ break;
+ }
+
+
if(\App::$is_sys && is_site_admin()) {
$sys = get_sys_channel();
if($sys && intval($sys['channel_id'])) {
@@ -270,29 +292,15 @@ class Webpages extends \Zotlabs\Web\Controller {
$elements['pages'] = scan_webpage_elements($_POST['path'], 'page', $cloud);
$elements['layouts'] = scan_webpage_elements($_POST['path'], 'layout', $cloud);
$elements['blocks'] = scan_webpage_elements($_POST['path'], 'block', $cloud);
-
+ $_SESSION['blocks'] = $elements['blocks'];
+ $_SESSION['layouts'] = $elements['layouts'];
+ $_SESSION['pages'] = $elements['pages'];
if(!(empty($elements['pages']) && empty($elements['blocks']) && empty($elements['layouts']))) {
info( t('Webpages elements detected.') . EOL);
-
- $o .= replace_macros(get_markup_template('webpage_import.tpl'), array(
- '$title' => t('Import Webpage Elements'),
- ));
-
- return $o;
-
+ $_SESSION['action'] = 'import';
} else {
notice( t('No webpage 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');
+ $_SESSION['action'] = null;
}
}
@@ -303,8 +311,69 @@ class Webpages extends \Zotlabs\Web\Controller {
}
break;
- case 'import':
- break;
+
+ case 'importselected':
+ require_once('include/import.php');
+ $channel = \App::get_channel();
+
+ // Import layout first so that pages that reference new layouts will find
+ // the mid of layout items in the database
+
+ // Obtain the user-selected layouts to import and import them
+ $checkedlayouts = $_POST['layout'];
+ $layouts = [];
+ if (!empty($checkedlayouts)) {
+ foreach ($checkedlayouts as $name) {
+ foreach ($_SESSION['layouts'] as &$layout) {
+ if ($layout['name'] === $name) {
+ $layout['import'] = 1;
+ $layoutstoimport[] = $layout;
+ }
+ }
+ }
+ foreach ($layoutstoimport as $elementtoimport) {
+ $layouts[] = import_webpage_element($elementtoimport, $channel, 'layout');
+ }
+ }
+ $_SESSION['import_layouts'] = $layouts;
+
+ // Obtain the user-selected blocks to import and import them
+ $checkedblocks = $_POST['block'];
+ $blocks = [];
+ if (!empty($checkedblocks)) {
+ foreach ($checkedblocks as $name) {
+ foreach ($_SESSION['blocks'] as &$block) {
+ if ($block['name'] === $name) {
+ $block['import'] = 1;
+ $blockstoimport[] = $block;
+ }
+ }
+ }
+ foreach ($blockstoimport as $elementtoimport) {
+ $blocks[] = import_webpage_element($elementtoimport, $channel, 'block');
+ }
+ }
+ $_SESSION['import_blocks'] = $blocks;
+
+ // Obtain the user-selected pages to import and import them
+ $checkedpages = $_POST['page'];
+ $pages = [];
+ if (!empty($checkedpages)) {
+ foreach ($checkedpages as $pagelink) {
+ foreach ($_SESSION['pages'] as &$page) {
+ if ($page['pagelink'] === $pagelink) {
+ $page['import'] = 1;
+ $pagestoimport[] = $page;
+ }
+ }
+ }
+ foreach ($pagestoimport as $elementtoimport) {
+ $pages[] = import_webpage_element($elementtoimport, $channel, 'page');
+ }
+ }
+ $_SESSION['import_pages'] = $pages;
+ break;
+
default :
break;
}