Пример #1
0
         $messages[] = __gettext("Widget edited.");
         $_SESSION['messages'] = $messages;
         // Redirect back to the relevant location
         switch ($widget->location) {
             case 'profile':
             case '':
                 $redirect_url = $CFG->wwwroot . $username . "/profile/";
                 break;
             default:
                 // get module from the widget type
                 $module = '';
                 $mod_pos = strpos($widget->type, "::");
                 if ($mod_pos) {
                     $module = substr($widget->type, 0, $mod_pos);
                 }
                 $redirect_url = widget_get_display_url($module) . '?' . widget_get_display_query();
                 break;
         }
         header("Location: " . $redirect_url);
         exit;
     } else {
         $result = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>';
         $result .= '<answer>';
         $result .= '<result>' . $widget->ident . '</result>';
         $result .= '</answer>';
         header('Content-Type: application/xml');
         print $result;
     }
 } else {
     // Do we have permission to touch this?
     // If so, display edit screen
Пример #2
0
function widget_page_display($owner = 0, $location = '', $location_id = 0, $columns = 1, $count = 0, $collapsed = 0)
{
    if (!$owner) {
        $owner = $_SESSION['userid'];
    }
    $offset = optional_param('_dwidget_offset', 0, PARAM_INT);
    $total = optional_param('_dwidget_total', 0, PARAM_INT);
    // print("In widget_page_display: offset: $offset, count: $count, total: $total\n");
    $html = '';
    if ($count) {
        // handle pagination
        if (!$total) {
            $total = widget_for_user_count($owner, $location, $location_id);
        }
        $widgets = widget_for_user_paginated($owner, $location, $location_id, NULL, $offset, $count);
        if ($widgets) {
            $paginator = widget_get_paginator(widget_get_display_url($location), $owner, $location, $location_id, $offset, $count, $total, $collapsed);
            $html .= $paginator;
            $html .= widget_get_html($widgets, $columns, $collapsed);
        }
        $html .= $paginator;
    } else {
        $widgets = widget_for_user($owner, $location, $location_id);
        if ($widgets) {
            $html .= widget_get_html($widgets, $columns, $collapsed);
        }
    }
    return $html;
}