Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #11  
Old 08-14-2014, 03:35 PM
Hwona's Avatar
Hwona Hwona is offline
Member
 
Join Date: Mar 2013
Posts: 620
Gender: Female
Credits: 48,754
Hwona is on a distinguished road
Default

Shop.php:
PHP Code:
<?php

class ShopController extends AppController{

    const 
PARAM "shop";
    private 
$view;
    private 
$subController;

    public function 
__construct(){
        
parent::__construct("member");    
        
$mysidia Registry::get("mysidia");        
        
$mysidia->user->getstatus();
        if(
$mysidia->user->status->canshop == "no"){
            throw new 
NoPermissionException($mysidia->lang->denied);
        }
        if(
$mysidia->input->action() != "index" and !$mysidia->input->get("shop")){
            throw new 
InvalidIDException($mysidia->lang->global_id);
        }
    }
    
    public function 
index(){
        
$mysidia Registry::get("mysidia");
        
$document $mysidia->frame->getDocument();
        
$document->setTitle($mysidia->lang->access);
        
        
$typeForm = new Form("shoptypes""shop""post");
        
$typeSelection = new DropdownList("shoptype");
        
$typeSelection->add(new Option("Itemshop""itemshop"));
        
$typeSelection->add(new Option("Adoptshop""adoptshop"));
        
$typeForm->add($typeSelection);
        
$typeForm->add(new Button("Go""submit""submit"));
        
$document->add($typeForm);
 
        
$shoplist = new Shoplist($mysidia->input->post("shoptype"));
        
$shoplist->display();
    }
    
    public function 
browse(){
        
$mysidia Registry::get("mysidia");
        
$document $mysidia->frame->getDocument();                    
        
$document->setTitle($mysidia->lang->welcome);
        
        
$shoptype $mysidia->db->select("shops", array("shoptype"), "shopname = '{$mysidia->input->get("shop")}'")->fetchColumn();
        
$shoplist = new Shoplist($shoptype);
        
$shop $shoplist->createshop($mysidia->input->get("shop"));
        
$shop->display();
    }
    
    public function 
purchase(){
        
$mysidia Registry::get("mysidia");
        
$document $mysidia->frame->getDocument();
        if(!
$mysidia->input->post("buy")) throw new InvalidIDException($mysidia->lang->global_id);
        
        if(
$mysidia->input->post("shoptype") == "itemshop"){
            
$shop = new Itemshop($mysidia->input->get("shop"));
            
$item $shop->getitem($mysidia->input->post("itemname"));
            
$item->assign($mysidia->user->username);
            
$oldquantity $item->getoldquantity();
            
$newquantity $oldquantity $mysidia->input->post("quantity");
            
            if(!
is_numeric($mysidia->input->post("quantity"))){
                throw new 
InvalidActionException($mysidia->lang->invalid_quantity);
            }
            elseif(
$newquantity $item->cap){
                throw new 
InvalidActionException($mysidia->lang->full_quantity); 
            }
            else{
                
$shop->purchase($item);
                
$document->setTitle($mysidia->lang->global_transaction_complete);
                
$document->addLangvar("{$mysidia->lang->purchase_item}{$item->getcost($shop->salestax)} {$mysidia->settings->cost} and {$item->getcost2($shop->salestax)} {$mysidia->settings->cost2}.");
            }
        }
        elseif(
$mysidia->input->post("shoptype") == "adoptshop"){
        
$adoptobedience rand(0,100);
            
$shop = new Adoptshop($mysidia->input->get("shop"));
            
$adopt $shop->getadopt($mysidia->input->post("adopttype"));
            
$adopt->assign($mysidia->user->username);
            
$shop->purchase($adopt);
            
$num 1;
            
$adoptid $mysidia->db->select("owned_adoptables", array("aid"), "1 ORDER BY aid DESC LIMIT 1")->fetchColumn() - $num 1;
             
$personalities = array('Shy''Friendly''Loyal''Bold''Courageous''Witty''Agressive''Docile''Mischievious''Serious''Quirky''Playful''Lazy');
           
shuffle($personalities);
foreach (
$personalities as $personality) {
    
$adoptablepersonality "$personality";
}
            
$adoptobedience rand(0100);
                
$adoptintellect rand(0,100);
            
$adoptspeed rand(0,100);
            
$adoptstrength rand(0,100); 
            
$mysidia->db->update("owned_adoptables",array("obedience" => $adoptobedience"personality" => $adoptablepersonality"intellect" => $adoptintellect"speed" => $adoptspeed"strength" => $adoptstrength),"aid = $adoptid");
               
$document->setTitle($mysidia->lang->global_transaction_complete);
            
$document->addLangvar("{$mysidia->lang->purchase_adopt}{$adopt->getcost($shop->salestax)} {$mysidia->settings->cost} and {$adopt->getcost2($shop->salestax)} {$mysidia->settings->cost2}.");      
        }
        else throw new 
InvalidActionException($mysidia->lang->global_action);
    }
}
?>
class_adoptshop:
PHP Code:
<?php

