Author: basos
Date: 2010-02-03 13:34:25 +0100 (Wed, 03 Feb 2010)
New Revision: 27487

Added:
   
plugins/sfSimplePagePlugin/trunk/modules/sfSimplePage/actions/components.class.php
   
plugins/sfSimplePagePlugin/trunk/modules/sfSimplePage/lib/BasesfSimplePageComponents.class.php
   plugins/sfSimplePagePlugin/trunk/modules/sfSimplePage/templates/_static.php
Modified:
   plugins/sfSimplePagePlugin/trunk/README
   
plugins/sfSimplePagePlugin/trunk/modules/sfSimplePage/lib/BasesfSimplePageActions.class.php
   
plugins/sfSimplePagePlugin/trunk/modules/sfSimplePage/templates/indexSuccess.php
Log:
ADDed the sfSimplePage/static component to embed static pages anywhere in the 
view layer


Modified: plugins/sfSimplePagePlugin/trunk/README
===================================================================
--- plugins/sfSimplePagePlugin/trunk/README     2010-02-03 12:23:51 UTC (rev 
27486)
+++ plugins/sfSimplePagePlugin/trunk/README     2010-02-03 12:34:25 UTC (rev 
27487)
@@ -76,9 +76,20 @@
         
         The application is responsible for management of a sane sf_culture 
session variable. 
         Read i18n support in "symfony book".
+        
+  * [Optional] Use the component sfSimplePage/static ('file'=>$file) from 
anywhere in the view layer to embed static
+      content on every page you desire.
+      
+    e.g. in apps/frontend/modules/product/templates/showSuccess.php
+      [...]
+      ><div id="terms">
+      ><?php include_component('sfSimplePage','static', 
array('file'=>'terms.html') ) ?>
+      ></div>
+      will output the contents of terms.html file inside the #terms div !
+    
 NOTES:
 -----
-    The names of the route prefix and the static content directory can be 
changed 
+ *  The names of the route prefix and the static content directory can be 
changed 
     from the application app.yml configuration file
     
     e.g. in apps/frontend/config/app.yml:
@@ -86,4 +97,6 @@
     >  sf_simple_page_plugin_route_prefix: documentation
     >  sf_simple_page_plugin_template_path: %SF_DATA_DIR%/doc
     This will mean that the route prefix for static content is documentation 
(i.e. domain.com/index.php/documentation) and
-    that the file data are in data/doc relative to sympfony root on a typical 
installation
\ No newline at end of file
+    that the file data are in data/doc relative to sympfony root on a typical 
installation
+
+    
\ No newline at end of file

Added: 
plugins/sfSimplePagePlugin/trunk/modules/sfSimplePage/actions/components.class.php
===================================================================
--- 
plugins/sfSimplePagePlugin/trunk/modules/sfSimplePage/actions/components.class.php
                          (rev 0)
+++ 
plugins/sfSimplePagePlugin/trunk/modules/sfSimplePage/actions/components.class.php
  2010-02-03 12:34:25 UTC (rev 27487)
@@ -0,0 +1,15 @@
+<?php
+
+require_once dirname(__FILE__).'/../lib/BasesfSimplePageComponents.class.php';
+
+/**
+ * sfSimplePage component.
+ * 
+ * @package    sfSimplePagePlugin
+ * @subpackage sfSimplePage
+ * @author     Your name here
+ * @version    SVN: $Id: actions.class.php 12628 2008-11-04 14:43:36Z 
Kris.Wallsmith $
+ */
+class sfSimplePageComponents extends BasesfSimplePageComponents
+{
+}

Modified: 
plugins/sfSimplePagePlugin/trunk/modules/sfSimplePage/lib/BasesfSimplePageActions.class.php
===================================================================
--- 
plugins/sfSimplePagePlugin/trunk/modules/sfSimplePage/lib/BasesfSimplePageActions.class.php
 2010-02-03 12:23:51 UTC (rev 27486)
+++ 
plugins/sfSimplePagePlugin/trunk/modules/sfSimplePage/lib/BasesfSimplePageActions.class.php
 2010-02-03 12:34:25 UTC (rev 27487)
@@ -20,47 +20,9 @@
     $route_prefix = '/'. trim( $route_prefix, '/' ) ;
     $pathinfo = preg_replace( "#^{$route_prefix}#", "", $pathinfo ) ;
 
-    //check i18n support
-    $culture = '' ;
-    $cult_template_path = '' ;
-    $gen_template_path = 
sfConfig::get("app_sf_simple_page_plugin_template_path", "static") . 
DIRECTORY_SEPARATOR . ltrim($pathinfo,'/');     
-    if ( sfConfig::get('app_sf_simple_page_plugin_use_i18n', false ) ) {
-        $culture = $this->getUser()->getCulture() ;
-        $cult_template_path = 
sfConfig::get("app_sf_simple_page_plugin_template_path", "static") . 
DIRECTORY_SEPARATOR . 
-            $culture . DIRECTORY_SEPARATOR . ltrim($pathinfo,'/');
-    }
+    // prepare component file parameter
+    $this->file = $pathinfo ;
     
