diff options
-rw-r--r-- | Zotlabs/Module/Webpages.php | 34 | ||||
-rw-r--r-- | include/import.php | 62 | ||||
-rw-r--r-- | include/text.php | 12 | ||||
-rw-r--r-- | include/widgets.php | 4 | ||||
-rw-r--r-- | view/css/mod_webpages.css | 74 | ||||
-rw-r--r-- | view/pdl/mod_webpages.pdl | 2 | ||||
-rw-r--r-- | view/tpl/webpage_export_list.tpl | 51 | ||||
-rw-r--r-- | view/tpl/website_portation_tools.tpl (renamed from view/tpl/website_import_tools.tpl) | 29 |
8 files changed, 254 insertions, 14 deletions
diff --git a/Zotlabs/Module/Webpages.php b/Zotlabs/Module/Webpages.php index 0a48d43c6..b927f95df 100644 --- a/Zotlabs/Module/Webpages.php +++ b/Zotlabs/Module/Webpages.php @@ -41,7 +41,6 @@ class Webpages extends \Zotlabs\Web\Controller { $uid = local_channel(); $owner = 0; - $channel = null; $observer = \App::get_observer(); $channel = \App::get_channel(); @@ -62,6 +61,25 @@ class Webpages extends \Zotlabs\Web\Controller { case 'importselected': $_SESSION['action'] = null; break; + case 'export_select_list': + $_SESSION['action'] = null; + if(!$uid) { + $_SESSION['export'] = null; + break; + } + require_once('include/import.php'); + + $elements = get_webpage_elements($channel, 'pages'); + logger(json_encode($elements), LOGGER_DEBUG); + $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' + '$pages' => $elements['pages'], + )); + $_SESSION['export'] = null; + return $o; + default : $_SESSION['action'] = null; break; @@ -233,7 +251,6 @@ class Webpages extends \Zotlabs\Web\Controller { } function post() { - $action = $_REQUEST['action']; if( $action ){ switch ($action) { @@ -382,7 +399,18 @@ class Webpages extends \Zotlabs\Web\Controller { info( t('Import complete.') . EOL); } break; - + + case 'exportzipfile': + + if(isset($_POST['w_download'])) { + $_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 : break; } diff --git a/include/import.php b/include/import.php index 84881a420..f7df636f3 100644 --- a/include/import.php +++ b/include/import.php @@ -1472,3 +1472,65 @@ function scan_webpage_elements($path, $type, $cloud = false) { return $element; } + +function get_webpage_elements($channel, $type = 'all') { + $elements = array(); + if(!$channel['channel_id']) { + return null; + } + switch ($type) { + case 'pages': + $elements['pages'] = null; + $owner = $channel['channel_id']; + + $sql_extra = item_permissions_sql($owner); + + + $r = q("select * from iconfig left join item on iconfig.iid = item.id + where item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'WEBPAGE' and item_type = %d + $sql_extra order by item.created desc", + intval($owner), + intval(ITEM_TYPE_WEBPAGE) + ); + + $pages = null; + + if($r) { + $elements['pages'] = array(); + $pages = array(); + foreach($r as $rr) { + unobscure($rr); + + //$lockstate = (($rr['allow_cid'] || $rr['allow_gid'] || $rr['deny_cid'] || $rr['deny_gid']) ? 'lock' : 'unlock'); + + $element_arr = array( + 'type' => 'webpage', + 'title' => $rr['title'], + 'body' => $rr['body'], + 'created' => $rr['created'], + 'edited' => $rr['edited'], + 'mimetype' => $rr['mimetype'], + 'pagetitle' => $rr['v'], + 'mid' => $rr['mid'], + 'layout_mid' => $rr['layout_mid'] + ); + $pages[$rr['iid']][] = array( + 'url' => $rr['iid'], + 'pagetitle' => $rr['v'], + 'title' => $rr['title'], + 'created' => datetime_convert('UTC',date_default_timezone_get(),$rr['created']), + 'edited' => datetime_convert('UTC',date_default_timezone_get(),$rr['edited']), + 'bb_element' => '[element]' . base64url_encode(json_encode($element_arr)) . '[/element]', + //'lockstate' => $lockstate + ); + $elements['pages'][] = $element_arr; + } + + } + break; + + default: + return null; + } + return $elements; +}
\ No newline at end of file diff --git a/include/text.php b/include/text.php index a2a6d918b..1729048e9 100644 --- a/include/text.php +++ b/include/text.php @@ -2267,11 +2267,11 @@ function design_tools() { } /** - * @brief Creates website import tools menu + * @brief Creates website portation tools menu * * @return string */ -function website_import_tools() { +function website_portation_tools() { $channel = App::get_channel(); $sys = false; @@ -2282,7 +2282,7 @@ function website_import_tools() { $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'), '$import_label' => t('Import website...'), '$import_placeholder' => t('Select folder to import'), @@ -2290,7 +2290,11 @@ function website_import_tools() { '$file_import_text' => t('Import from cloud files:'), '$desc' => t('/cloud/channel/path/to/folder'), '$hint' => t('Enter path to website files'), - '$select' => t('Select folder'), + '$select' => t('Select folder'), + '$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.'), )); } diff --git a/include/widgets.php b/include/widgets.php index 68db74703..2f8416f8e 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -779,7 +779,7 @@ function widget_design_tools($arr) { 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. // otherwise local_channel() is sufficient for permissions. @@ -791,7 +791,7 @@ function widget_website_import_tools($arr) { if(! local_channel()) return ''; - return website_import_tools(); + return website_portation_tools(); } function widget_findpeople($arr) { diff --git a/view/css/mod_webpages.css b/view/css/mod_webpages.css index f72f632dd..805d95dc2 100644 --- a/view/css/mod_webpages.css +++ b/view/css/mod_webpages.css @@ -119,3 +119,77 @@ opacity: 1; } + +/* SQUARED THREE */ +.squaredThree { + width: 14px; + height: 14px; + background: #fcfff4; + + background: -webkit-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%); + background: -moz-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%); + background: -o-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%); + background: -ms-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%); + background: linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%); + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fcfff4', endColorstr='#b3bead',GradientType=0 ); + margin: 5px auto; + + -webkit-box-shadow: inset 0px 1px 1px white, 0px 1px 3px rgba(0,0,0,0.5); + -moz-box-shadow: inset 0px 1px 1px white, 0px 1px 3px rgba(0,0,0,0.5); + box-shadow: inset 0px 1px 1px white, 0px 1px 3px rgba(0,0,0,0.5); + position: relative; +} + +.squaredThree label { + cursor: pointer; + position: absolute; + width: 10px; + height: 10px; + left: 2px; + top: 2px; + + -webkit-box-shadow: inset 0px 1px 1px rgba(0,0,0,0.5), 0px 1px 0px rgba(255,255,255,1); + -moz-box-shadow: inset 0px 1px 1px rgba(0,0,0,0.5), 0px 1px 0px rgba(255,255,255,1); + box-shadow: inset 0px 1px 1px rgba(0,0,0,0.5), 0px 1px 0px rgba(255,255,255,1); + + background: -webkit-linear-gradient(top, #222 0%, #45484d 100%); + background: -moz-linear-gradient(top, #222 0%, #45484d 100%); + background: -o-linear-gradient(top, #222 0%, #45484d 100%); + background: -ms-linear-gradient(top, #222 0%, #45484d 100%); + background: linear-gradient(top, #222 0%, #45484d 100%); + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#222', endColorstr='#45484d',GradientType=0 ); +} + +.squaredThree label:after { + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; + filter: alpha(opacity=0); + opacity: 0; + content: ''; + position: absolute; + width: 9px; + height: 5px; + background: transparent; + top: 2px; + left: 2px; + border: 3px solid #fcfff4; + border-top: none; + border-right: none; + + -webkit-transform: rotate(-45deg); + -moz-transform: rotate(-45deg); + -o-transform: rotate(-45deg); + -ms-transform: rotate(-45deg); + transform: rotate(-45deg); +} + +.squaredThree label:hover::after { + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)"; + filter: alpha(opacity=30); + opacity: 0.3; +} + +.squaredThree input[type=checkbox]:checked + label:after { + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; + filter: alpha(opacity=100); + opacity: 1; +}
\ No newline at end of file diff --git a/view/pdl/mod_webpages.pdl b/view/pdl/mod_webpages.pdl index b62ec6e7c..9e4d604ba 100644 --- a/view/pdl/mod_webpages.pdl +++ b/view/pdl/mod_webpages.pdl @@ -1,4 +1,4 @@ [region=aside] [widget=design_tools][/widget] -[widget=website_import_tools][/widget] +[widget=website_portation_tools][/widget] [/region]
\ No newline at end of file diff --git a/view/tpl/webpage_export_list.tpl b/view/tpl/webpage_export_list.tpl new file mode 100644 index 000000000..1b943ace8 --- /dev/null +++ b/view/tpl/webpage_export_list.tpl @@ -0,0 +1,51 @@ +<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> Toggle Select All</button> + </div> + + <div class="clear"></div> + <h4>Pages</h4> + <div> + <table class="table-striped table-responsive table-hover" style="width: 100%;"> + <tr><td>Export?</td><td>Page Title</td><td>Page Link</td><td>Type</td></tr> + {{foreach $pages as $page}} + <tr> + <td> + <div class='squaredThree'> + <input type="checkbox" id="page_{{$page.mid}}" name="page[]" value="{{$page.mid}}"> + <label for="page_{{$page.mid}}"></label> + </div> + </td> + <td> + <div class='desc'> + {{$page.title}}<br> + </div> + </td> + <td> + <div class='desc'> + {{$page.pagetitle}}<br> + </div> + </td> + <td> + <div class='desc'> + {{$page.mimetype}}<br> + </div> + </td> + </tr> + {{/foreach}} + </table> + </div> + </div> + </form> +</div> + diff --git a/view/tpl/website_import_tools.tpl b/view/tpl/website_portation_tools.tpl index cb3e6b524..d9ebed179 100644 --- a/view/tpl/website_import_tools.tpl +++ b/view/tpl/website_portation_tools.tpl @@ -1,16 +1,15 @@ -<div id="website-import-tools" class="widget"> - <h3>{{$title}}</h3> +<div id="website-portation-tools" class="widget"> <ul class="nav nav-pills nav-stacked"> <li> <a href="#" onclick="openClose('import-form'); return false;"><i class="fa fa-cloud-upload generic-icons"></i> {{$import_label}}</a> </li> - <li> + <li style="margin-left: 12px;" > <form id="import-form" enctype="multipart/form-data" method="post" action="" style="display: none;" class="sub-menu"> <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="input-group"> <input class="widget-input" type="text" name="path" title="{{$hint}}" placeholder="{{$desc}}" /> @@ -34,4 +33,26 @@ </form> </li> </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> |