Changeset 2629

Show
Ignore:
Timestamp:
07/29/08 13:50:05 (5 months ago)
Author:
david
Message:

Dumped "xhtml" output type from sample app and introduced a replacement, closes #802

Location:
branches/0.11
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • branches/0.11/CHANGELOG

    r2614 r2629  
    88ADD: Support for doctrine connection settings and options (#788) (David) 
    99 
     10CHG: Dump "xhtml" output type from sample app and introduce a replacement (#802) (David) 
    1011CHG: Assigning of "inner" content to $slots template array should be configurable (#793) (David) 
    1112 
  • branches/0.11/samples/app/config/output_types.xml

    r2370 r2629  
    22<configurations xmlns="http://agavi.org/agavi/1.0/config" xmlns:xi="http://www.w3.org/2001/XInclude"> 
    33 
     4  <!-- the sandbox. we can put anything in here. very useful for sharing stuff inside the document using XIncludes --> 
    45  <sandbox> 
    5  
    6     <renderers default="php"> 
    7        
    8       <renderer name="php" class="AgaviPhpRenderer"> 
    9         <parameter name="assigns"> 
    10           <parameter name="routing">ro</parameter> 
    11           <parameter name="request">rq</parameter> 
    12           <parameter name="controller">ct</parameter> 
    13           <parameter name="user">us</parameter> 
    14           <parameter name="translation_manager">tm</parameter> 
    15           <parameter name="request_data">rd</parameter> 
    16         </parameter> 
    17       </renderer> 
    18        
    19     </renderers> 
    20      
    21     <layouts default="default"> 
    22        
    23       <layout name="default"> 
    24         <layer name="content" /> 
    25         <layer name="decorator"> 
    26           <slot name="menu" module="Default" action="Menu" /> 
    27           <parameter name="directory">%core.template_dir%</parameter> 
    28           <parameter name="template">Master</parameter> 
    29         </layer> 
    30       </layout> 
    31        
    32       <layout name="slot"> 
    33         <layer name="content" /> 
    34       </layout> 
    35        
    36     </layouts> 
    37  
     6    <!-- our common layers that all layouts use. only the content layer in here, and empty, but who knows! --> 
     7    <layers> 
     8      <layer name="content" /> 
     9    </layers> 
    3810  </sandbox> 
    3911 
     
    4214 
    4315      <output_type name="html"> 
    44         <xi:include xpointer="xmlns(a=http://agavi.org/agavi/1.0/config) xpointer(/a:configurations/a:sandbox/a:renderers)" /> 
    45         <xi:include xpointer="xmlns(a=http://agavi.org/agavi/1.0/config) xpointer(/a:configurations/a:sandbox/a:layouts)" /> 
    46          
     16        <renderers default="php"> 
     17 
     18          <renderer name="php" class="AgaviPhpRenderer"> 
     19            <parameter name="assigns"> 
     20              <parameter name="routing">ro</parameter> 
     21              <parameter name="request">rq</parameter> 
     22              <parameter name="controller">ct</parameter> 
     23              <parameter name="user">us</parameter> 
     24              <parameter name="translation_manager">tm</parameter> 
     25              <parameter name="request_data">rd</parameter> 
     26            </parameter> 
     27          </renderer> 
     28 
     29        </renderers> 
     30 
     31        <layouts default="default"> 
     32 
     33          <layout name="default"> 
     34            <!-- include common layer definitions from the sandbox --> 
     35            <xi:include xpointer="xmlns(a=http://agavi.org/agavi/1.0/config) xpointer(/a:configurations/a:sandbox/a:layers/*)" /> 
     36            <!-- and then define those special tp this layout --> 
     37            <layer name="decorator"> 
     38              <slot name="menu" module="Default" action="Menu" /> 
     39              <parameter name="directory">%core.template_dir%</parameter> 
     40              <parameter name="template">Master</parameter> 
     41            </layer> 
     42          </layout> 
     43 
     44          <layout name="slot"> 
     45            <!-- include common layer definitions from the sandbox --> 
     46            <xi:include xpointer="xmlns(a=http://agavi.org/agavi/1.0/config) xpointer(/a:configurations/a:sandbox/a:layers/*)" /> 
     47          </layout> 
     48 
     49        </layouts> 
     50 
    4751        <parameter name="http_headers"> 
    4852          <parameter name="Content-Type">text/html; charset=UTF-8</parameter> 
     
    5054      </output_type> 
    5155 
    52       <output_type name="xhtml"> 
    53         <xi:include xpointer="xmlns(a=http://agavi.org/agavi/1.0/config) xpointer(/a:configurations/a:sandbox/a:renderers)" /> 
    54         <xi:include xpointer="xmlns(a=http://agavi.org/agavi/1.0/config) xpointer(/a:configurations/a:sandbox/a:layouts)" /> 
    55          
     56      <output_type name="json"> 
    5657        <parameter name="http_headers"> 
    57           <parameter name="Content-Type">application/xhtml+xml; charset=UTF-8</parameter> 
     58          <parameter name="Content-Type">application/json; charset=UTF-8</parameter> 
    5859        </parameter> 
    5960      </output_type> 
  • branches/0.11/samples/app/config/routing.xml

    r1949 r2629  
    1111      </route> 
    1212       
    13       <!-- If the HTTP Accept: header contains "application/xhtml+xml", set the output type to "xhtml". Look at output_types.xml for the declaration of that output type. Execution will not stop if this route matches. --> 
    14       <route pattern="application/xhtml+xml" source="_SERVER[HTTP_ACCEPT]" output_type="xhtml" stop="false" /> 
    15      
     13      <!-- If the HTTP Accept: header contains "application/json" (i.e. if you do an XMLHTTPRequest with one of the usual JS frameworks), set the output type to "json". Look at output_types.xml for the declaration of that output type. Execution will not stop if this route matches. This is nice for making XMLHTTPRequest calls. --> 
     14      <route pattern="application/json" source="_SERVER[HTTP_ACCEPT]" output_type="json" stop="false" /> 
     15       
    1616      <route name="disabled" pattern="^/disabled" module="Disabled" action="Index" /> 
    1717       
  • branches/0.11/samples/app/lib/view/AgaviSampleAppBaseView.class.php

    r2370 r2629  
    5858  } 
    5959   
    60   public function executeXhtml(AgaviRequestDataHolder $rd) 
     60  public function executeJson(AgaviRequestDataHolder $rd) 
    6161  { 
    62     if(method_exists($this, 'executeHtml')) { 
    63       return $this->executeHtml($rd); 
    64     } else { 
    65       return $this->execute($rd); 
    66     } 
     62    throw new AgaviViewException(sprintf( 
     63      'The View "%1$s" does not implement an "execute%3$s()" method to serve '. 
     64      'the Output Type "%2$s". It is recommended that you change the code of '. 
     65      'the method "execute%3$s()" in the base View "%4$s" that is throwing '. 
     66      'this exception to deal with this situation in a more appropriate '. 
     67      'way, for example by forwarding to the default 404 error action, or by '. 
     68      'showing some other meaningful error message to the user which explains '. 
     69      'that the operation was unsuccessful beacuse the desired Output Type is '. 
     70      'not implemented.', 
     71      get_class($this), 
     72      $this->container->getOutputType()->getName(), 
     73      ucfirst(strtolower($this->container->getOutputType()->getName())), 
     74      get_class() 
     75    )); 
    6776  } 
    6877   
  • branches/0.11/samples/app/modules/Default/views/SearchEngineSpamErrorView.class.php

    r1898 r2629  
    1010  { 
    1111    return $this->createForwardContainer(AgaviConfig::get('actions.error_404_module'), AgaviConfig::get('actions.error_404_action')); 
     12  } 
     13 
     14  /** 
     15   * Execute any presentation logic for JSON requests. 
     16   */ 
     17  public function executeJson(AgaviRequestDataHolder $rd) 
     18  { 
     19    return json_encode( 
     20      array( 
     21        '_error' => 404, 
     22      ) 
     23    ); 
    1224  } 
    1325 
  • branches/0.11/samples/app/modules/Default/views/SearchEngineSpamSuccessView.class.php

    r2370 r2629  
    1414    // set the title 
    1515    $this->setAttribute('title', $this->getContext()->getTranslationManager()->_('Congratulations!', 'default.SearchEngineSpam')); 
     16  } 
     17 
     18  /** 
     19   * Execute any presentation logic for JSON requests. 
     20   */ 
     21  public function executeJson(AgaviRequestDataHolder $rd) 
     22  { 
     23    return json_encode( 
     24      array( 
     25        'product_price' => $this->getAttribute('product_price'), 
     26      ) 
     27    ); 
    1628  } 
    1729