2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2006 by Greg Gay & Joel Kronenberg */
6 /* Adaptive Technology Resource Centre / University of Toronto */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /****************************************************************/
39 function ContentManager(&$db, $course_id) {
41 $this->course_id = $course_id;
44 function initContent( ) {
45 if ($this->course_id == '') {
48 $sql = "SELECT content_id, content_parent_id, ordering, title, UNIX_TIMESTAMP(release_date) AS u_release_date FROM ".TABLE_PREFIX."content WHERE course_id=$this->course_id ORDER BY content_parent_id, ordering";
49 $result = mysql_query($sql, $this->db);
51 /* x could be the ordering or even the content_id */
52 /* don't really need the ordering anyway. */
53 /* $_menu[content_parent_id][x] = array('content_id', 'ordering', 'title') */
56 /* number of content sections */
61 while ($row = mysql_fetch_assoc($result)) {
63 $_menu[$row['content_parent_id']][] = array('content_id'=> $row['content_id'],
64 'ordering' => $row['ordering'],
65 'title' => htmlspecialchars($row['title']));
67 $_menu_info[$row['content_id']] = array('content_parent_id' => $row['content_parent_id'],
68 'title' => htmlspecialchars($row['title']),
69 'ordering' => $row['ordering'],
70 'u_release_date' => $row['u_release_date']);
72 if ($row['content_parent_id'] == 0){
73 $max_depth[$row['content_id']] = 1;
75 $max_depth[$row['content_id']] = $max_depth[$row['content_parent_id']]+1;
79 $this->_menu = $_menu;
81 $this->_menu_info = $_menu_info;
83 $this->num_sections = $num_sections;
85 if (count($max_depth) > 1) {
86 $this->max_depth = max($max_depth);
91 $this->content_length = count($_menu[0]);
95 function getContent($parent_id=-1, $length=-1) {
96 if ($parent_id == -1) {
97 $my_menu_copy = $this->_menu;
99 $my_menu_copy[0] = array_slice($my_menu_copy[0], 0, $length);
101 return $my_menu_copy;
103 return $this->_menu[$parent_id];
107 function &getContentPath($content_id) {
110 $path[] = array('content_id' => $content_id, 'title' => $this->_menu_info[$content_id]['title']);
112 $this->getContentPathRecursive($content_id, $path);
114 $path = array_reverse($path);
119 function getContentPathRecursive($content_id, &$path) {
120 $parent_id = $this->_menu_info[$content_id]['content_parent_id'];
122 if ($parent_id > 0) {
123 $path[] = array('content_id' => $parent_id, 'title' => $this->_menu_info[$parent_id]['title']);
124 $this->getContentPathRecursive($parent_id, $path);
129 function addContent($course_id, $content_parent_id, $ordering, $title, $text, $keywords, $related, $formatting, $release_date) {
131 if (!authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN) && ($_SESSION['course_id'] != -1)) {
135 // shift the new neighbouring content down
136 $sql = "UPDATE ".TABLE_PREFIX."content SET ordering=ordering+1 WHERE ordering>=$ordering AND content_parent_id=$content_parent_id AND course_id=$_SESSION[course_id]";
137 $result = mysql_query($sql, $this->db);
139 /* main topics all have minor_num = 0 */
140 $sql = "INSERT INTO ".TABLE_PREFIX."content VALUES (NULL,$course_id, $content_parent_id, $ordering, NOW(), 0, $formatting, '$release_date', '$keywords', '', '$title','$text')";
142 $err = mysql_query($sql, $this->db);
144 /* insert the related content */
145 $sql = "SELECT LAST_INSERT_ID() AS insert_id";
146 $result = mysql_query($sql, $this->db);
147 $row = mysql_fetch_assoc($result);
148 $cid = $row['insert_id'];
151 if (is_array($related)) {
152 foreach ($related as $x => $related_content_id) {
153 $related_content_id = intval($related_content_id);
155 if ($related_content_id != 0) {
159 $sql .= '('.$cid.', '.$related_content_id.')';
160 $sql .= ', ('.$related_content_id.', '.$cid.')';
165 $sql = 'INSERT INTO '.TABLE_PREFIX.'related_content VALUES '.$sql;
166 $result = mysql_query($sql, $this->db);
174 function editContent($content_id, $title, $text, $keywords, $new_content_ordering, $related, $formatting, $new_content_parent_id, $release_date) {
175 if (!authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN)) {
179 /* first get the content to make sure it exists */
180 $sql = "SELECT ordering, content_parent_id FROM ".TABLE_PREFIX."content WHERE content_id=$content_id AND course_id=$_SESSION[course_id]";
181 $result = mysql_query($sql, $this->db);
182 if (!($row = mysql_fetch_assoc($result)) ) {
185 $old_ordering = $row['ordering'];
186 $content_parent_id = $row['content_parent_id'];
187 if (($content_parent_id != $new_content_parent_id) || ($old_ordering != $new_content_ordering)) {
188 // remove the gap left by the moved content
189 $sql = "UPDATE ".TABLE_PREFIX."content SET ordering=ordering-1 WHERE ordering>=$old_ordering AND content_parent_id=$content_parent_id AND content_id<>$content_id AND course_id=$_SESSION[course_id]";
190 $result = mysql_query($sql, $this->db);
192 // shift the new neighbouring content down
193 $sql = "UPDATE ".TABLE_PREFIX."content SET ordering=ordering+1 WHERE ordering>=$new_content_ordering AND content_parent_id=$new_content_parent_id AND content_id<>$content_id AND course_id=$_SESSION[course_id]";
194 $result = mysql_query($sql, $this->db);
197 /* update the title, text of the newly moved (or not) content */
198 $sql = "UPDATE ".TABLE_PREFIX."content SET title='$title', text='$text', keywords='$keywords', formatting=$formatting, content_parent_id=$new_content_parent_id, ordering=$new_content_ordering, revision=revision+1, last_modified=NOW(), release_date='$release_date' WHERE content_id=$content_id AND course_id=$_SESSION[course_id]";
199 $result = mysql_query($sql, $this->db);
201 /* update the related content */
202 $result = mysql_query("DELETE FROM ".TABLE_PREFIX."related_content WHERE content_id=$content_id OR related_content_id=$content_id", $this->db);
204 if (is_array($related)) {
205 foreach ($related as $x => $related_content_id) {
206 $related_content_id = intval($related_content_id);
208 if ($related_content_id != 0) {
212 $sql .= '('.$content_id.', '.$related_content_id.')';
213 $sql .= ', ('.$related_content_id.', '.$content_id.')';
218 /* delete the old related content */
219 $result = mysql_query("DELETE FROM ".TABLE_PREFIX."related_content WHERE content_id=$content_id OR related_content_id=$content_id", $this->db);
221 /* insert the new, and the old related content again */
222 $sql = 'INSERT INTO '.TABLE_PREFIX.'related_content VALUES '.$sql;
223 $result = mysql_query($sql, $this->db);
229 function deleteContent($content_id) {
230 if (!authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN)) {
234 /* check if exists */
235 $sql = "SELECT ordering, content_parent_id FROM ".TABLE_PREFIX."content WHERE content_id=$content_id AND course_id=$_SESSION[course_id]";
236 $result = mysql_query($sql, $this->db);
237 if (!($row = @mysql_fetch_assoc($result)) ) {
240 $ordering = $row['ordering'];
241 $content_parent_id = $row['content_parent_id'];
243 /* check if this content has sub content */
244 $children = $this->_menu[$content_id];
246 if (is_array($children) && (count($children)>0) ) {
247 /* delete its children recursively first*/
248 foreach ($children as $x => $info) {
249 $this->deleteContentRecursive($info['content_id']);
253 /* delete this content page */
254 $sql = "DELETE FROM ".TABLE_PREFIX."content WHERE content_id=$content_id AND course_id=$_SESSION[course_id]";
255 $result = mysql_query($sql, $this->db);
257 /* delete this content from member tracking page */
258 $sql = "DELETE FROM ".TABLE_PREFIX."member_track WHERE content_id=$content_id AND course_id=$_SESSION[course_id]";
259 $result = mysql_query($sql, $this->db);
261 $sql = "DELETE FROM ".TABLE_PREFIX."related_content WHERE content_id=$content_id OR related_content_id=$content_id";
262 $result = mysql_query($sql, $this->db);
264 /* re-order the rest of the content */
265 $sql = "UPDATE ".TABLE_PREFIX."content SET ordering=ordering-1 WHERE ordering>=$ordering AND content_parent_id=$content_parent_id AND course_id=$_SESSION[course_id]";
266 $result = mysql_query($sql, $this->db);
267 /* end moving block */
269 /* remove the "resume" to this page, b/c it was deleted */
270 $sql = "UPDATE ".TABLE_PREFIX."course_enrollment SET last_cid=0 WHERE course_id=$_SESSION[course_id] AND last_cid=$content_id";
271 $result = mysql_query($sql, $this->db);
277 /* private. call from deleteContent only. */
278 function deleteContentRecursive($content_id) {
279 /* check if this content has sub content */
280 $children = $this->_menu[$content_id];
282 if (is_array($children) && (count($children)>0) ) {
283 /* delete its children recursively first*/
284 foreach ($children as $x => $info) {
285 $this->deleteContent($info['content_id']);
289 /* delete this content page */
290 $sql = "DELETE FROM ".TABLE_PREFIX."content WHERE content_id=$content_id AND course_id=$_SESSION[course_id]";
291 $result = mysql_query($sql, $this->db);
293 /* delete this content from member tracking page */
294 $sql = "DELETE FROM ".TABLE_PREFIX."member_track WHERE content_id=$content_id";
295 $result = mysql_query($sql, $this->db);
297 $sql = "DELETE FROM ".TABLE_PREFIX."related_content WHERE content_id=$content_id OR related_content_id=$content_id";
298 $result = mysql_query($sql, $this->db);
301 function & getContentPage($content_id) {
302 $sql = "SELECT *, DATE_FORMAT(release_date, '%Y-%m-%d %H:%i:00') AS release_date, release_date+0 AS r_date, NOW()+0 AS n_date FROM ".TABLE_PREFIX."content WHERE content_id=$content_id AND course_id=$this->course_id";
303 $result = mysql_query($sql, $this->db);
308 /* @See editor/edit_content.php include/html/dropdowns/related_topics.inc.php include/lib/editor_tabs_functions.inc.php */
309 function getRelatedContent($content_id, $all=false) {
310 if ($content_id == 0) {
313 if ($content_id == '') {
316 $related_content = array();
319 $sql = "SELECT * FROM ".TABLE_PREFIX."related_content WHERE content_id=$content_id OR related_content_id=$content_id";
321 $sql = "SELECT * FROM ".TABLE_PREFIX."related_content WHERE content_id=$content_id";
323 $result = mysql_query($sql, $this->db);
325 while ($row = mysql_fetch_assoc($result)) {
326 if ($row['related_content_id'] != $content_id) {
327 $related_content[] = $row['related_content_id'];
329 $related_content[] = $row['content_id'];
333 return $related_content;
337 function & cleanOutput($value) {
338 return stripslashes(htmlspecialchars($value));
342 /* @See include/html/editor_tabs/properties.inc.php */
344 function getNumSections() {
345 return $this->num_sections;
349 function getMaxDepth() {
350 return $this->max_depth;
354 function getContentLength() {
355 return $this->content_length;
358 /* @See include/html/dropdowns/local_menu.inc.php */
359 function getLocationPositions($parent_id, $content_id) {
360 $siblings = $this->getContent($parent_id);
361 for ($i=0;$i<count($siblings); $i++){
362 if ($siblings[$i]['content_id'] == $content_id) {
369 /* Access: Private */
370 function getNumbering($content_id) {
371 $path = $this->getContentPath($content_id);
374 foreach ($path as $page) {
375 $num = $this->getLocationPositions($parent, $page['content_id']) +1;
376 $parent = $page['content_id'];
377 $numbering .= $num.'.';
379 $numbering = substr($numbering, 0, -1);
384 /* Access: Private */
385 function getPreviousContent($content_id, $order=0) {
386 $myParent = $this->_menu_info[$content_id]['content_parent_id'];
387 $myOrder = $this->_menu_info[$content_id]['ordering'];
389 if (($this->_menu[$myParent][$myOrder-2] != '') && ($order==0)) {
390 // has sibling: checking if sibling has children
392 $mySibling = $this->_menu[$myParent][$myOrder-2];
394 if ( is_array($this->_menu[$mySibling['content_id']]) && ($order==0) ) {
395 $num_children = count($this->_menu[$mySibling['content_id']]);
397 // sibling has $num_children children
399 return($this->getPreviousContent($this->_menu[$mySibling[content_id]][$num_children-1]['content_id'], 1));
402 // sibling has no children. return it
403 return($this->_menu[$myParent][$myOrder-2]);
407 if ($myParent == 0) {
408 /* we're at the top */
412 /* No more siblings */
414 return(array('content_id' => $myParent,
415 'ordering' => $this->_menu_info[$myParent]['ordering'],
416 'title' => $this->_menu_info[$myParent]['title']));
418 if ( is_array($this->_menu[$content_id]) ) {
419 $num_children = count($this->_menu[$content_id]);
420 return ($this->getPreviousContent($this->_menu[$content_id][$num_children-1]['content_id'], 1));
424 return(array('content_id' => $content_id,
425 'ordering' => $this->_menu_info[$content_id]['ordering'],
426 'title' => $this->_menu_info[$content_id]['title']));
432 /* Access: Private */
433 function getNextContent($content_id, $order=0) {
434 $myParent = $this->_menu_info[$content_id]['content_parent_id'];
435 $myOrder = $this->_menu_info[$content_id]['ordering'];
437 /* if this content has children, then take the first one. */
438 if ( is_array($this->_menu[$content_id]) && ($order==0) ) {
440 return($this->_menu[$content_id][0]);
443 if ($this->_menu[$myParent][$myOrder] != '') {
445 return($this->_menu[$myParent][$myOrder]);
447 /* No more siblings */
448 if ($myParent != 0) {
449 return($this->getNextContent($myParent, 1));
455 /* @See include/header.inc.php */
456 function generateSequenceCrumbs($cid) {
459 $sequence_links = array();
461 $first = $this->getNextContent(0); // get first
462 if ($_SESSION['prefs']['PREF_NUMBERING'] && $first) {
463 $first['title'] = $this->getNumbering($first['content_id']).' '.$first['title'];
466 $first['url'] = $_base_path.'content.php?cid='.$first['content_id'];
467 $sequence_links['first'] = $first;
470 if (!$cid && $_SESSION['s_cid']) {
471 $resume['title'] = $this->_menu_info[$_SESSION['s_cid']]['title'];
473 if ($_SESSION['prefs']['PREF_NUMBERING']) {
474 $resume['title'] = $this->getNumbering($_SESSION['s_cid']).' ' . $resume['title'];
477 $resume['url'] = $_base_path.'content.php?cid='.$_SESSION['s_cid'];
479 $sequence_links['resume'] = $resume;
482 $previous = $this->getPreviousContent($cid);
484 $next = $this->getNextContent($cid ? $cid : 0);
486 if ($_SESSION['prefs']['PREF_NUMBERING']) {
487 $previous['title'] = $this->getNumbering($previous['content_id']).' '.$previous['title'];
488 $next['title'] = $this->getNumbering($next['content_id']).' '.$next['title'];
491 $next['url'] = $_base_path.'content.php?cid='.$next['content_id'];
492 $previous['url'] = $_base_path.'content.php?cid='.$previous['content_id'];
494 if ($previous['content_id']) {
495 $sequence_links['previous'] = $previous;
497 $previous['url'] = $_base_path . 'index.php';
498 $previous['title'] = _AT('home');
499 $sequence_links['previous'] = $previous;
501 if ($next['content_id']) {
502 $sequence_links['next'] = $next;
506 return $sequence_links;
509 /* @See include/html/dropdowns/menu_menu.inc.php */
510 function printMainMenu( ) {
516 $ignore_state = false;
519 $this->printMenu($parent_id, $depth, $path, $children, $truncate, $ignore_state);
522 /* @See tools/sitemap/index.php */
523 function printSiteMapMenu() {
529 $ignore_state = true;
532 $this->printMenu($parent_id, $depth, $path, $children, $truncate, $ignore_state);
536 function printTOCMenu($cid, $top_num) {
539 $path = $top_num.'.';
542 $ignore_state = false;
545 $this->printMenu($parent_id, $depth, $path, $children, $truncate, $ignore_state);
548 /* @See index.php include/html/dropdowns/local_menu.inc.php */
549 function printSubMenu($cid, $top_num) {
552 $path = $top_num.'.';
555 $ignore_state = false;
558 $this->printMenu($parent_id, $depth, $path, $children, $truncate, $ignore_state);
561 /* @See include/html/menu_menu.inc.php */
562 /* Access: PRIVATE */
563 function printMenu($parent_id, $depth, $path, $children, $truncate, $ignore_state) {
565 global $cid, $_my_uri, $_base_path, $rtl;
568 if (!isset($temp_path)) {
570 $temp_path = $this->getContentPath($cid);
572 $temp_path = $this->getContentPath($_SESSION['s_cid']);
576 $highlighted = array();
577 if (is_array($temp_path)) {
578 foreach ($temp_path as $temp_path_item) {
579 $_SESSION['menu'][$temp_path_item['content_id']] = 1;
580 $highlighted[$temp_path_item['content_id']] = true;
586 $this->start = false;
589 $top_level = $this->_menu[$parent_id];
591 if ( is_array($top_level) ) {
593 $num_items = count($top_level);
594 foreach ($top_level as $garbage => $content) {
596 if (!$ignore_state) {
597 $link .= '<a name="menu'.$content['content_id'].'"></a>';
602 if ( ($_SESSION['s_cid'] != $content['content_id']) || ($_SESSION['s_cid'] != $cid) ) {
603 if ($highlighted[$content['content_id']]) {
608 $link .= ' <a href="'.$_base_path.'content.php?cid='.$content['content_id'].'" title="';
609 if ($_SESSION['prefs']['PREF_NUMBERING']) {
610 $link .= $path.$counter.' ';
613 $link .= $content['title'].'">';
615 if ($truncate && (strlen($content['title']) > (28-$depth*4)) ) {
616 $content['title'] = rtrim(substr($content['title'], 0, (28-$depth*4)-4)).'...';
618 $link .= $content['title'];
621 $link .= '</strong>';
624 $link .= '<a href="'.$_my_uri.'"><img src="'.$_base_path.'images/clr.gif" alt="'._AT('you_are_here').': '.$content['title'].'" height="1" width="1" border="0" /></a><strong title="'.$content['title'].'">';
625 if ($truncate && (strlen($content['title']) > (26-$depth*4)) ) {
626 $content['title'] = rtrim(substr($content['title'], 0, (26-$depth*4)-4)).'...';
628 $link .= trim($content['title']).'</strong>';
636 if ( is_array($this->_menu[$content['content_id']]) ) {
638 for ($i=0; $i<$depth; $i++) {
639 if ($children[$i] == 1) {
640 echo '<img src="'.$_base_path.'images/'.$rtl.'tree/tree_vertline.gif" alt="" border="0" width="16" height="16" class="img-size-tree" />';
642 echo '<img src="'.$_base_path.'images/clr.gif" alt="" border="0" width="16" height="16" class="img-size-tree" />';
646 if (($counter == $num_items) && ($depth > 0)) {
647 echo '<img src="'.$_base_path.'images/'.$rtl.'tree/tree_end.gif" alt="" border="0" width="16" height="16" class="img-size-tree" />';
648 $children[$depth] = 0;
649 } else if ($counter == $num_items) {
650 echo '<img src="'.$_base_path.'images/'.$rtl.'tree/tree_end.gif" alt="" border="0" width="16" height="16" class="img-size-tree" />';
651 $children[$depth] = 0;
653 echo '<img src="'.$_base_path.'images/'.$rtl.'tree/tree_split.gif" alt="" border="0" width="16" height="16" class="img-size-tree" />';
654 $children[$depth] = 1;
657 if ($_SESSION['s_cid'] == $content['content_id']) {
658 if (is_array($this->_menu[$content['content_id']])) {
659 $_SESSION['menu'][$content['content_id']] = 1;
663 if ($_SESSION['menu'][$content['content_id']] == 1) {
665 echo '<img src="'.$_base_path.'images/tree/tree_disabled.gif" alt="'._AT('toggle_disabled').'" border="0" width="16" height="16" title="'._AT('toggle_disabled').'" class="img-size-tree" />';
668 echo '<a href="'.$_my_uri.'collapse='.$content['content_id'].'">';
669 echo '<img src="'.$_base_path.'images/'.$rtl.'tree/tree_collapse.gif" alt="'._AT('collapse').'" border="0" width="16" height="16" title="'._AT('collapse').' '.$content['title'].'" class="img-size-tree" />';
674 echo '<img src="'.$_base_path.'images/tree/tree_disabled.gif" alt="'._AT('toggle_disabled').'" border="0" width="16" height="16" title="'._AT('toggle_disabled').'" class="img-size-tree" />';
677 echo '<a href="'.$_my_uri.'expand='.$content['content_id'].'">';
678 echo '<img src="'.$_base_path.'images/'.$rtl.'tree/tree_expand.gif" alt="'._AT('expand').'" border="0" width="16" height="16" title="'._AT('expand').' '.$content['title'].'" class="img-size-tree" />';
684 /* doesn't have children */
685 if ($counter == $num_items) {
686 for ($i=0; $i<$depth; $i++) {
687 if ($children[$i] == 1) {
688 echo '<img src="'.$_base_path.'images/'.$rtl.'tree/tree_vertline.gif" alt="" border="0" width="16" height="16" class="img-size-tree" />';
690 echo '<img src="'.$_base_path.'images/clr.gif" alt="" border="0" width="16" height="16" class="img-size-tree" />';
693 echo '<img src="'.$_base_path.'images/'.$rtl.'tree/tree_end.gif" alt="" border="0" class="img-size-tree" />';
695 for ($i=0; $i<$depth; $i++) {
696 if ($children[$i] == 1) {
697 echo '<img src="'.$_base_path.'images/'.$rtl.'tree/tree_vertline.gif" alt="" border="0" width="16" height="16" class="img-size-tree" />';
699 echo '<img src="'.$_base_path.'images/'.$rtl.'tree/tree_space.gif" alt="" border="0" width="16" height="16" class="img-size-tree" />';
702 echo '<img src="'.$_base_path.'images/'.$rtl.'tree/tree_split.gif" alt="" border="0" width="16" height="16" class="img-size-tree" />';
704 echo '<img src="'.$_base_path.'images/'.$rtl.'tree/tree_horizontal.gif" alt="" border="0" width="16" height="16" class="img-size-tree" />';
707 if ($_SESSION['prefs']['PREF_NUMBERING']) {
715 if ( $ignore_state || ($_SESSION['menu'][$content['content_id']] == 1)) {
719 $this->printMenu($content['content_id'],
735 /* @See include/html/editor_tabs/properties.inc.php */
736 function printMoveMenu($menu, $parent_id, $depth, $path, $children) {
738 global $cid, $_my_uri, $_base_path, $rtl;
740 static $end, $ignore;
742 $top_level = $menu[$parent_id];
744 if ( is_array($top_level) ) {
746 $num_items = count($top_level);
747 foreach ($top_level as $garbage => $content) {
753 if (($parent_id == $_POST['new_pid']) && ($content['ordering'] < $_POST['new_ordering'])) {
754 $text = _AT('before_topic', $content['title']);
756 } else if ($parent_id != $_POST['new_pid']) {
757 $text = _AT('before_topic', $content['title']);
760 $text = _AT('after_topic', $content['title']);
763 if ($ignore && ($_POST['cid'] > 0)) {
764 $buttons = '<td><small> </small></td><td><small> </small></td><td>';
765 } else if ($_POST['new_pid'] == $content['content_id']) {
766 $buttons = '<td align="center"><small><input type="image" name="move['.$parent_id.'_'.$content['ordering'].']" src="'.$_base_path.'images/'.$img.'" alt="'.$text.'" title="'.$text.'" style="height:1.5em; width:1.9em;" /></small></td><td><small> </small></td><td>';
768 $buttons = '<td align="center"><small><input type="image" name="move['.$parent_id.'_'.$content['ordering'].']" src="'.$_base_path.'images/'.$img.'" title="'.$text.'" style="height:1.5em; width:1.9em;" /></small></td><td><input type="image" name="move['.$content['content_id'].'_1]" src="'.$_base_path.'images/child_of.gif" style="height:1.25em; width:1.7em;" alt="'._AT('child_of', $content['title']).'" title="'._AT('child_of', $content['title']).'" /></td><td>';
771 if (( $content['content_id'] == $cid ) || ($content['content_id'] == -1)) {
773 $link .= '<strong>'.trim($_POST['title']).' '._AT('current_location').'</strong>';
774 $buttons = '<td colspan="2"><small> </small></td><td>';
776 $link .= '<input type="checkbox" name="related[]" value="'.$content['content_id'].'" id="r'.$content['content_id'].'" ';
777 if (isset($_POST['related']) && in_array($content['content_id'], $_POST['related'])) {
778 $link .= ' checked="checked"';
780 $link .= ' /><label for="r'.$content['content_id'].'">'.$content['title'].'</label>';
783 if ( is_array($menu[$content['content_id']]) && !empty($menu[$content['content_id']]) ) {
786 for ($i=0; $i<$depth; $i++) {
787 if ($children[$i] == 1) {
790 if ($end && ($i==0)) {
791 echo '<img src="'.$_base_path.'images/clr.gif" alt="" border="0" width="16" height="16" class="img-size-tree" />';
793 echo '<img src="'.$_base_path.'images/'.$rtl.'tree/tree_vertline.gif" alt="" border="0" width="16" height="16" />';
796 echo '<img src="'.$_base_path.'images/clr.gif" alt="" border="0" width="16" height="16" class="img-size-tree" />';
800 if (($counter == $num_items) && ($depth > 0)) {
801 echo '<img src="'.$_base_path.'images/'.$rtl.'tree/tree_end.gif" alt="" border="0" width="16" height="16" />';
802 $children[$depth] = 0;
805 if (($num_items == $counter) && ($parent_id == 0)) {
806 echo '<img src="'.$_base_path.'images/'.$rtl.'tree/tree_end.gif" alt="" border="0" width="16" height="16" />';
809 echo '<img src="'.$_base_path.'images/'.$rtl.'tree/tree_split.gif" alt="" border="0" width="16" height="16" />';
811 $children[$depth] = 1;
814 if ($_SESSION['s_cid'] == $content['content_id']) {
815 if (is_array($menu[$content['content_id']])) {
816 $_SESSION['menu'][$content['content_id']] = 1;
820 if ($_SESSION['menu'][$content['content_id']] == 1) {
821 echo '<img src="'.$_base_path.'images/tree/tree_disabled.gif" alt="'._AT('toggle_disabled').'" border="0" width="16" height="16" title="'._AT('toggle_disabled').'" />';
824 echo '<img src="'.$_base_path.'images/tree/tree_disabled.gif" alt="'._AT('toggle_disabled').'" border="0" width="16" height="16" title="'._AT('toggle_disabled').'" />';
828 /* doesn't have children */
829 if ($counter == $num_items) {
832 for ($i=0; $i<$depth; $i++) {
833 if ($children[$i] == 1) {
834 if ($end && ($i == 0)) {
835 echo '<img src="'.$_base_path.'images/clr.gif" alt="" border="0" width="16" height="16" class="img-size-tree" />';
837 echo '<img src="'.$_base_path.'images/'.$rtl.'tree/tree_vertline.gif" alt="" border="0" width="16" height="16" />';
840 echo '<img src="'.$_base_path.'images/clr.gif" alt="" border="0" width="16" height="16" class="img-size-tree" />';
846 echo '<img src="'.$_base_path.'images/'.$rtl.'tree/tree_end.gif" alt="" border="0" />';
851 for ($i=0; $i<$depth; $i++) {
852 if ($children[$i] == 1) {
853 if ($end && !$print) {
855 echo '<img src="'.$_base_path.'images/'.$rtl.'tree/tree_space.gif" alt="" border="0" width="16" height="16" />';
857 echo '<img src="'.$_base_path.'images/'.$rtl.'tree/tree_vertline.gif" alt="" border="0" width="16" height="16" />';
860 echo '<img src="'.$_base_path.'images/'.$rtl.'tree/tree_space.gif" alt="" border="0" width="16" height="16" />';
868 echo '<img src="'.$_base_path.'images/'.$rtl.'tree/tree_split.gif" alt="" border="0" width="16" height="16" />';
870 echo '<img src="'.$_base_path.'images/'.$rtl.'tree/tree_horizontal.gif" alt="" border="0" width="16" height="16" />';
873 echo '<small> '.$path.$counter;
877 echo '</small></td></tr>';
879 $this->printMoveMenu($menu,
880 $content['content_id'],
888 if ( $content['content_id'] == $cid ) {
896 /* returns the timestamp of release if this page has not yet been released, or is under a page that has not been released, true otherwise */
897 /* finds the max(timestamp) of all parents and returns that, true if less than now */
899 function isReleased($cid) {
900 if ($this->_menu_info[$cid]['content_parent_id'] == 0) {
901 // this $cid has no parent, so we check its release date directly
902 if ($this->_menu_info[$cid]['u_release_date'] <= time()) {
903 // yup! it's released
906 // nope! not released
907 return $this->_menu_info[$cid]['u_release_date'];
910 // this is a sub page, need to check ALL its parents
911 $parent = $this->isReleased($this->_menu_info[$cid]['content_parent_id']); // recursion
913 if ($parent !== TRUE && $parent > $this->_menu_info[$cid]['u_release_date']) {
915 } else if ($this->_menu_info[$cid]['u_release_date'] <= time()) {
918 return $this->_menu_info[$cid]['u_release_date'];