Beispiel #1
0
 /**
  * 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;
 }
 /**
  * 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;
 }