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:
parent
b2ffde3f6b
commit
dfc2c1f805
|
@ -52,8 +52,9 @@ class Item extends BaseObject {
|
|||
$ssl_state = ((local_user()) ? true : false);
|
||||
$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;
|
||||
}
|
||||
|
||||
// Prepare the children
|
||||
if (count($data['children'])) {
|
||||
|
@ -63,10 +64,10 @@ class Item extends BaseObject {
|
|||
*/
|
||||
if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
|
||||
continue;
|
||||
}
|
||||
if(! visible_activity($item)) {
|
||||
} elseif (! visible_activity($item)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$item['pagedrop'] = $data['pagedrop'];
|
||||
$child = new Item($item);
|
||||
$this->add_child($child);
|
||||
|
@ -111,7 +112,6 @@ class Item extends BaseObject {
|
|||
|
||||
$conv = $this->get_conversation();
|
||||
|
||||
|
||||
$lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
|
||||
|| strlen($item['deny_cid']) || strlen($item['deny_gid']))))
|
||||
? t('Private Message')
|
||||
|
@ -142,14 +142,16 @@ class Item extends BaseObject {
|
|||
|
||||
$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']);
|
||||
if($item['author-link'] && (! $item['author-name']))
|
||||
if ($item['author-link'] && (! $item['author-name'])) {
|
||||
$profile_name = $item['author-link'];
|
||||
}
|
||||
|
||||
$sp = false;
|
||||
$profile_link = best_link_url($item,$sp);
|
||||
if ($profile_link === 'mailbox') {
|
||||
$profile_link = '';
|
||||
}
|
||||
|
||||
if ($sp) {
|
||||
$sparkle = ' sparkle';
|
||||
} else {
|
||||
|
@ -198,8 +200,9 @@ class Item extends BaseObject {
|
|||
|
||||
// process action responses - e.g. like/dislike/attend/agree/whatever
|
||||
$response_verbs = array('like');
|
||||
if(feature_enabled($conv->get_profile_owner(),'dislike'))
|
||||
if (feature_enabled($conv->get_profile_owner(),'dislike')) {
|
||||
$response_verbs[] = 'dislike';
|
||||
}
|
||||
if ($item['object-type'] === ACTIVITY_OBJ_EVENT) {
|
||||
$response_verbs[] = 'attendyes';
|
||||
$response_verbs[] = 'attendno';
|
||||
|
@ -213,8 +216,7 @@ class Item extends BaseObject {
|
|||
$responses = get_responses($conv_responses,$response_verbs,$this,$item);
|
||||
|
||||
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();
|
||||
|
||||
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';
|
||||
}
|
||||
|
||||
if ($this->is_toplevel()) {
|
||||
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")),
|
||||
'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);
|
||||
|
@ -298,8 +303,9 @@ class Item extends BaseObject {
|
|||
|
||||
foreach ($languages as $language) {
|
||||
$langdata = explode(";", $language);
|
||||
if ($langstr != "")
|
||||
if ($langstr != "") {
|
||||
$langstr .= ", ";
|
||||
}
|
||||
|
||||
//$langstr .= $langdata[0]." (".round($langdata[1]*100, 1)."%)";
|
||||
$langstr .= round($langdata[1]*100, 1)."% ".$langdata[0];
|
||||
|
@ -318,8 +324,7 @@ class Item extends BaseObject {
|
|||
$title_e = template_escape($item['title']);
|
||||
$location_e = template_escape($location);
|
||||
$owner_name_e = template_escape($this->get_owner_name());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$body_e = $body;
|
||||
$text_e = strip_tags($body);
|
||||
$name_e = $profile_name;
|
||||
|
@ -334,28 +339,32 @@ class Item extends BaseObject {
|
|||
$tagger = '';
|
||||
}
|
||||
|
||||
if (($item["item_network"] == NETWORK_FEED) AND isset($buttons["like"]))
|
||||
if (($item["item_network"] == NETWORK_FEED) AND isset($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"]);
|
||||
}
|
||||
|
||||
// Diaspora isn't able to do likes on comments - but red does
|
||||
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"]);
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
// 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"]);
|
||||
}
|
||||
|
||||
$tmp_item = array(
|
||||
'template' => $this->get_template(),
|
||||
|
||||
'type' => implode("",array_slice(explode("/",$item['verb']),-1)),
|
||||
'tags' => $item['tags'],
|
||||
'hashtags' => $item['hashtags'],
|
||||
|
@ -440,8 +449,7 @@ class Item extends BaseObject {
|
|||
$result['children'][0]['hide_text'] = t('show more');
|
||||
if ($thread_level > 1) {
|
||||
$result['children'][$nb_children - 1]['comment_lastcollapsed'] = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$result['children'][$nb_children - 3]['comment_lastcollapsed'] = true;
|
||||
}
|
||||
}
|
||||
|
@ -458,8 +466,7 @@ class Item extends BaseObject {
|
|||
if ($this->is_threaded()) {
|
||||
$result['flatten'] = false;
|
||||
$result['threaded'] = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$result['flatten'] = true;
|
||||
$result['threaded'] = false;
|
||||
}
|
||||
|
@ -478,13 +485,12 @@ class Item extends BaseObject {
|
|||
/**
|
||||
* Add a child item
|
||||
*/
|
||||
public function add_child($item) {
|
||||
public function add_child(Item $item) {
|
||||
$item_id = $item->get_id();
|
||||
if (!$item_id) {
|
||||
logger('[ERROR] Item::add_child : Item has no ID!!', LOGGER_DEBUG);
|
||||
return false;
|
||||
}
|
||||
if($this->get_child($item->get_id())) {
|
||||
} elseif ($this->get_child($item->get_id())) {
|
||||
logger('[WARN] Item::add_child : Item already exists ('. $item->get_id() .').', LOGGER_DEBUG);
|
||||
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')) {
|
||||
return false;
|
||||
}
|
||||
if(activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE)) {
|
||||
} elseif (activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -508,9 +513,10 @@ class Item extends BaseObject {
|
|||
*/
|
||||
public function get_child($id) {
|
||||
foreach ($this->get_children() as $child) {
|
||||
if($child->get_id() == $id)
|
||||
if ($child->get_id() == $id) {
|
||||
return $child;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -575,9 +581,10 @@ class Item extends BaseObject {
|
|||
$this->conversation = $conv;
|
||||
|
||||
// Set it on our children too
|
||||
foreach($this->get_children() as $child)
|
||||
foreach ($this->get_children() as $child) {
|
||||
$child->set_conversation($conv);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get conversation
|
||||
|
@ -615,8 +622,6 @@ class Item extends BaseObject {
|
|||
* Set template
|
||||
*/
|
||||
private function set_template($name) {
|
||||
$a = get_app();
|
||||
|
||||
if (!x($this->available_templates, $name)) {
|
||||
logger('[ERROR] Item::set_template : Template not available ("'. $name .'").', LOGGER_DEBUG);
|
||||
return false;
|
||||
|
@ -650,8 +655,9 @@ class Item extends BaseObject {
|
|||
// and community forums even if somebody else wrote the post.
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// this fixes for visitors
|
||||
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_name = $a->page_contact['name'];
|
||||
$this->wall_to_wall = true;
|
||||
}
|
||||
else if($this->get_data_value('owner-link')) {
|
||||
} elseif($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')));
|
||||
$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')))
|
||||
&& ($this->get_data_value('network') === NETWORK_DFRN)) {
|
||||
$this->owner_url = $this->get_redirect_url();
|
||||
}
|
||||
else
|
||||
} else {
|
||||
$this->owner_url = zrl($this->get_data_value('owner-link'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->wall_to_wall) {
|
||||
$this->set_template('wall');
|
||||
|
@ -830,8 +835,6 @@ class Item extends BaseObject {
|
|||
return $this->visiting;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @TODO These are discouraged and should be removed:
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue
Block a user