コード例 #1
0
ファイル: HelpTopicDAO.inc.php プロジェクト: JovanyJeff/hrp
 /**
  * Retrieve a topic by its ID.
  * @param $topicId string
  * @return HelpTopic
  */
 function &getTopic($topicId)
 {
     $cache =& $this->_getCache($topicId);
     $data = $cache->getContents();
     // check if data exists after loading
     if (!is_array($data)) {
         $returner = false;
         return $returner;
     }
     $topic = new HelpTopic();
     $topic->setId($data['topic'][0]['attributes']['id']);
     $topic->setTitle($data['topic'][0]['attributes']['title']);
     $topic->setTocId($data['topic'][0]['attributes']['toc']);
     if (isset($data['topic'][0]['attributes']['subtoc'])) {
         $topic->setSubTocId($data['topic'][0]['attributes']['subtoc']);
     }
     if (isset($data['section'])) {
         foreach ($data['section'] as $sectionData) {
             $section = new HelpTopicSection();
             $section->setTitle(isset($sectionData['attributes']['title']) ? $sectionData['attributes']['title'] : null);
             $section->setContent($sectionData['value']);
             $topic->addSection($section);
         }
     }
     if (isset($data['related_topic'])) {
         foreach ($data['related_topic'] as $relatedTopic) {
             $relatedTopicArray = array('id' => $relatedTopic['attributes']['id'], 'title' => $relatedTopic['attributes']['title']);
             $topic->addRelatedTopic($relatedTopicArray);
         }
     }
     return $topic;
 }