Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Addons and Modifications > Mys v1.3.x Mods

Notices

Reply
 
Thread Tools Display Modes
  #11  
Old 05-22-2015, 04:26 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 111,644
Abronsyth is on a distinguished road
Default

I know you're busy, but, when you have the chance...I'm not sure what I'm messing up and I'm by no means an experienced coder...but I'm getting this error:
Quote:
Fatal error: Uncaught exception 'Resource\Exception\NosuchElementException' in /hermes/bosoraweb162/b1009/ipg.ferrepetscom/classes/resource/collection/linkedhashmapiterator.php:83 Stack trace: #0 /hermes/bosoraweb162/b1009/ipg.ferrepetscom/classes/resource/collection/entrylinkediterator.php(26): Resource\Collection\LinkedHashMapIterator->nextEntry() #1 /hermes/bosoraweb162/b1009/ipg.ferrepetscom/view/shopview.php(47): Resource\Collection\EntryLinkedIterator->next() #2 /hermes/bosoraweb162/b1009/ipg.ferrepetscom/classes/class_frontcontroller.php(100): ShopView->index() #3 /hermes/bosoraweb162/b1009/ipg.ferrepetscom/index.php(74): FrontController->render() #4 /hermes/bosoraweb162/b1009/ipg.ferrepetscom/index.php(78): IndexController::main() #5 {main} thrown in /hermes/bosoraweb162/b1009/ipg.ferrepetscom/classes/resource/collection/linkedhashmapiterator.php on line 83
Here's my shopview:
PHP Code:
<?php

use Resource\Collection\LinkedList;

