Beatification/coding convention:

- added a lot spaces to make it look nicer
- added curly braces (coding convention)
- added needed spaces (coding convention)get_id
- removed obsolete $a = get_app() call

Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
Roland Häder 2016-12-22 11:21:50 +01:00
parent a314dbc562
commit 5d0db51fdf
1 changed files with 193 additions and 190 deletions

View File

@ -52,8 +52,9 @@ class Item extends BaseObject {
$ssl_state = ((local_user()) ? true : false); $ssl_state = ((local_user()) ? true : false);
$this->redirect_url = 'redir/' . $this->get_data_value('cid') ; $this->redirect_url = 'redir/' . $this->get_data_value('cid') ;
if(get_config('system','thread_allow') && $a->theme_thread_allow && !$this->is_toplevel()) if (get_config('system','thread_allow') && $a->theme_thread_allow && !$this->is_toplevel()) {
$this->threaded = true; $this->threaded = true;
}
// Prepare the children // Prepare the children
if (count($data['children'])) { if (count($data['children'])) {
@ -63,10 +64,10 @@ class Item extends BaseObject {
*/ */
if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) { if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
continue; continue;
} } elseif (! visible_activity($item)) {
if(! visible_activity($item)) {
continue; continue;
} }
$item['pagedrop'] = $data['pagedrop']; $item['pagedrop'] = $data['pagedrop'];
$child = new Item($item); $child = new Item($item);
$this->add_child($child); $this->add_child($child);
@ -111,7 +112,6 @@ class Item extends BaseObject {
$conv = $this->get_conversation(); $conv = $this->get_conversation();
$lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) $lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
|| strlen($item['deny_cid']) || strlen($item['deny_gid'])))) || strlen($item['deny_cid']) || strlen($item['deny_gid']))))
? t('Private Message') ? t('Private Message')
@ -142,14 +142,16 @@ class Item extends BaseObject {
$diff_author = ((link_compare($item['url'],$item['author-link'])) ? false : true); $diff_author = ((link_compare($item['url'],$item['author-link'])) ? false : true);
$profile_name = htmlentities(((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']); $profile_name = htmlentities(((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']);
if($item['author-link'] && (! $item['author-name'])) if ($item['author-link'] && (! $item['author-name'])) {
$profile_name = $item['author-link']; $profile_name = $item['author-link'];
}
$sp = false; $sp = false;
$profile_link = best_link_url($item,$sp); $profile_link = best_link_url($item,$sp);
if ($profile_link === 'mailbox') { if ($profile_link === 'mailbox') {
$profile_link = ''; $profile_link = '';
} }
if ($sp) { if ($sp) {
$sparkle = ' sparkle'; $sparkle = ' sparkle';
} else { } else {
@ -198,8 +200,9 @@ class Item extends BaseObject {
// process action responses - e.g. like/dislike/attend/agree/whatever // process action responses - e.g. like/dislike/attend/agree/whatever
$response_verbs = array('like'); $response_verbs = array('like');
if(feature_enabled($conv->get_profile_owner(),'dislike')) if (feature_enabled($conv->get_profile_owner(),'dislike')) {
$response_verbs[] = 'dislike'; $response_verbs[] = 'dislike';
}
if ($item['object-type'] === ACTIVITY_OBJ_EVENT) { if ($item['object-type'] === ACTIVITY_OBJ_EVENT) {
$response_verbs[] = 'attendyes'; $response_verbs[] = 'attendyes';
$response_verbs[] = 'attendno'; $response_verbs[] = 'attendno';
@ -213,8 +216,7 @@ class Item extends BaseObject {
$responses = get_responses($conv_responses,$response_verbs,$this,$item); $responses = get_responses($conv_responses,$response_verbs,$this,$item);
foreach ($response_verbs as $value=>$verbs) { foreach ($response_verbs as $value=>$verbs) {
$responses[$verbs][output] = ((x($conv_responses[$verbs],$item['uri'])) ? format_like($conv_responses[$verbs][$item['uri']],$conv_responses[$verbs][$item['uri'] . '-l'],$verbs,$item['uri']) : ''); $responses[$verbs]['output'] = ((x($conv_responses[$verbs],$item['uri'])) ? format_like($conv_responses[$verbs][$item['uri']],$conv_responses[$verbs][$item['uri'] . '-l'],$verbs,$item['uri']) : '');
} }
/* /*
@ -224,8 +226,9 @@ class Item extends BaseObject {
*/ */
$this->check_wall_to_wall(); $this->check_wall_to_wall();
if($this->is_wall_to_wall() && ($this->get_owner_url() == $this->get_redirect_url())) if ($this->is_wall_to_wall() && ($this->get_owner_url() == $this->get_redirect_url())) {
$osparkle = ' sparkle'; $osparkle = ' sparkle';
}
if ($this->is_toplevel()) { if ($this->is_toplevel()) {
if ($conv->get_profile_owner() == local_user()) { if ($conv->get_profile_owner() == local_user()) {
@ -271,7 +274,9 @@ class Item extends BaseObject {
'like' => array( t("I like this \x28toggle\x29"), t("like")), 'like' => array( t("I like this \x28toggle\x29"), t("like")),
'dislike' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? array( t("I don't like this \x28toggle\x29"), t("dislike")) : ''), 'dislike' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? array( t("I don't like this \x28toggle\x29"), t("dislike")) : ''),
); );
if ($shareable) $buttons['share'] = array( t('Share this'), t('share')); if ($shareable) {
$buttons['share'] = array( t('Share this'), t('share'));
}
} }
$comment = $this->get_comment_box($indent); $comment = $this->get_comment_box($indent);
@ -298,8 +303,9 @@ class Item extends BaseObject {
foreach ($languages as $language) { foreach ($languages as $language) {
$langdata = explode(";", $language); $langdata = explode(";", $language);
if ($langstr != "") if ($langstr != "") {
$langstr .= ", "; $langstr .= ", ";
}
//$langstr .= $langdata[0]." (".round($langdata[1]*100, 1)."%)"; //$langstr .= $langdata[0]." (".round($langdata[1]*100, 1)."%)";
$langstr .= round($langdata[1]*100, 1)."% ".$langdata[0]; $langstr .= round($langdata[1]*100, 1)."% ".$langdata[0];
@ -318,8 +324,7 @@ class Item extends BaseObject {
$title_e = template_escape($item['title']); $title_e = template_escape($item['title']);
$location_e = template_escape($location); $location_e = template_escape($location);
$owner_name_e = template_escape($this->get_owner_name()); $owner_name_e = template_escape($this->get_owner_name());
} } else {
else {
$body_e = $body; $body_e = $body;
$text_e = strip_tags($body); $text_e = strip_tags($body);
$name_e = $profile_name; $name_e = $profile_name;
@ -334,28 +339,32 @@ class Item extends BaseObject {
$tagger = ''; $tagger = '';
} }
if (($item["item_network"] == NETWORK_FEED) AND isset($buttons["like"])) if (($item["item_network"] == NETWORK_FEED) AND isset($buttons["like"])) {
unset($buttons["like"]); unset($buttons["like"]);
}
if (($item["item_network"] == NETWORK_MAIL) AND isset($buttons["like"])) if (($item["item_network"] == NETWORK_MAIL) AND isset($buttons["like"])) {
unset($buttons["like"]); unset($buttons["like"]);
}
// Diaspora isn't able to do likes on comments - but red does // Diaspora isn't able to do likes on comments - but red does
if (($item["item_network"] == NETWORK_DIASPORA) AND ($indent == 'comment') AND if (($item["item_network"] == NETWORK_DIASPORA) AND ($indent == 'comment') AND
!diaspora::is_redmatrix($item["owner-link"]) AND isset($buttons["like"])) !diaspora::is_redmatrix($item["owner-link"]) AND isset($buttons["like"])) {
unset($buttons["like"]); unset($buttons["like"]);
}
// Diaspora doesn't has multithreaded comments // Diaspora doesn't has multithreaded comments
if (($item["item_network"] == NETWORK_DIASPORA) AND ($indent == 'comment')) if (($item["item_network"] == NETWORK_DIASPORA) AND ($indent == 'comment')) {
unset($comment); unset($comment);
}
// Facebook can like comments - but it isn't programmed in the connector yet. // Facebook can like comments - but it isn't programmed in the connector yet.
if (($item["item_network"] == NETWORK_FACEBOOK) AND ($indent == 'comment') AND isset($buttons["like"])) if (($item["item_network"] == NETWORK_FACEBOOK) AND ($indent == 'comment') AND isset($buttons["like"])) {
unset($buttons["like"]); unset($buttons["like"]);
}
$tmp_item = array( $tmp_item = array(
'template' => $this->get_template(), 'template' => $this->get_template(),
'type' => implode("",array_slice(explode("/",$item['verb']),-1)), 'type' => implode("",array_slice(explode("/",$item['verb']),-1)),
'tags' => $item['tags'], 'tags' => $item['tags'],
'hashtags' => $item['hashtags'], 'hashtags' => $item['hashtags'],
@ -440,8 +449,7 @@ class Item extends BaseObject {
$result['children'][0]['hide_text'] = t('show more'); $result['children'][0]['hide_text'] = t('show more');
if ($thread_level > 1) { if ($thread_level > 1) {
$result['children'][$nb_children - 1]['comment_lastcollapsed'] = true; $result['children'][$nb_children - 1]['comment_lastcollapsed'] = true;
} } else {
else {
$result['children'][$nb_children - 3]['comment_lastcollapsed'] = true; $result['children'][$nb_children - 3]['comment_lastcollapsed'] = true;
} }
} }
@ -458,8 +466,7 @@ class Item extends BaseObject {
if ($this->is_threaded()) { if ($this->is_threaded()) {
$result['flatten'] = false; $result['flatten'] = false;
$result['threaded'] = true; $result['threaded'] = true;
} } else {
else {
$result['flatten'] = true; $result['flatten'] = true;
$result['threaded'] = false; $result['threaded'] = false;
} }
@ -478,13 +485,12 @@ class Item extends BaseObject {
/** /**
* Add a child item * Add a child item
*/ */
public function add_child($item) { public function add_child(Item $item) {
$item_id = $item->get_id(); $item_id = $item->get_id();
if (!$item_id) { if (!$item_id) {
logger('[ERROR] Item::add_child : Item has no ID!!', LOGGER_DEBUG); logger('[ERROR] Item::add_child : Item has no ID!!', LOGGER_DEBUG);
return false; return false;
} } elseif ($this->get_child($item->get_id())) {
if($this->get_child($item->get_id())) {
logger('[WARN] Item::add_child : Item already exists ('. $item->get_id() .').', LOGGER_DEBUG); logger('[WARN] Item::add_child : Item already exists ('. $item->get_id() .').', LOGGER_DEBUG);
return false; return false;
} }
@ -493,8 +499,7 @@ class Item extends BaseObject {
*/ */
if ($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid')) { if ($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid')) {
return false; return false;
} } elseif (activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE)) {
if(activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE)) {
return false; return false;
} }
@ -508,9 +513,10 @@ class Item extends BaseObject {
*/ */
public function get_child($id) { public function get_child($id) {
foreach ($this->get_children() as $child) { foreach ($this->get_children() as $child) {
if($child->get_id() == $id) if ($child->get_id() == $id) {
return $child; return $child;
} }
}
return null; return null;
} }
@ -575,9 +581,10 @@ class Item extends BaseObject {
$this->conversation = $conv; $this->conversation = $conv;
// Set it on our children too // Set it on our children too
foreach($this->get_children() as $child) foreach ($this->get_children() as $child) {
$child->set_conversation($conv); $child->set_conversation($conv);
} }
}
/** /**
* get conversation * get conversation
@ -615,8 +622,6 @@ class Item extends BaseObject {
* Set template * Set template
*/ */
private function set_template($name) { private function set_template($name) {
$a = get_app();
if (!x($this->available_templates, $name)) { if (!x($this->available_templates, $name)) {
logger('[ERROR] Item::set_template : Template not available ("'. $name .'").', LOGGER_DEBUG); logger('[ERROR] Item::set_template : Template not available ("'. $name .'").', LOGGER_DEBUG);
return false; return false;
@ -650,8 +655,9 @@ class Item extends BaseObject {
// and community forums even if somebody else wrote the post. // and community forums even if somebody else wrote the post.
// bug #517 - this fixes for conversation owner // bug #517 - this fixes for conversation owner
if($conv->get_mode() == 'profile' && $conv->get_profile_owner() == local_user()) if ($conv->get_mode() == 'profile' && $conv->get_profile_owner() == local_user()) {
return true; return true;
}
// this fixes for visitors // this fixes for visitors
return ($this->writable || ($this->is_visiting() && $conv->get_mode() == 'profile')); return ($this->writable || ($this->is_visiting() && $conv->get_mode() == 'profile'));
@ -768,8 +774,7 @@ class Item extends BaseObject {
$this->owner_photo = $a->page_contact['thumb']; $this->owner_photo = $a->page_contact['thumb'];
$this->owner_name = $a->page_contact['name']; $this->owner_name = $a->page_contact['name'];
$this->wall_to_wall = true; $this->wall_to_wall = true;
} } elseif($this->get_data_value('owner-link')) {
else if($this->get_data_value('owner-link')) {
$owner_linkmatch = (($this->get_data_value('owner-link')) && link_compare($this->get_data_value('owner-link'),$this->get_data_value('author-link'))); $owner_linkmatch = (($this->get_data_value('owner-link')) && link_compare($this->get_data_value('owner-link'),$this->get_data_value('author-link')));
$alias_linkmatch = (($this->get_data_value('alias')) && link_compare($this->get_data_value('alias'),$this->get_data_value('author-link'))); $alias_linkmatch = (($this->get_data_value('alias')) && link_compare($this->get_data_value('alias'),$this->get_data_value('author-link')));
@ -794,13 +799,13 @@ class Item extends BaseObject {
if ((link_compare($this->get_data_value('owner-link'),$this->get_data_value('url'))) if ((link_compare($this->get_data_value('owner-link'),$this->get_data_value('url')))
&& ($this->get_data_value('network') === NETWORK_DFRN)) { && ($this->get_data_value('network') === NETWORK_DFRN)) {
$this->owner_url = $this->get_redirect_url(); $this->owner_url = $this->get_redirect_url();
} } else {
else
$this->owner_url = zrl($this->get_data_value('owner-link')); $this->owner_url = zrl($this->get_data_value('owner-link'));
} }
} }
} }
} }
}
if (!$this->wall_to_wall) { if (!$this->wall_to_wall) {
$this->set_template('wall'); $this->set_template('wall');
@ -830,8 +835,6 @@ class Item extends BaseObject {
return $this->visiting; return $this->visiting;
} }
} }
/// @TODO These are discouraged and should be removed:
?> ?>