Changeset 802

Show
Ignore:
Timestamp:
08/10/07 16:18:26 (1 year ago)
Author:
mikey
Message:

changed net.stubbles.websites.memphis.stubMemphisPageElement from an interface to an abstract class

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/websites/memphis/stubMemphisPageElement.php

    r267 r802  
    11<?php 
    22/** 
    3  * Interface for a memphis page element. 
     3 * Basic implementation for a memphis page element. 
    44 * 
    55 * @author      Frank Kleine <mikey@stubbles.net> 
     
    77 * @subpackage  websites_memphis 
    88 */ 
    9 stubClassLoader::load('net.stubbles.websites.stubPageElement'); 
     9stubClassLoader::load('net.stubbles.websites.stubAbstractPageElement'); 
    1010/** 
    11  * Interface for a memphis page element. 
     11 * Basic implementation for a memphis page element. 
    1212 * 
    1313 * @package     stubbles 
    1414 * @subpackage  websites_memphis 
    1515 */ 
    16 interface stubMemphisPageElement extends stubPageElement 
     16abstract class stubMemphisPageElement extends stubAbstractPageElement 
    1717{ 
    1818    /** 
    19      * set the source of the element 
     19     * for which part the page element applies 
    2020     * 
    21      * @param  string  $source 
     21     * @var  array<string> 
    2222     */ 
    23     public function setSource($source); 
     23    protected $parts = array(); 
    2424 
    2525    /** 
    26      * returns the source of the element 
     26     * checks whether the page element is available or not 
     27     *  
     28     * A memphis page element is available if the context contains a member with 
     29     * key part and if the value of this member is inside of the configured parts. 
    2730     * 
    28      * @return  string 
     31     * @param   stubRequest   $request   the request data 
     32     * @param   stubSession   $session   current session 
     33     * @param   stubResponse  $response  contains response data 
     34     * @param   array         $context   optional  additional context data 
     35     * @return  bool 
    2936     */ 
    30     public function getSource(); 
     37    public function isAvailable(stubRequest $request, stubSession $session, stubResponse $response, array $context = array()) 
     38    { 
     39        if (isset($context['part']) == false) { 
     40            return false; 
     41        } 
     42         
     43        return in_array($context['part'], $this->parts); 
     44    } 
     45 
     46    /** 
     47     * set the parts for which the element should be applied 
     48     * 
     49     * @param  string  $parts 
     50     */ 
     51    public function setParts($parts) 
     52    { 
     53        $this->parts = array_map('trim', explode(',', $parts)); 
     54    } 
    3155} 
    3256?>