Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php // UTF-8 marker äöüÄÖÜ߀
- /**
- * Class BlockTemplate for the exercises of the EWA lecture
- * Demonstrates use of PHP including class and OO.
- * Implements Zend coding standards.
- * Generate documentation with Doxygen or phpdoc
- *
- * PHP Version 5
- *
- * @category File
- * @package Pizzaservice
- * @author Bernhard Kreling, <b.kreling@fbi.h-da.de>
- * @author Ralf Hahn, <ralf.hahn@h-da.de>
- * @license http://www.h-da.de none
- * @Release 1.2
- * @link http://www.fbi.h-da.de
- */
- /**
- * This is a template for classes, which represent div-blocks
- * within a web page. Instances of these classes are used as members
- * of top level classes.
- * The order of methods might correspond to the order of thinking
- * during implementation.
- * @author Bernhard Kreling, <b.kreling@fbi.h-da.de>
- * @author Ralf Hahn, <ralf.hahn@h-da.de>
- */
- class Warenkorb // to do: change name of class
- {
- // --- ATTRIBUTES ---
- /**
- * Reference to the MySQLi-Database that is
- * accessed by all operations of the class.
- */
- protected $_database = null;
- // to do: declare reference variables for members
- // representing substructures/blocks
- // --- OPERATIONS ---
- /**
- * Gets the reference to the DB from the calling page template.
- * Stores the connection in member $_database.
- *
- * @param $database $database is the reference to the DB to be used
- *
- * @return none
- */
- public function __construct($database)
- {
- $this->_database = $database;
- // to do: instantiate members representing substructures/blocks
- }
- /**
- * Fetch all data that is necessary for later output.
- * Data is stored in an easily accessible way e.g. as associative array.
- *
- * @return none
- */
- protected function getViewData()
- {
- // to do: fetch data for this view from the database
- }
- /**
- * Generates an HTML block embraced by a div-tag with the submitted id.
- * If the block contains other blocks, delegate the generation of their
- * parts of the view to them.
- *
- * @param $id $id is the unique (!!) id to be used as id in the div-tag
- *
- * @return none
- */
- public function generateView($id = "")
- {
- $this->getViewData();
- if ($id) {
- $id = "id=\"$id\"";
- }
- echo "<div $id>\n";
- echo <<< EOT
- <h3>Warenkorb <span hidden>Name - Anzahl - Preis</span></h3>
- <label>
- <select id="warenkorb" name="Warenkorb[]" size="5" multiple dropzone="copy" ondrop="drop(event);" ondragover="allowDrop(event);" title="Pizzanamen">
- </select>
- </label>
- <input type="button" name="deleteall" value="Alle löschen" onclick="removeAllPizzas();"/>
- <input type="button" name="deleteselected" value="Auswahl löschen" onclick="removeTargetPizza();"/>
- <input id="preisfeld" type="text" name="preis" hidden/>
- <h4 id="gesamtpreis">Endbetrag: 0.00 €</h4>
- <h3>Lieferadresse</h3>
- <label><input pattern="[a-zA-Zäöüß-]{3,}" type="text" id="nachname" name="nachname" placeholder="Nachname" maxlength="30" required/> </label>
- <label><input pattern="[a-zA-ZÄÖÜäöüß. -]{3,}[0-9]{1,}[a-z]{0,1}" type="text" id="strasse" name="strasse" placeholder="Strasse und Hausnr." maxlength="40" required/> </label>
- <label><input pattern="[0-9]{5}" type="text" id="plz" name="plz" title="Fünfstellige PLZ in Deutschland." placeholder="PLZ" maxlength="10" required /> </label>
- <label><input pattern="[a-zA-Zäöüß-]{3,}" type="text" id="ort" name="ort" placeholder="Wohnort" maxlength="40" required/> </label>
- <p><button id="submitbutton" type="submit" onclick="preSubmit();" disabled>Bestellen</button></p>
- EOT;
- /* <label><input pattern="[0-9]{12}" id="telefon" name="tel" placeholder="Mobiltelefon" title="Zu kurze Handynummer" required/> </label> */
- echo "</div>\n";
- }
- /**
- * Processes the data that comes via GET or POST i.e. CGI.
- * If this block is supposed to do something with submitted
- * data do it here.
- * If the block contains other blocks, delegate processing of the
- * respective subsets of data to them.
- *
- * @return none
- */
- public function processReceivedData()
- {
- // to do: call processData() for all members
- }
- }
- // Zend standard does not like closing php-tag!
- // PHP doesn't require the closing tag (it is assumed when the file ends).
- // Not specifying the closing ? > helps to prevent accidents
- // like additional whitespace which will cause session
- // initialization to fail ("headers already sent").
- //? >
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement