Example #1
0
 function display()
 {
     global $PAGE, $COURSE;
     $editing = $PAGE->user_is_editing();
     $pageblocks = page_blocks_setup();
     /// Make sure we can see this page
     if (!($this->page->display & DISP_PUBLISH) and !(has_capability('format/page:editpages', $this->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();
         page_print_add_mods_form($this->page, $COURSE);
         $class = 'format-page editing';
     } else {
         $class = 'format-page';
     }
     echo '<table id="layout-table" class="' . $class . '" cellspacing="0" summary="' . get_string('layouttable') . '">';
     /// Check if the page is locked, if so, print lock message, otherwise print three columns
     if (page_is_locked($this->page)) {
         echo '<tr><td colspan="3">';
         page_print_lock_prerequisites($this->page);
         echo '</tr></td>';
     } else {
         echo '<tr>';
         if (blocks_have_content($pageblocks, BLOCK_POS_LEFT)) {
             page_print_position($pageblocks, BLOCK_POS_LEFT, $this->page->prefleftwidth);
         }
         page_print_position($pageblocks, BLOCK_POS_CENTER, '100%');
         if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT)) {
             page_print_position($pageblocks, BLOCK_POS_RIGHT, $this->page->prefrightwidth);
         }
         echo '</tr>';
     }
     /// Silently attempts to call a function from the block_recent_history block
     @block_method_result('recent_history', 'block_recent_history_record', $this->page);
     /// Display navigation buttons
     if ($this->page->showbuttons) {
         $nav = page_get_next_previous_pages($this->page->id, $this->page->courseid);
         $buttons = '';
         if ($nav->prev and $this->page->showbuttons & BUTTON_PREV) {
             $title = get_string('previous', 'format_page', page_get_name($nav->prev));
             $buttons .= '<span class="prevpage"><a href="' . $PAGE->url_build('page', $nav->prev->id) . "\" title=\"{$title}\">{$title}</a></span>";
         }
         if ($nav->next and $this->page->showbuttons & BUTTON_NEXT) {
             $title = get_string('next', 'format_page', page_get_name($nav->next));
             $buttons .= '<span class="nextpage"><a href="' . $PAGE->url_build('page', $nav->next->id) . "\" title=\"{$title}\">{$title}</a></span>";
         }
         // Make sure we have something to print
         if (!empty($buttons)) {
             echo "\n<tr><td></td><td>{$buttons}</td><td></td></tr>\n";
         }
     }
     echo '</table>';
 }
                    }
                    $sesskey = sesskey();
                    $showhidestr = get_string($showhide);
                    $eye = '';
                    if (has_capability('format/page:managepages', $context)) {
                        $eye .= "<a href=\"{$CFG->wwwroot}/course/format/page/managemenu.php?id={$course->id}&amp;pageid={$page->id}&amp;showhide={$showhide}&amp;sesskey={$sesskey}\">";
                    }
                    $eye .= "<img src=\"{$CFG->pixpath}/i/{$showhide}.gif\" alt=\"{$showhidestr}\" />";
                    if (has_capability('format/page:managepages', $context)) {
                        $eye .= '</a>';
                    }
                } else {
                    // No children, so cannot lock/unlock anything
                    $eye = get_string('nochildpages', 'format_page');
                }
                $name = page_get_name($page);
                $page = link_to_popup_window("/course/view.php?id={$course->id}&amp;page={$page->id}", 'course', $name, 800, 1000, $name, 'none', true);
                $table->data[] = array('', $page, $eye);
            }
        }
    }
    print_table($table);
} else {
    // No pages found
    notify(get_string('nomenupagesfound', 'format_page'));
}
print_footer($course);
?>


 /**
  * Builds an options array for pages and their children
  *
  * @param array $pages An array of pages with their children
  * @return array
  **/
 protected function build_select_menu($pages)
 {
     $options = array();
     foreach ($pages as $page) {
         if ($this->dont_display($page)) {
             continue;
         }
         // Build the name string - first add white space
         $options[$page->id] = str_repeat('&nbsp;&nbsp;', $page->depth);
         if ($page->depth > 0) {
             // Add a hyphen before all child pages
             $options[$page->id] .= '-&nbsp;';
         }
         // Add the actual name
         $name = page_get_name($page);
         $name = shorten_text($name, 28);
         $options[$page->id] .= $name;
         if (!empty($page->children)) {
             $options = $options + $this->build_select_menu($page->children);
         }
     }
     return $options;
 }
Example #4
0
/**
 * Prints the "Back to X" where is is the name
 * of a page format page.
 *
 * @return void
 **/
