/** * Add a unique key to the key index * * @internal * @access private * @param string key to add */ public static function add_key($key) { if (!is_array(self::$_keys)) { self::$_keys = array(); } if (!in_array($key, self::$_keys)) { self::$_keys[] = $key; } }
/** * Loads a set of content objects into the cached tree. * * @param boolean $loadprops If true, load the properties of those content objects * @param boolean $onlyexpanded Not implemented * @param boolean $loadcontent If false, only create the nodes in the tree, * don't load the content objects * @return mixed The cached tree of content */ function &GetAllContentAsHierarchy($loadcontent = false) { debug_buffer('', 'starting tree'); $gCms = cmsms(); $db = $gCms->GetDb(); $tree = null; $cachefilename = TMP_CACHE_LOCATION . '/contentcache.php'; $loadedcache = false; if (file_exists($cachefilename)) { $last_modified = cms_utils::get_app_data('last_content_modification'); if ($last_modified <= 0) { } $query = 'SELECT modified_date FROM ' . cms_db_prefix() . 'content ORDER BY modified_date DESC'; $val = $db->GetOne($query); $last_modified = $db->UnixTimeStamp($val); cms_utils::set_app_data('last_content_modification', $last_modified); if ($last_modified > 0 && $last_modified < filemtime($cachefilename)) { debug_buffer('Content tree file needs loading'); $handle = fopen($cachefilename, "r"); $data = fread($handle, filesize($cachefilename)); fclose($handle); $tree = unserialize(substr($data, 16)); if (strtolower(get_class($tree)) == 'cms_content_tree') { $loadedcache = true; } else { $loadedcache = false; } } } if (!$loadedcache) { debug_buffer('', 'Start Loading Children into Tree'); $query = 'SELECT content_id,parent_id,content_alias FROM ' . cms_db_prefix() . 'content ORDER BY parent_id,item_order'; $nodes = $db->GetArray($query); $tree = cms_tree_operations::load_from_list($nodes); debug_buffer('', 'End Loading Children into Tree'); } if (!$loadedcache) { debug_buffer("Serializing..."); @file_put_contents($cachefilename, '<?php return; ?>' . serialize($tree)); } if ($loadcontent) { $this->LoadChildren(-1, true, true); } debug_buffer('', 'ending tree'); return $tree; }
/** * Loads a set of content objects into the cached tree. * * @param boolean $loadprops If true, load the properties of those content objects * @param boolean $onlyexpanded Not implemented * @param boolean $loadcontent If false, only create the nodes in the tree, * don't load the content objects * @return mixed The cached tree of content */ function &GetAllContentAsHierarchy($loadcontent = false) { debug_buffer('', 'starting tree'); $gCms = cmsms(); $db = $gCms->GetDb(); $tree = null; $cachefilename = TMP_CACHE_LOCATION . '/contentcache.php'; $loadedcache = false; if (file_exists($cachefilename)) { $last_modified = cms_utils::get_app_data('last_content_modification'); if (!$last_modified) { } $query = 'SELECT modified_date FROM ' . cms_db_prefix() . 'content ORDER BY modified_date DESC'; $val = $db->GetOne($query); $last_modified = $db->UnixTimeStamp($val); cms_utils::set_app_data('last_content_modification', $last_modified); if ($last_modified > 0 && $last_modified < filemtime($cachefilename)) { debug_buffer('file needs loading'); $handle = fopen($cachefilename, "r"); $data = fread($handle, filesize($cachefilename)); fclose($handle); $tree = unserialize(substr($data, 16)); if (strtolower(get_class($tree)) == 'cms_content_tree') { $loadedcache = true; } else { die('problem loading cache'); $loadedcache = false; } } } if (!$loadedcache) { $query = "SELECT id_hierarchy,content_alias FROM " . cms_db_prefix() . "content ORDER BY hierarchy"; $dbresult = $db->Execute($query); $nodes = array(); if ($dbresult && $dbresult->RecordCount() > 0) { while ($row = $dbresult->FetchRow()) { $nodes[] = $row['id_hierarchy'] . ',' . $row['content_alias']; } $dbresult->Close(); } debug_buffer('', 'Start Loading Children into Tree'); $tree = cms_tree_operations::load_from_list($nodes); debug_buffer('', 'End Loading Children into Tree'); } if (!$loadedcache) { debug_buffer("Serializing..."); @file_put_contents($cachefilename, '<?php return; ?>' . serialize($tree)); } if ($loadcontent) { $this->LoadChildren(-1, true, true); } debug_buffer('', 'ending tree'); return $tree; }