Improved UI. Removed logger statements.

This commit is contained in:
Andrew Manning 2016-07-31 07:30:25 -04:00
parent 32366284a8
commit 7c47557554
5 changed files with 58 additions and 45 deletions

View File

@ -51,12 +51,12 @@ class Webpages extends \Zotlabs\Web\Controller {
$_SESSION['action'] = null; $_SESSION['action'] = null;
$o .= replace_macros(get_markup_template('webpage_import.tpl'), array( $o .= replace_macros(get_markup_template('webpage_import.tpl'), array(
'$title' => t('Import Webpage Elements'), '$title' => t('Import Webpage Elements'),
'$importbtn' => t('Import selected'),
'$action' => 'import', '$action' => 'import',
'$pages' => $_SESSION['pages'], '$pages' => $_SESSION['pages'],
'$layouts' => $_SESSION['layouts'], '$layouts' => $_SESSION['layouts'],
'$blocks' => $_SESSION['blocks'], '$blocks' => $_SESSION['blocks'],
)); ));
//logger('webpage_import.tpl: ' . $o);
return $o; return $o;
case 'importselected': case 'importselected':
@ -254,7 +254,8 @@ class Webpages extends \Zotlabs\Web\Controller {
} }
} }
if(!$okay) { if(!$okay) {
json_return_and_die(array('message' => 'Invalid file MIME type')); notice( t('Invalid file type.') . EOL);
return;
} }
$zip = new \ZipArchive(); $zip = new \ZipArchive();
if ($zip->open($source) === true) { 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->extractTo($website); // change this to the correct site path
$zip->close(); $zip->close();
@unlink($source); // delete the compressed file now that the content has been extracted @unlink($source); // delete the compressed file now that the content has been extracted
$cloud = false; $cloud = false;
} else { } else {
notice( t('Error opening zip file') . EOL); notice( t('Error opening zip file') . EOL);
@ -289,14 +289,19 @@ class Webpages extends \Zotlabs\Web\Controller {
if ($cloud !== null) { if ($cloud !== null) {
require_once('include/import.php'); require_once('include/import.php');
$elements = []; $elements = [];
$elements['pages'] = scan_webpage_elements($_POST['path'], 'page', $cloud); if($cloud) {
$elements['layouts'] = scan_webpage_elements($_POST['path'], 'layout', $cloud); $path = $_POST['path'];
$elements['blocks'] = scan_webpage_elements($_POST['path'], 'block', $cloud); } 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['blocks'] = $elements['blocks'];
$_SESSION['layouts'] = $elements['layouts']; $_SESSION['layouts'] = $elements['layouts'];
$_SESSION['pages'] = $elements['pages']; $_SESSION['pages'] = $elements['pages'];
if(!(empty($elements['pages']) && empty($elements['blocks']) && empty($elements['layouts']))) { 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'; $_SESSION['action'] = 'import';
} else { } else {
notice( t('No webpage elements detected.') . EOL); 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 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 rrmdir($website); // Delete the temporary decompressed files
} }
@ -372,6 +377,9 @@ class Webpages extends \Zotlabs\Web\Controller {
} }
} }
$_SESSION['import_pages'] = $pages; $_SESSION['import_pages'] = $pages;
if(!(empty($_SESSION['import_pages']) && empty($_SESSION['import_blocks']) && empty($_SESSION['import_layouts']))) {
info( t('Import complete.') . EOL);
}
break; break;
default : default :

View File

@ -1252,15 +1252,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 :

View File

@ -2258,17 +2258,14 @@ function website_import_tools() {
$sys = true; $sys = true;
} }
$who = $channel['channel_address'];
return replace_macros(get_markup_template('website_import_tools.tpl'), array( return replace_macros(get_markup_template('website_import_tools.tpl'), array(
'$title' => t('Import'), '$title' => t('Import'),
//'$who' => $who,
'$import_label' => t('Import website...'), '$import_label' => t('Import website...'),
'$import_placeholder' => t('Select folder to import'), '$import_placeholder' => t('Select folder to import'),
'$file_upload_text' => t('Import from a zipped folder:'), '$file_upload_text' => t('Import from a zipped folder:'),
'$file_import_text' => t('Import from cloud files:'), '$file_import_text' => t('Import from cloud files:'),
'$desc' => t('/path/to/folder'), '$desc' => t('/cloud/channel/path/to/folder'),
'$hint' => t('/path/to/folder'), '$hint' => t('Enter path to website files'),
'$select' => t('Select folder'), '$select' => t('Select folder'),
)); ));
} }

View File

@ -3,7 +3,7 @@
<input type="hidden" name="action" value="importselected"> <input type="hidden" name="action" value="importselected">
<div class="section-title-wrapper"> <div class="section-title-wrapper">
<div class="pull-right"> <div class="pull-right">
<input class="webpage-import-button" type="submit" name="submit" value="Import selected"/> <button class="btn btn-md btn-success" type="submit" name="submit" value="{{$importbtn}}">{{$importbtn}}</button>
</div> </div>
<h2>{{$title}}</h2> <h2>{{$title}}</h2>
<div class="clear"></div> <div class="clear"></div>

View File

@ -2,13 +2,15 @@
<h3>{{$title}}</h3> <h3>{{$title}}</h3>
<ul class="nav nav-pills nav-stacked"> <ul class="nav nav-pills nav-stacked">
<li> <li>
<a href="#" onclick="openClose('import-form'); return false;"><i class="fa fa-cloud-upload generic-icons"></i> {{$import_label}}</a> <a href="#" onclick="openClose('import-form');
return false;"><i class="fa fa-cloud-upload generic-icons"></i> {{$import_label}}</a>
</li> </li>
<li>
<form id="import-form" enctype="multipart/form-data" method="post" action="" style="display: none;" class="sub-menu"> <form id="import-form" enctype="multipart/form-data" method="post" action="" style="display: none;" class="sub-menu">
<input type="hidden" name="action" value="scan"> <input type="hidden" name="action" value="scan">
<p class="descriptive-text">{{$file_import_text}}</p> <p style="margin-top: 20px;" class="descriptive-text">{{$file_import_text}}</p>
<div class="form-group"> <div class="form-group">
<div class="input-group"> <div class="input-group">
<input class="widget-input" type="text" name="path" title="{{$hint}}" placeholder="{{$desc}}" /> <input class="widget-input" type="text" name="path" title="{{$hint}}" placeholder="{{$desc}}" />
@ -21,9 +23,15 @@
<!-- Or upload a zipped file containing the website --> <!-- Or upload a zipped file containing the website -->
<p class="descriptive-text">{{$file_upload_text}}</p> <p class="descriptive-text">{{$file_upload_text}}</p>
<div class="form-group"> <div class="form-group">
<input id="website-upload-choose" type="file" name="zip_file" />
<div class="input-group">
<input class="widget-input" type="file" name="zip_file" />
<div class="input-group-btn">
<button class="btn btn-default btn-sm" type="submit" name="w_upload" value="w_upload"><i class="fa fa-file-archive-o generic-icons"></i></button>
</div>
</div>
</div> </div>
<button class="btn btn-primary btn-sm" type="submit" name="w_upload" value="w_upload">Upload</button>
</form> </form>
</li>
</ul> </ul>
</div> </div>