All pastes #154409 Raw Edit

Unnamed

public php v1 · immutable
#154409 ·published 2006-08-30 10:08 UTC
rendered paste body
SearchServie<?phperror_reporting(E_ALL);/** * In dieser Klasse werden die Modelle Search und Product abgebildet, sie greift * nötig auf die Data Access Schicht zu. * * @author Christoph Nagel */if (0 > version_compare(PHP_VERSION, '5')) {    die('This file was generated for PHP 5');}/** * Die Klasse BrowseView ist für die Ansicht beim stöbern zuständig. * * @author Christoph Nagel */require_once('class.BrowseView.php');/** * Die ProductDAO Klasse ist für die Produkte zuständig, ihre Methoden enthält * SQL- Statements bezüglich der Produkte und nutzt die Methoden „retrieve“ oder * ,bei einer Datenbankabfrage, der Klasse DAO. Als Methodenparameter werden * Statemnets übergeben. * * @author firstname and lastname of author, <author@example.org> */require_once('class.ProductDAO.php');/* user defined includes */// section .:0000000000000B15-includes begin// section .:0000000000000B15-includes end/* user defined constants */// section .:0000000000000B15-constants begin// section .:0000000000000B15-constants end/** * In dieser Klasse werden die Modelle Search und Product abgebildet, sie greift * nötig auf die Data Access Schicht zu. * * @access public * @author Christoph Nagel */class SearchService{    // --- ATTRIBUTES ---    /**     * Attribut der Klasse SearchService     *     * @access private     * @var ProductDao     */    private $m_dao = null;    /**     * Attribut der Klasse SearchService     *     * @access public     * @var SearchService     */    public static $m_searchService = null;    // --- OPERATIONS ---    /**     * Liefert alle Produkte als Suchergebniss und gibt sie aus     *     * @access public     * @author firstname and lastname of author, <author@example.org>     * @return object     */    public function findAll()    {        $returnValue = null;        // section .:0000000000000AFB begin        $returnValue = $this->m_dao->findAll();        // section .:0000000000000AFB end        return $returnValue;    }    /**     * Sucht nach Produkten, deren Beschreibung eingegeben wurde und gibt sie     *     * @access public     * @author firstname and lastname of author, <author@example.org>     * @param string     * @return object     */    public function searchByDescription($description)    {        $returnValue = null;        // section .:0000000000000AFF begin        $returnValue = $this->m_dao->searchByDescription($description);        // section .:0000000000000AFF end        return $returnValue;    }    /**     * Sucht nach Produkten, die dem eingegebenen Preis entsprechen und gibt sie     *     * @access public     * @author firstname and lastname of author, <author@example.org>     * @param float     * @return object     */    public function searchByPrice($price)    {        $returnValue = null;        // section .:0000000000000B03 begin        $returnValue = $this->m_dao->searchByPrice($price);        // section .:0000000000000B03 end        return $returnValue;    }    /**     * Sucht nach Produkten die sich in einer eingegebenen Kategorie befinden     * gibt sie aus     *     * @access public     * @author firstname and lastname of author, <author@example.org>     * @param string     * @return object     */    public function searchByCategory($category)    {        $returnValue = null;        // section .:0000000000000B07 begin        $returnValue = $this->m_dao->searchByCategory($category);        // section .:0000000000000B07 end        return $returnValue;    }    /**     * Sucht ein Produkt direkt über die ID und gibt es aus     *     * @access public     * @author firstname and lastname of author, <author@example.org>     * @param int     * @return object     */    public function searchByID($ID)    {        $returnValue = null;        // section .:0000000000000B0B begin        // section .:0000000000000B0B end        return $returnValue;    }    /**     * Erzeugt einen Standart Konstruktor     *     * @access protected     * @author firstname and lastname of author, <author@example.org>     * @return void     */    public function __construct()    {        // section .:0000000000000B0E begin        $this->m_dao = ProductDAO::getInstance();        // section .:0000000000000B0E end    }    /**     * Erzeugt eine Instanz der Klasse SearchService     *     * @access public     * @author firstname and lastname of author, <author@example.org>     * @return object     */    public static function getInstance()    {        $returnValue = null;        // section .:0000000000000B11 begin        if(!isset(self::$m_searchService))			self::$m_searchService = new SearchService();		$returnValue = self::$m_searchService;        // section .:0000000000000B11 end        return $returnValue;    }} /* end of class SearchService */?>SearchView<?phperror_reporting(E_ALL);/** * Die Klasse SearchView ist für die Ansicht der Suchmaske zusändig. * * @author Christoph Nagel */if (0 > version_compare(PHP_VERSION, '5')) {    die('This file was generated for PHP 5');}/** * In dieser Klasse werden die Modelle Search und Product abgebildet, sie greift * nötig auf die Data Access Schicht zu. * * @author Christoph Nagel */require_once('class.SearchService.php');/** * Die abstrakte Klasse View ist die Elternklasse aller Views (OrderView, * SearchView, BrowseView, OrderStatusView) in der View Schicht. Sie stellt die * Methode „display():void“ zur Verfügung. Zur Erstellung eigener Views müssen * Klassen erstellt werden, welche von der Klasse View erben und die abstrakte * umsetzten. * * @author Christoph Nagel */require_once('class.View.php');/* user defined includes */// section .:0000000000000B81-includes begin// section .:0000000000000B81-includes end/* user defined constants */// section .:0000000000000B81-constants begin// section .:0000000000000B81-constants end/** * Die Klasse SearchView ist für die Ansicht der Suchmaske zusändig. * * @access public * @author Christoph Nagel */class SearchView    extends View{    // --- ATTRIBUTES ---    /**     * Attribut der Klasse SearchView     *     * @access private     * @var arry     */    private $m_request = null;    // --- OPERATIONS ---    /**     * Gibt das Suchergebnis am Bildschirm aus     *     * @access public     * @author firstname and lastname of author, <author@example.org>     * @return void     */    public function display()    {        // section .:0000000000000B7C begin        if (array_key_exists('description', $this->m_request))			$desc = $this->m_request['description'];		if (array_key_exists('price', $this->m_request))			$price = $this->m_request['price'];		if (array_key_exists('category', $this->m_request))			$category = $this->m_request['category'];		if (!empty ($desc)) {			$daresult = SearchService::getInstance()->searchByDescription($desc);		}		if (!empty ($price)){			$price = 0.0;			$daresult = SearchService::getInstance()->serachByPrice($price);		} else{				if (!empty ($category))				$daresult = SearchService::getInstance()->searchByCategory($category);			}    		if ($daresult->rowCount() == 0) {			echo "Kein Eintrag gefunden";		} else {			echo "Search results:<br>\n<table>\n";			for ($i = 0; $i < $daresult->rowCount(); $i ++) {				echo "\t<tr>\n";				$row = $daresult->getRow();				if ($i == 0) {					$keys = array_keys($row);					foreach ($keys as $keyname) {						echo "\t\t<td><b>$keyname</b></td>\n";					}					echo "\t</tr>\n\t<tr>\n";				}				foreach ($row as $col_value) {					echo "\t\t<td>$col_value</td>\n";				}				echo "\t</tr>\n";			}			echo "</table>\n";		}        // section .:0000000000000B7C end    }    /**     * Erzeugt einen Konstruktor, der die Anfrage als Übergabeparameter bekommt     *     * @access public     * @author firstname and lastname of author, <author@example.org>     * @param array     * @return void     */    public function __construct($request)    {        // section .:0000000000000B80 begin			$this->m_request = $request;        // section .:0000000000000B80 end    }} /* end of class SearchView */?>