]> git.mxchange.org Git - friendica.git/commitdiff
Item: new methods get|set_template
authorDomovoy <domovoy@errlock.org>
Sat, 11 Aug 2012 14:56:10 +0000 (16:56 +0200)
committerDomovoy <domovoy@errlock.org>
Sat, 11 Aug 2012 14:56:10 +0000 (16:56 +0200)
object/Conversation.php
object/Item.php

index 0ce016649bc110c02bd3ba7baa23ff7fd0e7d32c..6675a005306b0315a13ac0b08d4c0047c1e4b3b2 100644 (file)
@@ -50,13 +50,13 @@ class Conversation extends BaseObject {
         *              _ The data requested on success
         *              _ false on failure
         */
-       public function get_template_data($cmnt_tpl) {
+       public function get_template_data($cmnt_tpl, $alike, $dlike) {
                $result = array();
 
                foreach($this->threads as $item) {
                        if($item->get_network() === NETWORK_MAIL && local_user() != $item->get_uid())
                                continue;
-                       $item_data = $item->get_template_data($cmnt_tpl, $this->mode);
+                       $item_data = $item->get_template_data($cmnt_tpl, $this->mode, $alike, $dlike);
                        if(!$item_data) {
                                logger('[ERROR] Conversation::get_template_data : Failed to get item template data ('. $item->get_id() .').', LOGGER_DEBUG);
                                return false;
index 796f9cae642e47904b25fe14fb702f726962d6b9..b96b7e44f49c83ce3d083ec6807ecaaaae5b0f84 100644 (file)
@@ -4,6 +4,7 @@ if(class_exists('Item'))
 
 require_once('object/BaseObject.php');
 require_once('include/text.php');
+require_once('boot.php');
 
 /**
  * An item
@@ -21,7 +22,7 @@ class Item extends BaseObject {
 
        public function __construct($data) {
                $this->data = $data;
-               $this->template = $this->available_templates['wall'];
+               $this->set_template('wall');
        }
 
        /**
@@ -31,7 +32,7 @@ class Item extends BaseObject {
         *              _ The data requested on success
         *              _ false on failure
         */
-       public function get_template_data($cmnt_tpl, $mode) {
+       public function get_template_data($cmnt_tpl, $mode, $alike, $dlike) {
                $result = array();
 
                $a = $this->get_app();
@@ -40,9 +41,6 @@ class Item extends BaseObject {
 
                $item = $this->get_data();
 
-               $alike = array();
-               $dlike = array();
-               $template = $this->available_templates['wall'];
                $comment = '';
                $commentww = '';
                $sparkle = '';
@@ -130,7 +128,7 @@ class Item extends BaseObject {
                                        $owner_url = zrl($a->page_contact['url']);
                                        $owner_photo = $a->page_contact['thumb'];
                                        $owner_name = $a->page_contact['name'];
-                                       $template = $this->available_templates['wall2wall'];
+                                       $this->set_template('wall2wall');
                                        $commentww = 'ww';      
                                }
                        }
@@ -154,7 +152,7 @@ class Item extends BaseObject {
                                        $owner_url = $item['owner-link'];
                                        $owner_photo = $item['owner-avatar'];
                                        $owner_name = $item['owner-name'];
-                                       $template = $this->available_templates['wall2wall'];
+                                       $this->set_template('wall2wall');
                                        $commentww = 'ww';
                                        // If it is our contact, use a friendly redirect link
                                        if((link_compare($item['owner-link'],$item['url'])) 
@@ -252,7 +250,7 @@ class Item extends BaseObject {
                        'comment_firstcollapsed' => $firstcollapsed,
                        'comment_lastcollapsed' => $lastcollapsed,
                        // template to use to render item (wall, walltowall, search)
-                       'template' => $template,
+                       'template' => $this->get_template(),
                        
                        'type' => implode("",array_slice(explode("/",$item['verb']),-1)),
                        'tags' => $tags,
@@ -303,7 +301,7 @@ class Item extends BaseObject {
 
                $item_result['children'] = array();
                if(count($item['children'])) {
-                       $item_result['children'] = prepare_threads_body($a, $item['children'], $cmnt_tpl, $this->is_page_writeable(), $this->get_mode(), $this->get_profile_owner(), ($thread_level + 1));
+                       $item_result['children'] = prepare_threads_body($a, $item['children'], $cmnt_tpl, $this->is_page_writeable(), $this->get_mode(), $this->get_profile_owner(), $alike, $dlike, ($thread_level + 1));
                }
                $item_result['private'] = $item['private'];
                $item_result['toplevel'] = ($toplevelpost ? 'toplevel_item' : '');
@@ -410,5 +408,21 @@ class Item extends BaseObject {
        private function is_page_writeable() {
                return $this->page_writeable;
        }
+
+       /**
+        * Set template
+        */
+       private function set_template($name) {
+               if(!x($this->available_templates, $name))
+                       return false;
+               $this->template = $this->available_templates[$name];
+       }
+
+       /**
+        * Get template
+        */
+       private function get_template() {
+               return $this->template;
+       }
 }
 ?>