View Single Post
  #35  
Old 02-15-2016, 07:18 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 89,175
Kyttias is on a distinguished road
Default

It's quite bizarre that two other people have this mod installed on their site, other than myself, just fine and never experienced fatal errors. Yet, no matter how much I search, I can't find any helpful reference to a similar error that they would have fixed elsewhere. My classes/class_guicontainer.php and classes/class_guicomponent.php files identical to the default install!

EDIT: I can actually recreate your error... if you followed the instructions wrong, you replaced your entire view/inventoryview.php file instead of replacing only the index() function as instructed. Try replacing your entire file with this (or go back and follow the instructions more carefully):
  Spoiler: replace inventoryview.php 
PHP Code:
<?php

use Resource\Collection\LinkedList;

class 
InventoryView extends View{
    
    public function 
index(){
        
$mysidia Registry::get("mysidia");
        
$document $this->document;
        
$document->setTitle($mysidia->lang->inventory);
        
        
$inventory $this->getField("inventory");
        
        
$document->add(new Comment(" <style>
                .sc_item {
                  display: inline-table;
                  padding: 5px;
                  text-align: center;
                  font-family: 'Trebuchet MS', Helvetica, sans-serif;
                  font-size: 14px;
                  margin-bottom: 3px;
                  width: 120px;
                }
                .s_panel {
                  border-radius: 2px;
                  border: 1px solid #CCC;
                  background-color: #FBFDF2;  
                }
            </style> "
FALSE));
        
$iids $inventory->getiids();
        for(
$i 0$i $iids->length(); $i++){
            
$item $inventory->getitem($iids[$i]);
                 
            
# Descriptions of the item functions
            
switch ($item->function) {
                case 
"Click1"$usage "<br/><b>use:</b> Feed a pet to give them {$item->value} EXP."; break;
                case 
"Click2"$usage "<br/><b>use:</b> Feed a pet to set their EXP to {$item->value}."; break;
                case 
"Click3"$usage "<br/><b>use:</b> Resets EXP earned today to 0."; break;
                case 
"Level1"$usage "<br/><b>use:</b> Raises the Level of your pet by {$item->value}."; break;
                case 
"Level2"$usage "<br/><b>use:</b> Sets the Level of your pet to {$item->value}."; break;
                case 
"Level3"$usage "<br/><b>use:</b> Makes your pet Level 0 again!"; break;
                case 
"Gender"$usage "<br/><b>use:</b> Swaps the gender of your pet to its opposite!"; break;            
                default;
                    
$usage ""; break;
            }  
# End item function descriptions        

            
            # Rendering items now
            
$document->add(new Comment("
            <div class=\"s_panel sc_item\">
            <img rel=\"tooltip\" title=\"
{$item->description} <em>{$usage}</em>\" src=\"{$item->imageurl}\"/><br/>
              <b>
{$item->itemname}</b><br> Own &times;{$item->quantity}<br/>"FALSE));

            
# If item is consumable, add use button
            
if($item->consumable == "yes") {
                
$useForm = new FormBuilder("useform""inventory/uses""post");
                
$useForm->setLineBreak(FALSE);
                
$useForm->buildPasswordField("hidden""action""uses")
                        ->
buildPasswordField("hidden""itemname"$item->itemname)
                        ->
buildButton("Use""use""use");
                
$document->add($useForm);
            }

            
# Add sellback button so long as the item is not a key item
            
$sellback $item->price 2;
            
$document->add(new Comment("<hr>{$sellback} {$mysidia->settings->cost} Each "FALSE));
            if(
$item->category != "Key Items") {
                
$sellForm = new FormBuilder("sellform""inventory/sell""post");
                
$sellForm->setLineBreak(FALSE);
                
$sellForm->buildPasswordField("hidden""action""sell")
                         ->
buildPasswordField("hidden""itemname"$item->itemname);
                
                
$quantity = new TextField("quantity");
                
$quantity->setSize(3);
                
$quantity->setMaxLength(3);
                
$quantity->setLineBreak(FALSE);

                
$sell = new Button("Sell""sell""sell");
                
$sell->setLineBreak(FALSE);

                
$sellForm->add($quantity);
                
$sellForm->add($sell);
                            
$document->add($sellForm);
            }    

            
$document->add(new Comment("</div>"FALSE));   

        } 
# END item for loop

    
# END index function  
    
    
public function sell(){
        
$mysidia Registry::get("mysidia");
        
$document $this->document;
        
$document->setTitle($this->lang->global_transaction_complete);
        
$document->addLangvar("{$this->lang->sell}{$mysidia->input->post("quantity")} {$mysidia->input->post("itemname")} {$this->lang->sell2}");
    }
    
    public function 
toss(){
        
$mysidia Registry::get("mysidia");
        
$document $this->document;
        if(
$mysidia->input->get("confirm")){
            
$document->setTitle($this->lang->global_action_complete);
            
$document->addLangvar("{$this->lang->toss}{$mysidia->input->post("itemname")}{$this->lang->toss2}");
            return;
        }
    
        
$document->setTitle($this->lang->toss_confirm);
        
$document->addLangvar($this->lang->toss_warning);    

        
$confirmForm = new FormBuilder("confirmform""toss/confirm""post");
        
$confirmForm->buildPasswordField("hidden""action""toss")
                    ->
buildPasswordField("hidden""itemname"$mysidia->input->post("itemname"))
                    ->
buildButton("Please Toss""confirm""confirm");
        
$document->add($confirmForm);            
    }
}
?>


Anyway, yeah, the Key item thing seems to be a bug or afterthought with the baseline Mysidia framework... by the sounds of it. In classes/class_itemtablehelper.php, the category "Key Items" is referenced twice, rather than the function "Key". I literally just imitated the existing file to render the form, so I copied over the same error.

However, if I do create an item with the category "Key Items" on a default install, it renders as expected on a default install of Mysidia (you can never sell key items). I cannot actually recreate your problem on a default install whatsoever.

  Spoiler: screenshot of default install with key items working as intended 


So, this DOES come down to being a bug with my mod, AND I managed to fix it. The fix is in the file above. (I moved $document->add($sellForm); inside the if statement, because that makes more sense, anyway. The variable should have still never been built to display, anyway... but apparently it was?)
__________________
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.

Last edited by Kyttias; 02-15-2016 at 08:15 PM.
Reply With Quote