From 7c475575549161d465189fa5e726739f4a4ac76c Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Sun, 31 Jul 2016 07:30:25 -0400 Subject: Improved UI. Removed logger statements. --- Zotlabs/Module/Webpages.php | 26 ++++++++++------ include/import.php | 6 ++-- include/text.php | 7 ++--- view/tpl/webpage_import.tpl | 2 +- view/tpl/website_import_tools.tpl | 62 ++++++++++++++++++++++----------------- 5 files changed, 58 insertions(+), 45 deletions(-) diff --git a/Zotlabs/Module/Webpages.php b/Zotlabs/Module/Webpages.php index ee9633243..d3199f223 100644 --- a/Zotlabs/Module/Webpages.php +++ b/Zotlabs/Module/Webpages.php @@ -51,12 +51,12 @@ class Webpages extends \Zotlabs\Web\Controller { $_SESSION['action'] = null; $o .= replace_macros(get_markup_template('webpage_import.tpl'), array( '$title' => t('Import Webpage Elements'), + '$importbtn' => t('Import selected'), '$action' => 'import', '$pages' => $_SESSION['pages'], '$layouts' => $_SESSION['layouts'], '$blocks' => $_SESSION['blocks'], )); - //logger('webpage_import.tpl: ' . $o); return $o; case 'importselected': @@ -254,7 +254,8 @@ class Webpages extends \Zotlabs\Web\Controller { } } if(!$okay) { - json_return_and_die(array('message' => 'Invalid file MIME type')); + notice( t('Invalid file type.') . EOL); + return; } $zip = new \ZipArchive(); if ($zip->open($source) === true) { @@ -263,7 +264,6 @@ class Webpages extends \Zotlabs\Web\Controller { $zip->extractTo($website); // change this to the correct site path $zip->close(); @unlink($source); // delete the compressed file now that the content has been extracted - $cloud = false; } else { notice( t('Error opening zip file') . EOL); @@ -289,14 +289,19 @@ class Webpages extends \Zotlabs\Web\Controller { if ($cloud !== null) { require_once('include/import.php'); $elements = []; - $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); + if($cloud) { + $path = $_POST['path']; + } else { + $path = $website; + } + $elements['pages'] = scan_webpage_elements($path, 'page', $cloud); + $elements['layouts'] = scan_webpage_elements($path, 'layout', $cloud); + $elements['blocks'] = scan_webpage_elements($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); + //info( t('Webpages elements detected.') . EOL); $_SESSION['action'] = 'import'; } else { notice( t('No webpage elements detected.') . EOL); @@ -306,7 +311,7 @@ class Webpages extends \Zotlabs\Web\Controller { } // If the website elements were imported from a zip file, delete the temporary decompressed files - if ($cloud === false && $website) { + if ($cloud === false && $website && $elements) { rrmdir($website); // Delete the temporary decompressed files } @@ -372,7 +377,10 @@ class Webpages extends \Zotlabs\Web\Controller { } } $_SESSION['import_pages'] = $pages; - break; + if(!(empty($_SESSION['import_pages']) && empty($_SESSION['import_blocks']) && empty($_SESSION['import_layouts']))) { + info( t('Import complete.') . EOL); + } + break; default : break; diff --git a/include/import.php b/include/import.php index c69f2eadd..0b2cd38df 100644 --- a/include/import.php +++ b/include/import.php @@ -1252,15 +1252,15 @@ function scan_webpage_elements($path, $type, $cloud = false) { $dirtoscan = $path; switch ($type) { case 'page': - $dirtoscan .= 'pages/'; + $dirtoscan .= '/pages/'; $json_filename = 'page.json'; break; case 'layout': - $dirtoscan .= 'layouts/'; + $dirtoscan .= '/layouts/'; $json_filename = 'layout.json'; break; case 'block': - $dirtoscan .= 'blocks/'; + $dirtoscan .= '/blocks/'; $json_filename = 'block.json'; break; default : diff --git a/include/text.php b/include/text.php index f81155edb..d508f8ab3 100644 --- a/include/text.php +++ b/include/text.php @@ -2258,17 +2258,14 @@ function website_import_tools() { $sys = true; } - $who = $channel['channel_address']; - return replace_macros(get_markup_template('website_import_tools.tpl'), array( '$title' => t('Import'), - //'$who' => $who, '$import_label' => t('Import website...'), '$import_placeholder' => t('Select folder to import'), '$file_upload_text' => t('Import from a zipped folder:'), '$file_import_text' => t('Import from cloud files:'), - '$desc' => t('/path/to/folder'), - '$hint' => t('/path/to/folder'), + '$desc' => t('/cloud/channel/path/to/folder'), + '$hint' => t('Enter path to website files'), '$select' => t('Select folder'), )); } diff --git a/view/tpl/webpage_import.tpl b/view/tpl/webpage_import.tpl index b047ee6f9..255a41c2b 100644 --- a/view/tpl/webpage_import.tpl +++ b/view/tpl/webpage_import.tpl @@ -3,7 +3,7 @@
- +

{{$title}}

diff --git a/view/tpl/website_import_tools.tpl b/view/tpl/website_import_tools.tpl index 133d6268e..cb3e6b524 100644 --- a/view/tpl/website_import_tools.tpl +++ b/view/tpl/website_import_tools.tpl @@ -1,29 +1,37 @@
-

{{$title}}

- +

{{$title}}

+
-- cgit v1.2.3