private function handleItemOperations($request) { //include_once data handling class include_once __DIR__ . '/../dataController/ItemController.php'; $item = new ItemController(); //set data and header if (isset($request[1])) { //TODO: authorize first, then return a customer (customer login, admin) else respond with 401 $this->setResponseCodesAndData($item->getById($request[1]), 1); } else { //TODO: authorize first, then return all customers (admin only) else respond with 401 $this->setResponseCodesAndData($item->getAll(), 1); } }
public static function start($parameters) { switch ($parameters['target']) { case 'listOfItems': require_once dirname(__FILE__) . '/ItemController.php'; $body = ItemController::start(); $title = 'Tooted'; break; case 'listOfOrderPersons': require_once dirname(__FILE__) . '/OrderPersonController.php'; $body = OrderPersonController::start(array('target' => 'listOfOrderPersons')); $title = 'Kliendid'; break; case 'selectOrderPerson': require_once dirname(__FILE__) . '/OrderPersonController.php'; $body = OrderPersonController::start(array('id' => $_GET['id'], 'target' => 'selectOrderPerson')); $title = 'Kliendid'; break; default: exit('Mida teeme?'); } require_once dirname(__FILE__) . '/View.php'; echo View::buildView(array('body' => $body, 'title' => $title)); }
<?php require_once 'settings.php'; class ItemController { public static function start() { // get data require_once dirname(__FILE__) . '/Item.php'; $items = Item::getListOfTypeItem(array()); // get view require_once dirname(__FILE__) . '/ItemView.php'; $view = ItemView::buildListOfItems(array('items' => $items)); echo $view; } } ItemController::start();
// Vaatteen muokkaussivu - esittäminen $routes->get('/items/:item_id/edit', function ($item_id) { ItemController::edit($item_id); }); // Vaatteen muokkaussivu - käsittely $routes->post('/items/:item_id/edit', function ($item_id) { ItemController::update($item_id); }); // Vaatteen poisto $routes->post('/items/:item_id/destroy', function ($item_id) { ItemController::destroy($item_id); //HelloWorldController::sandbox(); }); // Store $routes->post('/items/', function () { ItemController::store(); }); // Wardrobes // Näytä oma vaatekaappi $routes->get('/wardrobe/', function () { WardrobeController::show_all_by_person_id(); }); $routes->get('/wardrobe/:user_id/', function () { WardrobeController::show_all_by_person_id(); }); // Lisää uusi vaate omaan vaatekaappiin - näkymä $routes->get('/wardrobe/:user_id/newitem/', function () { WardrobeController::create_new_item_to_wardrobe(); }); // Lisää uusi vaate omaan vaatekaappiin - käsittely $routes->post('/wardrobe/:user_id/newitem/', function () {
function POST($matches) { $item = new ItemController($matches); $item->add(); }
<?php include_once 'header.php'; ?> <img id="top" src="top.png" alt=""> <div id="form_container"> <h1><a>Eliminar Items</a></h1> <form id="form_492329" class="appnitro" method="post" action="decider.php"> <div class="form_description"> <h2>Eliminar items</h2> <p>Aca va a ir un search box con autocompletado.</p> </div> <ul > <?php require_once 'controladoras/ItemController.php'; ItemController::getInstance()->getAllItems(); foreach (ItemController::$resultsFromSearch as $item) { ?> <a href="decider.php?removeId=<?php echo $item->getId(); ?> "><li> <?php echo $item->getName(); ?> <?php echo $item->getCode(); ?> </li></a><?php } ?>
public function testSetSystemValue() { $post = array('somesetting' => 'this is a test'); $request = new Request(null, $post); // create an api mock object $api = $this->getAPIMock(array('setSystemValue')); // expects to be called once with the method // setSystemValue('somesetting', 'this is a test') $api->expects($this->once())->method('setSystemValue')->with($this->equalTo('somesetting'), $this->equalTo('this is a test')); // we want to return the appname apptemplate_advanced when this method // is being called $api->expects($this->any())->method('getAppName')->will($this->returnValue('apptemplate_advanced')); $controller = new ItemController($api, $request, null); $response = $controller->setSystemValue(null); // check if the correct parameters of the json response are set $this->assertEquals($post, $response->getParams()); }
function searchForItems($searchBox) { $mc = MysqlConnectionHandler::getInstance(); $conn = $mc->getDbConn(); if (!$conn) { echo "OMG"; } else { $statement = $conn->prepare("select * from Item where code LIKE CONCAT('%', ?, '%') OR name LIKE CONCAT('%', ?, '%') or id =?"); if ($statement) { $id = $searchBox; if (is_numeric($id)) { $id = intval($id); $statement->bind_param("ssi", $searchBox, $searchBox, $id); } else { $id = 0; $statement->bind_param("ssi", $searchBox, $searchBox, $id); } $statement->execute(); $return = $statement->get_result(); $statement->close(); $ireturn = array(); while ($item = $return->fetch_row()) { $itemret = new Auto(); $itemret->setId($item[0]); $itemret->setName($item[1]); $itemret->setCode($item[2]); array_push($ireturn, $itemret); } ItemController::$resultsFromSearch = $ireturn; return True; } else { return false; } } }
<?php session_start(); require_once 'config.php'; require_once 'controladoras/ItemController.php'; foreach ($_POST as $key => $value) { if ($key == "form_id") { if ($_POST["form_id"] == '492329') { $ret = ItemController::getInstance()->saveItem($_POST); header("Location:http://" . $host . "/" . $mainURI . "/addItem.php"); } } else { if ($key == "idToUpdate") { $ret = ItemController::getInstance()->updateItem(); header("Location:http://" . $host . "/" . $mainURI . "/index.php"); } } } foreach ($_GET as $key => $value) { if ($key == 'removeId') { $ret = ItemController::getInstance()->eliminarItem($_GET['removeId']); } else { if ($key == "updateFormSearchInput") { $_SESSION['allItemsSet'] = 1; $searchBox = $_GET["updateFormSearchInput"]; ItemController::getInstance()->searchForItems($searchBox); include_once 'updateItem.php'; } } }
public function loadtags() { // load controller require_once ZOO_ADMIN_PATH . "/controllers/item.php"; // perform the request task $controller = new ItemController(); $controller->execute('loadtags'); $controller->redirect(); }
ini_set('display_errors', 1); define("APPPATH", realpath(__DIR__ . "/../app") . DIRECTORY_SEPARATOR); require_once APPPATH . "/ClassLoader.php"; system\core\ClassLoader::registerDir(APPPATH . "/models/lib"); system\core\ClassLoader::registerDir(APPPATH . "/models"); system\core\ClassLoader::registerDir(APPPATH . "/models/util"); system\core\ClassLoader::registerDir(APPPATH . "/controllers"); system\core\ClassLoader::registerDir(APPPATH . "/views"); system\core\ClassLoader::registerDir(APPPATH . "/views/helper"); system\core\ClassLoader::registerDir(APPPATH . "/views/util"); if (!empty($_SERVER["PATH_INFO"])) { $path = $_SERVER["PATH_INFO"]; } else { $controller = new ErrorController(); $controller->render($_GET, 400, "PATH_INFO doesn't exist"); exit; } if (preg_match("!/item/([0-9]+)/?!", $path, $match)) { $_GET["id"] = $match[1]; $controller = new ItemController(); $controller->detail($_GET); } elseif (preg_match("!/items/?(.?+)!", $path, $match)) { $controller = new ItemController(); $controller->search($_GET); } elseif (preg_match("!/categories/?(.?+)!", $path, $match)) { $controller = new CategoryController(); $controller->search($_GET); } else { $controller = new ErrorController(); $controller->render($_GET, 404, "Request URL is no longer available"); }
ItemController::edit($id); }); $routes->post('/item/:id/edit', function ($id) { ItemController::update($id); }); $routes->post('/item/:id/destroy', function ($id) { ItemController::destroy($id); }); $routes->get('/item/:id/vendoritem', function ($id) { ItemController::addVendorItem($id); }); $routes->post('/item/:id/vendoritem', function ($id) { ItemController::storeVendorItem($id); }); $routes->post('/item/:id/vendoritem/remove', function ($id) { ItemController::removeVendorItem($id); }); // ItemType $routes->get('/itemtype', function () { ItemTypeController::index(); }); $routes->post('/itemtype', function () { ItemTypeController::store(); }); $routes->get('/itemtype/new', function () { ItemTypeController::create(); }); $routes->get('/itemtype/:id', function ($id) { ItemTypeController::show($id); }); $routes->get('/itemtype/:id/edit', function ($id) {