$page->id = clean_param($page->pageid, PARAM_INT); $page->modified = time(); if (!empty($page->publish)) { $page->publish = 1; } else { $page->publish = 0; } $page->body = strip_tags($page->body, $ALLOWED_TAGS); $page->body = addslashes($page->body); $oldbody = addslashes(get_field('cmspages', 'body', 'id', $page->id)); if (!update_record("cmspages", $page)) { error("Couldn't update page: {$page->title}!"); } if ($oldbody != $page->body) { // Get old version info and add new entry to history table. if ($history = cms_get_page_version($page->id, true)) { $history->version = floatval($history->version); $history->version = (string) ($history->version + 0.1); if (strpos($history->version, ".") === FALSE) { $history->version .= '.0'; } $history->modified = time(); $history->content = !empty($page->url) ? $page->url : $page->body; $history->author = (int) $USER->id; unset($history->id); insert_record("cmspages_history", $history); } } if (defined('SITEID')) { if ($course->id != SITEID) { // We're in course level.
/** * Construct data for table class used in pagesindex page. * @global object $USER * @staticvar array $output * @staticvar int $count * @staticvar object $prevpage * @param int $parentid * @return array */ function get_page_tree_rows($parentid) { global $USER; static $output, $count, $prevpage; if (empty($output)) { $output = array(); } if (empty($count)) { $count = 0; } if (!empty($this->pages)) { $count++; foreach ($this->pages as $p) { if ($p->parentid == $parentid) { $row = array(); $row[] = '<input type="checkbox" name="id" value="' . $p->id . '" />'; $hrefup = '<a href="pages.php?sesskey=' . $USER->sesskey . '&sort=up&menuid=' . $p->naviid . '&pid=' . $p->id . '&mid=' . $p->parentid . '&course=' . $this->courseid . '">' . $this->imgup . '</a>'; $hrefdown = '<a href="pages.php?sesskey=' . $USER->sesskey . '&sort=down&menuid=' . $p->naviid . '&pid=' . $p->id . '&mid=' . $p->parentid . '&course=' . $this->courseid . '">' . $this->imgdown . '</a>'; $hrefleft = ''; if (!empty($prevpage->id) or $this->__hasParent($p->id)) { $moveto = $this->__hasParent($p->parentid, true); if (empty($moveto)) { $moveto = '0'; } $hrefleft = '<a href="pages.php?sesskey=' . $USER->sesskey . '&move=' . $moveto . '&pid=' . $p->id . '&menuid=' . $p->naviid . '&course=' . $this->courseid . '" alt="">' . $this->imgleft . '</a>'; } $hrefright = ''; if (!empty($prevpage->id)) { $hrefright = '<a href="pages.php?sesskey=' . $USER->sesskey . '&move=' . $prevpage->id . '&pid=' . $p->id . '&menuid=' . $p->naviid . '&course=' . $this->courseid . '" alt="">' . $this->imgright . '</a>'; } $moverow = '<table border="0" cellpadding="2"><tr>'; if ($this->__firstAtLevel($p->parentid, $p->id) && $this->__hasSibling($p->parentid)) { $moverow .= '<td>' . $hrefdown . '</td><td>' . $this->imgblank . '</td>'; } else { if ($this->__lastAtLevel($p->parentid, $p->id) && $this->__hasSibling($p->parentid)) { $moverow .= '<td>' . $this->imgblank . '</td><td>' . $hrefup . '</td>'; } else { if ($this->__hasSibling($p->parentid)) { $moverow .= '<td>' . $hrefdown . '</td><td>' . $hrefup . '</td>'; } else { $moverow .= '<td>' . $this->imgblank . '</td><td>' . $this->imgblank . '</td>'; } } } // Add level changers. if ($this->__hasParent($p->id)) { $moverow .= '<td>' . $hrefleft . '</td>'; } else { $moverow .= '<td>' . $this->imgblank . '</td>'; } if ($this->__hasSibling($p->parentid) && !$this->__firstAtLevel($p->parentid, $p->id)) { $moverow .= '<td>' . $hrefright . '</td>'; } $row[] = $moverow . '</tr></table>'; $pageurl = ''; if (!empty($this->siteid)) { $pageurl = $this->courseid > $this->siteid ? $this->wwwroot . '/course/view.php?id=' . $this->courseid . '&pid=' . $this->__get_path($p->id) : $this->wwwroot . '/index.php?pid=' . $this->__get_path($p->id); } // If link is a direct url to resource or webpage if (!empty($p->url)) { $pageurl = $p->url; } $p->title = '<a href="' . $pageurl . '" target="_blank">' . s($p->title) . '</a>'; $pagetitle = str_repeat(" ", $count - 1); $pagetitle .= !empty($p->isfp) ? '<strong>' . $p->title . '</strong>' : $p->title; $row[] = $pagetitle; $default = !empty($p->isfp) ? stripslashes($this->strisdefault) : (!empty($p->publish) && empty($p->parentid) ? '<a href="pages.php?course=' . $this->courseid . '&sesskey=' . $USER->sesskey . '&setfp=' . $p->id . '">' . stripslashes($this->strsetasdefault) . '</a>' : ''); $row[] = $default; $publishurl = '<a href="pages.php?sesskey=' . $USER->sesskey . '&pid=' . $p->id . '&menuid=' . $p->naviid . '&course=' . $this->courseid; $publish = !empty($p->publish) ? $publishurl . '&publish=no">' . $this->imgpub . '</a>' : $publishurl . '&publish=yes">' . $this->imgunpub . '</a>'; $row[] = $publish; // Get version information. $version = cms_get_page_version($p->id); $historylink = '<a href="pagehistory.php?sesskey=' . $USER->sesskey . '&course=' . $this->courseid . '&menuid=' . $p->naviid . '&pageid=' . $p->id . '">' . s($version) . '</a>'; $row[] = $historylink; //s($version); $row[] = userdate($p->modified, "%x %X"); array_push($output, $row); $this->get_page_tree_rows($p->id); $prevpage = $p; } } $count--; } return $output; }