Author: weaverryan
Date: 2010-02-07 21:16:04 +0100 (Sun, 07 Feb 2010)
New Revision: 27664

Added:
   
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/_latest_posts.php
   
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/_monthly_history.php
   
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/_top_authors.php
Modified:
   plugins/sfSympalBlogPlugin/branches/1.4/config/app.yml
   
plugins/sfSympalBlogPlugin/branches/1.4/lib/model/doctrine/PluginsfSympalBlogPostTable.class.php
   
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/lib/Basesympal_blogComponents.class.php
   
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/_list.php
   
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/_sidebar.php
   
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/_view.php
   
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/monthSuccess.php
   plugins/sfSympalBlogPlugin/branches/1.4/web/css/blog.css
Log:
[1.4][sfSympalBlogPlugin][1.0] Refactoring of the sidebar of this plugin as 
well as a few other details.

 * The "widgets" that render in the sidebar are now stored in app.yml and their 
order can be configured via the "display" key.
 * Fixed a bug with the months - it was programmed to only return months in 
which posts were published in the future (not past posts)
 * Removed a few of the very broad dom ids (e.g. "view") and replaced them with 
classes
 * Removed some excess args passed to get_sympal_breadcrumbs(), probably from 
older versions of that function


Modified: plugins/sfSympalBlogPlugin/branches/1.4/config/app.yml
===================================================================
--- plugins/sfSympalBlogPlugin/branches/1.4/config/app.yml      2010-02-07 
20:02:21 UTC (rev 27663)
+++ plugins/sfSympalBlogPlugin/branches/1.4/config/app.yml      2010-02-07 
20:16:04 UTC (rev 27664)
@@ -5,6 +5,14 @@
       content_templates:
         default_view:
           template: sympal_blog/view
+      sidebar:
+        # The widgets (and the order) that will be displayed. Defaults to ALL 
widgets
+        #display:      [latest_posts, top_authors, monthly_history]
+        widgets:
+          latest_posts: sympal_blog/latest_posts
+          top_authors:  sympal_blog/top_authors
+          monthly_history: sympal_blog/monthly_history
+          #my_sidebar_widget: template: my_module/sidebar
     content-list:
       content_templates:
         blog_post_list:

Modified: 
plugins/sfSympalBlogPlugin/branches/1.4/lib/model/doctrine/PluginsfSympalBlogPostTable.class.php
===================================================================
--- 
plugins/sfSympalBlogPlugin/branches/1.4/lib/model/doctrine/PluginsfSympalBlogPostTable.class.php
    2010-02-07 20:02:21 UTC (rev 27663)
+++ 
plugins/sfSympalBlogPlugin/branches/1.4/lib/model/doctrine/PluginsfSympalBlogPostTable.class.php
    2010-02-07 20:16:04 UTC (rev 27664)
@@ -28,21 +28,39 @@
     return $q->execute();
   }
 
+  /**
+   * Returns an array of months in which posts were published. The array
+   * takes the format:
+   * array(
+   *  'm/1/Y' => # of posts that month
+   * );
+   * 
+   * @return array
+   */
   public function retrieveMonths()
   {
     $now = new Doctrine_Expression('NOW()');
     $results = Doctrine_Core::getTable('sfSympalContent')
       ->getTypeQuery('sfSympalBlogPost')
       ->select('c.date_published')
-      ->where('c.date_published >= '.$now)
+      ->where('c.date_published <= '.$now)
       ->orderBy('c.date_published DESC')
       ->execute(array(), Doctrine_Core::HYDRATE_NONE);
     $months = array();
+    
     foreach ($results as $result)
     {
-      $months[] = date('m/1/Y', strtotime($result[0]));
+      $month = date('m/1/Y', strtotime($result[0]));
+      if (!isset($months[$month]))
+      {
+        $months[$month] = 1;
+      }
+      else
+      {
+        $months[$month]++;
+      }
     }
-    $months = array_unique($months);
+    
     return $months;
   }
 

Modified: 
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/lib/Basesympal_blogComponents.class.php
===================================================================
--- 
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/lib/Basesympal_blogComponents.class.php
 2010-02-07 20:02:21 UTC (rev 27663)
+++ 
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/lib/Basesympal_blogComponents.class.php
 2010-02-07 20:16:04 UTC (rev 27664)
@@ -12,8 +12,46 @@
 {
   public function executeSidebar()
   {
+    $config = sfSympalConfig::get('blog-post', 'sidebar', array());
+    
+    if (isset($config['display']))
+    {
+      $this->widgets = array();
+      foreach($config['display'] as $name)
+      {
+        if (in_array($name, $config['display']))
+        {
+          $this->widgets[] = $config['widgets'][$name];
+        }
+      }
+    }
+    else
+    {
+      $this->widgets = $config['widgets'];
+    }
+  }
+  
+  /**
+   * Executes the "latest posts" section of the sidebar
+   */
+  public function executeLatest_posts(sfWebRequest $request)
+  {
     $this->latestPosts = 
Doctrine::getTable('sfSympalBlogPost')->retrieveLatestPosts(5);
+  }
+  
+  /**
+   * Executes the "top authors" section of the sidebar
+   */
+  public function executeTop_authors(sfWebRequest $request)
+  {
     $this->authors = 
Doctrine::getTable('sfSympalBlogPost')->retrieveTopAuthors(5);
+  }
+  
+  /**
+   * Executes the "top authors" section of the sidebar
+   */
+  public function executeMonthly_history(sfWebRequest $request)
+  {
     $this->months = Doctrine::getTable('sfSympalBlogPost')->retrieveMonths();
   }
 }
\ No newline at end of file

Added: 
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/_latest_posts.php
===================================================================
--- 
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/_latest_posts.php
                             (rev 0)
+++ 
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/_latest_posts.php
     2010-02-07 20:16:04 UTC (rev 27664)
@@ -0,0 +1,6 @@
+<h3>Latest 5 Posts</h3>
+<ul>
+  <?php foreach ($latestPosts as $content): ?>
+    <li><?php echo link_to($content, $content->getRoute()) ?></li>
+  <?php endforeach; ?>
+</ul>
\ No newline at end of file

Modified: 
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/_list.php
===================================================================
--- 
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/_list.php 
    2010-02-07 20:02:21 UTC (rev 27663)
+++ 
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/_list.php 
    2010-02-07 20:16:04 UTC (rev 27664)
@@ -1,11 +1,11 @@
 <?php use_stylesheet('/sfSympalBlogPlugin/css/blog.css') ?>
 
-<?php echo get_sympal_breadcrumbs($menuItem, null, null, true) ?>
+<?php echo get_sympal_breadcrumbs($menuItem) ?>
 
 <?php echo auto_discovery_link_tag('rss', 
$content->getRoute().'?sf_format=rss') ?>
 
 <div id="sympal_blog">
-  <div id="list">
+  <div class="list">
     <h2><?php echo get_sympal_content_slot($content, 'title') ?></h2>
 
     <?php echo get_sympal_content_slot($content, 'header') ?>

Added: 
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/_monthly_history.php
===================================================================
--- 
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/_monthly_history.php
                          (rev 0)
+++ 
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/_monthly_history.php
  2010-02-07 20:16:04 UTC (rev 27664)
@@ -0,0 +1,6 @@
+<h3>History</h3>
+<ul>
+  <?php foreach ($months as $month => $postCount): ?>
+    <li><?php echo link_to(sprintf('%s (%s)', date('M Y', strtotime($month)), 
$postCount) , '@sympal_blog_month?m='.date('m', 
strtotime($month)).'&y='.date('Y', strtotime($month))) ?></li>
+  <?php endforeach; ?>
+</ul>
\ No newline at end of file

Modified: 
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/_sidebar.php
===================================================================
--- 
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/_sidebar.php
  2010-02-07 20:02:21 UTC (rev 27663)
+++ 
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/_sidebar.php
  2010-02-07 20:16:04 UTC (rev 27664)
