rewrote for() loop to foreach() + added curly braces/spaces

Signed-off-by: Roland Haeder <roland@mxchange.org>
This commit is contained in:
Roland Haeder 2017-03-25 14:32:49 +01:00
parent 006b4b88b2
commit 73ee285212
No known key found for this signature in database
GPG key ID: B72F8185C6C7BD78
2 changed files with 44 additions and 44 deletions

View file

@ -395,7 +395,7 @@ $a->init_page_end();
// If you're just visiting, let javascript take you home // If you're just visiting, let javascript take you home
if (x($_SESSION, 'visitor_home')) { if (x($_SESSION, 'visitor_home')) {
$homebase = $_SESSION['visitor_home']; $homebase = $_SESSION['visitor_home'];
] elseif (local_user()) { } elseif (local_user()) {
$homebase = 'profile/' . $a->user['nickname']; $homebase = 'profile/' . $a->user['nickname'];
} }
@ -403,17 +403,11 @@ if (isset($homebase)) {
$a->page['content'] .= '<script>var homebase="' . $homebase . '" ; </script>'; $a->page['content'] .= '<script>var homebase="' . $homebase . '" ; </script>';
} }
<<<<<<< HEAD
// now that we've been through the module content, see if the page reported
// a permission problem and if so, a 403 response would seem to be in order.
=======
/* /*
* now that we've been through the module content, see if the page reported * now that we've been through the module content, see if the page reported
* a permission problem and if so, a 403 response would seem to be in order. * a permission problem and if so, a 403 response would seem to be in order.
*/ */
>>>>>>> 29f1028... Convention: if (stristr(implode("", $_SESSION['sysmsg']), t('Permission denied'))) {
if (stristr( implode("",$_SESSION['sysmsg']), t('Permission denied'))) {
header($_SERVER["SERVER_PROTOCOL"] . ' 403 ' . t('Permission denied.')); header($_SERVER["SERVER_PROTOCOL"] . ' 403 ' . t('Permission denied.'));
} }

View file