function page_theme_print_backto_button()
{
    global $CFG, $SESSION, $COURSE;
    if (page_theme_config('page_backtobutton')) {
        if (isset($COURSE->format) and $COURSE->format == 'page') {
            $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 aren't on a course format page already
            if (!in_array($url, $locations)) {
                require_once $CFG->dirroot . '/course/format/page/lib.php';
                // Make sure we have a page to go to
                if ($page = page_get_current_page($COURSE->id)) {
                    echo '<p><span class="button"><a href="' . $CFG->wwwroot . '/course/view.php?id=' . $page->courseid . '&amp;page=' . $page->id . '">' . get_string('backtopage', 'theme_page', page_get_name($page)) . '</a></span></p>';
                }
            }
        }
    }
}
$f_note_id = gpc_get_int('f_note_id');
$f_page_id = gpc_get_int('f_page_id');
$f_email = gpc_get_string('f_email');
$f_note = gpc_get_string('f_note');
$t_page_info = page_get_info(page_where_id_equals($f_page_id));
if (false === $t_page_info) {
    echo "page not found";
    exit;
}
$t_note['id'] = '0';
$t_note['email'] = string_prepare_note_for_viewing($f_email);
$t_note['date'] = time();
$t_note['note'] = string_prepare_note_for_viewing($f_note);
$t_page_data = array();
$t_page_data['id'] = 0;
$t_page_data['page'] = page_get_name($f_page_id);
$t_page_data['url'] = $t_page_info['url'];
$t_page_data['preview'] = true;
$t_page_data['prev_page'] = '';
$t_page_data['prev_url'] = '';
$t_page_data['next_page'] = '';
$t_page_data['next_url'] = '';
$t_page_data['notes'] = array($t_note);
theme_body($t_page_data);
$f_email = string_to_form($f_email);
$f_note = string_to_form($f_note);
echo <<<EOT
\t<div class="spacer"></div>
\t<form method="post" action="{$g_note_add}">
\t\t<input type="hidden" name="f_note_id" value="{$f_note_id}" />
\t\t<input type="hidden" name="f_page_id" value="{$f_page_id}" />
Example #6
0
    echo '<tr>';
    page_print_position($pageblocks, BLOCK_POS_LEFT, null);
    page_print_position($pageblocks, BLOCK_POS_CENTER, null);
    page_print_position($pageblocks, BLOCK_POS_RIGHT, null);
    echo '</tr>';
}
/// Silently attempts to call a function from the block_recent_history block
@block_method_result('recent_history', 'block_recent_history_record', $page);
/// Display navigation buttons
if ($page->showbuttons && !$USER->raflmode) {
    $nav = page_get_next_previous_pages($page->id, $page->courseid);
    $buttons = '';
    if ($nav->prev and $page->showbuttons & BUTTON_PREV) {
        $buttons .= '<span class="prevpage"><a href="' . $PAGE->url_build('page', $nav->prev->id) . '">' . get_string('previous', 'format_page', page_get_name($nav->prev)) . '</a></span>';
    }
    if ($completion_link) {
        $buttons .= '<span class="completion">' . $completion_link . '</span>';
    }
    if ($overview_link) {
        $buttons .= '<span class="overview">' . $overview_link . '</span>';
    }
    if ($nav->next and $page->showbuttons & BUTTON_NEXT) {
        $buttons .= '<span class="nextpage"><a href="' . $PAGE->url_build('page', $nav->next->id) . '">' . get_string('next', 'format_page', page_get_name($nav->next)) . '</a></span>';
    }
    // Make sure we have something to print
    if (!empty($buttons)) {
        echo "\n<tr><td></td><td><div class=\"course-links\">{$buttons}</div></td><td></td></tr>\n";
    }
}
echo '</table>';
echo "\n<!-- end layout table -->\n";
    }
    $t_default_body = '';
    $t_note_id = 0;
} else {
    $t_note_info = note_get_info(note_where_id_equals($f_note_id));
    if (false === $t_note_info) {
        # @@@@ proper error
        echo "no note with the specified id";
        exit;
    }
    $t_default_email = $t_note_info['email'];
    $t_default_body = $t_note_info['note'];
    $t_note_id = db_prepare_int($f_note_id);
    $f_page_id = $t_note_info['page_id'];
}
$t_page_name = page_get_name($f_page_id);
if (empty($t_page_name)) {
    echo "<div align=\"center\">";
    # @@@@ replace with one parameterised localisation string
    echo "{$s_not_indexed_part1} <a href=\"mailto:{$g_administrator_email}\">{$s_administrator}</a> {$s_not_indexed_part2}";
    echo "</div>";
} else {
    ?>

<?php 
    # @@@@ When themes are supported, this won't be needed (or at least done in another way.
    ### Display a nice message
    if (file_exists($g_note_add_include)) {
        include $g_note_add_include;
    }
    $t_base_page_name = basename($t_page_name);
/**
 * Prints or returns the code for the "Back to X" where is is the name
 * of a page format page.
 *
 * @return void
 **/
function page_theme_print_backto_button($return = false)
{
    global $CFG, $SESSION, $COURSE;
    if (page_theme_config('page_backtobutton')) {
        if ($COURSE->format == 'page') {
            $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 aren't on a course format page already
            if (!in_array($url, $locations)) {
                require_once $CFG->dirroot . '/course/format/page/lib.php';
                // Make sure we have a page to go to
                if ($page = page_get_current_page($COURSE->id)) {
                    if ($COURSE->id == SITEID) {
                        $baseurl = $CFG->wwwroot . '/index.php';
                    } else {
                        $baseurl = "{$CFG->wwwroot}/course/view.php";
                    }
                    $output = print_single_button($baseurl, array('id' => $page->courseid, 'page' => $page->id), get_string('backtopage', 'format_page', page_get_name($page)), 'get', '_self', true);
                    if ($return) {
                        return $output;
                    }
                    print $output;
                }
            }
        }
    }
}