superfluous whitespace cleanup

This commit is contained in:
zotlabs 2017-01-31 17:32:52 -08:00
parent f4aca35a88
commit 4f99d641c5
3 changed files with 361 additions and 354 deletions

View File

@ -112,7 +112,7 @@ class Import extends \Zotlabs\Web\Controller {
// print_r($data);
if(! array_key_exists('compatibility,$data)) {
if(! array_key_exists('compatibility',$data)) {
call_hooks('import_foreign_channel_data',$data);
if($data['handled'])
return;

View File

@ -846,7 +846,7 @@ function channel_export_items($channel_id, $start, $finish) {
$ret['relocate'] = [ 'channel_address' => $ch['channel_address'], 'url' => z_root()];
}
$r = q("select * from item where ( item_wall = 1 or item_type != %d ) and item_deleted = 0 and uid = %d and created >= '%s' and created < '%s' and resource_type = '' order by created",
$r = q("select * from item where ( item_wall = 1 or item_type != %d ) and item_deleted = 0 and uid = %d and created >= '%s' and created <= '%s' and resource_type = '' order by created",
intval(ITEM_TYPE_POST),
intval($channel_id),
dbesc($start),

View File

@ -1209,38 +1209,41 @@ function scan_webpage_elements($path, $type, $cloud = false) {
$dirtoscan = get_dirpath_by_cloudpath($channel, $dirtoscan);
}
$elements = [];
if (is_dir($dirtoscan)) {
if(is_dir($dirtoscan)) {
$dirlist = scandir($dirtoscan);
if ($dirlist) {
foreach ($dirlist as $element) {
if ($element === '.' || $element === '..') {
if($dirlist) {
foreach($dirlist as $element) {
if($element === '.' || $element === '..') {
continue;
}
$folder = $dirtoscan . '/' . $element;
if (is_dir($folder)) {
if(is_dir($folder)) {
if($cloud) {
$jsonfilepath = $folder . '/' . get_filename_by_cloudname($json_filename, $channel, $folder);
} else {
}
else {
$jsonfilepath = $folder . '/' . $json_filename;
}
if (is_file($jsonfilepath)) {
if(is_file($jsonfilepath)) {
$metadata = json_decode(file_get_contents($jsonfilepath), true);
if($cloud) {
$contentfilename = get_filename_by_cloudname($metadata['contentfile'], $channel, $folder);
$metadata['path'] = $folder . '/' . $contentfilename;
} else {
}
else {
$contentfilename = $metadata['contentfile'];
$metadata['path'] = $folder . '/' . $contentfilename;
}
if ($metadata['contentfile'] === '') {
if($metadata['contentfile'] === '') {
logger('Invalid ' . $type . ' content file');
return false;
}
$content = file_get_contents($folder . '/' . $contentfilename);
if (!$content) {
if(!$content) {
if(is_readable($folder . '/' . $contentfilename)) {
$content = '';
} else {
}
else {
logger('Failed to get file content for ' . $metadata['contentfile']);
return false;
}
@ -1252,14 +1255,14 @@ function scan_webpage_elements($path, $type, $cloud = false) {
}
}
return $elements;
}
}
function import_webpage_element($element, $channel, $type) {
function import_webpage_element($element, $channel, $type) {
$arr = array(); // construct information for the webpage element item table record
switch ($type) {
switch($type) {
//
// PAGES
//
@ -1325,7 +1328,8 @@ function scan_webpage_elements($path, $type, $cloud = false) {
);
$arr['mid'] = $arr['parent_mid'] = $iteminfo[0]['mid'];
$arr['created'] = $iteminfo[0]['created'];
} else { // otherwise, generate the creation times and unique id
}
else { // otherwise, generate the creation times and unique id
$arr['created'] = datetime_convert('UTC', 'UTC');
$arr['mid'] = $arr['parent_mid'] = item_message_id();
}
@ -1348,21 +1352,23 @@ function scan_webpage_elements($path, $type, $cloud = false) {
// Blocks and pages can have any of the valid mimetypes, but layouts must be text/bbcode
if((in_array($element['mimetype'], $mimetypes)) && ($type === 'page' || $type === 'block') ) {
$arr['mimetype'] = $element['mimetype'];
} else {
}
else {
$arr['mimetype'] = 'text/bbcode';
}
// Verify ability to use html or php!!!
$execflag = false;
if ($arr['mimetype'] === 'application/x-php' || $arr['mimetype'] === 'text/html') {
if($arr['mimetype'] === 'application/x-php' || $arr['mimetype'] === 'text/html') {
$z = q("select account_id, account_roles, channel_pageflags from account "
. "left join channel on channel_account_id = account_id where channel_id = %d limit 1",
intval(local_channel())
);
if ($z && (($z[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($z[0]['channel_pageflags'] & PAGE_ALLOWCODE))) {
if($z && (($z[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($z[0]['channel_pageflags'] & PAGE_ALLOWCODE))) {
$execflag = true;
} else {
}
else {
logger('Unable to import element "' . $name .'" because AllowCode permission is denied.');
notice( t('Unable to import element "' . $name .'" because AllowCode permission is denied.') . EOL);
$element['import_success'] = 0;
@ -1380,14 +1386,15 @@ function scan_webpage_elements($path, $type, $cloud = false) {
intval(local_channel())
);
$remote_id = 0;
if ($z && $i) {
if($z && $i) {
$remote_id = $z[0]['id'];
$arr['id'] = $i[0]['id'];
// don't update if it has the same timestamp as the original
if ($arr['edited'] > $i[0]['edited'])
if($arr['edited'] > $i[0]['edited'])
$x = item_store_update($arr, $execflag);
} else {
if (($i) && (intval($i[0]['item_deleted']))) {
}
else {
if(($i) && (intval($i[0]['item_deleted']))) {
// was partially deleted already, finish it off
q("delete from item where mid = '%s' and uid = %d",
dbesc($arr['mid']),
@ -1396,16 +1403,16 @@ function scan_webpage_elements($path, $type, $cloud = false) {
}
$x = item_store($arr, $execflag);
}
if ($x['success']) {
if($x['success']) {
$item_id = $x['item_id'];
update_remote_id($channel, $item_id, $arr['item_type'], $name, $namespace, $remote_id, $arr['mid']);
$element['import_success'] = 1;
} else {
}
else {
$element['import_success'] = 0;
}
return $element;
}
function get_webpage_elements($channel, $type = 'all') {
@ -1413,7 +1420,7 @@ function get_webpage_elements($channel, $type = 'all') {
if(!$channel['channel_id']) {
return null;
}
switch ($type) {
switch($type) {
case 'all':
// If all, execute all the pages, layouts, blocks case statements
case 'pages':
@ -1501,7 +1508,6 @@ function get_webpage_elements($channel, $type = 'all') {
'mid' => $rr['mid'],
);
}
}
if($type !== 'all') {
@ -1558,32 +1564,32 @@ function get_webpage_elements($channel, $type = 'all') {
/* creates a compressed zip file */
function create_zip_file($files = array(), $destination = '', $overwrite = false) {
//if the zip file already exists and overwrite is false, return false
if (file_exists($destination) && !$overwrite) {
// if the zip file already exists and overwrite is false, return false
if(file_exists($destination) && !$overwrite) {
return false;
}
//vars
$valid_files = array();
//if files were passed in...
if (is_array($files)) {
//cycle through each file
foreach ($files as $file) {
//make sure the file exists
if (file_exists($file)) {
// if files were passed in...
if(is_array($files)) {
// cycle through each file
foreach($files as $file) {
// make sure the file exists
if(file_exists($file)) {
$valid_files[] = $file;
}
}
}
//if we have good files...
if (count($valid_files)) {
// if we have good files...
if(count($valid_files)) {
//create the archive
$zip = new ZipArchive();
if ($zip->open($destination, $overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {
if($zip->open($destination, $overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {
return false;
}
//add the files
foreach ($valid_files as $file) {
// add the files
foreach($valid_files as $file) {
$zip->addFile($file, $file);
}
//debug
@ -1591,9 +1597,10 @@ function create_zip_file($files = array(), $destination = '', $overwrite = false
//close the zip -- done!
$zip->close();
//check to make sure the file exists
// check to make sure the file exists
return file_exists($destination);
} else {
}
else {
return false;
}
}