Author: Jonathan.Wage
Date: 2010-02-10 18:48:06 +0100 (Wed, 10 Feb 2010)
New Revision: 27833

Added:
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalAdminPlugin/modules/sympal_themes/templates/previewSuccess.php
Modified:
   plugins/sfSympalPlugin/trunk/config/app.yml
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalAdminPlugin/config/routing.yml
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalAdminPlugin/modules/sympal_themes/lib/Basesympal_themesActions.class.php
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalAdminPlugin/modules/sympal_themes/templates/indexSuccess.php
   plugins/sfSympalPlugin/trunk/lib/sfSympalConfiguration.class.php
   plugins/sfSympalPlugin/trunk/lib/util/sfSympalFormToolkit.class.php
Log:
[1.4][sfSympalPlugin][1.0] Enhancing theme configurations for available and 
disabled. Also enhanced the themes modules to allow previewing and making it 
the default theme globally or for the current site by clicking buttons next to 
each theme


Modified: plugins/sfSympalPlugin/trunk/config/app.yml
===================================================================
--- plugins/sfSympalPlugin/trunk/config/app.yml 2010-02-10 17:39:07 UTC (rev 
27832)
+++ plugins/sfSympalPlugin/trunk/config/app.yml 2010-02-10 17:48:06 UTC (rev 
27833)
@@ -109,21 +109,29 @@
     # Configure Sympal themes
     themes:
       default:
+        available: true
+        disabled: false
         layout: default
         stylesheets:
           - /sfSympalPlugin/css/default.css
 
       wordpress_default:
+        available: true
+        disabled: false
         layout: wordpress
         stylesheets:
           - /sfSympalPlugin/css/wordpress.css
 
       sympal:
+        available: true
+        disabled: false
         layout: sympal
         stylesheets:
           - /sfSympalPlugin/css/sympal.css
 
       admin:
+        available: false # Don't show in the list of available themes to 
switch to
+        disabled: false
         layout: admin
         admin_generator_class: sfSympalDoctrineGenerator
         admin_generator_theme: sympal_admin

Modified: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalAdminPlugin/config/routing.yml
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalAdminPlugin/config/routing.yml 
    2010-02-10 17:39:07 UTC (rev 27832)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalAdminPlugin/config/routing.yml 
    2010-02-10 17:48:06 UTC (rev 27833)
@@ -108,6 +108,10 @@
   url:    /admin/themes
   param: { module: sympal_themes, action: index }
 
+sympal_themes_make_default:
+  url:    /admin/themes/make_default/:name/:site
+  param: { module: sympal_themes, action: make_default, site: 0 }
+
 sympal_themes_preview:
   url:    /admin/themes/:preview
   param: { module: sympal_themes, action: index }
\ No newline at end of file

Modified: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalAdminPlugin/modules/sympal_themes/lib/Basesympal_themesActions.class.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalAdminPlugin/modules/sympal_themes/lib/Basesympal_themesActions.class.php
   2010-02-10 17:39:07 UTC (rev 27832)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalAdminPlugin/modules/sympal_themes/lib/Basesympal_themesActions.class.php
   2010-02-10 17:48:06 UTC (rev 27833)
