<?php

// $Id: config_instance_tabs.php,v 1.15 2009/05/07 08:55:11 tjhunt Exp $
/// This file to be included so we can assume config.php has already been included.
/// We also assume that $inactive, $activetab and $currentaction have been set
global $USER;
$tabs = $row = array();
// TODO - temporary hack to get the block context only if it already exists.
global $DB;
if ($DB->record_exists('context', array('contextlevel' => CONTEXT_BLOCK, 'instanceid' => $this->instance->id))) {
    $context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
} else {
    $context = get_context_instance(CONTEXT_SYSTEM);
    // pinned blocks do not have own context
}
if (has_capability('moodle/site:manageblocks', $context)) {
    $script = $page->url->out(array('instanceid' => $this->instance->id, 'sesskey' => sesskey(), 'blockaction' => 'config', 'currentaction' => 'configblock', 'id' => $id, 'section' => 'rss'));
    $row[] = new tabobject('configblock', $script, get_string('configblock', 'block_rss_client'));
}
$script = $page->url->out(array('instanceid' => $this->instance->id, 'sesskey' => sesskey(), 'blockaction' => 'config', 'currentaction' => 'managefeeds', 'id' => $id, 'section' => 'rss'));
$row[] = new tabobject('managefeeds', $script, get_string('managefeeds', 'block_rss_client'));
$tabs[] = $row;
/// Print out the tabs and continue!
print "\n" . '<div class="tabs">' . "\n";
print_tabs($tabs, $currentaction);
print '</div>' . print_location_comment(__FILE__, __LINE__, true);
Ejemplo n.º 2
0
/**
 * Prints or returns a form for managing rss feed entries.
 * @param string $act The current action. If "rssedit" then and "update" button is used, otherwise "add" is used.
 * @param string $url The url of the feed that is being updated or NULL
 * @param int $rssid The dataabse id of the feed that is being updated or NULL
 * @param string $preferredtitle The preferred title to display for this feed
 * @param int $shared Whether this feed is to be shared or not
 * @param int $courseid The id of the course that is currently being viewed if applicable
 * @param object $context The context that we will use to check for permissions
 * @return string Either the form is printed directly and nothing is returned or the form is returned as a string
 */
function rss_get_form($act = 'none', $url = '', $rssid = '', $preferredtitle = '', $shared = 0, $courseid = '', $context)
{
    global $USER, $CFG, $_SERVER, $blockid, $blockaction;
    global $blogid;
    //hackish, but if there is a blogid it would be good to preserve it
    $stredit = get_string('edit');
    $stradd = get_string('add');
    $strupdatefeed = get_string('updatefeed', 'block_rss_client');
    $straddfeed = get_string('addfeed', 'block_rss_client');
    $returnstring = '';
    $returnstring .= '<form action="' . $CFG->wwwroot . '/blocks/rss_client/block_rss_client_action.php" method="post" id="block_rss">' . "\n";
    print_location_comment(__FILE__, __LINE__);
    $returnstring .= '<div id="rss_table">' . "\n";
    if ($act == 'rssedit') {
        $returnstring .= $strupdatefeed;
    } else {
        $returnstring .= $straddfeed;
    }
    $returnstring .= "\n" . '<br /><input type="text" size="60" maxlength="256" name="url" value="';
    if ($act == 'rssedit') {
        $returnstring .= $url;
    }
    $returnstring .= '" />' . "\n";
    $returnstring .= '<br />' . get_string('customtitlelabel', 'block_rss_client');
    $returnstring .= '<br /><input type="text" size="60" maxlength="128" name="preferredtitle" value="';
    if ($act == 'rssedit') {
        $returnstring .= $preferredtitle;
    }
    $returnstring .= '" />' . "\n";
    if (has_capability('block/rss_client:createsharedfeeds', $context)) {
        $returnstring .= '<br /><input type="checkbox" name="shared" value="1" ';
        if ($shared) {
            $returnstring .= 'checked="checked" ';
        }
        $returnstring .= '/> ';
        $returnstring .= get_string('sharedfeed', 'block_rss_client');
        $returnstring .= '<br />' . "\n";
    }
    $returnstring .= '<input type="hidden" name="act" value="';
    if ($act == 'rssedit') {
        $returnstring .= 'updfeed';
    } else {
        $returnstring .= 'addfeed';
    }
    $returnstring .= '" />' . "\n";
    if ($act == 'rssedit') {
        $returnstring .= '<input type="hidden" name="rssid" value="' . $rssid . '" />' . "\n";
    }
    $returnstring .= '<input type="hidden" name="id" value="' . $courseid . '" />' . "\n";
    $returnstring .= '<input type="hidden" name="blogid" value="' . $blogid . '" />' . "\n";
    $returnstring .= '<input type="hidden" name="user" value="' . $USER->id . '" />' . "\n";
    $returnstring .= '<br /><input type="submit" value="';
    $validatestring = "<a href=\"#\" onclick=\"window.open('http://feedvalidator.org/check.cgi?url='+getElementById('block_rss').elements['url'].value,'validate','width=640,height=480,scrollbars=yes,status=yes,resizable=yes');return true;\">" . get_string('validatefeed', 'block_rss_client') . "</a>";
    if ($act == 'rssedit') {
        $returnstring .= $stredit;
    } else {
        $returnstring .= $stradd;
    }
    $returnstring .= '" />&nbsp;' . $validatestring . "\n";
    // $returnstring .= '</div></form>'."\n"; // Avoiding nested forms... Ugly temporary hack #8922
    return $returnstring . print_location_comment(__FILE__, __LINE__, true);
}