From 32366284a8372a4d5c7798b3ee3b238a614915ab Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Sat, 30 Jul 2016 09:56:47 -0400 Subject: Import element selection page added to allow selective importing. --- Zotlabs/Module/Webpages.php | 113 ++++++++++++++++++++------ view/css/mod_webpages.css | 85 ++++++++++++++++++++ view/js/mod_webpages.js | 15 ++++ view/tpl/webpage_import.tpl | 188 +++++++++++++++++++++++++++----------------- 4 files changed, 307 insertions(+), 94 deletions(-) create mode 100644 view/js/mod_webpages.js 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; } diff --git a/view/css/mod_webpages.css b/view/css/mod_webpages.css index 1c6ec4aea..f72f632dd 100644 --- a/view/css/mod_webpages.css +++ b/view/css/mod_webpages.css @@ -34,3 +34,88 @@ .webpage-list-tool { padding: 7px 10px; } + +.webpage-import-button { + background-color: green; + color: white; +} + +.webpage-import-button:hover { + background-color: darkgreen; +} + + +/* SQUARED TWO */ +.squaredTwo { + width: 28px; + height: 28px; + 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: 20px 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; +} + +.squaredTwo label { + cursor: pointer; + position: absolute; + width: 20px; + height: 20px; + left: 4px; + top: 4px; + + -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 ); +} + +.squaredTwo 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: 4px; + left: 4px; + 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); +} + +.squaredTwo label:hover::after { + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)"; + filter: alpha(opacity=30); + opacity: 0.3; +} + +.squaredTwo input[type=checkbox]:checked + label:after { + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; + filter: alpha(opacity=100); + opacity: 1; +} + diff --git a/view/js/mod_webpages.js b/view/js/mod_webpages.js new file mode 100644 index 000000000..7cfe297e1 --- /dev/null +++ b/view/js/mod_webpages.js @@ -0,0 +1,15 @@ +$(document).ready(function() { + $("input[type=\"checkbox\"]").hide(); +}); + +window.isChecked = true; + +function checkedAll(isChecked) { + window.isChecked = !window.isChecked ; + var c = document.getElementsByTagName('input'); + for (var i = 0; i < c.length; i++){ + if (c[i].type == 'checkbox'){ + c[i].checked = isChecked; + } + } +} \ No newline at end of file diff --git a/view/tpl/webpage_import.tpl b/view/tpl/webpage_import.tpl index 524460408..b047ee6f9 100644 --- a/view/tpl/webpage_import.tpl +++ b/view/tpl/webpage_import.tpl @@ -1,76 +1,120 @@
-
- {{if $editor}} -
- +
+ +
+
+ +
+

{{$title}}

+
+
+
+
+ +
+
+

Scanned Pages

+
+ + + {{foreach $pages as $page}} + + + + + + {{/foreach}} +
Import?PageExisting Page
+
+ + +
+
+
+ Page Link: {{$page.pagelink}}
+ Layout: {{$page.layout}}
+ Title: {{$page.title}}
+ Content File: {{$page.contentfile}}
+ Type: {{$page.type}}
+
+
+
+ Name: {{$page.curpage.pagelink}}
+ Layout: {{$page.curpage.layout}}
+ Title: {{$page.curpage.title}}
+ Last edit: {{$page.curpage.edited}}
+ Type: {{$page.curpage.type}}
+
+
+
+ + +

Scanned Layouts

+
+ + + {{foreach $layouts as $layout}} + + + + + + {{/foreach}} +
Import?LayoutExisting Layout
+
+ + +
+
+
+ Name: {{$layout.name}}
+ Description: {{$layout.description}}
+ Content File: {{$layout.contentfile}}
+
+
+
+ Name: {{$layout.curblock.name}}
+ Title: {{$layout.curblock.description}}
+ Last edit: {{$layout.curblock.edited}}
+
+
+
+ +

Scanned Blocks

+
+ + + {{foreach $blocks as $block}} + + + + + + {{/foreach}} +
Import?BlockExisting Block
+
+ + +
+
+
+ Name: {{$block.name}}
+ Title: {{$block.title}}
+ Content File: {{$block.contentfile}}
+ Type: {{$block.type}}
+
+
+
+ Name: {{$block.curblock.name}}
+ Title: {{$block.curblock.title}}
+ Last edit: {{$block.curblock.edited}}
+ Type: {{$block.curblock.type}}
+
+
+
+
- {{/if}} -

{{$listtitle}}

-
- {{if $editor}} -
- {{$editor}} -
- {{/if}} - {{if $pages}} -
- - - - - - - - - - - - {{foreach $pages as $key => $items}} - {{foreach $items as $item}} - - - - - - - - - - - {{/foreach}} - {{/foreach}} -
{{$pagelink_txt}}{{$title_txt}}
- {{if $view}} - {{$item.pagetitle}} - {{else}} - {{$item.pagetitle}} - {{/if}} - - {{$item.title}} - - {{if $edit}} - - {{/if}} - - {{if $item.bb_element}} - - {{/if}} - - {{if $edit}} - - {{/if}} -
-
- {{/if}} -
+
+ -- cgit v1.2.3