aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Manning <tamanning@zoho.com>2016-07-30 09:56:47 -0400
committerAndrew Manning <tamanning@zoho.com>2016-07-30 09:56:47 -0400
commit32366284a8372a4d5c7798b3ee3b238a614915ab (patch)
tree5f777a13eb7e9d1db7a2471321b3851e246940f8
parentf17f51a9c1f62dc0229e2428cacea4e84313560e (diff)
downloadvolse-hubzilla-32366284a8372a4d5c7798b3ee3b238a614915ab.tar.gz
volse-hubzilla-32366284a8372a4d5c7798b3ee3b238a614915ab.tar.bz2
volse-hubzilla-32366284a8372a4d5c7798b3ee3b238a614915ab.zip
Import element selection page added to allow selective importing.
-rw-r--r--Zotlabs/Module/Webpages.php113
-rw-r--r--view/css/mod_webpages.css85
-rw-r--r--view/js/mod_webpages.js15
-rw-r--r--view/tpl/webpage_import.tpl188
4 files changed, 307 insertions, 94 deletions
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 @@
<div class="generic-content-wrapper">
- <div class="section-title-wrapper">
- {{if $editor}}
- <div class="pull-right">
- <button id="webpage-create-btn" class="btn btn-xs btn-success" onclick="openClose('webpage-editor');"><i class="fa fa-pencil-square-o"></i>&nbsp;{{$create}}</button>
+ <form action="" method="post" autocomplete="on" >
+ <input type="hidden" name="action" value="importselected">
+ <div class="section-title-wrapper">
+ <div class="pull-right">
+ <input class="webpage-import-button" type="submit" name="submit" value="Import selected"/>
+ </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>
+ <h4>Scanned Pages</h4>
+ <div>
+ <table class="table-striped table-responsive table-hover" style="width: 100%;">
+ <tr><td>Import?</td><td>Page</td><td>Existing Page</td></tr>
+ {{foreach $pages as $page}}
+ <tr>
+ <td>
+ <div class='squaredTwo'>
+ <input type="checkbox" id="page_{{$page.pagelink}}" name="page[]" value="{{$page.pagelink}}">
+ <label for="page_{{$page.pagelink}}"></label>
+ </div>
+ </td>
+ <td>
+ <div class='desc'>
+ Page Link: {{$page.pagelink}}<br>
+ Layout: {{$page.layout}}<br>
+ Title: {{$page.title}}<br>
+ Content File: {{$page.contentfile}}<br>
+ Type: {{$page.type}}<br>
+ </div>
+ </td>
+ <td>
+ <div class='desc'>
+ Name: {{$page.curpage.pagelink}}<br>
+ Layout: {{$page.curpage.layout}}<br>
+ Title: {{$page.curpage.title}}<br>
+ Last edit: {{$page.curpage.edited}}<br>
+ Type: {{$page.curpage.type}}<br>
+ </div>
+ </td>
+ </tr>
+ {{/foreach}}
+ </table>
+ </div>
+
+
+ <h4>Scanned Layouts</h4>
+ <div>
+ <table class="table-striped table-responsive table-hover" style="width: 100%;">
+ <tr><td>Import?</td><td>Layout</td><td>Existing Layout</td></tr>
+ {{foreach $layouts as $layout}}
+ <tr>
+ <td>
+ <div class='squaredTwo'>
+ <input type="checkbox" id="layout_{{$layout.name}}" name="layout[]" value="{{$layout.name}}">
+ <label for="layout_{{$layout.name}}"></label>
+ </div>
+ </td>
+ <td>
+ <div class='desc'>
+ Name: {{$layout.name}}<br>
+ Description: {{$layout.description}}<br>
+ Content File: {{$layout.contentfile}}<br>
+ </div>
+ </td>
+ <td>
+ <div class='desc'>
+ Name: {{$layout.curblock.name}}<br>
+ Title: {{$layout.curblock.description}}<br>
+ Last edit: {{$layout.curblock.edited}}<br>
+ </div>
+ </td>
+ </tr>
+ {{/foreach}}
+ </table>
+ </div>
+
+ <h4>Scanned Blocks</h4>
+ <div>
+ <table class="table-striped table-responsive table-hover" style="width: 100%;">
+ <tr><td>Import?</td><td>Block</td><td>Existing Block</td></tr>
+ {{foreach $blocks as $block}}
+ <tr>
+ <td>
+ <div class='squaredTwo'>
+ <input type="checkbox" id="block_{{$block.name}}" name="block[]" value="{{$block.name}}">
+ <label for="block_{{$block.name}}"></label>
+ </div>
+ </td>
+ <td>
+ <div class='desc'>
+ Name: {{$block.name}}<br>
+ Title: {{$block.title}}<br>
+ Content File: {{$block.contentfile}}<br>
+ Type: {{$block.type}}<br>
+ </div>
+ </td>
+ <td>
+ <div class='desc'>
+ Name: {{$block.curblock.name}}<br>
+ Title: {{$block.curblock.title}}<br>
+ Last edit: {{$block.curblock.edited}}<br>
+ Type: {{$block.curblock.type}}<br>
+ </div>
+ </td>
+ </tr>
+ {{/foreach}}
+ </table>
+ </div>
+
</div>
- {{/if}}
- <h2>{{$listtitle}}</h2>
<div class="clear"></div>
- </div>
- {{if $editor}}
- <div id="webpage-editor" class="section-content-tools-wrapper">
- {{$editor}}
- </div>
- {{/if}}
- {{if $pages}}
- <div id="pagelist-content-wrapper" class="section-content-wrapper-np">
- <table id="webpage-list-table">
- <tr>
- <th width="1%">{{$pagelink_txt}}</th>
- <th width="95%">{{$title_txt}}</th>
- <th width="1%"></th>
- <th width="1%"></th>
- <th width="1%"></th>
- <th width="1%"></th>
- <th width="1%" class="hidden-xs">{{$created_txt}}</th>
- <th width="1%" class="hidden-xs">{{$edited_txt}}</th>
- </tr>
- {{foreach $pages as $key => $items}}
- {{foreach $items as $item}}
- <tr id="webpage-list-item-{{$item.url}}">
- <td>
- {{if $view}}
- <a href="page/{{$channel}}/{{$item.pagetitle}}" title="{{$view}}">{{$item.pagetitle}}</a>
- {{else}}
- {{$item.pagetitle}}
- {{/if}}
- </td>
- <td>
- {{$item.title}}
- </td>
- <td class="webpage-list-tool dropdown">
- {{if $item.lockstate=='lock'}}
- <i class="fa fa-lock dropdown-toggle lockview" data-toggle="dropdown" onclick="lockview('item',{{$item.url}});" ></i>
- <ul id="panel-{{$item.url}}" class="lockview-panel dropdown-menu"></ul>
- {{/if}}
- </td>
- <td class="webpage-list-tool">
- {{if $edit}}
- <a href="{{$baseurl}}/{{$item.url}}" title="{{$edit}}"><i class="fa fa-pencil"></i></a>
- {{/if}}
- </td>
- <td class="webpage-list-tool">
- {{if $item.bb_element}}
- <a href="rpost?attachment={{$item.bb_element}}" title="{{$share}}"><i class="fa fa-share-square-o"></i></a>
- {{/if}}
- </td>
- <td class="webpage-list-tool">
- {{if $edit}}
- <a href="#" title="{{$delete}}" onclick="dropItem('item/drop/{{$item.url}}', '#webpage-list-item-{{$item.url}}'); return false;"><i class="fa fa-trash-o drop-icons"></i></a>
- {{/if}}
- </td>
- <td class="hidden-xs">
- {{$item.created}}
- </td>
- <td class="hidden-xs">
- {{$item.edited}}
- </td>
- </tr>
- {{/foreach}}
- {{/foreach}}
- </table>
- </div>
- {{/if}}
- <div class="clear"></div>
+ </form>
</div>
+