class 
ShopView extends View{
    
    public function 
index(){
        
$document $this->document;
        
$document->setTitle($this->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 $this->getField("shopList"); 
        
$document->addLangvar($this->lang->select);
        
$shopTable = new TableBuilder("shoplist");
        
$shopTable->setAlign(new Align("center""middle"));
        
$shopTable->buildHeaders("Enter""Sells""Description""Location");    
        
$shopTable->setHelper(new ShopTableHelper);         
        
        
$iterator $shopList->iterator();
        while(
$iterator->hasNext()){
            
$entry $iterator->next();
            
$shop $shopList->createshop($entry->getKey());
            
$cells = new LinkedList;
            
$cells->add(new TCell($shopTable->getHelper()->getShopStatus($shop)));
            
            if(
$shop->status == "open") { 
                if (
$shop->shoptype == "itemshop"){ $cells->add(new TCell("Items")); }
                if (
$shop->shoptype == "adoptshop"){ $cells->add(new TCell("Pets")); }
                
$cells->add(new TCell($shop->description));
                
$cells->add(new TCell($shop->category));
                
# $cells->add(new TCell($shopTable->getHelper()->getSalestax($shop->salestax)));    
            
}    
            if(
$shop->status == "closed") { 
                
$cells->add(new TCell(""));
                
$cells->add(new TCell("Not Open."));
                
$cells->add(new TCell("")); 
            }    
            
$shopTable->buildRow($cells);
        } {
            
$entry $iterator->next();
            
$shop $shopList->createshop($entry->getKey());
            
$cells = new LinkedList;
            
            
$cells->add(new TCell($shopList->getshopimage($shop->imageurl)));
            
$cells->add(new TCell($shop->category));
            
$cells->add(new TCell($shop->shoptype));
            
$cells->add(new TCell($shop->shopname));
            
$cells->add(new TCell($shop->description));
            
$cells->add(new TCell($shopTable->getHelper()->getSalestax($shop->salestax)));
            
$cells->add(new TCell($shopTable->getHelper()->getShopStatus($shop)));
            
$shopTable->buildRow($cells);
        }
        
$document->add($shopTable);  
    }
    
    public function 
browse(){
        
$document $this->document;                    
        
$document->setTitle($this->lang->welcome);
        
$shop $this->getField("shop");
        
$shop->display();
    }
    
    public function 
purchase(){
        
$mysidia Registry::get("mysidia");
        
$cost $this->getField("cost");
        
$document $this->document;        
        
        if(
$mysidia->input->post("shoptype") == "itemshop"){
            
$document->setTitle($this->lang->global_transaction_complete);
            
$document->addLangvar("{$this->lang->purchase_item}{$cost->getValue()} {$mysidia->settings->cost}");
        }
        elseif(
$mysidia->input->post("shoptype") == "adoptshop"){
               
$document->setTitle($this->lang->global_transaction_complete);
            
$document->addLangvar("{$this->lang->purchase_adopt}{$cost->getValue()} {$mysidia->settings->cost}");      
        }
        else return;
    }
}
?>
And here's my shoptablehelper:
PHP Code:
<?php

/**
 * The ShopTableHelper Class, extends from the TableHelper class.
 * It is a specific helper for tables that involves operations on shops.
 * @category Resource
 * @package Helper
 * @author Hall of Famer 
 * @copyright Mysidia Adoptables Script
 * @link http://www.mysidiaadoptables.com
 * @since 1.3.3
 * @todo Not much at this point.
 *
 */

class ShopTableHelper extends TableHelper{

    
/**
     * Constructor of ShopTableHelper Class, it simply serves as a wrap-up.
     * @access public
     * @return Void
     */
    
public function __construct(){
        
parent::__construct();         
    }

    
/**
     * The getSalestax method, formats and retrieves the salestax of a shop.
     * @param Int  $salestax
     * @access public
     * @return String
     */
    
public function getSalestax($salestax){
        return 
"{$salestax}%";                
    }
    
    
/**
     * The getShopstatus method, returns the shop status with an enter link or a closed message.
     * @param Shop  $shop
     * @access public
     * @return Link|String
     */
    
public function getShopStatus($shop){    
        if(
$shop->status == "open") return new Link("shop/browse/{$shop->shopname}", new Image($shop->imageurl));
        if(
$shop->status == "closed") return "<img src='{$shop->imageurl}' style='opacity:0.3;'>";
        else return 
"Closed";        
    } 
    
    
/**
     * The getItemPurchaseForm method, constructs a buy form for an itemshop table.
     * @param Itemshop  $shop
     * @param Item  $item 
     * @access public
     * @return Form
     */
    
public function getItemPurchaseForm(Itemshop $shopItem $item){    
        
$mysidia Registry::get("mysidia");
        
$buyForm = new FormBuilder("buyform""../purchase/{$mysidia->input->get("shop")}""post");
        
$buyForm->setLineBreak(FALSE);
        
$buyForm->buildComment("<br>")
                ->
buildPasswordField("hidden""action""purchase")
                ->
buildPasswordField("hidden""itemname"$item->itemname)
                ->
buildPasswordField("hidden""shopname"$shop->shopname)
                ->
buildPasswordField("hidden""shoptype""itemshop")
                ->
buildPasswordField("hidden""salestax"$shop->salestax);
                
        
$quantity = new TextField("quantity");
        
$quantity->setSize(3);
        
$quantity->setMaxLength(3);
        
$quantity->setLineBreak(TRUE);

        
$buy = new Button("Buy""buy""buy");
        
$buy->setLineBreak(FALSE);

        
$buyForm->add($quantity);
        
$buyForm->add($buy);
        return 
$buyForm;                
    }
    
    
/**
     * The getAdoptPurchaseForm method, constructs a purchase form for an adoptshop table.
     * @param Adoptshop  $shop
     * @param Adoptable  $adopt 
     * @access public
     * @return Form
     */
    
public function getAdoptPurchaseForm(Adoptshop $shop$adopt){    
        
$mysidia Registry::get("mysidia");
        
$buyForm = new FormBuilder("buyform""../purchase/{$mysidia->input->get("shop")}""post");
        
$buyForm->setLineBreak(FALSE);
        
$buyForm->buildComment("<br>")
                ->
buildPasswordField("hidden""action""purchase")
                ->
buildPasswordField("hidden""adopttype"$adopt->type)
                ->
buildPasswordField("hidden""shopname"$shop->shopname)
                ->
buildPasswordField("hidden""shoptype""adoptshop")
                ->
buildPasswordField("hidden""salestax"$shop->salestax);
                
        
$buy = new Button("Buy""buy""buy");
        
$buy->setLineBreak(FALSE);
        
$buyForm->add($buy);
        return 
$buyForm;                
    }
    
    
/**
     * Magic method __toString for ShopTableHelper class, it reveals that the object is a shop table helper.
     * @access public
     * @return String
     */
    
public function __toString(){
        return new 
String("This is an instance of Mysidia ShopTableHelper class.");
    }    

?>
Are you able to spot my mistake?
__________________
My Mods Site (1.3.4, 2020 Mods)
Reply With Quote
  #12  
Old 05-23-2015, 12:49 AM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 86,931
Kyttias is on a distinguished road
Default

I can tell you that the index function is wrong in shopview.php.

This is the original index function:
PHP Code:
    public function index(){
        
$document $this->document;
        
$document->setTitle($this->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 $this->getField("shopList"); 
        
$document->addLangvar($this->lang->select);
        
$shopTable = new TableBuilder("shoplist");
        
$shopTable->setAlign(new Align("center""middle"));
        
$shopTable->buildHeaders("Image""Category""Type""Name""Description""Sales Tax""Enter");    
        
$shopTable->setHelper(new ShopTableHelper);         
        
        
$iterator $shopList->iterator();
        while(
$iterator->hasNext()){
            
$entry $iterator->next();
            
$shop $shopList->createshop($entry->getKey());
            
$cells = new LinkedList;
            
            
$cells->add(new TCell($shopList->getshopimage($shop->imageurl)));
            
$cells->add(new TCell($shop->category));
            
$cells->add(new TCell($shop->shoptype));
            
$cells->add(new TCell($shop->shopname));
            
$cells->add(new TCell($shop->description));
            
$cells->add(new TCell($shopTable->getHelper()->getSalestax($shop->salestax)));
            
$cells->add(new TCell($shopTable->getHelper()->getShopStatus($shop)));
            
$shopTable->buildRow($cells);
        }
        
$document->add($shopTable);  
    } 
This is what it needs to be:
PHP Code:
    public function index(){
        
$document $this->document;
        
$document->setTitle($this->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 $this->getField("shopList"); 
        
$document->addLangvar($this->lang->select);
        
$shopTable = new TableBuilder("shoplist");
        
$shopTable->setAlign(new Align("center""middle"));
        
$shopTable->buildHeaders("Enter""Sells""Description""Location");    
        
$shopTable->setHelper(new ShopTableHelper);         
        
        
$iterator $shopList->iterator();
        while(
$iterator->hasNext()){
            
$entry $iterator->next();
            
$shop $shopList->createshop($entry->getKey());
            
$cells = new LinkedList;
            
$cells->add(new TCell($shopTable->getHelper()->getShopStatus($shop)));
            
            if(
$shop->status == "open") { 
                if (
$shop->shoptype == "itemshop"){ $cells->add(new TCell("Items")); }
                if (
$shop->shoptype == "adoptshop"){ $cells->add(new TCell("Pets")); }
                
$cells->add(new TCell($shop->description));
                
$cells->add(new TCell($shop->category));
                
# $cells->add(new TCell($shopTable->getHelper()->getSalestax($shop->salestax)));    
            
}    
            if(
$shop->status == "closed") { 
                
$cells->add(new TCell(""));
                
$cells->add(new TCell("Not Open."));
                
$cells->add(new TCell("")); 
            }    
            
$shopTable->buildRow($cells);
        }  
        
$document->add($shopTable);  
    } 
Or, basically, I replaced lines 19 through 40 in the original document with the ones from my first post. From where $shopList is defined to the end of the while loop, leaving everything before $shopList is defined intact, and leaving everything after the end of the while loop intact.
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.
Reply With Quote
  #13  
Old 05-23-2015, 11:14 AM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 111,644
Abronsyth is on a distinguished road
Default

Awesome, thank you! I was pretty tired when I was putting it together, so it's no wonder I messed up XD

It's working wondrously now, thank you!
__________________
My Mods Site (1.3.4, 2020 Mods)
Reply With Quote
  #14  
Old 06-13-2016, 02:31 PM
Suzanne Suzanne is offline
Member
 
Join Date: Jun 2016
Posts: 11
Gender: Female
Credits: 1,458
Suzanne is on a distinguished road
Default

Thank you so much for taking the time to offer this. It works perfectly!
Reply With Quote
Reply

Tags
shop image, shops

Thread Tools
Display Modes

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
Mys v1.3.4 Item Shop Mod(s): NPC + Item Display + Tooltips Kyttias Mys v1.3.x Mods 55 06-19-2020 11:21 AM
Display on Phone? Glow Questions and Supports 1 01-05-2015 08:56 AM
Changing Shop and Item Display? Abronsyth Questions and Supports 2 12-16-2014 03:25 PM
Display AdoptSpotlight anywhere? c: pachoofoosh Questions and Supports 11 07-07-2013 02:53 PM
Display codes for all of your adoptables kisazeky Questions and Supports 9 09-03-2010 03:32 PM


All times are GMT -5. The time now is 03:59 AM.

Currently Active Users: 475 (0 members and 475 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