class Adoptshop extends AdoptContainer{
  public 
$sid;
  public 
$category;
  public 
$shopname;
  public 
$shoptype;
  public 
$description;
  public 
$imageurl;
  public 
$status;
  public 
$restriction;
  public 
$salestax;
  public 
$adopts;
  protected 
$total 0;
  
  public function 
__construct($shopname){
      
// Fetch the database info into object property
      
      
$mysidia Registry::get("mysidia");
      
$row $mysidia->db->select("shops", array(), "shopname ='{$shopname}'")->fetchObject();
      if(!
is_object($row)) throw new Exception("Invalid Shopname specified");
      
      
// loop through the anonymous object created to assign properties
      
foreach($row as $key => $val){
         
$this->$key $val;         
      }

      
$this->adopts $this->getadopttypes();
      
$this->total = (is_array($this->adopts))?count($this->adopts):0;
  }

  public function 
getcategory(){
      
// This method checks if the shop category exists in adoptables database or not
      
      
$mysidia Registry::get("mysidia");
      
$stmt $mysidia->db->select("shops", array(), "category ='{$this->category}'");
      
$cate_exist = ($row $stmt->fetchObject())?TRUE:FALSE;     
      return 
$cate_exist;
  }
  
  public function 
getshop(){
      
// This method check if a shop exists in database or not
      
      
$mysidia Registry::get("mysidia");
      if(empty(
$this->shopname)) $shop_exist FALSE;
      else{
         
$stmt $mysidia->db->select("shops", array(), "shopname ='{$this->shopname}'");
         
$shop_exist = ($row $stmt->fetchObject())?TRUE:FALSE;    
      }
      return 
$shop_exist;
  }
  
  public function 
getadopttypes(){
       if(!
$this->adopts){
        
// The iids have yet to be loaded, lets acquire their info from database
        
$mysidia Registry::get("mysidia");
        
        
$stmt $mysidia->db->join("adoptables_conditions""adoptables_conditions.id = adoptables.id")
                            ->
select("adoptables", array(), constant("PREFIX")."adoptables.shop ='{$this->shopname}'");    
        
$adopts = array();
        while(
$adopt $stmt->fetchObject()){
           
$aid $row->id;
           
$promocode "";
           if(
canadopt($aid"showing"$promocode$row)) $adopts[] = $adopt;
        }
        return 
$adopts;
     }
     else return 
$this->adopts;
  }
  
  public function 
gettotal(){
      
// This method returns the total number of adoptables available      
      
return $this->total;
  }
  
  public function 
display(){
      
// This method displays the shoplist to users. It may look messy at this moment, but not after we create a table class    
      
$mysidia Registry::get("mysidia");      
      
$document $mysidia->frame->getDocument();              
      
$document->addLangvar($mysidia->lang->select_adopt);
      if(
$this->gettotal() == 0){
         
$document->addLangvar($mysidia->lang->empty);
         return 
FALSE;
      }     
      
      
$adoptList = new TableBuilder("shop");
      
$adoptList->setAlign(new Align("center""middle"));
      
$adoptList->buildHeaders("Image""Class""Type""Description""Fuzz Puff Price""Dream Price",  "Buy");    
      
$adoptList->setHelper(new ShopTableHelper);      
      
$this->adopts $this->getadopttypes();
      
      foreach(
$this->adopts as $stockadopt){
         
$adopt $this->getadopt($stockadopt->type);
         
$image = new TCell($this->getadoptimage($adopt->eggimage));
         
$class = new TCell($adopt->class);
         
$type = new TCell($adopt->type);
         
$description = new TCell($adopt->description);
         
$price = new TCell($adopt->cost);
         
$price2 = new TCell($adopt->cost2);
         
$buy = new TCell($adoptList->getHelper()->getAdoptPurchaseForm($this$adopt));
         
$adoptList->buildRow(array($image$class$type$description$price$price2$buy));
      }      
      
$document->add($adoptList);        
  }
  
