PDA

View Full Version : Alter Shop Table?


Abronsyth
08-25-2014, 10:09 AM
Just trying to make things less cluttered in general. I did something similar for my adoption page, but this is confusing me quite a bit.

I am trying to remove the columns "Category" "type" and "name" from the shop page. I am using Mys 1.3.3 and this is the shop file:
<?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}");
}
}
elseif($mysidia->input->post("shoptype") == "adoptshop"){
$shop = new Adoptshop($mysidia->input->get("shop"));
$adopt = $shop->getadopt($mysidia->input->post("adopttype"));
$adopt->assign($mysidia->user->username);

$shop->purchase($adopt);
$document->setTitle($mysidia->lang->global_transaction_complete);
$document->addLangvar("{$mysidia->lang->purchase_adopt}{$adopt->getcost($shop->salestax)} {$mysidia->settings->cost}");
}
else throw new InvalidActionException($mysidia->lang->global_action);
}
}
?>

I just can't seem to find the place I would edit to remove these three columns?

Thanks for any help,
Abron

IntoRain
08-25-2014, 05:13 PM
Seeing this:

$shoplist = new Shoplist($mysidia->input->post("shoptype"));
$shoplist->display();

I'd say it's on the file class_shoplist.php, function display() (I don't have the files on hand atm so can't confirm)

Abronsyth
08-27-2014, 07:12 PM
Awesome! I found it on line 87 in class_shoplist.php, just had to edit buildHeaders and buildRow!

Thank you, IntoRain! I swear I'll get the hang of this eventually XD

IntoRain
08-27-2014, 10:26 PM
Glad you found it! ^^

Abronsyth
09-28-2014, 09:44 AM
Oookay so I've since updated to 1.3.4, and the files are a bit different, so I am a little perplexed on how to do the same exact thing:
<?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("templates/icons/next.gif"));
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 $shop, Item $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.");
}
}
?>

Any pointers?