Esempio n. 1
0
/**
 * Returns the current page set in the session or
 * returns the default first page.
 *
 * @param int $courseid (Optional) The course in which to check for a page.  Defaults to global $COURSE->id
 * @param boolean $disablehack (Optional) Disable any hacks this funtion may employ
 * @return mixed A page object if found or false
 **/
function page_get_current_page($courseid = 0, $disablehack = true)
{
    global $CFG, $USER, $COURSE;
    if (empty($courseid)) {
        $courseid = $COURSE->id;
    }
    // HACK! This method can be called anywhere - so check to see if
    // we are navigating and we are now viewing a new page but have not
    // hit format.php yet (Example: call this method from theme header)
    if (!$disablehack and $pageid = optional_param('page', 0, PARAM_INT)) {
        $url = qualified_me();
        $url = strip_querystring($url);
        // URLs where the format could be displayed
        $locations = array($CFG->wwwroot, $CFG->wwwroot . '/', $CFG->wwwroot . '/index.php', $CFG->wwwroot . '/course/view.php', $CFG->wwwroot . '/course/format/page/format.php');
        // See if we are on a course format page already
        if (in_array($url, $locations)) {
            if ($page = page_validate_pageid($pageid, $courseid)) {
                return $page;
            }
        }
    }
    // Check session for current page ID
    if (isset($USER->formatpage_display[$courseid])) {
        if ($page = page_validate_pageid($USER->formatpage_display[$courseid], $courseid)) {
            return $page;
        }
    }
    // Last try, attempt to get the default page for the course
    if ($page = page_get_default_page($courseid)) {
        return $page;
    }
    return false;
}
/**
 * Called from {@link page_print_position()} and it is
 * supposed to print the front page settings in the
 * center column for the site course and only for
 * the default page (EG: the landing page).
 *
 * @return boolean
 **/
function page_frontpage_settings()
{
    global $CFG, $SESSION, $SITE, $PAGE, $COURSE;
    // Cheap check first - course ID
    if ($COURSE->id != SITEID) {
        return false;
    }
    // More expensive check - make sure we are viewing default page
    $default = page_get_default_page();
    $current = $PAGE->get_formatpage();
    if (empty($default->id) or empty($current->id) or $default->id != $current->id) {
        return false;
    }
    $editing = $PAGE->user_is_editing();
    /// START COPY/PASTE FROM INDEX.PHP
    print_container_start();
    /// Print Section
    if ($SITE->numsections > 0) {
        if (!($section = get_record('course_sections', 'course', $SITE->id, 'section', 1))) {
            delete_records('course_sections', 'course', $SITE->id, 'section', 1);
            // Just in case
            $section->course = $SITE->id;
            $section->section = 1;
            $section->summary = '';
            $section->sequence = '';
            $section->visible = 1;
            $section->id = insert_record('course_sections', $section);
        }
        if (!empty($section->sequence) or !empty($section->summary) or $editing) {
            print_box_start('generalbox sitetopic');
            /// If currently moving a file then show the current clipboard
            if (ismoving($SITE->id)) {
                $stractivityclipboard = strip_tags(get_string('activityclipboard', '', addslashes($USER->activitycopyname)));
                echo '<p><font size="2">';
                echo "{$stractivityclipboard}&nbsp;&nbsp;(<a href=\"course/mod.php?cancelcopy=true&amp;sesskey={$USER->sesskey}\">" . get_string('cancel') . '</a>)';
                echo '</font></p>';
            }
            $options = NULL;
            $options->noclean = true;
            echo format_text($section->summary, FORMAT_HTML, $options);
            if ($editing) {
                $streditsummary = get_string('editsummary');
                echo "<a title=\"{$streditsummary}\" " . " href=\"course/editsection.php?id={$section->id}\"><img src=\"{$CFG->pixpath}/t/edit.gif\" " . " class=\"iconsmall\" alt=\"{$streditsummary}\" /></a><br /><br />";
            }
            get_all_mods($SITE->id, $mods, $modnames, $modnamesplural, $modnamesused);
            print_section($SITE, $section, $mods, $modnamesused, true);
            if ($editing) {
                print_section_add_menus($SITE, $section->section, $modnames);
            }
            print_box_end();
        }
    }
    if (isloggedin() and !isguest() and isset($CFG->frontpageloggedin)) {
        $frontpagelayout = $CFG->frontpageloggedin;
    } else {
        $frontpagelayout = $CFG->frontpage;
    }
    foreach (explode(',', $frontpagelayout) as $v) {
        switch ($v) {
            /// Display the main part of the front page.
            case FRONTPAGENEWS:
                if ($SITE->newsitems) {
                    // Print forums only when needed
                    require_once $CFG->dirroot . '/mod/forum/lib.php';
                    if (!($newsforum = forum_get_course_forum($SITE->id, 'news'))) {
                        error('Could not find or create a main news forum for the site');
                    }
                    if (!empty($USER->id)) {
                        $SESSION->fromdiscussion = $CFG->wwwroot;
                        if (forum_is_subscribed($USER->id, $newsforum)) {
                            $subtext = get_string('unsubscribe', 'forum');
                        } else {
                            $subtext = get_string('subscribe', 'forum');
                        }
                        print_heading_block($newsforum->name);
                        echo '<div class="subscribelink"><a href="mod/forum/subscribe.php?id=' . $newsforum->id . '">' . $subtext . '</a></div>';
                    } else {
                        print_heading_block($newsforum->name);
                    }
                    forum_print_latest_discussions($SITE, $newsforum, $SITE->newsitems, 'plain', 'p.modified DESC');
                }
                break;
            case FRONTPAGECOURSELIST:
                if (isloggedin() and !has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)) and !isguest() and empty($CFG->disablemycourses)) {
                    print_heading_block(get_string('mycourses'));
                    print_my_moodle();
                } else {
                    if (!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)) and !isguest() or count_records('course') <= FRONTPAGECOURSELIMIT) {
                        // admin should not see list of courses when there are too many of them
                        print_heading_block(get_string('availablecourses'));
                        print_courses(0);
                    }
                }
                break;
            case FRONTPAGECATEGORYNAMES:
                print_heading_block(get_string('categories'));
                print_box_start('generalbox categorybox');
                print_whole_category_list(NULL, NULL, NULL, -1, false);
                print_box_end();
                print_course_search('', false, 'short');
                break;
            case FRONTPAGECATEGORYCOMBO:
                print_heading_block(get_string('categories'));
                print_box_start('generalbox categorybox');
                print_whole_category_list(NULL, NULL, NULL, -1, true);
                print_box_end();
                print_course_search('', false, 'short');
                break;
            case FRONTPAGETOPICONLY:
                // Do nothing!!  :-)
                break;
        }
        // echo '<br />';  REMOVED FOR THE FORMAT
    }
    print_container_end();
    /// END COPY/PASTE FROM INDEX.PHP
    return true;
}
Esempio n. 3
0
/**
 * returns the 'station' pages for the passed learning path
 *
 * @param int $courseid
 *
 * @return array
 */
