Ejemplo n.º 1
0
 function load()
 {
     $isFirst = TRUE;
     // check if the user attende the course
     if ($GLOBALS['course_descriptor']->getValue('course_type') == 'classroom') {
         require_once _lms_ . '/lib/lib.date.php';
         $man_date = new DateManager();
         $this->user_presence = $man_date->checkUserPresence(getLogUserId(), $_SESSION['idCourse']);
     }
     $tree = $this->printState();
     $coll = $this->_retrieveData();
     $stack = array();
     $level = 0;
     $count = 0;
     $tree .= '<div class="TreeViewContainer">' . "\n";
     $folder = $this->tdb->getRootFolder();
     $stack[$level] = array();
     $stack[$level]['folder'] = $folder;
     $stack[$level]['childs'] = $this->posTree[0];
     $stack[$level]['isLast'] = TRUE;
     $stack[$level]['isLeaf'] = FALSE;
     $stack[$level]['isExpanded'] = FALSE;
     $stack[$level]['idSeq'] = $folder->id;
     $stack[$level]['isFirst'] = $isFirst;
     $tree .= '<div class="TreeViewRowOdd" id="row_' . $stack[$level]['idSeq'] . '">';
     $tree .= $this->printElement($stack, $level);
     $tree .= '</div>';
     $level++;
     if ($coll !== FALSE) {
         while ($folder = $coll->getNext()) {
             list($key, $val) = each($stack[$level - 1]['childs']);
             $stack[$level] = array();
             $stack[$level]['folder'] = $folder;
             $stack[$level]['childs'] = $val;
             $stack[$level]['isFirst'] = $isFirst;
             $isFirst = FALSE;
             if (current($stack[$level - 1]['childs'])) {
                 $stack[$level]['isLast'] = false;
             } else {
                 $stack[$level]['isLast'] = true;
             }
             if (is_array($val)) {
                 $stack[$level]['isExpanded'] = TRUE;
             } else {
                 $stack[$level]['isExpanded'] = FALSE;
             }
             if ($folder->countChildrens() > 0) {
                 $stack[$level]['isLeaf'] = FALSE;
             } else {
                 $stack[$level]['isLeaf'] = TRUE;
             }
             $stack[$level]['idSeq'] = $stack[$level - 1]['idSeq'] . '.' . $folder->id;
             $row_content = $this->printElement($stack, $level);
             if ($row_content !== false) {
                 $count++;
                 if ($count % 2 == 0) {
                     $tree .= '<div class="TreeViewRowOdd" id="row_' . $stack[$level]['idSeq'] . '">';
                 } else {
                     $tree .= '<div class="TreeViewRowEven" id="row_' . $stack[$level]['idSeq'] . '">';
                 }
                 $tree .= $row_content;
                 $tree .= '</div>';
                 if (is_array($val)) {
                     $level++;
                     $isFirst = TRUE;
                 } else {
                     if ($stack[$level]['isLast']) {
                         while ($stack[$level]['isLast'] && $level > 1) {
                             $level--;
                         }
                     }
                 }
             }
         }
     } else {
         $tree .= "\n<!-- coll is null -->";
     }
     /* echo "\n<!-- diag ";
     		print_r( $this->posTree );
     		print_r( $this->posFlat );
     		print_r( $this->expandList );
     		print_r( $this->compressList );
     		echo "-->\n"; */
     $tree .= '</div>' . "\n";
     return $tree;
 }