/** * Get the first tree node * * This function returns the array corresponding to the first node in the tree. * <br/>Example: * <code> * $content = new EfrontContentTree(4); //Create the content tree for lesson with id 4 * $firstNode = $content -> getFirstNode(); //$firstNode now holds the array of the tree's first node * </code> * * @param ArrayIterator $iterator An specific iterator to use, instead of the default one * @return array The first node array * @since 3.5.0 * @access public */ public function getFirstNode($iterator = false) { // if (!$iterator) { // $iterator = new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($this -> tree), RecursiveIteratorIterator :: SELF_FIRST)); //Create a new iterator, so that the internal iterator pointer is not reset // } if (!$iterator) { if (EfrontUser::isOptionVisible('tests')) { $iterator = new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($this->tree), RecursiveIteratorIterator::SELF_FIRST)); //Create a new iterator, so that the internal iterator pointer is not reset } else { $iterator = new EfrontNoTestsFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($this->tree), RecursiveIteratorIterator::SELF_FIRST))); //Create a new iterator, so that the internal iterator pointer is not reset } } $iterator->rewind(); //Initialize iterator return $iterator->current(); }
//Get to the first unseen unit while ($firstUnseenUnit && in_array($firstUnseenUnit['id'], array_keys($seenContent))) { $firstUnseenUnit = $currentContent->getNextNode($firstUnseenUnit, $firstNodeIterator); } if (!$firstUnseenUnit) { $firstUnseenUnit = $currentContent->getFirstNode($firstNodeIterator); } if ($currentLesson->options['start_resume'] && $firstUnseenUnit) { $headerOptions[] = array('text' => _RESUMELESSON, 'image' => '32x32/continue.png', 'href' => basename($_SERVER['PHP_SELF']) . '?view_unit=' . $firstUnseenUnit['id']); } $smarty->assign("T_CURRENT_UNIT", $firstUnseenUnit); } else { if (EfrontUser::isOptionVisible('tests')) { $iterator = new EfrontVisitableFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($currentContent->tree), RecursiveIteratorIterator::SELF_FIRST))); } else { $iterator = new EfrontNoTestsFilterIterator(new EfrontVisitableFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($currentContent->tree), RecursiveIteratorIterator::SELF_FIRST)))); //Create a new iterator, so that the internal iterator pointer is not reset } $iterator->next(); $firstUnseenUnit = $firstUnit = $iterator->current(); if ($firstUnit && $currentLesson->options['start_resume']) { $headerOptions[] = array('text' => _STARTLESSON, 'image' => '32x32/start.png', 'href' => basename($_SERVER['PHP_SELF']) . '?ctg=content&view_unit=' . $firstUnit['id']); } } if (isset($currentLesson->options['show_dashboard']) && !$currentLesson->options['show_dashboard'] && $firstUnseenUnit) { eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=content&view_unit=" . $firstUnseenUnit['id']); } $currentLesson->options['lesson_info'] ? $headerOptions[] = array('text' => _LESSONINFORMATION, 'image' => '32x32/information.png', 'href' => basename($_SERVER['PHP_SELF']) . '?ctg=lesson_information&popup=1', 'onClick' => "eF_js_showDivPopup(event, '" . _LESSONINFORMATION . "', 2)", 'target' => 'POPUP_FRAME') : null; } //Digital library mini file manager block if ($currentLesson->options['digital_library'] && $currentUser->coreAccess['digital_library'] != 'hidden') {