@ -1325,16 +1325,17 @@ function photos_content(App $a) {
dbesc($datum) dbesc($datum)
); );
if (! count($ph)) { if (! dbm::is_result($ph)) {
$ph = q("SELECT `id` FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' $ph = q("SELECT `id` FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'
LIMIT 1", LIMIT 1",
intval($owner_uid), intval($owner_uid),
dbesc($datum) dbesc($datum)
); );
if (count($ph)) if (dbm::is_result($ph)) {
notice( t('Permission denied. Access to this item may be restricted.')); notice(t('Permission denied. Access to this item may be restricted.'));
else } else {
notice( t('Photo not available') . EOL ); notice(t('Photo not available') . EOL );
}
return; return;
} }
@ -1356,15 +1357,17 @@ function photos_content(App $a) {
intval($owner_uid) intval($owner_uid)
); );
if (count($prvnxt)) { if (dbm::is_result($prvnxt)) {
for($z = 0; $z < count($prvnxt); $z++) { foreach ($prvnxt as $z => $entry) {
if ($prvnxt[$z]['resource-id'] == $ph[0]['resource-id']) { if ($entry['resource-id'] == $ph[0]['resource-id']) {
$prv = $z - 1; $prv = $z - 1;
$nxt = $z + 1; $nxt = $z + 1;
if ($prv < 0) if ($prv < 0) {
$prv = count($prvnxt) - 1; $prv = count($prvnxt) - 1;
if ($nxt >= count($prvnxt)) }
if ($nxt >= count($prvnxt)) {
$nxt = 0; $nxt = 0;
}
break; break;
} }
} }
@ -1387,8 +1390,8 @@ function photos_content(App $a) {
} }
$album_link = 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($ph[0]['album']); $album_link = 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($ph[0]['album']);
$tools = Null; $tools = null;
$lock = Null; $lock = null;
if ($can_post && ($ph[0]['uid'] == $owner_uid)) { if ($can_post && ($ph[0]['uid'] == $owner_uid)) {
$tools = array( $tools = array(
@ -1426,8 +1429,9 @@ function photos_content(App $a) {
'filename' => $hires['filename'], 'filename' => $hires['filename'],
); );
if ($nextlink) if ($nextlink) {
$nextlink = array($nextlink, '<div class="icon next"></div>'); $nextlink = array($nextlink, '<div class="icon next"></div>');
}
// Do we have an item for this photo? // Do we have an item for this photo?
@ -1444,8 +1448,9 @@ function photos_content(App $a) {
$map = null; $map = null;
if (count($linked_items)) { if (dbm::is_result($linked_items)) {
$link_item = $linked_items[0]; $link_item = $linked_items[0];
$r = qu("SELECT COUNT(*) AS `total` $r = qu("SELECT COUNT(*) AS `total`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0 and `item`.`moderated` = 0 WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0 and `item`.`moderated` = 0
@ -1458,8 +1463,9 @@ function photos_content(App $a) {
); );
if (dbm::is_result($r)) if (dbm::is_result($r)) {
$a->set_pager_total($r[0]['total']); $a->set_pager_total($r[0]['total']);
}
$r = qu("SELECT `item`.*, `item`.`id` AS `item_id`, $r = qu("SELECT `item`.*, `item`.`id` AS `item_id`,
@ -1493,15 +1499,16 @@ function photos_content(App $a) {
} }
} }
$tags=Null; $tags = null;
if (count($linked_items) && strlen($link_item['tag'])) { if (count($linked_items) && strlen($link_item['tag'])) {
$arr = explode(',',$link_item['tag']); $arr = explode(',',$link_item['tag']);
// parse tags and add links // parse tags and add links
$tag_str = ''; $tag_str = '';
foreach ($arr as $t) { foreach ($arr as $t) {
if (strlen($tag_str)) if (strlen($tag_str)) {
$tag_str .= ', '; $tag_str .= ', ';
}
$tag_str .= bbcode($t); $tag_str .= bbcode($t);
} }
$tags = array(t('Tags: '), $tag_str); $tags = array(t('Tags: '), $tag_str);
@ -1518,21 +1525,25 @@ function photos_content(App $a) {
// Private/public post links for the non-JS ACL form // Private/public post links for the non-JS ACL form
$private_post = 1; $private_post = 1;
if ($_REQUEST['public']) if ($_REQUEST['public']) {
$private_post = 0; $private_post = 0;
}
$query_str = $a->query_string; $query_str = $a->query_string;
if (strpos($query_str, 'public=1') !== false) if (strpos($query_str, 'public=1') !== false) {
$query_str = str_replace(array('?public=1', '&public=1'), array('', ''), $query_str); $query_str = str_replace(array('?public=1', '&public=1'), array('', ''), $query_str);
}
// I think $a->query_string may never have ? in it, but I could be wrong /*
// It looks like it's from the index.php?q=[etc] rewrite that the web * I think $a->query_string may never have ? in it, but I could be wrong
// server does, which converts any ? to &, e.g. suggest&ignore=61 for suggest?ignore=61 * It looks like it's from the index.php?q=[etc] rewrite that the web
if (strpos($query_str, '?') === false) * server does, which converts any ? to &, e.g. suggest&ignore=61 for suggest?ignore=61
*/
if (strpos($query_str, '?') === false) {
$public_post_link = '?public=1'; $public_post_link = '?public=1';
else } else {
$public_post_link = '&public=1'; $public_post_link = '&public=1';
}
if ($a->theme['template_engine'] === 'internal') { if ($a->theme['template_engine'] === 'internal') {
$album_e = template_escape($ph[0]['album']); $album_e = template_escape($ph[0]['album']);
@ -1596,6 +1607,7 @@ function photos_content(App $a) {
$comments = ''; $comments = '';
if (! dbm::is_result($r)) { if (! dbm::is_result($r)) {
/// @TODO merge into one if() ?
if ($can_post || can_write_wall($a,$owner_uid)) { if ($can_post || can_write_wall($a,$owner_uid)) {
if ($link_item['last-child']) { if ($link_item['last-child']) {
$comments .= replace_macros($cmnt_tpl,array( $comments .= replace_macros($cmnt_tpl,array(
@ -1630,8 +1642,6 @@ function photos_content(App $a) {
'attendyes' => array('title' => t('Attending','title')), 'attendno' => array('title' => t('Not attending','title')), 'attendmaybe' => array('title' => t('Might attend','title')) 'attendyes' => array('title' => t('Attending','title')), 'attendno' => array('title' => t('Not attending','title')), 'attendmaybe' => array('title' => t('Might attend','title'))
); );
// display comments // display comments
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
@ -1642,8 +1652,7 @@ function photos_content(App $a) {
$like = ((x($conv_responses['like'],$link_item['uri'])) ? format_like($conv_responses['like'][$link_item['uri']],$conv_responses['like'][$link_item['uri'] . '-l'],'like',$link_item['id']) : ''); $like = ((x($conv_responses['like'],$link_item['uri'])) ? format_like($conv_responses['like'][$link_item['uri']],$conv_responses['like'][$link_item['uri'] . '-l'],'like',$link_item['id']) : '');
$dislike = ((x($conv_responses['dislike'],$link_item['uri'])) ? format_like($conv_responses['dislike'][$link_item['uri']],$conv_responses['dislike'][$link_item['uri'] . '-l'],'dislike',$link_item['id']) : ''); $dislike = ((x($conv_responses['dislike'],$link_item['uri'])) ? format_like($conv_responses['dislike'][$link_item['uri']],$conv_responses['dislike'][$link_item['uri'] . '-l'],'dislike',$link_item['id']) : '');
/// @TODO merge into one if() ?
if ($can_post || can_write_wall($a,$owner_uid)) { if ($can_post || can_write_wall($a,$owner_uid)) {
if ($link_item['last-child']) { if ($link_item['last-child']) {
$comments .= replace_macros($cmnt_tpl,array( $comments .= replace_macros($cmnt_tpl,array(
@ -1675,7 +1684,7 @@ function photos_content(App $a) {
if (((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE))) && ($item['id'] != $item['parent'])) if (((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE))) && ($item['id'] != $item['parent']))
continue; continue;
$redirect_url = 'redir/' . $item['cid'] ; $redirect_url = 'redir/' . $item['cid'];
if (local_user() && ($item['contact-uid'] == local_user()) if (local_user() && ($item['contact-uid'] == local_user())
@ -1694,8 +1703,6 @@ function photos_content(App $a) {
$profile_link = $profile_url; $profile_link = $profile_url;
$dropping = (($item['contact-id'] == $contact_id) || ($item['uid'] == local_user())); $dropping = (($item['contact-id'] == $contact_id) || ($item['uid'] == local_user()));
$drop = array( $drop = array(
'dropping' => $dropping, 'dropping' => $dropping,
@ -1704,7 +1711,6 @@ function photos_content(App $a) {
'delete' => t('Delete'), 'delete' => t('Delete'),
); );
if ($a->theme['template_engine'] === 'internal') { if ($a->theme['template_engine'] === 'internal') {
$name_e = template_escape($profile_name); $name_e = template_escape($profile_name);
$title_e = template_escape($item['title']); $title_e = template_escape($item['title']);
@ -1729,10 +1735,10 @@ function photos_content(App $a) {
'$comment' => $comment '$comment' => $comment
)); ));
if ($can_post || can_write_wall($a,$owner_uid)) { /// @TODO merge into one if() ?
if ($can_post || can_write_wall($a, $owner_uid)) {
if ($item['last-child']) { if ($item['last-child']) {
$comments .= replace_macros($cmnt_tpl,array( $comments .= replace_macros($cmnt_tpl, array(
'$return_path' => '', '$return_path' => '',
'$jsreload' => $return_url, '$jsreload' => $return_url,
'$type' => 'wall-comment', '$type' => 'wall-comment',