]> git.mxchange.org Git - friendica.git/blob - object/Item.php
Vier: Adding some shadows. In the thread view showing the application when hovering...
[friendica.git] / object / Item.php
1 <?php
2 if(class_exists('Item'))
3         return;
4
5 require_once('object/BaseObject.php');
6 require_once('include/text.php');
7 require_once('boot.php');
8
9 /**
10  * An item
11  */
12 class Item extends BaseObject {
13         private $data = array();
14         private $template = null;
15         private $available_templates = array(
16                 'wall' => 'wall_thread.tpl',
17                 'wall2wall' => 'wallwall_thread.tpl'
18         );
19         private $comment_box_template = 'comment_item.tpl';
20         private $toplevel = false;
21         private $writable = false;
22         private $children = array();
23         private $parent = null;
24         private $conversation = null;
25         private $redirect_url = null;
26         private $owner_url = '';
27         private $owner_photo = '';
28         private $owner_name = '';
29         private $wall_to_wall = false;
30         private $threaded = false;
31         private $visiting = false;
32
33         public function __construct($data) {
34                 $a = $this->get_app();
35                 
36                 $this->data = $data;
37                 $this->set_template('wall');
38                 $this->toplevel = ($this->get_id() == $this->get_data_value('parent'));
39
40                 if(is_array($_SESSION['remote'])) {
41                         foreach($_SESSION['remote'] as $visitor) {
42                                 if($visitor['cid'] == $this->get_data_value('contact-id')) {
43                                         $this->visiting = true;
44                                         break;
45                                 }
46                         }
47                 }
48                 
49                 $this->writable = ($this->get_data_value('writable') || $this->get_data_value('self'));
50
51                 $ssl_state = ((local_user()) ? true : false);
52                 $this->redirect_url = $a->get_baseurl($ssl_state) . '/redir/' . $this->get_data_value('cid') ;
53
54                 if(get_config('system','thread_allow') && $a->theme_thread_allow && !$this->is_toplevel())
55                         $this->threaded = true;
56
57                 // Prepare the children
58                 if(count($data['children'])) {
59                         foreach($data['children'] as $item) {
60                                 /*
61                                  * Only add will be displayed
62                                  */
63                                 if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
64                                         continue;
65                                 }
66                                 if(! visible_activity($item)) {
67                                         continue;
68                                 }
69                                 $item['pagedrop'] = $data['pagedrop'];
70                                 $child = new Item($item);
71                                 $this->add_child($child);
72                         }
73                 }
74         }
75
76         /**
77          * Get data in a form usable by a conversation template
78          *
79          * Returns:
80          *      _ The data requested on success
81          *      _ false on failure
82          */
83         public function get_template_data($alike, $dlike, $thread_level=1) {
84                 $result = array();
85
86                 $a = $this->get_app();
87
88                 $item = $this->get_data();
89                 $edited = false;
90                 if (strcmp($item['created'], $item['edited'])<>0) {
91                       $edited = array(
92                           'label' => t('This entry was edited'),
93                           'date' => datetime_convert('UTC', date_default_timezone_get(), $item['edited'], 'r'),
94                           'relative' => relative_date($item['edited'])
95                       );
96                 }
97                 $commentww = '';
98                 $sparkle = '';
99                 $buttons = '';
100                 $dropping = false;
101                 $star = false;
102                 $isstarred = "unstarred";
103                 $indent = '';
104                 $shiny = '';
105                 $osparkle = '';
106                 $total_children = $this->count_descendants();
107
108                 $conv = $this->get_conversation();
109
110
111                 $lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) 
112                         || strlen($item['deny_cid']) || strlen($item['deny_gid']))))
113                         ? t('Private Message')
114                         : false);
115                 $shareable = ((($conv->get_profile_owner() == local_user()) && ($item['private'] != 1)) ? true : false);
116                 if(local_user() && link_compare($a->contact['url'],$item['author-link']))
117                         $edpost = array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit"));
118                 else
119                         $edpost = false;
120                 if(($this->get_data_value('uid') == local_user()) || $this->is_visiting())
121                         $dropping = true;
122
123                 $drop = array(
124                         'dropping' => $dropping,
125                         'pagedrop' => ((feature_enabled($conv->get_profile_owner(),'multi_delete')) ? $item['pagedrop'] : ''),
126                         'select' => t('Select'),
127                         'delete' => t('Delete'),
128                 );
129
130                 $filer = (($conv->get_profile_owner() == local_user()) ? t("save to folder") : false);
131
132                 $diff_author    = ((link_compare($item['url'],$item['author-link'])) ? false : true);
133                 $profile_name   = (((strlen($item['author-name']))   && $diff_author) ? $item['author-name']   : $item['name']);
134                 if($item['author-link'] && (! $item['author-name']))
135                         $profile_name = $item['author-link'];
136
137                 $sp = false;
138                 $profile_link = best_link_url($item,$sp);
139                 if($profile_link === 'mailbox')
140                         $profile_link = '';
141                 if($sp)
142                         $sparkle = ' sparkle';
143                 else
144                         $profile_link = zrl($profile_link);
145
146                 $normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']);
147                 if(($normalised != 'mailbox') && (x($a->contacts,$normalised)))
148                         $profile_avatar = $a->contacts[$normalised]['thumb'];
149                 else
150                         $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $a->get_cached_avatar_image($this->get_data_value('thumb')));
151
152                 $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => '');
153                 call_hooks('render_location',$locate);
154                 $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_google($locate));
155
156                 $searchpath = $a->get_baseurl()."/search?tag=";
157                 $tags=array();
158                 $hashtags = array();
159                 $mentions = array();
160
161
162                 /*foreach(explode(',',$item['tag']) as $tag){
163                         $tag = trim($tag);
164                         if ($tag!="") {
165                                 $t = bbcode($tag);
166                                 $tags[] = $t;
167                                 if($t[0] == '#')
168                                         $hashtags[] = $t;
169                                 elseif($t[0] == '@')
170                                         $mentions[] = $t;
171                         }
172                 }*/
173
174                 $like    = ((x($alike,$item['uri'])) ? format_like($alike[$item['uri']],$alike[$item['uri'] . '-l'],'like',$item['uri']) : '');
175                 $dislike = ((x($dlike,$item['uri'])) ? format_like($dlike[$item['uri']],$dlike[$item['uri'] . '-l'],'dislike',$item['uri']) : '');
176
177                 /*
178                  * We should avoid doing this all the time, but it depends on the conversation mode
179                  * And the conv mode may change when we change the conv, or it changes its mode
180                  * Maybe we should establish a way to be notified about conversation changes
181                  */
182                 $this->check_wall_to_wall();
183
184                 if($this->is_wall_to_wall() && ($this->get_owner_url() == $this->get_redirect_url()))
185                         $osparkle = ' sparkle';
186
187                 if($this->is_toplevel()) {
188                         if($conv->get_profile_owner() == local_user()) {
189                                 $isstarred = (($item['starred']) ? "starred" : "unstarred");
190
191                                 $star = array(
192                                         'do' => t("add star"),
193                                         'undo' => t("remove star"),
194                                         'toggle' => t("toggle star status"),
195                                         'classdo' => (($item['starred']) ? "hidden" : ""),
196                                         'classundo' => (($item['starred']) ? "" : "hidden"),
197                                         'starred' =>  t('starred'),
198                                 );
199                                 $tagger = '';
200                                 if(feature_enabled($conv->get_profile_owner(),'commtag')) {
201                                         $tagger = array(
202                                                 'add' => t("add tag"),
203                                                 'class' => "",
204                                         );
205                                 }
206                         }
207                 } else {
208                         $indent = 'comment';
209                 }
210
211                 if($conv->is_writable()) {
212                         $buttons = array(
213                                 'like' => array( t("I like this \x28toggle\x29"), t("like")),
214                                 'dislike' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? array( t("I don't like this \x28toggle\x29"), t("dislike")) : ''),
215                         );
216                         if ($shareable) $buttons['share'] = array( t('Share this'), t('share'));
217                 }
218
219                 if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0){
220                         $shiny = 'shiny';
221                 }
222
223                 localize_item($item);
224
225                 if ($item["postopts"] and !get_config("system", "suppress_language")) {
226                         //$langdata = explode(";", $item["postopts"]);
227                         //$langstr = substr($langdata[0], 5)." (".round($langdata[1]*100, 1)."%)";
228                         $langstr = "";
229                         if (substr($item["postopts"], 0, 5) == "lang=") {
230                                 $postopts = substr($item["postopts"], 5);
231
232                                 $languages = explode(":", $postopts);
233
234                                 if (sizeof($languages) == 1) {
235                                         $languages = array();
236                                         $languages[] = $postopts;
237                                 }
238
239                                 foreach ($languages as $language) {
240                                         $langdata = explode(";", $language);
241                                         if ($langstr != "")
242                                                 $langstr .= ", ";
243
244                                         //$langstr .= $langdata[0]." (".round($langdata[1]*100, 1)."%)";
245                                         $langstr .= round($langdata[1]*100, 1)."% ".$langdata[0];
246                                 }
247                         }
248                 }
249
250                 $body = prepare_body($item,true);
251
252                 list($categories, $folders) = get_cats_and_terms($item);
253
254                 if($a->theme['template_engine'] === 'internal') {
255                         $body_e = template_escape($body);
256                         $text_e = strip_tags(template_escape($body));
257                         $name_e = template_escape($profile_name);
258                         $title_e = template_escape($item['title']);
259                         $location_e = template_escape($location);
260                         $owner_name_e = template_escape($this->get_owner_name());
261                 }
262                 else {
263                         $body_e = $body;
264                         $text_e = strip_tags($body);
265                         $name_e = $profile_name;
266                         $title_e = $item['title'];
267                         $location_e = $location;
268                         $owner_name_e = $this->get_owner_name();
269                 }
270
271                 $tmp_item = array(
272                         'template' => $this->get_template(),
273
274                         'type' => implode("",array_slice(explode("/",$item['verb']),-1)),
275                         'tags' => $item['tags'],
276                         'hashtags' => $item['hashtags'],
277                         'mentions' => $item['mentions'],
278                         'txt_cats' => t('Categories:'),
279                         'txt_folders' => t('Filed under:'),
280                         'has_cats' => ((count($categories)) ? 'true' : ''),
281                         'has_folders' => ((count($folders)) ? 'true' : ''),
282                         'categories' => $categories,
283                         'folders' => $folders,
284                         'body' => $body_e,
285                         'text' => $text_e,
286                         'id' => $this->get_id(),
287                         'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])),
288                         'olinktitle' => sprintf( t('View %s\'s profile @ %s'), $this->get_owner_name(), ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])),
289                         'to' => t('to'),
290                         'via' => t('via'),
291                         'wall' => t('Wall-to-Wall'),
292                         'vwall' => t('via Wall-To-Wall:'),
293                         'profile_url' => $profile_link,
294                         'item_photo_menu' => item_photo_menu($item),
295                         'name' => $name_e,
296                         'thumb' => $profile_avatar,
297                         'osparkle' => $osparkle,
298                         'sparkle' => $sparkle,
299                         'title' => $title_e,
300                         'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'),
301                         'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])),
302                         'app' => $item['app'],
303                         'created' => relative_date($item['created']),
304                         'lock' => $lock,
305                         'location' => $location_e,
306                         'indent' => $indent,
307                         'shiny' => $shiny,
308                         'owner_url' => $this->get_owner_url(),
309                         'owner_photo' => $this->get_owner_photo(),
310                         'owner_name' => $owner_name_e,
311                         'plink' => get_plink($item),
312                         'edpost'    => ((feature_enabled($conv->get_profile_owner(),'edit_posts')) ? $edpost : ''),
313                         'isstarred' => $isstarred,
314                         'star'      => ((feature_enabled($conv->get_profile_owner(),'star_posts')) ? $star : ''),
315                         'tagger'        => $tagger,
316                         'filer'     => ((feature_enabled($conv->get_profile_owner(),'filing')) ? $filer : ''),
317                         'drop' => $drop,
318                         'vote' => $buttons,
319                         'like' => $like,
320                         'dislike'   => $dislike,
321                         'switchcomment' => t('Comment'),
322                         'comment' => $this->get_comment_box($indent),
323                         'previewing' => ($conv->is_preview() ? ' preview ' : ''),
324                         'wait' => t('Please wait'),
325                         'thread_level' => $thread_level,
326                         'postopts' => $langstr,
327                         'edited' => $edited,
328                         'network' => $item["item_network"],
329                         'network_name' => network_to_name($item['item_network']),
330                 );
331
332                 $arr = array('item' => $item, 'output' => $tmp_item);
333                 call_hooks('display_item', $arr);
334
335                 $result = $arr['output'];
336
337                 $result['children'] = array();
338                 $children = $this->get_children();
339                 $nb_children = count($children);
340                 if($nb_children > 0) {
341                         foreach($children as $child) {
342                                 $result['children'][] = $child->get_template_data($alike, $dlike, $thread_level + 1);
343                         }
344                         // Collapse
345                         if(($nb_children > 2) || ($thread_level > 1)) {
346                                 $result['children'][0]['comment_firstcollapsed'] = true;
347                                 $result['children'][0]['num_comments'] = sprintf( tt('%d comment','%d comments',$total_children),$total_children );
348                                 $result['children'][0]['hidden_comments_num'] = $total_children;
349                                 $result['children'][0]['hidden_comments_text'] = tt('comment', 'comments', $total_children);
350                                 $result['children'][0]['hide_text'] = t('show more');
351                                 if($thread_level > 1) {
352                                         $result['children'][$nb_children - 1]['comment_lastcollapsed'] = true;
353                                 }
354                                 else {
355                                         $result['children'][$nb_children - 3]['comment_lastcollapsed'] = true;
356                                 }
357                         }
358                 }
359
360         if ($this->is_toplevel()) {
361             $result['total_comments_num'] = "$total_children";
362             $result['total_comments_text'] = tt('comment', 'comments', $total_children);
363         }
364
365                 $result['private'] = $item['private'];
366                 $result['toplevel'] = ($this->is_toplevel() ? 'toplevel_item' : '');
367
368                 if($this->is_threaded()) {
369                         $result['flatten'] = false;
370                         $result['threaded'] = true;
371                 }
372                 else {
373                         $result['flatten'] = true;
374                         $result['threaded'] = false;
375                 }
376
377                 return $result;
378         }
379         
380         public function get_id() {
381                 return $this->get_data_value('id');
382         }
383
384         public function is_threaded() {
385                 return $this->threaded;
386         }
387
388         /**
389          * Add a child item
390          */
391         public function add_child($item) {
392                 $item_id = $item->get_id();
393                 if(!$item_id) {
394                         logger('[ERROR] Item::add_child : Item has no ID!!', LOGGER_DEBUG);
395                         return false;
396                 }
397                 if($this->get_child($item->get_id())) {
398                         logger('[WARN] Item::add_child : Item already exists ('. $item->get_id() .').', LOGGER_DEBUG);
399                         return false;
400                 }
401                 /*
402                  * Only add what will be displayed
403                  */
404                 if($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid')) {
405                         return false;
406                 }
407                 if(activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE)) {
408                         return false;
409                 }
410                 
411                 $item->set_parent($this);
412                 $this->children[] = $item;
413                 return end($this->children);
414         }
415
416         /**
417          * Get a child by its ID
418          */
419         public function get_child($id) {
420                 foreach($this->get_children() as $child) {
421                         if($child->get_id() == $id)
422                                 return $child;
423                 }
424                 return null;
425         }
426
427         /**
428          * Get all ou children
429          */
430         public function get_children() {
431                 return $this->children;
432         }
433
434         /**
435          * Set our parent
436          */
437         protected function set_parent($item) {
438                 $parent = $this->get_parent();
439                 if($parent) {
440                         $parent->remove_child($this);
441                 }
442                 $this->parent = $item;
443                 $this->set_conversation($item->get_conversation());
444         }
445
446         /**
447          * Remove our parent
448          */
449         protected function remove_parent() {
450                 $this->parent = null;
451                 $this->conversation = null;
452         }
453
454         /**
455          * Remove a child
456          */
457         public function remove_child($item) {
458                 $id = $item->get_id();
459                 foreach($this->get_children() as $key => $child) {
460                         if($child->get_id() == $id) {
461                                 $child->remove_parent();
462                                 unset($this->children[$key]);
463                                 // Reindex the array, in order to make sure there won't be any trouble on loops using count()
464                                 $this->children = array_values($this->children);
465                                 return true;
466                         }
467                 }
468                 logger('[WARN] Item::remove_child : Item is not a child ('. $id .').', LOGGER_DEBUG);
469                 return false;
470         }
471
472         /**
473          * Get parent item
474          */
475         protected function get_parent() {
476                 return $this->parent;
477         }
478
479         /**
480          * set conversation
481          */
482         public function set_conversation($conv) {
483                 $previous_mode = ($this->conversation ? $this->conversation->get_mode() : '');
484                 
485                 $this->conversation = $conv;
486
487                 // Set it on our children too
488                 foreach($this->get_children() as $child)
489                         $child->set_conversation($conv);
490         }
491
492         /**
493          * get conversation
494          */
495         public function get_conversation() {
496                 return $this->conversation;
497         }
498
499         /**
500          * Get raw data
501          *
502          * We shouldn't need this
503          */
504         public function get_data() {
505                 return $this->data;
506         }
507
508         /**
509          * Get a data value
510          *
511          * Returns:
512          *      _ value on success
513          *      _ false on failure
514          */
515         public function get_data_value($name) {
516                 if(!isset($this->data[$name])) {
517 //                      logger('[ERROR] Item::get_data_value : Item has no value name "'. $name .'".', LOGGER_DEBUG);
518                         return false;
519                 }
520
521                 return $this->data[$name];
522         }
523
524         /**
525          * Set template
526          */
527         private function set_template($name) {
528                 $a = get_app();
529
530                 if(!x($this->available_templates, $name)) {
531                         logger('[ERROR] Item::set_template : Template not available ("'. $name .'").', LOGGER_DEBUG);
532                         return false;
533                 }
534
535                 $this->template = $this->available_templates[$name];
536         }
537
538         /**
539          * Get template
540          */
541         private function get_template() {
542                 return $this->template;
543         }
544
545         /**
546          * Check if this is a toplevel post
547          */
548         private function is_toplevel() {
549                 return $this->toplevel;
550         }
551
552         /**
553          * Check if this is writable
554          */
555         private function is_writable() {
556                 $conv = $this->get_conversation();
557
558                 if($conv) {
559                         // This will allow us to comment on wall-to-wall items owned by our friends
560                         // and community forums even if somebody else wrote the post.
561
562                         // bug #517 - this fixes for conversation owner
563                         if($conv->get_mode() == 'profile' && $conv->get_profile_owner() == local_user())
564                                 return true; 
565
566                         // this fixes for visitors
567                         return ($this->writable || ($this->is_visiting() && $conv->get_mode() == 'profile'));
568                 }
569                 return $this->writable;
570         }
571
572         /**
573          * Count the total of our descendants
574          */
575         private function count_descendants() {
576                 $children = $this->get_children();
577                 $total = count($children);
578                 if($total > 0) {
579                         foreach($children as $child) {
580                                 $total += $child->count_descendants();
581                         }
582                 }
583                 return $total;
584         }
585
586         /**
587          * Get the template for the comment box
588          */
589         private function get_comment_box_template() {
590                 return $this->comment_box_template;
591         }
592
593         /**
594          * Get the comment box
595          *
596          * Returns:
597          *      _ The comment box string (empty if no comment box)
598          *      _ false on failure
599          */
600         private function get_comment_box($indent) {
601                 $a = $this->get_app();
602                 if(!$this->is_toplevel() && !(get_config('system','thread_allow') && $a->theme_thread_allow)) {
603                         return '';
604                 }
605                 
606                 $comment_box = '';
607                 $conv = $this->get_conversation();
608                 $template = get_markup_template($this->get_comment_box_template());
609                 $ww = '';
610                 if( ($conv->get_mode() === 'network') && $this->is_wall_to_wall() )
611                         $ww = 'ww';
612
613                 if($conv->is_writable() && $this->is_writable()) {
614                         $qc = $qcomment =  null;
615
616                         /*
617                          * Hmmm, code depending on the presence of a particular plugin?
618                          * This should be better if done by a hook
619                          */
620                         if(in_array('qcomment',$a->plugins)) {
621                                 $qc = ((local_user()) ? get_pconfig(local_user(),'qcomment','words') : null);
622                                 $qcomment = (($qc) ? explode("\n",$qc) : null);
623                         }
624                         $comment_box = replace_macros($template,array(
625                                 '$return_path' => $a->query_string,
626                                 '$threaded' => $this->is_threaded(),
627 //                              '$jsreload' => (($conv->get_mode() === 'display') ? $_SESSION['return_url'] : ''),
628                                 '$jsreload' => '',
629                                 '$type' => (($conv->get_mode() === 'profile') ? 'wall-comment' : 'net-comment'),
630                                 '$id' => $this->get_id(),
631                                 '$parent' => $this->get_id(),
632                                 '$qcomment' => $qcomment,
633                                 '$profile_uid' =>  $conv->get_profile_owner(),
634                                 '$mylink' => $a->contact['url'],
635                                 '$mytitle' => t('This is you'),
636                                 '$myphoto' => $a->contact['thumb'],
637                                 '$comment' => t('Comment'),
638                                 '$submit' => t('Submit'),
639                                 '$edbold' => t('Bold'),
640                                 '$editalic' => t('Italic'),
641                                 '$eduline' => t('Underline'),
642                                 '$edquote' => t('Quote'),
643                                 '$edcode' => t('Code'),
644                                 '$edimg' => t('Image'),
645                                 '$edurl' => t('Link'),
646                                 '$edvideo' => t('Video'),
647                                 '$preview' => ((feature_enabled($conv->get_profile_owner(),'preview')) ? t('Preview') : ''),
648                                 '$indent' => $indent,
649                                 '$sourceapp' => t($a->sourcename),
650                                 '$ww' => (($conv->get_mode() === 'network') ? $ww : ''),
651                                 '$rand_num' => random_digits(12)
652                         ));
653                 }
654
655                 return $comment_box;
656         }
657
658         private function get_redirect_url() {
659                 return $this->redirect_url;
660         }
661
662         /**
663          * Check if we are a wall to wall item and set the relevant properties
664          */
665         protected function check_wall_to_wall() {
666                 $a = $this->get_app();
667                 $conv = $this->get_conversation();
668                 $this->wall_to_wall = false;
669                 
670                 if($this->is_toplevel()) {
671                         if( (! $this->get_data_value('self')) && ($conv->get_mode() !== 'profile')) {
672                                 if($this->get_data_value('wall')) {
673
674                                         // On the network page, I am the owner. On the display page it will be the profile owner.
675                                         // This will have been stored in $a->page_contact by our calling page.
676                                         // Put this person as the wall owner of the wall-to-wall notice.
677
678                                         $this->owner_url = zrl($a->page_contact['url']);
679                                         $this->owner_photo = $a->page_contact['thumb'];
680                                         $this->owner_name = $a->page_contact['name'];
681                                         $this->wall_to_wall = true;
682                                 }
683                                 else if($this->get_data_value('owner-link')) {
684
685                                         $owner_linkmatch = (($this->get_data_value('owner-link')) && link_compare($this->get_data_value('owner-link'),$this->get_data_value('author-link')));
686                                         $alias_linkmatch = (($this->get_data_value('alias')) && link_compare($this->get_data_value('alias'),$this->get_data_value('author-link')));
687                                         $owner_namematch = (($this->get_data_value('owner-name')) && $this->get_data_value('owner-name') == $this->get_data_value('author-name'));
688                                         if((! $owner_linkmatch) && (! $alias_linkmatch) && (! $owner_namematch)) {
689
690                                                 // The author url doesn't match the owner (typically the contact)
691                                                 // and also doesn't match the contact alias. 
692                                                 // The name match is a hack to catch several weird cases where URLs are 
693                                                 // all over the park. It can be tricked, but this prevents you from
694                                                 // seeing "Bob Smith to Bob Smith via Wall-to-wall" and you know darn
695                                                 // well that it's the same Bob Smith. 
696
697                                                 // But it could be somebody else with the same name. It just isn't highly likely. 
698                                                 
699
700                                                 $this->owner_photo = $this->get_data_value('owner-avatar');
701                                                 $this->owner_name = $this->get_data_value('owner-name');
702                                                 $this->wall_to_wall = true;
703                                                 // If it is our contact, use a friendly redirect link
704                                                 if((link_compare($this->get_data_value('owner-link'),$this->get_data_value('url'))) 
705                                                         && ($this->get_data_value('network') === NETWORK_DFRN)) {
706                                                         $this->owner_url = $this->get_redirect_url();
707                                                 }
708                                                 else
709                                                         $this->owner_url = zrl($this->get_data_value('owner-link'));
710                                         }
711                                 }
712                         }
713                 }
714
715                 if(!$this->wall_to_wall) {
716                         $this->set_template('wall');
717                         $this->owner_url = '';
718                         $this->owner_photo = '';
719                         $this->owner_name = '';
720                 }
721         }
722
723         private function is_wall_to_wall() {
724                 return $this->wall_to_wall;
725         }
726
727         private function get_owner_url() {
728                 return $this->owner_url;
729         }
730
731         private function get_owner_photo() {
732                 return $this->owner_photo;
733         }
734
735         private function get_owner_name() {
736                 return $this->owner_name;
737         }
738
739         private function is_visiting() {
740                 return $this->visiting;
741         }
742
743
744
745
746 }
747 ?>