Reformatted Webpages.php to clean up whitespace, where there was a mixture of spaces and tabs for indentation. No other changes made.
This commit is contained in:
parent
635b8ff73a
commit
e99be61d49
@ -1,36 +1,34 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Zotlabs\Module;
|
namespace Zotlabs\Module;
|
||||||
|
|
||||||
require_once('include/channel.php');
|
require_once('include/channel.php');
|
||||||
require_once('include/conversation.php');
|
require_once('include/conversation.php');
|
||||||
require_once('include/acl_selectors.php');
|
require_once('include/acl_selectors.php');
|
||||||
|
|
||||||
|
|
||||||
class Webpages extends \Zotlabs\Web\Controller {
|
class Webpages extends \Zotlabs\Web\Controller {
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
if(argc() > 1 && argv(1) === 'sys' && is_site_admin()) {
|
if (argc() > 1 && argv(1) === 'sys' && is_site_admin()) {
|
||||||
$sys = get_sys_channel();
|
$sys = get_sys_channel();
|
||||||
if($sys && intval($sys['channel_id'])) {
|
if ($sys && intval($sys['channel_id'])) {
|
||||||
\App::$is_sys = true;
|
\App::$is_sys = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(argc() > 1)
|
if (argc() > 1)
|
||||||
$which = argv(1);
|
$which = argv(1);
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
profile_load($which);
|
profile_load($which);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function get() {
|
function get() {
|
||||||
|
|
||||||
if(! \App::$profile) {
|
if (!\App::$profile) {
|
||||||
notice( t('Requested profile is not available.') . EOL );
|
notice(t('Requested profile is not available.') . EOL);
|
||||||
\App::$error = 404;
|
\App::$error = 404;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -63,7 +61,7 @@ class Webpages extends \Zotlabs\Web\Controller {
|
|||||||
break;
|
break;
|
||||||
case 'export_select_list':
|
case 'export_select_list':
|
||||||
$_SESSION['action'] = null;
|
$_SESSION['action'] = null;
|
||||||
if(!$uid) {
|
if (!$uid) {
|
||||||
$_SESSION['export'] = null;
|
$_SESSION['export'] = null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -89,55 +87,53 @@ class Webpages extends \Zotlabs\Web\Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(\App::$is_sys && is_site_admin()) {
|
if (\App::$is_sys && is_site_admin()) {
|
||||||
$sys = get_sys_channel();
|
$sys = get_sys_channel();
|
||||||
if($sys && intval($sys['channel_id'])) {
|
if ($sys && intval($sys['channel_id'])) {
|
||||||
$uid = $owner = intval($sys['channel_id']);
|
$uid = $owner = intval($sys['channel_id']);
|
||||||
$channel = $sys;
|
$channel = $sys;
|
||||||
$observer = $sys;
|
$observer = $sys;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(! $owner) {
|
if (!$owner) {
|
||||||
// Figure out who the page owner is.
|
// Figure out who the page owner is.
|
||||||
$r = q("select channel_id from channel where channel_address = '%s'",
|
$r = q("select channel_id from channel where channel_address = '%s'", dbesc($which)
|
||||||
dbesc($which)
|
|
||||||
);
|
);
|
||||||
if($r) {
|
if ($r) {
|
||||||
$owner = intval($r[0]['channel_id']);
|
$owner = intval($r[0]['channel_id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$ob_hash = (($observer) ? $observer['xchan_hash'] : '');
|
$ob_hash = (($observer) ? $observer['xchan_hash'] : '');
|
||||||
|
|
||||||
$perms = get_all_perms($owner,$ob_hash);
|
$perms = get_all_perms($owner, $ob_hash);
|
||||||
|
|
||||||
if(! $perms['write_pages']) {
|
if (!$perms['write_pages']) {
|
||||||
notice( t('Permission denied.') . EOL);
|
notice(t('Permission denied.') . EOL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$mimetype = (($_REQUEST['mimetype']) ? $_REQUEST['mimetype'] : get_pconfig($owner,'system','page_mimetype'));
|
$mimetype = (($_REQUEST['mimetype']) ? $_REQUEST['mimetype'] : get_pconfig($owner, 'system', 'page_mimetype'));
|
||||||
|
|
||||||
$layout = (($_REQUEST['layout']) ? $_REQUEST['layout'] : get_pconfig($owner,'system','page_layout'));
|
$layout = (($_REQUEST['layout']) ? $_REQUEST['layout'] : get_pconfig($owner, 'system', 'page_layout'));
|
||||||
|
|
||||||
// Create a status editor (for now - we'll need a WYSIWYG eventually) to create pages
|
// Create a status editor (for now - we'll need a WYSIWYG eventually) to create pages
|
||||||
// Nickname is set to the observers xchan, and profile_uid to the owner's.
|
// Nickname is set to the observers xchan, and profile_uid to the owner's.
|
||||||
// This lets you post pages at other people's channels.
|
// This lets you post pages at other people's channels.
|
||||||
|
|
||||||
if((! $channel) && ($uid) && ($uid == \App::$profile_uid)) {
|
if ((!$channel) && ($uid) && ($uid == \App::$profile_uid)) {
|
||||||
$channel = \App::get_channel();
|
$channel = \App::get_channel();
|
||||||
}
|
}
|
||||||
if($channel) {
|
if ($channel) {
|
||||||
$channel_acl = array(
|
$channel_acl = array(
|
||||||
'allow_cid' => $channel['channel_allow_cid'],
|
'allow_cid' => $channel['channel_allow_cid'],
|
||||||
'allow_gid' => $channel['channel_allow_gid'],
|
'allow_gid' => $channel['channel_allow_gid'],
|
||||||
'deny_cid' => $channel['channel_deny_cid'],
|
'deny_cid' => $channel['channel_deny_cid'],
|
||||||
'deny_gid' => $channel['channel_deny_gid']
|
'deny_gid' => $channel['channel_deny_gid']
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
else {
|
$channel_acl = ['allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => ''];
|
||||||
$channel_acl = [ 'allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '' ];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -150,7 +146,7 @@ class Webpages extends \Zotlabs\Web\Controller {
|
|||||||
'is_owner' => true,
|
'is_owner' => true,
|
||||||
'nickname' => \App::$profile['channel_address'],
|
'nickname' => \App::$profile['channel_address'],
|
||||||
'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
|
'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
|
||||||
'acl' => (($is_owner) ? populate_acl($channel_acl,false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_pages')) : ''),
|
'acl' => (($is_owner) ? populate_acl($channel_acl, false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_pages')) : ''),
|
||||||
'permissions' => $channel_acl,
|
'permissions' => $channel_acl,
|
||||||
'showacl' => (($is_owner) ? true : false),
|
'showacl' => (($is_owner) ? true : false),
|
||||||
'visitor' => true,
|
'visitor' => true,
|
||||||
@ -162,16 +158,16 @@ class Webpages extends \Zotlabs\Web\Controller {
|
|||||||
'layout' => $layout,
|
'layout' => $layout,
|
||||||
'layoutselect' => true,
|
'layoutselect' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'novoting'=> true,
|
'novoting' => true,
|
||||||
'bbco_autocomplete' => 'bbcode',
|
'bbco_autocomplete' => 'bbcode',
|
||||||
'bbcode' => true
|
'bbcode' => true
|
||||||
);
|
);
|
||||||
|
|
||||||
if($_REQUEST['title'])
|
if ($_REQUEST['title'])
|
||||||
$x['title'] = $_REQUEST['title'];
|
$x['title'] = $_REQUEST['title'];
|
||||||
if($_REQUEST['body'])
|
if ($_REQUEST['body'])
|
||||||
$x['body'] = $_REQUEST['body'];
|
$x['body'] = $_REQUEST['body'];
|
||||||
if($_REQUEST['pagetitle'])
|
if ($_REQUEST['pagetitle'])
|
||||||
$x['pagetitle'] = $_REQUEST['pagetitle'];
|
$x['pagetitle'] = $_REQUEST['pagetitle'];
|
||||||
|
|
||||||
|
|
||||||
@ -180,15 +176,12 @@ class Webpages extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
|
|
||||||
/** @TODO - this should be replaced with pagelist_widget */
|
/** @TODO - this should be replaced with pagelist_widget */
|
||||||
|
|
||||||
$sql_extra = item_permissions_sql($owner);
|
$sql_extra = item_permissions_sql($owner);
|
||||||
|
|
||||||
|
|
||||||
$r = q("select * from iconfig left join item on iconfig.iid = item.id
|
$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
|
where item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'WEBPAGE' and item_type = %d
|
||||||
$sql_extra order by item.created desc",
|
$sql_extra order by item.created desc", intval($owner), intval(ITEM_TYPE_WEBPAGE)
|
||||||
intval($owner),
|
|
||||||
intval(ITEM_TYPE_WEBPAGE)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// $r = q("select * from item_id left join item on item_id.iid = item.id
|
// $r = q("select * from item_id left join item on item_id.iid = item.id
|
||||||
@ -197,16 +190,16 @@ class Webpages extends \Zotlabs\Web\Controller {
|
|||||||
// intval(ITEM_TYPE_WEBPAGE)
|
// intval(ITEM_TYPE_WEBPAGE)
|
||||||
// );
|
// );
|
||||||
|
|
||||||
if(! $r)
|
if (!$r)
|
||||||
$x['pagetitle'] = 'home';
|
$x['pagetitle'] = 'home';
|
||||||
|
|
||||||
$editor = status_editor($a,$x);
|
$editor = status_editor($a, $x);
|
||||||
|
|
||||||
$pages = null;
|
$pages = null;
|
||||||
|
|
||||||
if($r) {
|
if ($r) {
|
||||||
$pages = array();
|
$pages = array();
|
||||||
foreach($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
unobscure($rr);
|
unobscure($rr);
|
||||||
|
|
||||||
$lockstate = (($rr['allow_cid'] || $rr['allow_gid'] || $rr['deny_cid'] || $rr['deny_gid']) ? 'lock' : 'unlock');
|
$lockstate = (($rr['allow_cid'] || $rr['allow_gid'] || $rr['deny_cid'] || $rr['deny_gid']) ? 'lock' : 'unlock');
|
||||||
@ -226,8 +219,8 @@ class Webpages extends \Zotlabs\Web\Controller {
|
|||||||
'url' => $rr['iid'],
|
'url' => $rr['iid'],
|
||||||
'pagetitle' => $rr['v'],
|
'pagetitle' => $rr['v'],
|
||||||
'title' => $rr['title'],
|
'title' => $rr['title'],
|
||||||
'created' => datetime_convert('UTC',date_default_timezone_get(),$rr['created']),
|
'created' => datetime_convert('UTC', date_default_timezone_get(), $rr['created']),
|
||||||
'edited' => datetime_convert('UTC',date_default_timezone_get(),$rr['edited']),
|
'edited' => datetime_convert('UTC', date_default_timezone_get(), $rr['edited']),
|
||||||
'bb_element' => '[element]' . base64url_encode(json_encode($element_arr)) . '[/element]',
|
'bb_element' => '[element]' . base64url_encode(json_encode($element_arr)) . '[/element]',
|
||||||
'lockstate' => $lockstate
|
'lockstate' => $lockstate
|
||||||
);
|
);
|
||||||
@ -262,7 +255,7 @@ class Webpages extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
function post() {
|
function post() {
|
||||||
$action = $_REQUEST['action'];
|
$action = $_REQUEST['action'];
|
||||||
if( $action ){
|
if ($action) {
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'scan':
|
case 'scan':
|
||||||
|
|
||||||
@ -270,7 +263,7 @@ class Webpages extends \Zotlabs\Web\Controller {
|
|||||||
$cloud = null;
|
$cloud = null;
|
||||||
|
|
||||||
// Website files are to be imported from an uploaded zip file
|
// Website files are to be imported from an uploaded zip file
|
||||||
if(($_FILES) && array_key_exists('zip_file',$_FILES) && isset($_POST['w_upload'])) {
|
if (($_FILES) && array_key_exists('zip_file', $_FILES) && isset($_POST['w_upload'])) {
|
||||||
$source = $_FILES["zip_file"]["tmp_name"];
|
$source = $_FILES["zip_file"]["tmp_name"];
|
||||||
$type = $_FILES["zip_file"]["type"];
|
$type = $_FILES["zip_file"]["type"];
|
||||||
$okay = false;
|
$okay = false;
|
||||||
@ -281,8 +274,8 @@ class Webpages extends \Zotlabs\Web\Controller {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!$okay) {
|
if (!$okay) {
|
||||||
notice( t('Invalid file type.') . EOL);
|
notice(t('Invalid file type.') . EOL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$zip = new \ZipArchive();
|
$zip = new \ZipArchive();
|
||||||
@ -294,22 +287,21 @@ class Webpages extends \Zotlabs\Web\Controller {
|
|||||||
@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);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Website files are to be imported from the channel cloud files
|
// Website files are to be imported from the channel cloud files
|
||||||
if (($_POST) && array_key_exists('path',$_POST) && isset($_POST['cloudsubmit'])) {
|
if (($_POST) && array_key_exists('path', $_POST) && isset($_POST['cloudsubmit'])) {
|
||||||
|
|
||||||
$channel = \App::get_channel();
|
$channel = \App::get_channel();
|
||||||
$dirpath = get_dirpath_by_cloudpath($channel, $_POST['path']);
|
$dirpath = get_dirpath_by_cloudpath($channel, $_POST['path']);
|
||||||
if(!$dirpath) {
|
if (!$dirpath) {
|
||||||
notice( t('Invalid folder path.') . EOL);
|
notice(t('Invalid folder path.') . EOL);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$cloud = true;
|
$cloud = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the website files were uploaded or specified in the cloud files, then $cloud
|
// If the website files were uploaded or specified in the cloud files, then $cloud
|
||||||
@ -317,7 +309,7 @@ class Webpages extends \Zotlabs\Web\Controller {
|
|||||||
if ($cloud !== null) {
|
if ($cloud !== null) {
|
||||||
require_once('include/import.php');
|
require_once('include/import.php');
|
||||||
$elements = [];
|
$elements = [];
|
||||||
if($cloud) {
|
if ($cloud) {
|
||||||
$path = $_POST['path'];
|
$path = $_POST['path'];
|
||||||
} else {
|
} else {
|
||||||
$path = $website;
|
$path = $website;
|
||||||
@ -328,14 +320,13 @@ class Webpages extends \Zotlabs\Web\Controller {
|
|||||||
$_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);
|
||||||
$_SESSION['action'] = null;
|
$_SESSION['action'] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
@ -352,7 +343,6 @@ class Webpages extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
// Import layout first so that pages that reference new layouts will find
|
// Import layout first so that pages that reference new layouts will find
|
||||||
// the mid of layout items in the database
|
// the mid of layout items in the database
|
||||||
|
|
||||||
// Obtain the user-selected layouts to import and import them
|
// Obtain the user-selected layouts to import and import them
|
||||||
$checkedlayouts = $_POST['layout'];
|
$checkedlayouts = $_POST['layout'];
|
||||||
$layouts = [];
|
$layouts = [];
|
||||||
@ -406,10 +396,10 @@ 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']))) {
|
if (!(empty($_SESSION['import_pages']) && empty($_SESSION['import_blocks']) && empty($_SESSION['import_layouts']))) {
|
||||||
info( t('Import complete.') . EOL);
|
info(t('Import complete.') . EOL);
|
||||||
}
|
}
|
||||||
if(isset($_SESSION['tempimportpath'])) {
|
if (isset($_SESSION['tempimportpath'])) {
|
||||||
rrmdir($_SESSION['tempimportpath']); // Delete the temporary decompressed files
|
rrmdir($_SESSION['tempimportpath']); // Delete the temporary decompressed files
|
||||||
unset($_SESSION['tempimportpath']);
|
unset($_SESSION['tempimportpath']);
|
||||||
}
|
}
|
||||||
@ -417,22 +407,21 @@ class Webpages extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
case 'exportzipfile':
|
case 'exportzipfile':
|
||||||
|
|
||||||
if(isset($_POST['w_download'])) {
|
if (isset($_POST['w_download'])) {
|
||||||
$_SESSION['action'] = 'export_select_list';
|
$_SESSION['action'] = 'export_select_list';
|
||||||
$_SESSION['export'] = 'zipfile';
|
$_SESSION['export'] = 'zipfile';
|
||||||
if(isset($_POST['zipfilename']) && $_POST['zipfilename'] !== '') {
|
if (isset($_POST['zipfilename']) && $_POST['zipfilename'] !== '') {
|
||||||
$filename = filter_var($_POST['zipfilename'], FILTER_SANITIZE_ENCODED);
|
$filename = filter_var($_POST['zipfilename'], FILTER_SANITIZE_ENCODED);
|
||||||
} else {
|
} else {
|
||||||
$filename = 'website.zip';
|
$filename = 'website.zip';
|
||||||
}
|
}
|
||||||
$_SESSION['zipfilename'] = $filename;
|
$_SESSION['zipfilename'] = $filename;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'exportcloud':
|
case 'exportcloud':
|
||||||
if(isset($_POST['exportcloudpath']) && $_POST['exportcloudpath'] !== '') {
|
if (isset($_POST['exportcloudpath']) && $_POST['exportcloudpath'] !== '') {
|
||||||
$_SESSION['action'] = 'export_select_list';
|
$_SESSION['action'] = 'export_select_list';
|
||||||
$_SESSION['export'] = 'cloud';
|
$_SESSION['export'] = 'cloud';
|
||||||
$_SESSION['exportcloudpath'] = filter_var($_POST['exportcloudpath'], FILTER_SANITIZE_ENCODED);
|
$_SESSION['exportcloudpath'] = filter_var($_POST['exportcloudpath'], FILTER_SANITIZE_ENCODED);
|
||||||
@ -462,11 +451,9 @@ class Webpages extends \Zotlabs\Web\Controller {
|
|||||||
foreach ($checkedblocks as $mid) {
|
foreach ($checkedblocks as $mid) {
|
||||||
$b = q("select iconfig.v, iconfig.k, mimetype, title, body from iconfig
|
$b = q("select iconfig.v, iconfig.k, mimetype, title, body from iconfig
|
||||||
left join item on item.id = iconfig.iid
|
left join item on item.id = iconfig.iid
|
||||||
where mid = '%s' and item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'BUILDBLOCK' order by iconfig.v asc limit 1",
|
where mid = '%s' and item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'BUILDBLOCK' order by iconfig.v asc limit 1", dbesc($mid), intval($channel['channel_id'])
|
||||||
dbesc($mid),
|
|
||||||
intval($channel['channel_id'])
|
|
||||||
);
|
);
|
||||||
if($b) {
|
if ($b) {
|
||||||
$b = $b[0];
|
$b = $b[0];
|
||||||
$blockinfo = array(
|
$blockinfo = array(
|
||||||
'body' => $b['body'],
|
'body' => $b['body'],
|
||||||
@ -520,11 +507,9 @@ class Webpages extends \Zotlabs\Web\Controller {
|
|||||||
foreach ($checkedlayouts as $mid) {
|
foreach ($checkedlayouts as $mid) {
|
||||||
$l = q("select iconfig.v, iconfig.k, mimetype, title, body from iconfig
|
$l = q("select iconfig.v, iconfig.k, mimetype, title, body from iconfig
|
||||||
left join item on item.id = iconfig.iid
|
left join item on item.id = iconfig.iid
|
||||||
where mid = '%s' and item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'PDL' order by iconfig.v asc limit 1",
|
where mid = '%s' and item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'PDL' order by iconfig.v asc limit 1", dbesc($mid), intval($channel['channel_id'])
|
||||||
dbesc($mid),
|
|
||||||
intval($channel['channel_id'])
|
|
||||||
);
|
);
|
||||||
if($l) {
|
if ($l) {
|
||||||
$l = $l[0];
|
$l = $l[0];
|
||||||
$layoutinfo = array(
|
$layoutinfo = array(
|
||||||
'body' => $l['body'],
|
'body' => $l['body'],
|
||||||
@ -564,24 +549,19 @@ class Webpages extends \Zotlabs\Web\Controller {
|
|||||||
foreach ($checkedpages as $mid) {
|
foreach ($checkedpages as $mid) {
|
||||||
|
|
||||||
$p = q("select * from iconfig left join item on iconfig.iid = item.id
|
$p = q("select * from iconfig left join item on iconfig.iid = item.id
|
||||||
where item.uid = %d and item.mid = '%s' and iconfig.cat = 'system' and iconfig.k = 'WEBPAGE' and item_type = %d",
|
where item.uid = %d and item.mid = '%s' and iconfig.cat = 'system' and iconfig.k = 'WEBPAGE' and item_type = %d", intval($channel['channel_id']), dbesc($mid), intval(ITEM_TYPE_WEBPAGE)
|
||||||
intval($channel['channel_id']),
|
|
||||||
dbesc($mid),
|
|
||||||
intval(ITEM_TYPE_WEBPAGE)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if($p) {
|
if ($p) {
|
||||||
foreach ($p as $pp) {
|
foreach ($p as $pp) {
|
||||||
// Get the associated layout
|
// Get the associated layout
|
||||||
$layoutinfo = array();
|
$layoutinfo = array();
|
||||||
if($pp['layout_mid']) {
|
if ($pp['layout_mid']) {
|
||||||
$l = q("select iconfig.v, iconfig.k, mimetype, title, body from iconfig
|
$l = q("select iconfig.v, iconfig.k, mimetype, title, body from iconfig
|
||||||
left join item on item.id = iconfig.iid
|
left join item on item.id = iconfig.iid
|
||||||
where mid = '%s' and item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'PDL' order by iconfig.v asc limit 1",
|
where mid = '%s' and item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'PDL' order by iconfig.v asc limit 1", dbesc($pp['layout_mid']), intval($channel['channel_id'])
|
||||||
dbesc($pp['layout_mid']),
|
|
||||||
intval($channel['channel_id'])
|
|
||||||
);
|
);
|
||||||
if($l) {
|
if ($l) {
|
||||||
$l = $l[0];
|
$l = $l[0];
|
||||||
$layoutinfo = array(
|
$layoutinfo = array(
|
||||||
'body' => $l['body'],
|
'body' => $l['body'],
|
||||||
@ -637,12 +617,12 @@ class Webpages extends \Zotlabs\Web\Controller {
|
|||||||
'pagelink' => $pp['v'],
|
'pagelink' => $pp['v'],
|
||||||
'mimetype' => $pp['mimetype'],
|
'mimetype' => $pp['mimetype'],
|
||||||
'contentfile' => $pp['v'] . '.' . $page_ext,
|
'contentfile' => $pp['v'] . '.' . $page_ext,
|
||||||
'layout' => ((x($layoutinfo,'name')) ? $layoutinfo['name'] : ''),
|
'layout' => ((x($layoutinfo, 'name')) ? $layoutinfo['name'] : ''),
|
||||||
'json' => array(
|
'json' => array(
|
||||||
'title' => $pp['title'],
|
'title' => $pp['title'],
|
||||||
'pagelink' => $pp['v'],
|
'pagelink' => $pp['v'],
|
||||||
'mimetype' => $pp['mimetype'],
|
'mimetype' => $pp['mimetype'],
|
||||||
'layout' => ((x($layoutinfo,'name')) ? $layoutinfo['name'] : ''),
|
'layout' => ((x($layoutinfo, 'name')) ? $layoutinfo['name'] : ''),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$page_filename = $pageinfo['pagelink'] . '.' . $page_ext;
|
$page_filename = $pageinfo['pagelink'] . '.' . $page_ext;
|
||||||
@ -660,7 +640,7 @@ class Webpages extends \Zotlabs\Web\Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($action === 'zipfile') {
|
if ($action === 'zipfile') {
|
||||||
// Generate the zip file
|
// Generate the zip file
|
||||||
\Zotlabs\Lib\ExtendedZip::zipTree($tmp_folderpath, $zip_filepath, \ZipArchive::CREATE);
|
\Zotlabs\Lib\ExtendedZip::zipTree($tmp_folderpath, $zip_filepath, \ZipArchive::CREATE);
|
||||||
// Output the file for download
|
// Output the file for download
|
||||||
@ -668,12 +648,12 @@ class Webpages extends \Zotlabs\Web\Controller {
|
|||||||
header("Content-Type: application/zip");
|
header("Content-Type: application/zip");
|
||||||
$success = readfile($zip_filepath);
|
$success = readfile($zip_filepath);
|
||||||
} elseif ($action === 'cloud') { // Only zipfile or cloud should be possible values for $action here
|
} elseif ($action === 'cloud') { // Only zipfile or cloud should be possible values for $action here
|
||||||
if(isset($_SESSION['exportcloudpath'])) {
|
if (isset($_SESSION['exportcloudpath'])) {
|
||||||
require_once('include/attach.php');
|
require_once('include/attach.php');
|
||||||
$cloudpath = urldecode($_SESSION['exportcloudpath']);
|
$cloudpath = urldecode($_SESSION['exportcloudpath']);
|
||||||
$channel = \App::get_channel();
|
$channel = \App::get_channel();
|
||||||
$dirpath = get_dirpath_by_cloudpath($channel, $cloudpath);
|
$dirpath = get_dirpath_by_cloudpath($channel, $cloudpath);
|
||||||
if(!$dirpath) {
|
if (!$dirpath) {
|
||||||
$x = attach_mkdirp($channel, $channel['channel_hash'], array('pathname' => $cloudpath));
|
$x = attach_mkdirp($channel, $channel['channel_hash'], array('pathname' => $cloudpath));
|
||||||
$folder_hash = (($x['success']) ? $x['data']['hash'] : '');
|
$folder_hash = (($x['success']) ? $x['data']['hash'] : '');
|
||||||
|
|
||||||
@ -689,19 +669,18 @@ class Webpages extends \Zotlabs\Web\Controller {
|
|||||||
$success = copy_folder_to_cloudfiles($channel, $channel['channel_hash'], $tmp_folderpath, $cloudpath);
|
$success = copy_folder_to_cloudfiles($channel, $channel['channel_hash'], $tmp_folderpath, $cloudpath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!$success) {
|
if (!$success) {
|
||||||
logger('Error exporting webpage elements', LOGGER_NORMAL);
|
logger('Error exporting webpage elements', LOGGER_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
rrmdir($zip_folderpath); rrmdir($tmp_folderpath); // delete temporary files
|
rrmdir($zip_folderpath);
|
||||||
|
rrmdir($tmp_folderpath); // delete temporary files
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user