Author: Jonathan.Wage
Date: 2010-01-28 18:24:57 +0100 (Thu, 28 Jan 2010)
New Revision: 27281

Modified:
   plugins/sfSympalPlugin/trunk/lib/helper/SympalHelper.php
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/config/sfSympalEditorPluginConfiguration.class.php
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_editor/templates/_editor.php
Log:
[1.4][sfSympalPlugin][1.0] Fixing issue with editor when page cache is enabled


Modified: plugins/sfSympalPlugin/trunk/lib/helper/SympalHelper.php
===================================================================
--- plugins/sfSympalPlugin/trunk/lib/helper/SympalHelper.php    2010-01-28 
16:46:26 UTC (rev 27280)
+++ plugins/sfSympalPlugin/trunk/lib/helper/SympalHelper.php    2010-01-28 
17:24:57 UTC (rev 27281)
@@ -85,14 +85,13 @@
 function get_sympal_editor($menuItem = null, $content = null)
 {
   $sympalContext = sfSympalContext::getInstance();
-
-  $sympalContext->
+  $editorPluginConfigurartion = $sympalContext->
     getSymfonyContext()->
     getConfiguration()->
-    getPluginConfiguration('sfSympalEditorPlugin')->
-    loadEditorAssets()
-  ;
+    getPluginConfiguration('sfSympalEditorPlugin');
 
+  $editorPluginConfigurartion->loadEditorAssets();
+
   $content = $sympalContext->getCurrentContent();
   $menuItem = $sympalContext->getCurrentMenuItem();
 
@@ -106,7 +105,9 @@
     ));
   }
 
-  return get_partial('sympal_editor/editor');
+  return get_partial('sympal_editor/editor', array(
+    'loadInlineEditor' => $editorPluginConfigurartion->shouldLoadInlineEditor()
+  ));
 }
 
 /**

Modified: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/config/sfSympalEditorPluginConfiguration.class.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/config/sfSympalEditorPluginConfiguration.class.php
    2010-01-28 16:46:26 UTC (rev 27280)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/config/sfSympalEditorPluginConfiguration.class.php
    2010-01-28 17:24:57 UTC (rev 27281)
@@ -14,15 +14,24 @@
     $format = sfContext::getInstance()->getRequest()->getRequestFormat();
     $format = $format ? $format : 'html';
 
-    // Only load the editor if
-    // ... edit mode is on
-    // ... request format is html
-    return sfContext::getInstance()->getUser()->isEditMode()
-      && $format == 'html'
-      && !sfSympalConfig::get('page_cache', 'enabled')
-      && sfSympalConfig::get('inline_editing', 'enabled');
+    return sfContext::getInstance()->getUser()->isEditMode() && $format == 
'html';
   }
 
+  public function shouldLoadInlineEditor()
+  {
+    // Load inline editor if
+    // ...page caching is off
+    // ...and inline editing is enabled
+    // ...and we are editing a content record
+    // OR
+    // ...we are in the admin module
+    // ...and we are editing a content record
+    return (!sfSympalConfig::get('page_cache', 'enabled')
+      && sfSympalConfig::get('inline_editing', 'enabled')
+      && sfSympalContext::getInstance()->getCurrentContent())
+      || (sfSympalConfiguration::getActive()->isAdminModule() && 
sfSympalContext::getInstance()->getCurrentContent());
+  }
+
   public function loadEditor(sfEvent $event)
   {
     if ($this->shouldLoadEditor())

Modified: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_editor/templates/_editor.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_editor/templates/_editor.php
   2010-01-28 16:46:26 UTC (rev 27280)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalEditorPlugin/modules/sympal_editor/templates/_editor.php
   2010-01-28 17:24:57 UTC (rev 27281)
@@ -24,7 +24,7 @@
 
 <input type="hidden" id="sympal_base_url" value="<?php echo 
url_for('@homepage', 'absolute=true') ?>" />
 
-<?php if (isset($sf_sympal_content) && $sf_sympal_content): ?>
+<?php if ($loadInlineEditor): ?>
   <input type="hidden" id="sympal_save_slots_url" value="<?php echo 
url_for('@sympal_save_content_slots?content_id='.$sf_sympal_content->getId()) 
?>" />
   <div class="sympal_inline_edit_bar_bottom_background"></div>
 <?php endif; ?>
@@ -32,7 +32,7 @@
 <div class="sympal_inline_edit_bar_container">
   <div class="sympal_inline_edit_bar sympal_form">
   
-    <?php if (isset($sf_sympal_content) && $sf_sympal_content): ?>
+    <?php if ($loadInlineEditor): ?>
       <div class="sympal_inline_edit_bar_publish">
         <?php if ($sf_sympal_content->getIsPublished()): ?>
           <?php echo 
link_to(image_tag('/sfSympalPlugin/images/published_icon.png', 
'title='.__('Published on %date%', array('%date%' => 
format_date($sf_sympal_content->getDatePublished(), 'g'))).'. '.__('Click to 
unpublish content.')), 
'@sympal_unpublish_content?id='.$sf_sympal_content['id']) ?>
@@ -52,7 +52,7 @@
       <?php echo link_to(image_tag('/sfSympalPlugin/images/signout.png', 
'title='.__('Signout')), '@sympal_signout', 'confirm='.__('Are you sure you 
want to signout?')) ?>
     </div>
 
-    <?php if (isset($sf_sympal_content) && $sf_sympal_content): ?>
+    <?php if ($loadInlineEditor): ?>
       <ul class="sympal_inline_edit_bar_big_buttons">
         <?php if (sfSympalConfig::isI18nEnabled()): ?>
           <li>
@@ -90,7 +90,7 @@
   </div>
 </div>
 
-<?php if (isset($sf_sympal_content) && $sf_sympal_content): ?>
+<?php if ($loadInlineEditor): ?>
   <div id="sympal_assets"></div>
   <div id="sympal_links"></div>
   <div id="sympal_dashboard"></div>

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