Advertisement
algore87

auswahl_warenkorb.php

Jan 10th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.58 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 Auswahl_Warenkorb        // to do: change name of class
  31. {
  32.     // --- ATTRIBUTES ---
  33.     protected $auswahl = null;
  34.     protected $warenkorb = null;
  35.  
  36.     /**
  37.      * Reference to the MySQLi-Database that is
  38.      * accessed by all operations of the class.
  39.      */
  40.     protected $_database = null;
  41.    
  42.     // to do: declare reference variables for members
  43.     // representing substructures/blocks
  44.    
  45.     // --- OPERATIONS ---
  46.    
  47.     /**
  48.      * Gets the reference to the DB from the calling page template.
  49.      * Stores the connection in member $_database.
  50.      *
  51.      * @param $database $database is the reference to the DB to be used    
  52.      *
  53.      * @return none
  54.      */
  55.     public function __construct($database)
  56.     {
  57.         $this->_database = $database;
  58.         // to do: instantiate members representing substructures/blocks
  59.         require_once 'auswahl.php';
  60.         $this->auswahl = new Auswahl($this->_database);
  61.         require_once 'warenkorb.php';
  62.         $this->warenkorb = new Warenkorb($this->_database);
  63.     }
  64.  
  65.     /**
  66.      * Fetch all data that is necessary for later output.
  67.      * Data is stored in an easily accessible way e.g. as associative array.
  68.      *
  69.      * @return none
  70.      */
  71.     protected function getViewData()
  72.     {
  73.         // to do: fetch data for this view from the database
  74.     }
  75.    
  76.     /**
  77.      * Generates an HTML block embraced by a div-tag with the submitted id.
  78.      * If the block contains other blocks, delegate the generation of their
  79.      * parts of the view to them.
  80.      *
  81.      * @param $id $id is the unique (!!) id to be used as id in the div-tag    
  82.      *
  83.      * @return none
  84.      */
  85.     public function generateView($id = "")
  86.     {
  87.         $this->getViewData();
  88.         if ($id) {
  89.             $id = "id=\"$id\"";
  90.         }
  91.         echo "<div $id>\n";
  92.         $this->auswahl->generateView("div_auswahl");
  93.         $this->warenkorb->generateView("div_warenkorb");
  94.         echo "</div>\n";
  95.     }
  96.    
  97.     /**
  98.      * Processes the data that comes via GET or POST i.e. CGI.
  99.      * If this block is supposed to do something with submitted
  100.      * data do it here.
  101.      * If the block contains other blocks, delegate processing of the
  102.      * respective subsets of data to them.
  103.      *
  104.      * @return none
  105.      */
  106.     public function processReceivedData()
  107.     {
  108.         // to do: call processData() for all members
  109.     }
  110. }
  111. // Zend standard does not like closing php-tag!
  112. // PHP doesn't require the closing tag (it is assumed when the file ends).
  113. // Not specifying the closing ? >  helps to prevent accidents
  114. // like additional whitespace which will cause session
  115. // initialization to fail ("headers already sent").
  116. //? >
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement