Update for caching
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 15 Aug 2014 14:39:47 +0000 (10:39 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 15 Aug 2014 14:40:31 +0000 (10:40 -0400)
Update to cache the serialized array from the paragraph part

Toolkit/Template/Page/Toolbox.php

index 6745c88..04e58b5 100644 (file)
@@ -387,7 +387,7 @@ class Toolkit_Template_Page_Toolbox implements Toolkit_Template_Page_IBody
                $cache = $this->cache->get("paragraphs-$id", 'Toolbox');
 
                if ($cache) {
-                       return $cache;
+                       return unserialize($cache);
                } else {
             $sections = array();
                        $page       = $this->pageGateway->find($id);
@@ -422,28 +422,24 @@ class Toolkit_Template_Page_Toolbox implements Toolkit_Template_Page_IBody
                                break;
                        }
 
-//                     $html = '';
                        $linksFormat = '<a href="#sect-%s">%s</a>';
                        foreach ($paragraphs as $paragraph) {
                                if ($paragraph['active']) {
                     $sect = array();
                     $sect = $paragraph;
-//                                     $html .= '<div class="listing" id="sect-'.$paragraph['id'].'">';
-//                                     $html .= "<h2>{$paragraph['title']}</h2>";
-                    $sect['image'] = $this->getParagraphImage($paragraph, $side[$key]);
-//                                     $html .= $this->getParagraphImage($paragraph, $side[$key]);
-                    $sect['description'] = $this->keywordReplacement->findAndReplace($paragraph['description']);
-//                                     $html .= $this->keywordReplacement->findAndReplace($paragraph['description']);
-                    $sect['files'] = $this->getParagraphFiles($paragraph['files']);
-//                                     $html .= $this->getParagraphFiles($paragraph['files']);
+                    $sect['image']
+                        = $this->getParagraphImage($paragraph, $side[$key]);
+                    $sect['description']
+                        = $this->keywordReplacement->
+                        findAndReplace($paragraph['description']);
+                    $sect['files']
+                        = $this->getParagraphFiles($paragraph['files']);
 
                                        if ($paragraph['back_to_top']) {
-                        $sect['back_to_top'] = '<a href="#toolbox">Back to Top</a>';
-//                                             $html .= '<a href="#toolbox">Back to Top</a>';
+                        $sect['back_to_top']
+                            = '<a href="#toolbox">Back to Top</a>';
                                        }
 
-//                                     $html .= '</div>';
-
                                        $this->paragraphLinks[] = sprintf(
                                                $linksFormat,
                                                $paragraph['id'],
@@ -454,8 +450,11 @@ class Toolkit_Template_Page_Toolbox implements Toolkit_Template_Page_IBody
                                }
                        }
 
-                       $this->cache->save($html, "paragraphs-$id", 'Toolbox');
-//                     return $html;
+                       $this->cache->save(
+                serialize($sections),
+                "paragraphs-$id",
+                'Toolbox'
+            );
             return $sections;
                }
        }
@@ -488,4 +487,3 @@ class Toolkit_Template_Page_Toolbox implements Toolkit_Template_Page_IBody
 
        //      }}}
 }
-?>