function tao_get_learning_path_stations($courseid)
{
    $toppage = page_get_default_page($courseid);
    return page_filter_child_pages($toppage->id, page_get_all_pages($courseid, 'flat'));
}
Esempio n. 4
0
if (!($page->display & DISP_PUBLISH) and !(has_capability('format/page:editpages', $context) and $editing)) {
    error(get_string('thispageisnotpublished', 'format_page'));
}
/// Finally, we can print the page
if ($editing) {
    $PAGE->print_tabs('layout');
    page_print_jump_menu();
    if (has_capability('format/learning:manageactivities', $context)) {
        page_print_add_mods_form($page, $course);
    }
    $class = 'format-page editing';
} else {
    $class = 'format-page';
}
//  get the overview page for the course
$overview_page = page_get_default_page($course->id);
$overview_link = "";
if ($overview_page->id != $page->id) {
    $overview_link = '<a href="' . course_page_uri($overview_page, $course) . '">דף מבוא</a>';
    // should be get_string('overviewpage','format_learning'); // (nadavkav)
}
// create the 'my learning path' specific links
$mypaths_link = "";
if (!tao_is_my_learning_path($course->id) && !isguest() && !($course->category == '7')) {
    // && !($course->category == '7')  added to make sure it is not displayed when in Yesumiy Lemida course (nadavkav)
    $mypaths_link = '<a href="' . course_enrol_uri($overview_page, $course) . '">' . get_string('addtomylearningpaths', 'format_learning') . '</a>';
}
$completion_page = '/local/lp/completion.php?id=' . $course->id;
$completion_link = '<a href="' . $CFG->wwwroot . $completion_page . '" onclick="this.target=\'completion\'; return openpopup(\'' . $completion_page . '\', \'completion\', \'menubar=0,location=0,scrollbars,status,resizable,width=700,height=500\', 0);">' . get_string('completion', 'format_learning') . '</a>';
// print control row for the course
echo '<table id="learning-path-header">';