@@ -1,23 +1,3 @@
-<h2>Latest 5 Posts</h2>
-
-<ul>
-  <?php foreach ($latestPosts as $content): ?>
-    <li><?php echo link_to($content, $content->getRoute()) ?></li>
-  <?php endforeach; ?>
-</ul>
-
-<h2>Top 5 Authors</h2>
-
-<ul>
-  <?php foreach ($authors as $author): ?>
-    <li><?php echo $author->getName() ?> (<?php echo $author->num_posts 
?>)</li>
-  <?php endforeach; ?>
-</ul>
-
-<h2>History</h2>
-
-<ul>
-  <?php foreach ($months as $month): ?>
-    <li><?php echo link_to(date('M Y', strtotime($month)), 
'@sympal_blog_month?m='.date('m', strtotime($month)).'&y='.date('Y', 
strtotime($month))) ?></li>
-  <?php endforeach; ?>
-</ul>
\ No newline at end of file
+<?php foreach ($widgets as $template): ?>
+  <?php echo sfSympalToolkit::getSymfonyResource($template) ?>
+<?php endforeach; ?>
\ No newline at end of file

Added: 
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/_top_authors.php
===================================================================
--- 
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/_top_authors.php
                              (rev 0)
+++ 
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/_top_authors.php
      2010-02-07 20:16:04 UTC (rev 27664)
@@ -0,0 +1,6 @@
+<h3>Top 5 Authors</h3>
+<ul>
+  <?php foreach ($authors as $author): ?>
+    <li><?php echo $author->getName() ?> (<?php echo $author->num_posts 
?>)</li>
+  <?php endforeach; ?>
+</ul>
\ No newline at end of file

Modified: 
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/_view.php
===================================================================
--- 
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/_view.php 
    2010-02-07 20:02:21 UTC (rev 27663)
+++ 
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/_view.php 
    2010-02-07 20:16:04 UTC (rev 27664)
@@ -1,10 +1,10 @@
 <?php use_stylesheet('/sfSympalBlogPlugin/css/blog.css') ?>
 
-<?php echo get_sympal_breadcrumbs($menuItem, $content) ?>
+<?php echo get_sympal_breadcrumbs($menuItem) ?>
 
 <div id="sympal_blog">
   <h2><?php echo get_sympal_content_slot($content, 'title') ?></h2>
-  <div id="view">
+  <div class="view">
     <?php echo 
image_tag(get_gravatar_url($content->CreatedBy->getEmailAddress()), 
'align=right') ?>
 
     <p>

Modified: 
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/monthSuccess.php
===================================================================
--- 
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/monthSuccess.php
      2010-02-07 20:02:21 UTC (rev 27663)
+++ 
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/templates/monthSuccess.php
      2010-02-07 20:16:04 UTC (rev 27664)
@@ -1,9 +1,9 @@
-<?php use_stylesheet('/sfSympalBlogPlugin/css/blog.css') ?>
+<?php use_stylesheet('/sfSympalBlogPlugin/css/blog.css', 'first') ?>
 
 <?php echo get_sympal_breadcrumbs($menuItem, $date = date('M Y', 
strtotime($month.'/01/'.$year))) ?>
 
 <div id="sympal_blog">
-  <div id="list">
+  <div class="list">
     <h2>Posts for the month of <?php echo $date ?></h2>
 
     <?php echo get_partial('sympal_blog/blog_list', array('pager' => $pager, 
'menuItem' => $menuItem, 'content' => $content)) ?>

Modified: plugins/sfSympalBlogPlugin/branches/1.4/web/css/blog.css
===================================================================
--- plugins/sfSympalBlogPlugin/branches/1.4/web/css/blog.css    2010-02-07 
20:02:21 UTC (rev 27663)
+++ plugins/sfSympalBlogPlugin/branches/1.4/web/css/blog.css    2010-02-07 
20:16:04 UTC (rev 27664)
@@ -1,4 +1,4 @@
-#sympal_blog #list .row
+#sympal_blog .list .row
 {
   -moz-border-radius: 10px;
   -webkit-border-radius: 10px;
@@ -11,7 +11,7 @@
   overflow/**/: auto;
 }
 
-#sympal_blog #list .row h3
+#sympal_blog .list .row h3
 {
   font-size: 16px;
   margin: 0;
@@ -19,7 +19,7 @@
   margin-bottom: 10px;
 }
 
-#sympal_blog #view
+#sympal_blog .view
 {
   -moz-border-radius: 10px;
   -webkit-border-radius: 10p

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