| Server IP : 195.130.67.5 / Your IP : 216.73.217.154 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Old Sites/Libteiser - Ojs/ojs2/classes/help/ |
Upload File : |
<?php
/**
* @file classes/help/HelpTocDAO.inc.php
*
* Copyright (c) 2003-2009 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class HelpTocDAO
* @ingroup help
* @see HelpToc
*
* @brief Operations for retrieving HelpToc objects.
*/
// $Id: HelpTocDAO.inc.php,v 1.20.2.1 2009/04/08 19:42:47 asmecher Exp $
import('help.HelpToc');
class HelpTocDAO extends XMLDAO {
function &_getCache($tocId) {
static $cache;
$locale = Help::getLocale();
if (!isset($cache[$locale][$tocId])) {
import('cache.CacheManager');
$help =& Help::getHelp();
$cacheManager =& CacheManager::getManager();
$cache[$locale][$tocId] = $cacheManager->getFileCache('help-toc-' . $help->getLocale(), $tocId, array($this, '_cacheMiss'));
// Check to see if the cache info is outdated.
$cacheTime = $cache[$locale][$tocId]->getCacheTime();
if ($cacheTime !== null && $cacheTime < filemtime($this->getFilename($tocId))) {
// The cached data is out of date.
$cache[$locale][$tocId]->flush();
}
}
return $cache[$locale][$tocId];
}
function _cacheMiss(&$cache, $id) {
static $data;
if (!isset($data)) {
$helpFile = $this->getFilename($cache->getCacheId());
$data = &$this->parseStruct($helpFile);
// check if data exists before saving it to cache
if ($data === false) {
$returner = false;
return $returner;
}
$cache->setEntireCache($data);
}
return null;
}
function &getMappingFile($tocId) {
$help =& Help::getHelp();
$mappingFiles =& $help->getMappingFiles();
for ($i=0; $i < count($mappingFiles); $i++) {
// "foreach by reference" hack
$mappingFile =& $mappingFiles[$i];
if ($mappingFile->containsToc($tocId)) return $mappingFile;
unset($mappingFile);
}
$returner = null;
return $returner;
}
function getFilename($tocId) {
$mappingFile =& $this->getMappingFile($tocId);
return $mappingFile?$mappingFile->getTocFilename($tocId):null;
}
/**
* Retrieves a toc by its ID.
* @param $tocId string
* @return HelpToc
*/
function &getToc($tocId) {
$cache =& $this->_getCache($tocId);
$data = $cache->getContents();
// check if data exists after loading
if (!is_array($data)) {
$returner = false;
return $returner;
}
$toc = &new HelpToc();
$toc->setId($data['toc'][0]['attributes']['id']);
$toc->setTitle($data['toc'][0]['attributes']['title']);
if (isset($data['toc'][0]['attributes']['parent_topic'])) {
$toc->setParentTopicId($data['toc'][0]['attributes']['parent_topic']);
}
if (isset($data['topic'])) {
foreach ($data['topic'] as $topicData) {
$topic = &new HelpTopic();
$topic->setId($topicData['attributes']['id']);
$topic->setTitle($topicData['attributes']['title']);
$toc->addTopic($topic);
}
}
if (isset($data['breadcrumb'])) {
foreach ($data['breadcrumb'] as $breadcrumbData) {
$toc->addBreadcrumb($breadcrumbData['attributes']['title'], $breadcrumbData['attributes']['url']);
}
}
return $toc;
}
}
?>