View Single Post
  #5  
Old 02-19-2014, 09:31 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 604,781
Hall of Famer is on a distinguished road
Default

Quote:
Originally Posted by IntoRain View Post
Directly on the stats page? Or when you click on it?

If you look at the database you will see that the description is associated with an Adoptable and not an OwnedAdoptable. So we have to get the species to get the description. Basically, through the OwnedAdoptable's type, we get the Adoptable and then we return the description.

In code-words, in the file class_ownedadoptable.php we add a protected $type; to the list at the top then we add this function:

public function getDescription(){
$adopt = new Adoptable($this->type);
return $adopt->getDescription();
}

So if you want it in the stats page, you just needed to add a comment on the getStats() function in the class_ownedadoptable.php file like:

$stats->add(new Comment("<br>Description: ",FALSE));
$stats->add(new Comment($this->getDescription()));

So you class_ownedadoptable.php should look like this:

PHP Code:
<?php

class OwnedAdoptable extends Adoptable{

    protected 
$aid;
    protected 
$name;
    protected 
$owner;
    protected 
$currentlevel;
    protected 
$totalclicks;
    protected 
$code;
    protected 
$imageurl;
    protected 
$usealternates;
    protected 
$tradestatus;
    protected 
$isfrozen;  
    protected 
$gender;
    protected 
$offsprings;
    protected 
$lastbred;
    protected 
$nextlevel;
    protected 
$voters;
    protected 
$motherID;
    protected 
$fatherID;
    protected 
$type;//add this
  
    
public function __construct($aid$owner ""){      
       (... 
rest of function)
    }
    
        
//add this function
    
public function getDescription(){
        
$adopt = new Adoptable($this->type);
        return 
$adopt->getDescription();
    }

(
rest of code here)...
    
    public function 
getStats(){
        
$mysidia Registry::get("mysidia");
        
$document $mysidia->frame->getDocument();    
        
$stats = new Division("adoptstats");
        
$stats->add(new Comment("<br><br><b>Total Clicks: {$this->totalclicks}"));
        
$stats->add(new Comment("Gender: "FALSE));
        
$stats->add(new Image("picuploads/{$this->gender}.png"));

                
//add this
        
$stats->add(new Comment("<br>Description: ",FALSE));
        
$stats->add(new    Comment($this->getDescription()));

        if(
$this->hasNextLevel()){
            
$level $this->getNextLevel();
            
$levelupClicks $this->getLevelupClicks();
            
$nextLevel $level->getLevel().$mysidia->lang->clicks.$levelupClicks
        }
        else 
$nextLevel $mysidia->lang->maximum;
        
        
$adoptStats "<br>Trade Status: {$this->tradestatus}<br>
                       Current Level: 
{$this->currentlevel}<br>Next Level: {$nextLevel}</b>";
        
$stats->add(new Comment($adoptStats));
        if(
$this->getMotherID() != NULL){
            
$stats->add(new Comment("<br><b>Mother:</b> <a href='../../levelup/click/{$this->getMotherID()}'>{$this->getMother()->getName()}</a><br><b>Father:</b> <a href='../../levelup/click/{$this->getFatherID()}'>{$this->getFather()->getName()}</a>"));
        }
        return 
$stats;        
    }
}
?>
Actually there is no need to add a type field and getDescription() method in class OwnedAdpptable, since this class extends from the parent Adoptable class so all properties/methods are inherited. You can just access the type field and getDescription() method directly inside or outside the class.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote