Advertisement
algore87

warenkorb.php

Jan 10th, 2016
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.66 KB | None | 0 0
  1. <?php   // UTF-8 marker äöüÄÖÜ߀
  2. /**
  3.  * Class BlockTemplate for the exercises of the EWA lecture
  4.  * Demonstrates use of PHP including class and OO.
  5.  * Implements Zend coding standards.
  6.  * Generate documentation with Doxygen or phpdoc
  7.  *
  8.  * PHP Version 5
  9.  *
  10.  * @category File
  11.  * @package  Pizzaservice
  12.  * @author   Bernhard Kreling, <b.kreling@fbi.h-da.de>
  13.  * @author   Ralf Hahn, <ralf.hahn@h-da.de>
  14.  * @license  http://www.h-da.de  none
  15.  * @Release  1.2
  16.  * @link     http://www.fbi.h-da.de
  17.  */
  18.  
  19. /**
  20.  * This is a template for classes, which represent div-blocks
  21.  * within a web page. Instances of these classes are used as members
  22.  * of top level classes.
  23.  * The order of methods might correspond to the order of thinking
  24.  * during implementation.
  25.  
  26.  * @author   Bernhard Kreling, <b.kreling@fbi.h-da.de>
  27.  * @author   Ralf Hahn, <ralf.hahn@h-da.de>
  28. */
  29.  
  30. class Warenkorb        // to do: change name of class
  31. {
  32.     // --- ATTRIBUTES ---
  33.  
  34.     /**
  35.      * Reference to the MySQLi-Database that is
  36.      * accessed by all operations of the class.
  37.      */
  38.     protected $_database = null;
  39.    
  40.     // to do: declare reference variables for members
  41.     // representing substructures/blocks
  42.    
  43.     // --- OPERATIONS ---
  44.    
  45.     /**
  46.      * Gets the reference to the DB from the calling page template.
  47.      * Stores the connection in member $_database.
  48.      *
  49.      * @param $database $database is the reference to the DB to be used    
  50.      *
  51.      * @return none
  52.      */
  53.     public function __construct($database)
  54.     {
  55.         $this->_database = $database;
  56.         // to do: instantiate members representing substructures/blocks
  57.     }
  58.  
  59.     /**
  60.      * Fetch all data that is necessary for later output.
  61.      * Data is stored in an easily accessible way e.g. as associative array.
  62.      *
  63.      * @return none
  64.      */
  65.     protected function getViewData()
  66.     {
  67.         // to do: fetch data for this view from the database
  68.     }
  69.    
  70.     /**
  71.      * Generates an HTML block embraced by a div-tag with the submitted id.
  72.      * If the block contains other blocks, delegate the generation of their
  73.      * parts of the view to them.
  74.      *
  75.      * @param $id $id is the unique (!!) id to be used as id in the div-tag    
  76.      *
  77.      * @return none
  78.      */
  79.     public function generateView($id = "")
  80.     {
  81.         $this->getViewData();
  82.         if ($id) {
  83.             $id = "id=\"$id\"";
  84.         }
  85.         echo "<div $id>\n";
  86.         echo <<< EOT
  87. <h3>Warenkorb <span hidden>Name - Anzahl - Preis</span></h3>
  88. <label>
  89.     <select id="warenkorb" name="Warenkorb[]" size="5" multiple dropzone="copy" ondrop="drop(event);" ondragover="allowDrop(event);" title="Pizzanamen">
  90.     </select>
  91. </label>
  92. <input type="button" name="deleteall" value="Alle l&ouml;schen" onclick="removeAllPizzas();"/>
  93. <input type="button" name="deleteselected" value="Auswahl l&ouml;schen" onclick="removeTargetPizza();"/>
  94. <input id="preisfeld" type="text" name="preis" hidden/>
  95. <h4 id="gesamtpreis">Endbetrag: 0.00 &euro;</h4>
  96. <h3>Lieferadresse</h3>
  97. <label><input pattern="[a-zA-Zäöüß-]{3,}" type="text" id="nachname" name="nachname" placeholder="Nachname" maxlength="30" required/> </label>
  98. <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>
  99. <label><input pattern="[0-9]{5}" type="text" id="plz" name="plz" title="F&uuml;nfstellige PLZ in Deutschland." placeholder="PLZ" maxlength="10" required /> </label>
  100. <label><input pattern="[a-zA-Zäöüß-]{3,}" type="text" id="ort" name="ort" placeholder="Wohnort" maxlength="40" required/> </label>
  101. <p><button id="submitbutton" type="submit" onclick="preSubmit();" disabled>Bestellen</button></p>
  102. EOT;
  103. /* <label><input pattern="[0-9]{12}" id="telefon" name="tel" placeholder="Mobiltelefon"  title="Zu kurze Handynummer" required/> </label> */
  104.         echo "</div>\n";
  105.     }
  106.    
  107.     /**
  108.      * Processes the data that comes via GET or POST i.e. CGI.
  109.      * If this block is supposed to do something with submitted
  110.      * data do it here.
  111.      * If the block contains other blocks, delegate processing of the
  112.      * respective subsets of data to them.
  113.      *
  114.      * @return none
  115.      */
  116.     public function processReceivedData()
  117.     {
  118.         // to do: call processData() for all members
  119.     }
  120. }
  121. // Zend standard does not like closing php-tag!
  122. // PHP doesn't require the closing tag (it is assumed when the file ends).
  123. // Not specifying the closing ? >  helps to prevent accidents
  124. // like additional whitespace which will cause session
  125. // initialization to fail ("headers already sent").
  126. //? >
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement