public
Description: Git mirror of the CMS Made Simple 2.0 rewrite
Homepage: http://cmsmadesimple.org
Clone URL: git://github.com/tedkulp/cmsmadesimple-2-0.git
Search Repo:
Added caching to hierarchy manager

git-svn-id: http://svn.cmsmadesimple.org/svn/cmsmadesimple/trunk@2429 
3d254a34-79dc-0310-9e5f-be208747d8a0
tedkulp (author)
Thu Jan 12 19:57:26 -0800 2006
commit  b75260f00bec78f2a8ee165275fb881b65ec102a
tree    260896b45fecf00acf4de483b842bee3a8c769a5
parent  b2a79cc3bf5b9945144ddcdebcdafaa893950249
...
1898
1899
1900
1901
 
 
1902
1903
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1904
1905
1906
...
1972
1973
1974
 
 
 
 
 
 
1975
1976
1977
...
1898
1899
1900
 
1901
1902
1903
 
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
...
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
0
@@ -1898,9 +1898,33 @@ class ContentManager
0
    * @param onlyexpanded : array of expanded contents ids. null if whole
0
    tree should be loaded
0
    */
0
- function & GetAllContentAsHierarchy($loadprops=true,$onlyexpanded=null) {
0
+ function & GetAllContentAsHierarchy($loadprops=true,$onlyexpanded=null)
0
+ {
0
     global $gCms;
0
- $db = &$gCms->db;
0
+
0
+ $cachefilename = TMP_CACHE_LOCATION . '/contentcache.php';
0
+ if (isset($gCms->variables['pageinfo']) && file_exists($cachefilename))
0
+ {
0
+ $pageinfo =& $gCms->variables['pageinfo'];
0
+ debug_buffer('content cache file exists... file: ' . filemtime($cachefilename) . ' content:' . $pageinfo->content_last_modified_date);
0
+ if (isset($pageinfo->content_last_modified_date) && $pageinfo->content_last_modified_date < filemtime($cachefilename))
0
+ {
0
+ debug_buffer('file needs loading');
0
+
0
+ $handle = fopen($cachefilename, "r");
0
+ $data = fread($handle, filesize($cachefilename));
0
+ fclose($handle);
0
+
0
+ $data = unserialize(substr($data, 16));
0
+
0
+ $variables =& $gCms->variables;
0
+ $variables['contentcache'] =& $data;
0
+
0
+ return $data;
0
+ }
0
+ }
0
+
0
+ $db = &$gCms->GetDb();
0
 
0
     // first, retrieve number of children
0
     $childrenCount = array();
0
@@ -1972,6 +1996,12 @@ class ContentManager
0
     }
0
     $toReturn = new ContentHierarchyManager();
0
     $toReturn->setRoot($root);
0
+
0
+ debug_buffer("Serializing...");
0
+ $handle = fopen($cachefilename, "w");
0
+ fwrite($handle, '<?php return; ?>'.serialize($toReturn));
0
+ fclose($handle);
0
+
0
     return $toReturn;
0
 
0
   }

Comments

    No one has commented yet.