moodle/blocks/rss_client/config_instance.html
2005-05-17 13:46:19 +00:00

161 lines
6.2 KiB
HTML

<?php
require_once($CFG->libdir .'/rsslib.php');
/// Print tabs at top
global $currentaction;
if (empty($currentaction) || $currentaction == 'configblock') {
$currentaction = 'configblock';
} else {
$currentaction = 'managefeeds';
}
include('config_instance_tabs.php');
if ($currentaction == 'configblock') {
?>
<table cellpadding="9" cellspacing="0" class="blockconfigtable">
<tr valign="top">
<td align="right" width="50%">
<?php print_string('block_rss_display_description_label', 'block_rss_client') ?>
</td>
<td width="50%">
<?php
if(! isset($CFG->block_rss_client_display_description) ) {
$CFG->block_rss_client_display_description = '0';
}
$selected = $CFG->block_rss_client_display_description;
if (isset($this->config) && isset($this->config->display_description)) {
$selected = $this->config->display_description;
}
$options[0] = get_string('no');
$options[1] = get_string('yes');
choose_from_menu ($options, 'display_description', $selected);
?>
</td>
</tr>
<tr valign="top">
<td align="right" width="50%">
<?php print_string('block_rss_shownumentries_label', 'block_rss_client') ?>
</td>
<td width="50%">
<input name="shownumentries" type="text" size="5" value="<?php
if(! isset($CFG->block_rss_client_num_entries) ) {
$CFG->block_rss_client_num_entries = '5';
}
$numentries = $CFG->block_rss_client_num_entries;
if (isset($this->config) && isset($this->config->shownumentries)) {
$numentries = intval($this->config->shownumentries);
}
p($numentries);
?>" />
</td>
</tr>
<tr valign="top">
<td align="right" width="50%">
<?php print_string('block_rss_choose_feed_label', 'block_rss_client') ?>
</td>
<td width="50%">
<?php
$selectedarray = array();
if (isset($this->config) && isset($this->config->rssid)) {
if (is_array($this->config->rssid)) {
// rssid is an array of rssids
$selectedarray = $this->config->rssid;
} else {
// rssid is a single rssid
$selectedarray = array($this->config->rssid);
}
}
if ($rssfeeds = get_records('block_rss_client')) {
foreach($rssfeeds as $rssfeed){
if (!empty($rssfeed->preferredtitle)) {
$feedtitle = stripslashes_safe($rssfeed->preferredtitle);
} else {
$feedtitle = stripslashes_safe($rssfeed->title);
}
$feedoptions[$rssfeed->id] = $feedtitle;
}
$dropdownmenustring = choose_from_menu($feedoptions, 'rssid[]', '', '', '', '0', true);
//Daryl Hawes note:
// moodle's choose_from_menu() function does not support
// the "multiple" or "size" options, so before printing out the
// calculated drop down menu we insert the keyword "multiple"
$dropdownmenustring = preg_replace("|\"rssid\[\]\" >*|","\"rssid[]\" multiple>", $dropdownmenustring);
// since there may be multiple rssids to select
// we need to check for each
if (!empty($selectedarray)) {
foreach ($selectedarray as $selected) {
$selected = intval($selected);
$dropdownmenustring = preg_replace("|\"$selected\">*|","\"$selected\" selected>", $dropdownmenustring);
}
}
print $dropdownmenustring;
} else {
print_string('block_rss_no_feeds', 'block_rss_client');
if ( isadmin() ){
print '&nbsp;<a href="'. $CFG->wwwroot .'/blocks/rss_client/block_rss_client_action.php"> '. get_string('block_rss_edit_news_feeds', 'block_rss_client') .'</a><br />';
}
}
?>
</td>
</tr>
<tr valign="top">
<td align="right" width="50%"><?php print_string('uploadlabel'); ?></td>
<?php
$title = '';
if (!empty($this->config) && !empty($this->config->title)) {
$title = $this->config->title;
}
?>
<td width="50%"><input type="text" name="title" size="30" value="<?php echo $title; ?>" />
</td>
</tr>
<tr valign="top">
<td align="right" width="50%"><?php print_string('block_rss_client_show_channel_link_label', 'block_rss_client'); ?></td>
<td width="50%">
<?php
if (isset($this->config) && isset($this->config->block_rss_client_show_channel_link)) {
$selected = $this->config->block_rss_client_show_channel_link;
} else {
$selected = '0';
}
$options = array ( '0' => get_string('no'),
'1' => get_string('yes') );
choose_from_menu ($options, 'block_rss_client_show_channel_link', $selected);
?>
</td>
</tr>
<tr valign="top">
<td align="right" width="50%"><?php print_string('block_rss_client_show_image_label', 'block_rss_client'); ?></td>
<td width="50%">
<?php
if (isset($this->config) && isset($this->config->block_rss_client_show_channel_image)) {
$selected = $this->config->block_rss_client_show_channel_image;
} else {
$selected = '0';
}
$options = array ( '0' => get_string('no'),
'1' => get_string('yes') );
choose_from_menu ($options, 'block_rss_client_show_channel_image', $selected);
?>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="<?php print_string('savechanges') ?>">
</td>
</tr>
</table>
<?php
} else {
global $act, $url, $rssid, $preferredtitle;
rss_display_feeds();
print '</form>';
rss_get_form($act, $url, $rssid, $preferredtitle);
} ?>