  public function 
getadopt($id){
      
// This method retrieves a new Stock adoptable
      
return new StockAdopt($id);
  }
  
  public function 
purchase($adopt){
      
// This method carries out the purchase transaction of an adoptable object
  
      
$mysidia Registry::get("mysidia");
      if(
$adopt->owner != $mysidia->user->username) Throw new NoPermissionException('Something is very very wrong, please contact an admin asap.');
      else{
         
$cost $adopt->getcost($this->salestax);
         
$cost2 $adopt->getcost2($this->salestax);
         
$moneyleft $mysidia->user->money $cost;
         
$money2left $mysidia->user->money2 $cost2;
         if(
$moneyleft >= && $money2left>= 0){    
            
$purchase $adopt->append($adopt->owner);
            
$mysidia->db->update("users", array("money" => $moneyleft"money2" => $money2left), "username = '{$adopt->owner}'");
            
$status TRUE;
         }            
         else throw new 
InvalidActionException($mysidia->lang->money);
      }
      return 
$status;
  }
  
  public function 
rent($adopt$period){
      
// This method will be added in future
  
}
  
  public function 
execute($action){
      
// This method will be added in future 
  
}
}
?>
class_itemshop:
PHP Code:
<?php

class Itemshop extends ItemContainer{
  public 
$sid;
  public 
$category;
  public 
$shopname;
  public 
$shoptype;
  public 
$description;
  public 
$imageurl;
  public 
$status;
  public 
$restriction;
  public 
$salestax;
  public 
$items;
  protected 
$total 0;
  
  public function 
__construct($shopname){
      
// Fetch the database info into object property
      
      
$mysidia Registry::get("mysidia");
      
$row $mysidia->db->select("shops", array(), "shopname ='{$shopname}'")->fetchObject();
      if(!
is_object($row)) throw new Exception("Invalid Shopname specified");
      
      
// loop through the anonymous object created to assign properties
      
foreach($row as $key => $val){
         
$this->$key $val;         
      }

      
$this->items $this->getitemnames();
      
$this->total = (is_array($this->items))?count($this->items):0;
  }

  public function 
getcategory(){
      
// This method checks if the shop category exists in items database or not
      
      
$mysidia Registry::get("mysidia");
      
$stmt $mysidia->db->select("shops", array(), "category ='{$this->category}'");
      
$cate_exist = ($row $stmt->fetchObject())?TRUE:FALSE;     
      return 
$cate_exist;
  }
  
  public function 
getshop(){
      
// This method check if a shop exists in database or not
      
      
$mysidia Registry::get("mysidia");
      if(empty(
$this->shopname)) $shop_exist FALSE;
      else{
         
$stmt $mysidia->db->select("shops", array(), "shopname ='{$this->shopname}'");
         
$shop_exist = ($row $stmt->fetchObject())?TRUE:FALSE;    
      }
      return 
$shop_exist;
  }
  
  public function 
getitemnames(){
       if(!
$this->items){
        
// The iids have yet to be loaded, lets acquire their info from database
        
$mysidia Registry::get("mysidia");
        
        
$stmt $mysidia->db->select("items", array("itemname"), "shop ='{$this->shopname}'");
        
$items = array();
        
        while(
$item $stmt->fetchColumn()){
           
$items[] = $item;
        }
        return 
$items;
     }
     else return 
$this->items;
  }
  
  public function 
gettotal(){
      
// This method returns the total number of item types available
      
      
return $this->total;
  }
  
