Progress implementing zip file export

This commit is contained in:
Andrew Manning 2016-08-17 21:25:50 -04:00
parent c98b91f514
commit f2e87a204d
7 changed files with 80 additions and 64 deletions

View File

@ -62,6 +62,16 @@ class Webpages extends \Zotlabs\Web\Controller {
case 'importselected': case 'importselected':
$_SESSION['action'] = null; $_SESSION['action'] = null;
break; break;
case 'export_select_list':
$_SESSION['action'] = null;
$o .= replace_macros(get_markup_template('webpage_export_list.tpl'), array(
'$title' => t('Export Webpage Elements'),
'$exportbtn' => t('Export selected'),
'$action' => $_SESSION['export'], // value should be 'zipfile' or 'cloud'
));
$_SESSION['export'] = null;
return $o;
default : default :
$_SESSION['action'] = null; $_SESSION['action'] = null;
break; break;
@ -233,7 +243,7 @@ class Webpages extends \Zotlabs\Web\Controller {
} }
function post() { function post() {
logger(json_encode($_REQUEST), LOGGER_DEBUG);
$action = $_REQUEST['action']; $action = $_REQUEST['action'];
if( $action ){ if( $action ){
switch ($action) { switch ($action) {
@ -383,6 +393,18 @@ class Webpages extends \Zotlabs\Web\Controller {
} }
break; break;
case 'exportzipfile':
if(isset($_POST['w_download'])) {
logger($_POST['w_download'], LOGGER_DEBUG);
$_SESSION['action'] = 'export_select_list';
$_SESSION['export'] = 'zipfile';
if(isset($_POST['filename'])) {
$filename = filter_var($_POST['filename'], 'FILTER_SANITIZE_ENCODED');
} else {
$filename = 'website.zip';
}
}
default : default :
break; break;
} }

View File

@ -2267,11 +2267,11 @@ function design_tools() {
} }
/** /**
* @brief Creates website import tools menu * @brief Creates website portation tools menu
* *
* @return string * @return string
*/ */
function website_import_tools() { function website_portation_tools() {
$channel = App::get_channel(); $channel = App::get_channel();
$sys = false; $sys = false;
@ -2282,7 +2282,7 @@ function website_import_tools() {
$sys = true; $sys = true;
} }
return replace_macros(get_markup_template('website_import_tools.tpl'), array( return replace_macros(get_markup_template('website_portation_tools.tpl'), array(
'$title' => t('Import'), '$title' => t('Import'),
'$import_label' => t('Import website...'), '$import_label' => t('Import website...'),
'$import_placeholder' => t('Select folder to import'), '$import_placeholder' => t('Select folder to import'),
@ -2291,28 +2291,10 @@ function website_import_tools() {
'$desc' => t('/cloud/channel/path/to/folder'), '$desc' => t('/cloud/channel/path/to/folder'),
'$hint' => t('Enter path to website files'), '$hint' => t('Enter path to website files'),
'$select' => t('Select folder'), '$select' => t('Select folder'),
));
}
/**
* @brief Creates website export tools menu
*
* @return string
*/
function website_export_tools() {
$channel = App::get_channel();
$sys = false;
if(App::$is_sys && is_site_admin()) {
require_once('include/channel.php');
$channel = get_sys_channel();
$sys = true;
}
return replace_macros(get_markup_template('website_export_tools.tpl'), array(
'$title' => t('Export'),
'$export_label' => t('Export website...'), '$export_label' => t('Export website...'),
'$file_download_text' => t('Export to a zip file'),
'$filename_desc' => t('website.zip'),
'$filename_hint' => t('Enter a name for the zip file.'),
)); ));
} }

View File

@ -779,7 +779,7 @@ function widget_design_tools($arr) {
return design_tools(); return design_tools();
} }
function widget_website_import_tools($arr) { function widget_website_portation_tools($arr) {
// mod menu doesn't load a profile. For any modules which load a profile, check it. // mod menu doesn't load a profile. For any modules which load a profile, check it.
// otherwise local_channel() is sufficient for permissions. // otherwise local_channel() is sufficient for permissions.
@ -791,22 +791,7 @@ function widget_website_import_tools($arr) {
if(! local_channel()) if(! local_channel())
return ''; return '';
return website_import_tools(); return website_portation_tools();
}
function widget_website_export_tools($arr) {
// mod menu doesn't load a profile. For any modules which load a profile, check it.
// otherwise local_channel() is sufficient for permissions.
if(App::$profile['profile_uid'])
if((App::$profile['profile_uid'] != local_channel()) && (! App::$is_sys))
return '';
if(! local_channel())
return '';
return website_export_tools();
} }
function widget_findpeople($arr) { function widget_findpeople($arr) {

View File

@ -1,5 +1,4 @@
[region=aside] [region=aside]
[widget=design_tools][/widget] [widget=design_tools][/widget]
[widget=website_import_tools][/widget] [widget=website_portation_tools][/widget]
[widget=website_export_tools][/widget]
[/region] [/region]

View File

@ -0,0 +1,21 @@
<div class="generic-content-wrapper">
<form action="" method="post" autocomplete="on" >
<input type="hidden" name="action" value="{{$action}}">
<div class="section-title-wrapper">
<div class="pull-right">
<button class="btn btn-md btn-success" type="submit" name="submit" value="{{$exportbtn}}">{{$exportbtn}}</button>
</div>
<h2>{{$title}}</h2>
<div class="clear"></div>
</div>
<div id="import-website-content-wrapper" class="section-content-wrapper">
<div class="pull-left">
<button id="toggle-select-all" class="btn btn-xs btn-primary" onclick="checkedAll(window.isChecked); return false;"><i class="fa fa-check"></i>&nbsp;Toggle Select All</button>
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
</form>
</div>

View File

@ -1,14 +0,0 @@
<div id="website-export-tools" class="widget">
<h3>{{$title}}</h3>
<ul class="nav nav-pills nav-stacked">
<li>
<a href="#" onclick="openClose('export-form');
return false;"><i class="fa fa-cloud-upload generic-icons"></i> {{$export_label}}</a>
</li>
<li>
<form id="export-form" enctype="multipart/form-data" method="post" action="" style="display: none;" class="sub-menu">
</form>
</li>
</ul>
</div>

View File

@ -1,16 +1,15 @@
<div id="website-import-tools" class="widget"> <div id="website-portation-tools" class="widget">
<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'); <a href="#" onclick="openClose('import-form');
return false;"><i class="fa fa-cloud-upload generic-icons"></i> {{$import_label}}</a> return false;"><i class="fa fa-cloud-upload generic-icons"></i> {{$import_label}}</a>
</li> </li>
<li> <li style="margin-left: 12px;" >
<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 style="margin-top: 20px;" class="descriptive-text">{{$file_import_text}}</p> <p style="margin-top: 10px;" 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}}" />
@ -34,4 +33,26 @@
</form> </form>
</li> </li>
</ul> </ul>
<ul class="nav nav-pills nav-stacked">
<li>
<a href="#" onclick="openClose('export-form');
return false;"><i class="fa fa-share-square-o generic-icons"></i> {{$export_label}}</a>
</li>
<li style="margin-left: 12px;" >
<form id="export-form" enctype="multipart/form-data" method="post" action="" style="display: none;" class="sub-menu">
<input type="hidden" name="action" value="exportzipfile">
<!-- Or download a zipped file containing the website -->
<p style="margin-top: 10px;" class="descriptive-text">{{$file_download_text}}</p>
<div class="form-group">
<div class="input-group">
<input class="widget-input" type="text" name="filename" title="{{$filename_hint}}" placeholder="{{$filename_desc}}" />
<div class="input-group-btn">
<button class="btn btn-default btn-sm" type="submit" name="w_download" value="w_download"><i class="fa fa-download generic-icons"></i></button>
</div>
</div>
</div>
</form>
</li>
</ul>
</div> </div>