Author: lombardot
Date: 2010-01-26 19:08:06 +0100 (Tue, 26 Jan 2010)
New Revision: 27206

Modified:
   plugins/sfDatagridPlugin/lib/sfDatagrid.class.php
   plugins/sfDatagridPlugin/web/css/datagrid.css
Log:
[spyritAdminPlugin] lombardot You can now use sfDatagrid::renderDirect() if you 
don't want to use ajax for the first loading

Modified: plugins/sfDatagridPlugin/lib/sfDatagrid.class.php
===================================================================
--- plugins/sfDatagridPlugin/lib/sfDatagrid.class.php   2010-01-26 18:02:17 UTC 
(rev 27205)
+++ plugins/sfDatagridPlugin/lib/sfDatagrid.class.php   2010-01-26 18:08:06 UTC 
(rev 27206)
@@ -539,14 +539,101 @@
        public static function render($div, $url)
        {
                self::addScriptAndCss();
-               
                $html = '<div id="' . $div . '">' . '<div 
class="datagrid-loader" id="loader-' . $div . '">' . 
sfDatagrid::traduct(sfDatagrid::getConfig('text_loading')) . '</div>' . 
'</div>';
                
if(sfConfig::get('app_datagrid_jsframwork','prototype')=='prototype')
                        $html.= javascript_tag(remote_function(array('update' 
=> $div, 'url' => $url, 'script' => true, 'loading' => 'dg_hide_show(\'' . $div 
. '\')')));
                else
                        $html.=javascript_tag(jq_remote_function(array('update' 
=> $div, 'url' => $url, 'script' => true, 'loading' => 'dg_hide_show(\'' . $div 
. '\')')));
                return $html;
-       }
+       }
+       
+       public static function renderDirect($div,$moduleName,$actionName){
+               self::addScriptAndCss();
+               
+               self::get_action($moduleName, $actionName);
+               $html = '<div id="' . $div . '">' . 
sfContext::getInstance()->getResponse()->getContent(). '</div>';
+               return $html;
+               
+       }
+       
+       protected static function 
get_action($moduleName,$actionName,$vars=array()){
+               $context = sfContext::getInstance();
+               //$actionName = '_'.$componentName;
+       
+                 $class = 
sfConfig::get('mod_'.strtolower($moduleName).'_partial_view_class', 
'sf').'PartialView';
+                 $view = new $class($context, $moduleName, $actionName, '');
+                 $view->setPartialVars($vars);
+               
+                 if ($retval = $view->getCache())
+                 {
+                   return $retval;
+                 }
+               
+                 $allVars = self::_call_action($moduleName, $actionName, 
$vars);
+               
+                 if (null !== $allVars)
+                 {
+                   // render
+                   $view->getAttributeHolder()->add($allVars);
+               
+                   return $view->render();
+                 }
+       }
+       protected static function _call_action($moduleName, $actionName, $vars)
+               {
+                 $context = sfContext::getInstance();
+               
+                 $controller = $context->getController();
+                
+                 if (!$controller->actionExists($moduleName, $actionName))
+                 {
+                   // cannot find component
+                   throw new sfConfigurationException(sprintf('The action does 
not exist: "%s", "%s".', $moduleName, $componentName));
+                 }
+               
+                 // create an instance of the action
+                 $componentInstance = $controller->getAction($moduleName, 
$actionName);
+               
+                 
sfContext::getInstance()->getActionStack()->addEntry($moduleName,$actionName,$componentInstance);
+                 // load component's module config file
+                 
require($context->getConfigCache()->checkConfig('modules/'.$moduleName.'/config/module.yml'));
+               
+                 // pass unescaped vars to the component if escaping_strategy 
is set to true
+                 $componentInstance->getVarHolder()->add(true === 
sfConfig::get('sf_escaping_strategy') ? sfOutputEscaper::unescape($vars) : 
$vars);
+               
+                 // dispatch component
+                 $componentToRun = 'execute'.ucfirst($actionName);
+                 if (!method_exists($componentInstance, $componentToRun))
+                 {
+                   if (!method_exists($componentInstance, 'execute'))
+                   {
+                     // component not found
+                     throw new sfInitializationException(sprintf('sfComponent 
initialization failed for module "%s", component "%s".', $moduleName, 
$componentName));
+                   }
+               
+                   $componentToRun = 'execute';
+                 }
+               
+                 if (sfConfig::get('sf_logging_enabled'))
+                 {
+                   $context->getEventDispatcher()->notify(new sfEvent(null, 
'application.log', array(sprintf('Call "%s->%s()'.'"', $moduleName, 
$componentToRun))));
+                 }
+               
+                 // run component
+                 if (sfConfig::get('sf_debug') && 
sfConfig::get('sf_logging_enabled'))
+                 {
+                   $timer = sfTimerManager::getTimer(sprintf('Component 
"%s/%s"', $moduleName, $actionName));
+                 }
+               
+                 $retval = 
$componentInstance->$componentToRun($context->getRequest());
+               
+                 if (sfConfig::get('sf_debug') && 
sfConfig::get('sf_logging_enabled'))
+                 {
+                   $timer->addTime();
+                 }
+               
+                 return sfView::NONE == $retval ? null : 
$componentInstance->getVarHolder()->getAll();
+               }
        
        /**
         * Create and return the check box value in html

Modified: plugins/sfDatagridPlugin/web/css/datagrid.css
===================================================================
--- plugins/sfDatagridPlugin/web/css/datagrid.css       2010-01-26 18:02:17 UTC 
(rev 27205)
+++ plugins/sfDatagridPlugin/web/css/datagrid.css       2010-01-26 18:08:06 UTC 
(rev 27206)
@@ -24,9 +24,13 @@
 
 .datagrid-loader { display: none; left: 50%; top: 45%; position: absolute; 
margin-left: -102px; width: 200px; text-align: center; color:#d85909; padding: 
50px 0px 10px 0px; font-size: 14px; font-weight: bold; border:2px solid 
#f1af73; background: #fff4e9 url(../img/ajax-loader.gif) no-repeat center 10px; 
}
 
-.grid-actions { background-image: url(../img/actions-row.gif); border: 1px 
solid #DADFE0; width: 100%; } 
-.grid-actions td { height: 24px; padding: 0px 5px 0px 5px; border-top: 1px 
solid #FFFFFF; }
-.grid-actions td.left-actions a { color: #EB5E00; font-size: 11px; }
+.grid-actions ,  #sf_admin_container .grid-actions {  border: 1px solid 
#DADFE0; width: 100%;
+background-color:#EBEBEB;
+background-image:url(../img/actions-row.gif);
+background-position:center bottom;
+background-repeat:repeat-x;} 
+.grid-actions td, #sf_admin_container .grid-actions td { height: 24px; 
padding: 0px 5px 0px 5px; border-top: 1px solid #FFFFFF; }
+.grid-actions td.left-actions a,  #sf_admin_container .grid-actions 
td.left-actions a{ color: #EB5E00; font-size: 11px; }
 .grid-actions td select { width: 200px; }
 
        #sf_admin_container td{
@@ -44,7 +48,7 @@
 /*
 Copy in your css
 */
-#sf_admin_container fieldset#sf_datagrid_fieldset_none {
+#sf_admin_container fieldset#sf_datagrid_fieldset_none, #sf_admin_container 
.grid-actions fieldset#sf_datagrid_fieldset_none{
 border:0;
 }
 .form-elem{

-- 
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