  public function 
display(){
      
// This method displays the shoplist to users. It may look messy at this moment, but not after we create a table class
    
      
$mysidia Registry::get("mysidia");
      
$document $mysidia->frame->getDocument();              
      
$document->addLangvar($mysidia->lang->select_item);
      
      if(
$this->gettotal() == 0){
         
$document->addLangvar($mysidia->lang->empty);
         return 
FALSE;
      }     
      
      
$itemList = new TableBuilder("shop");
      
$itemList->setAlign(new Align("center""middle"));
      
$itemList->buildHeaders("Image""Category""Name""Description""Fuzz Puff Price""Dream Price""Buy");    
      
$itemList->setHelper(new ShopTableHelper);
      
      foreach(
$this->items as $stockitem){
           
$item $this->getitem($stockitem);
         
$image = new TCell($this->getitemimage($item->imageurl));
         
$category = new TCell($item->category);
         
$itemname = new TCell($item->itemname);
         
$description = new TCell($item->description);
         
$price = new TCell($item->price);
         
$price2 = new TCell($item->price2);
         
$buy = new TCell($itemList->getHelper()->getItemPurchaseForm($this$item));
         
$itemList->buildRow(array($image$category$itemname$description$price$price2$buy));
      }      
      
$document->add($itemList);  
  }
  
  public function 
getitem($itemname){
      
// This method retrieves a new Stock item
      
return new StockItem($itemname);
  }
  
  public function 
purchase(Item $item){
      
// This method carries out the purchase transaction of an item object
  
      
$mysidia Registry::get("mysidia");
      if(
$item->owner != $mysidia->user->username) Throw new NoPermissionException('Something is very very wrong, please contact an admin asap.');
      else{
         
$item->quantity $mysidia->input->post("quantity");
         
$cost $item->getcost($this->salestax$item->quantity);
         
$cost2 $item->getcost2($this->salestax$item->quantity);
         
$moneyleft $mysidia->user->money $cost;
         
$money2left $mysidia->user->money2 $cost2;
         if(
$moneyleft >= and $money2left >= and $item->quantity 0){    
            
$purchase $item->append($item->quantity$item->owner);
            
$mysidia->db->update("users", array("money" => $moneyleft"money2" => $money2left), "username = '{$item->owner}'");            
            
$status TRUE;
         }            
         else throw new 
InvalidActionException($mysidia->lang->money);
      }
      return 
$status;
  }
  
  public function 
rent($item$period){
      
// This method will be added in future
  
}
  
  public function 
execute($action){
      
// This method will be added in future 
  
}
}
?>
__________________
Reply With Quote
  #12  
Old 08-15-2014, 05:58 AM
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: 333,244
Hall of Famer is on a distinguished road
Default

I see, you can fix the slashes issue by adding function stripslashes($yourtext) to each content in TCell(except for the image). But it may not be necessary, perhaps you can start with $item->description only at first(so change TCell($item->description) to TCell(stripslashes($item->description))), since I speculate that the slashes issue is mainly there. If it also appears somewhere else, lemme know and I will see what I can do to fix it further for you.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #13  
Old 08-15-2014, 07:49 AM
Hwona's Avatar
Hwona Hwona is offline
Member
 
Join Date: Mar 2013
Posts: 620
Gender: Female
Credits: 48,754
Hwona is on a distinguished road
Default

@HoF
Thank you so much for this! I'll go see if it works. :P
I also have this problem with adoptable bios, but seeing what you fixed, I may be able to get it done myself. Thanks! :D
__________________
Reply With Quote
  #14  
Old 08-15-2014, 09:05 AM
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: 333,244
Hall of Famer is on a distinguished road
Default

You are very welcome, give a try fixing your site and lemme know how it works. Id be glad to assist you further if anything goes wrong.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #15  
Old 08-15-2014, 10:34 AM
Hwona's Avatar
Hwona Hwona is offline
Member
 
Join Date: Mar 2013
Posts: 620
Gender: Female
Credits: 48,754
Hwona is on a distinguished road
Default

@HoF
Thanks! Everything works great! :D
__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help !! Shops not appearing é.è kitty08 Feedback and Suggestions 3 12-31-2014 11:15 AM
Site appearing blank? Pear Questions and Supports 18 11-09-2014 04:50 PM
friendlist - strange problem draugluin Questions and Supports 2 12-15-2011 03:37 AM
Strange code error Kyris Questions and Supports 2 03-17-2011 07:45 AM
Strange error PokePets Questions and Supports 11 02-03-2011 04:43 PM


All times are GMT -5. The time now is 04:37 AM.

Currently Active Users: 9776 (0 members and 9776 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636