function getItems() { global $common; $lines = $this->getLines(); if($lines == "" && count($lines) < 1) return ""; $items = array(); foreach($lines as $line) { if(!$common->contains($line, ":")) continue; if(!$common->contains($line, "=")) continue; $i = 1; $line = str_replace("\\:", ":", $line); $data = explode("=", $line, 2); $item_data = explode(":", $data[0]); // Create the item $item = new Shop_Item($item_data[0], $item_data[1]); $item_values = explode(",", $data[1]); foreach($item_values as $line_item) { $value = explode(":", $line_item); switch($i) { case 1: $item->setBuy($value[0], $value[1]); break; case 2: $item->setSell($value[0], $value[1]); break; case 3: $item->setStock($value[0], $value[1]); break; } $i++; } $items[] = $item; } return $items; }
} } } $file = $Shop->getShop($shop); if($file == false || $file == null) { $errors[] = "No shop with the name {$shop} was found."; } if(count($errors) < 1) { $data = explode(":", $item); $item = new Shop_Item($data[0], $data[1]); $item->setBuy($buyprice, $bundlebuy); $item->setSell($sellprice, $bundlesell); $item->setStock(0, $stock); if($Shop->addItem($item)) { $success = "<strong>Added item</strong> ".$items->getName($data[0] . ':' . $data[1])." to <strong>{$shop}</strong> - <a href='editor.php?edit={$shop}'>view changes</a> or add another:<br />"; } else { $errors[] = "Could not add item to {$shop} check to make sure the file is writable!"; } } } if(count($errors) > 0): echo '<p><strong>There was an error processing the form.</strong></p>'; echo '<ul>'; foreach($errors as $error): echo "<li>$error</li>";