/** * Cached extraction of content element field information * this cached version is shared between pages and hence makes a big improvement to load times * for newly visited pages in a cached scenario * * @param string $reference_table * @return value */ public function contentElementFields($reference_table) { static $info; if (!isset($info)) { $info = array(); } if (!isset($info[$reference_table])) { $cacheDir = JPATH_CACHE; $cacheFile = $cacheDir . "/" . $reference_table . "_cefields.cache"; if (file_exists($cacheFile)) { $cacheFileContent = file_get_contents($cacheFile); $info[$reference_table] = unserialize($cacheFileContent); } else { $jfm = JoomFishManager::getInstance(); $contentElement = $jfm->getContentElement($reference_table); // The language is not relevant for this function so just use the current language $registry = JFactory::getConfig(); $lang = $registry->getValue("config.jflang"); include_once JPATH_ADMINISTRATOR . DS . "components" . DS . "com_joomfish" . '/models/ContentObject.php'; $contentObject = new ContentObject($jfm->getLanguageID($lang), $contentElement); $textFields = $contentObject->getTextFields(); $info[$reference_table]["textFields"] = $textFields; $info[$reference_table]["fieldTypes"] = array(); if ($textFields !== null) { $defaultSet = false; foreach ($textFields as $field) { $info[$reference_table]["fieldTypes"][$field] = $contentObject->getFieldType($field); } } $cacheFileContent = serialize($info[$reference_table]); $handle = @fopen($cacheFile, "w"); if ($handle) { fwrite($handle, $cacheFileContent); fclose($handle); } } } return $info[$reference_table]; }