@@ -12,14 +12,41 @@
 {
   public function executeIndex(sfWebRequest $request)
   {
-    $this->themes = 
$this->getSympalContext()->getSympalConfiguration()->getThemes();
+    $this->themes = 
$this->getSympalContext()->getSympalConfiguration()->getAvailableThemes();
 
     if ($preview = $request->getParameter('preview'))
     {
       $this->getResponse()->setTitle(sprintf('Sympal Admin / Previewing %s', 
$preview));
       $this->loadTheme($preview);
+      $this->setTemplate('preview');
     } else {
       $this->getResponse()->setTitle(sprintf('Sympal Admin / Themes'));
     }
   }
+
+  public function executeMake_default(sfWebRequest $request)
+  {
+    $theme = $request->getParameter('name');
+
+    if ($request->getParameter('site'))
+    {
+      $site = $this->getSympalContext()->getSite();
+      $this->askConfirmation('Are you sure?', sprintf('This action will change 
the default theme to "%s" for the "%s" site.', $theme, $site->getTitle()));
+      if ($site->getTheme() == $theme)
+      {
+        $site->setTheme(null);
+      } else {
+        $site->setTheme($theme);
+      }
+      $site->save();
+    } else {
+      $this->askConfirmation('Are you sure?', sprintf('This action will change 
the global default theme to "%s"', $theme));
+      sfSympalConfig::writeSetting('default_theme', $theme);
+    }
+
+    $this->clearCache();
+    $this->getUser()->setFlash('notice', 'Theme successfully changed!');
+
+    $this->redirect('@sympal_themes');
+  }
 }
\ No newline at end of file

Modified: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalAdminPlugin/modules/sympal_themes/templates/indexSuccess.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalAdminPlugin/modules/sympal_themes/templates/indexSuccess.php
       2010-02-10 17:39:07 UTC (rev 27832)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalAdminPlugin/modules/sympal_themes/templates/indexSuccess.php
       2010-02-10 17:48:06 UTC (rev 27833)
@@ -1,10 +1,40 @@
 <h1><?php echo __('Themes') ?></h1>
 
-<p><?php echo __('Preview the available themes in this Sympal project. Click a 
-theme name below to see what it looks like!') ?></p>
-
-<ul>
-  <?php foreach ($themes as $name => $theme): ?>
-    <li><?php echo link_to(sfInflector::humanize($name), 
'@sympal_themes_preview?preview='.$name) ?></li>
-  <?php endforeach; ?>
-</ul>
\ No newline at end of file
+<div id="sf_admin_container">
+  <div id="sf_admin_content">
+    <div class="sf_admin_list">
+      <table cellspacing="0">
+        <thead>
+          <tr>
+            <th width="100%">Name</th>
+            <th></th>
+            <th></th>
+            <th></th>
+          </tr>
+        </thead>
+        <tbody>
+          <?php foreach ($themes as $name => $theme): ?>
+            <tr>
+              <td><strong><?php echo sfInflector::humanize($name) 
?></strong></td>
+              <td>
+                <?php echo button_to(__('Preview'), 
'@sympal_themes_preview?preview='.$name) ?>
+              </td>
+              <td>
+                <?php if ($name != sfSympalConfig::get('default_theme')): ?>
+                  <?php echo button_to(__('Make Global Default'), 
'@sympal_themes_make_default?name='.$name) ?>
+                <?php endif; ?>
+              </td>
+              <td>
+                <?php if ($name != $sf_sympal_context->getSite()->getTheme()): 
?>
+                  <?php echo button_to(__('Make %1% Default', array('%1%' => 
$sf_sympal_context->getSite()->getTitle())), 
'@sympal_themes_make_default?site=1&name='.$name) ?>
+                <?php else: ?>
+                  <?php echo button_to(__('Remove %1% Default', array('%1%' => 
$sf_sympal_context->getSite()->getTitle())), 
'@sympal_themes_make_default?site=1&name='.$name) ?>
+                <?php endif; ?>
+              </td>
+            </tr>
+          <?php endforeach; ?>
+        </tbody>
+      </table>
+    </div>
+  </div>
+</div>
\ No newline at end of file

Added: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalAdminPlugin/modules/sympal_themes/templates/previewSuccess.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalAdminPlugin/modules/sympal_themes/templates/previewSuccess.php
                             (rev 0)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalAdminPlugin/modules/sympal_themes/templates/previewSuccess.php
     2010-02-10 17:48:06 UTC (rev 27833)
@@ -0,0 +1,3 @@
+<h1><?php echo __('Previewing "%1%" Theme', array('%1%' => 
$sf_request->getParameter('preview'))) ?></h1>
+
+<?php echo __('You are previewing the <strong>%1%</strong> theme. Go back to 
the %2%.', array('%1%' => $sf_request->getParameter('preview'), '%2%' => 
link_to(__('list of themes'), '@sympal_themes'))) ?>
\ No newline at end of file

Modified: plugins/sfSympalPlugin/trunk/lib/sfSympalConfiguration.class.php
===================================================================
--- plugins/sfSympalPlugin/trunk/lib/sfSympalConfiguration.class.php    
2010-02-10 17:39:07 UTC (rev 27832)
+++ plugins/sfSympalPlugin/trunk/lib/sfSympalConfiguration.class.php    
2010-02-10 17:48:06 UTC (rev 27833)
@@ -11,7 +11,8 @@
     $_bootstrap,
     $_plugins = array(),
     $_modules = array(),
-    $_layouts = array(),
+    $_themes = null,
+    $_availableThemes = null,
     $_cache;
 
   public function __construct(sfEventDispatcher $dispatcher, 
ProjectConfiguration $projectConfiguration)
@@ -279,9 +280,38 @@
 
   public function getThemes()
   {
-    return sfSympalConfig::get('themes', null, array());
+    if ($this->_themes === null)
+    {
+      $themes = sfSympalConfig::get('themes', null, array());
+      foreach ($themes as $name => $theme)
+      {
+        if (isset($theme['disabled']) && $theme['disabled'] === true)
+        {
+          continue;
+        }
+        $this->_themes[$name] = $theme;
+      }
+    }
+    return $this->_themes;
   }
 
+  public function getAvailableThemes()
+  {
+    if ($this->_availableThemes === null)
+    {
+      $themes = $this->getThemes();
+      foreach ($themes as $name => $theme)
+      {
+        if (!isset($theme['available']) || (isset($theme['available']) && 
$theme['available'] === false))
+        {
+          continue;
+        }
+        $this->_availableThemes[$name] = $theme;
+      }
+    }
+    return $this->_availableThemes;
+  }
+
   public function getContentTemplates($model)
   {
     return sfSympalConfig::get($model, 'content_templates', array());

Modified: plugins/sfSympalPlugin/trunk/lib/util/sfSympalFormToolkit.class.php
===================================================================
--- plugins/sfSympalPlugin/trunk/lib/util/sfSympalFormToolkit.class.php 
2010-02-10 17:39:07 UTC (rev 27832)
+++ plugins/sfSympalPlugin/trunk/lib/util/sfSympalFormToolkit.class.php 
2010-02-10 17:48:06 UTC (rev 27833)
@@ -188,7 +188,7 @@
 
   public static function getThemeWidgetAndValidator()
   {
-    $themes = 
sfContext::getInstance()->getConfiguration()->getPluginConfiguration('sfSympalPlugin')->getSympalConfiguration()->getThemes();
+    $themes = 
sfContext::getInstance()->getConfiguration()->getPluginConfiguration('sfSympalPlugin')->getSympalConfiguration()->getAvailableThemes();
     $options = array('' => '');
     foreach ($themes as $name => $theme)
     {

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