Changeset 906

Show
Ignore:
Timestamp:
09/11/07 23:36:00 (11 months ago)
Author:
schst
Message:

Added the ability to add session resources to the DOM tree

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/examples/config/xml/pages/conf/index.xml

    r783 r906  
    88      <property name="skin">default</property> 
    99    </properties> 
     10    <resources> 
     11      <resource name="counter">net.stubbles.examples.resources.MyResource</resource> 
     12    </resources> 
    1013    <xmlElement type="net.stubbles.examples.pageelements.TestXMLPageElement" name="Test" /> 
    1114 
     
    1417    </xmlElementCachingDecorator> 
    1518    <xmlElement type="net.stubbles.examples.pageelements.CurrentTimeXMLPageElement" name="uncached" /> 
    16      
     19 
    1720    <xmlPassThru fileName="test.xml" name="passThru"> 
    1821      <cfg:stubConfig name="directory" method="getConfigPath" append="/misc"/> 
  • trunk/src/main/php/net/stubbles/examples/resources/MyResourceImpl.php

    r904 r906  
    1010    } 
    1111 
     12    /** 
     13     * get the current count value 
     14     * 
     15     * @return int 
     16     * @XMLTag(tagName='count') 
     17     */ 
    1218    public function getCount() { 
    1319        return $this->count; 
    1420    } 
    1521 
     22    /** 
     23     * Increment the count 
     24     * 
     25     * @XMLIgnore 
     26     */ 
    1627    public function incrementCount() { 
    1728        $this->count++; 
  • trunk/src/main/php/net/stubbles/websites/stubPage.php

    r589 r906  
    2222     */ 
    2323    protected $properties = array(); 
     24    /** 
     25     * Resources that are used by this page 
     26     * 
     27     * @var array<string,string> 
     28     */ 
     29    protected $resources  = array(); 
    2430    /** 
    2531     * list of the elements of this page 
     
    4955        $this->properties = $properties; 
    5056    } 
    51      
     57 
     58    /** 
     59     * sets the list of resources 
     60     * 
     61     * @param  array  $resources 
     62     */ 
     63    public function setResources(array $resources) 
     64    { 
     65        $this->resources = $resources; 
     66    } 
     67 
    5268    /** 
    5369     * checks whether a property for the page exists 
     
    7288            return $this->properties[$name]; 
    7389        } 
    74          
     90 
    7591        return null; 
     92    } 
     93 
     94    /** 
     95     * returns the list of resources 
     96     * 
     97     * @return array 
     98     */ 
     99    public function getResources() 
     100    { 
     101        return $this->resources; 
    76102    } 
    77103 
  • trunk/src/main/php/net/stubbles/websites/xml/stubXMLProcessor.php

    r857 r906  
    44 * 
    55 * @author      Frank Kleine <mikey@stubbles.net> 
     6 * @author      Stephan Schmidt <schst@stubbles.net> 
    67 * @package     stubbles 
    78 * @subpackage  websites_xml 
     
    6768            } 
    6869        } 
    69          
     70 
    7071        $xmlSerializer->serialize($formValues, $xmlStreamWriter, array(stubXMLSerializer::OPT_ROOT_TAG => 'forms')); 
    7172        $this->writeRequestValues($xmlStreamWriter, $xmlSerializer); 
     73 
     74        // write resources 
     75        $resourceManager = stubRegistry::get('net.stubbles.ipo.session.resourcemanager.stubSessionResourceManager'); 
     76        if ($resourceManager !== null) { 
     77            $xmlStreamWriter->writeStartElement('resources'); 
     78            foreach ($page->getResources() as $name => $interface) { 
     79               $resource = $resourceManager->getResource($interface); 
     80               $xmlSerializer->serialize($resource, $xmlStreamWriter, array(stubXMLSerializer::OPT_ROOT_TAG => $name)); 
     81            } 
     82            $xmlStreamWriter->writeEndElement(); 
     83        } 
     84 
    7285        // end document 
    7386        $xmlStreamWriter->writeEndElement(); 
  • trunk/src/main/resources/xjconf/websites.xml

    r813 r906  
    1111    <tag name="properties" type="array" /> 
    1212    <tag name="property" type="string" keyAttribute="name" /> 
    13      
     13    <tag name="resources" type="array" /> 
     14    <tag name="resource" type="array" keyAttribute="name"> 
     15      <attribute name="interface" type="string"/> 
     16    </tag> 
     17 
    1418    <abstractTag name="element" abstractType="net.stubbles.websites.stubPageElement" concreteTypeAttribute="type" setter="addElement" key="__none"> 
    1519      <attribute name="name" type="string" /> 
    1620    </abstractTag> 
    17      
     21 
    1822    <!-- Memphis --> 
    1923    <abstractTag name="memphisElement" extends="element" abstractType="net.stubbles.websites.memphis.stubMemphisPageElement" concreteTypeAttribute="type" setter="addElement" key="__none"> 
    2024      <attribute name="parts" type="string" /> 
    2125    </abstractTag> 
    22      
     26 
    2327    <tag name="includeFile" extends="memphisElement" type="net.stubbles.websites.memphis.stubMemphisIncludeFilePageElement" setter="addElement" key="__none"> 
    2428      <attribute name="source" type="string" /> 
    2529    </tag> 
    26      
     30 
    2731    <tag name="includeTemplate" extends="memphisElement" type="net.stubbles.websites.memphis.stubMemphisIncludeTemplatePageElement" setter="addElement" key="__none"> 
    2832      <attribute name="source" type="string" /> 
    2933    </tag> 
    30      
     34 
    3135    <!--tag name="loadExtension" extends="memphisElement" type="net.stubbles.websites.memphis.stubMemphisLoadExtensionPageElement" setter="addElement" key="__none"> 
    3236      <attribute name="extension" type="string" /> 
    3337    </tag--> 
    34      
     38 
    3539    <tag name="conditions" type="array"/> 
    3640    <abstractTag name="condition" abstractType="net.stubbles.websites.memphis.conditions.stubMemphisPageElementCondition" concreteTypeAttribute="type" setter="setCondition"> 
    3741      <attribute name="value" type="string" /> 
    3842    </abstractTag> 
    39      
     43 
    4044    <!-- XML/XSL --> 
    4145    <abstractTag name="xmlElement" extends="element" abstractType="net.stubbles.websites.xml.stubXMLPageElement" concreteTypeAttribute="type" setter="addElement" key="__none" /> 
     
    4549      <attribute name="fileName" type="string"/> 
    4650    </tag> 
    47      
     51 
    4852    <!-- Decorators --> 
    4953    <abstractTag name="xmlElementDecorator" abstractType="net.stubbles.websites.xml.stubXMLPageElement" concreteTypeAttribute="type" setter="addElement" key="__none">