-    $template_path =  ( (boolean)$culture ? $cult_template_path  : 
$gen_template_path ) ;
-    // check whether file is ended with directory separator or not
-    // if ended with '/', add "index.html"
-    if (preg_match("#/$#Di", $template_path)) {
-      $template_path .= "index.html";
-    }
-       
-    // check template file
-    $in = dirname($template_path);
-    $name = basename($template_path);
-    $files = sfFinder::type('file')
-             ->maxdepth(0)
-             ->name($name)
-             ->ignore_version_control()
-             ->in($in);
-    
-    // if i18n files were not found give it another try in the template path
-    if ( (boolean)$culture ) {
-        if ( !count($files) ) {
-            $in = dirname($gen_template_path);
-            $name = basename($gen_template_path);
-            $files = sfFinder::type('file')
-                     ->maxdepth(0)
-                     ->name($name)
-                     ->ignore_version_control()
-                     ->in($in);
-        }
-    }
-    $this->forward404unless(count($files)==1, "File not found ". $name );
-    // set template file path
-    $this->include_file_path = $files[0];
     return sfView::SUCCESS;
   }
 }

Added: 
plugins/sfSimplePagePlugin/trunk/modules/sfSimplePage/lib/BasesfSimplePageComponents.class.php
===================================================================
--- 
plugins/sfSimplePagePlugin/trunk/modules/sfSimplePage/lib/BasesfSimplePageComponents.class.php
                              (rev 0)
+++ 
plugins/sfSimplePagePlugin/trunk/modules/sfSimplePage/lib/BasesfSimplePageComponents.class.php
      2010-02-03 12:34:25 UTC (rev 27487)
@@ -0,0 +1,64 @@
+<?php
+
+/**
+ * Base components for the sfSimplePagePlugin sfSimplePage module.
+ * 
+ * @package     sfSimplePagePlugin
+ * @subpackage  sfSimplePage
+ * @author      Your name here
+ * @version     SVN: $Id: BaseActions.class.php 12628 2008-11-04 14:43:36Z 
Kris.Wallsmith $
+ */
+abstract class BasesfSimplePageComponents extends sfComponents
+{
+  public function executeStatic()
+  {  
+    if ( !isset( $this->file ) ) {
+        throw new sfException("Logical error: static component file parameter 
missing") ;
+    }
+
+    $pathinfo = $this->file ;
+    //check i18n support
+    $culture = '' ;
+    $cult_template_path = '' ;
+    $gen_template_path = 
sfConfig::get("app_sf_simple_page_plugin_template_path", "static") . 
DIRECTORY_SEPARATOR . ltrim($pathinfo,'/');     
+    if ( sfConfig::get('app_sf_simple_page_plugin_use_i18n', false ) ) {
+        $culture = $this->getUser()->getCulture() ;
+        $cult_template_path = 
sfConfig::get("app_sf_simple_page_plugin_template_path", "static") . 
DIRECTORY_SEPARATOR . 
+            $culture . DIRECTORY_SEPARATOR . ltrim($pathinfo,'/');
+    }
+    
+    $template_path =  ( (boolean)$culture ? $cult_template_path  : 
$gen_template_path ) ;
+    // check whether file is ended with directory separator or not
+    // if ended with '/', add "index.html"
+    if (preg_match("#/$#Di", $template_path)) {
+      $template_path .= "index.html";
+    }
+       
+    // check template file
+    $in = dirname($template_path);
+    $name = basename($template_path);
+    $files = sfFinder::type('file')
+             ->maxdepth(0)
+             ->name($name)
+             ->ignore_version_control()
+             ->in($in);
+    
+    // if i18n files were not found give it another try in the template path
+    if ( (boolean)$culture ) {
+        if ( !count($files) ) {
+            $in = dirname($gen_template_path);
+            $name = basename($gen_template_path);
+            $files = sfFinder::type('file')
+                     ->maxdepth(0)
+                     ->name($name)
+                     ->ignore_version_control()
+                     ->in($in);
+        }
+    }
+    if ( 1 !== count($files) ) {
+        throw new sfError404Exception("File not found ". $name ) ;
+    }
+    // set template file path
+    $this->include_file_path = $files[0];
+  }
+}

Added: 
plugins/sfSimplePagePlugin/trunk/modules/sfSimplePage/templates/_static.php
===================================================================
--- plugins/sfSimplePagePlugin/trunk/modules/sfSimplePage/templates/_static.php 
                        (rev 0)
+++ plugins/sfSimplePagePlugin/trunk/modules/sfSimplePage/templates/_static.php 
2010-02-03 12:34:25 UTC (rev 27487)
@@ -0,0 +1 @@
+<?php include_once($include_file_path) ?>
\ No newline at end of file

Modified: 
plugins/sfSimplePagePlugin/trunk/modules/sfSimplePage/templates/indexSuccess.php
===================================================================
--- 
plugins/sfSimplePagePlugin/trunk/modules/sfSimplePage/templates/indexSuccess.php
    2010-02-03 12:23:51 UTC (rev 27486)
+++ 
plugins/sfSimplePagePlugin/trunk/modules/sfSimplePage/templates/indexSuccess.php
    2010-02-03 12:34:25 UTC (rev 27487)
@@ -1 +1 @@
-<?php include_once($include_file_path) ?>
\ No newline at end of file
+<?php include_component('sfSimplePage', 'static', array('file'=>$file)) ?>
\ No newline at end of file

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to