/blocks/rss_client/config_instance.html

https://bitbucket.org/ciceidev/cicei_moodle_conditional_activities · HTML · 188 lines · 170 code · 18 blank · 0 comment · 0 complexity · ca95f756153ff7035e69dbe70a307eda MD5 · raw file

  1. <?php // $Id$ //
  2. require_once($CFG->libdir .'/rsslib.php');
  3. $id = optional_param('id', SITEID, PARAM_INT);
  4. //create a page object for url_get_full()
  5. $page = page_create_object($this->instance->pagetype, $this->instance->pageid);
  6. /// Print tabs at top
  7. $currentaction = optional_param('currentaction', '', PARAM_ALPHA);
  8. if (empty($currentaction) || $currentaction == 'configblock') {
  9. $currentaction = 'configblock';
  10. } else {
  11. $currentaction = 'managefeeds';
  12. }
  13. include('config_instance_tabs.php');
  14. if ($currentaction == 'configblock') {
  15. print_box_start();
  16. ?>
  17. <table cellpadding="9" cellspacing="0" class="blockconfigtable">
  18. <tr valign="top">
  19. <td class="label">
  20. <?php print_string('displaydescriptionlabel', 'block_rss_client') ?>
  21. </td>
  22. <td class="value">
  23. <?php
  24. if(! isset($CFG->block_rss_client_display_description) ) {
  25. $CFG->block_rss_client_display_description = '0';
  26. }
  27. $selected = $CFG->block_rss_client_display_description;
  28. if (isset($this->config) && isset($this->config->display_description)) {
  29. $selected = $this->config->display_description;
  30. }
  31. $options[0] = get_string('no');
  32. $options[1] = get_string('yes');
  33. choose_from_menu ($options, 'display_description', $selected);
  34. ?>
  35. </td>
  36. </tr>
  37. <tr valign="top">
  38. <td class="label">
  39. <?php print_string('shownumentrieslabel', 'block_rss_client') ?>
  40. </td>
  41. <td class="value">
  42. <input name="shownumentries" type="text" size="5" value="<?php
  43. if(! isset($CFG->block_rss_client_num_entries) ) {
  44. $CFG->block_rss_client_num_entries = '5';
  45. }
  46. $numentries = $CFG->block_rss_client_num_entries;
  47. if (isset($this->config) && isset($this->config->shownumentries)) {
  48. $numentries = intval($this->config->shownumentries);
  49. }
  50. p($numentries);
  51. ?>" />
  52. </td>
  53. </tr>
  54. <tr valign="top">
  55. <td class="label">
  56. <?php print_string('choosefeedlabel', 'block_rss_client') ?>
  57. </td>
  58. <td class="value">
  59. <?php
  60. $selectedarray = array();
  61. if (isset($this->config) && isset($this->config->rssid)) {
  62. if (is_array($this->config->rssid)) {
  63. // rssid is an array of rssids
  64. $selectedarray = $this->config->rssid;
  65. } else {
  66. // rssid is a single rssid
  67. $selectedarray = array($this->config->rssid);
  68. }
  69. }
  70. global $USER;
  71. if ($rssfeeds = get_records_select('block_rss_client', 'userid = '.$USER->id.' OR shared = 1')) {
  72. foreach($rssfeeds as $rssfeed) {
  73. if (!empty($rssfeed->preferredtitle)) {
  74. $feedtitle = stripslashes_safe($rssfeed->preferredtitle);
  75. } else {
  76. $feedtitle = stripslashes_safe($rssfeed->title);
  77. }
  78. $checked = '';
  79. if (in_array($rssfeed->id, $selectedarray)) {
  80. $checked = 'checked="checked"';
  81. }
  82. $checkbox = '<input type="checkbox" name="rssid[]" id="rssid" value="'. $rssfeed->id .'" '. $checked .' />';
  83. print $checkbox . $feedtitle .'<br />'."\n";
  84. }
  85. } else {
  86. if (empty($this->instance->pinned)) {
  87. $context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
  88. } else {
  89. $context = get_context_instance(CONTEXT_SYSTEM); // pinned blocks do not have own context
  90. }
  91. print_string('nofeeds', 'block_rss_client');
  92. if (has_capability('block/rss_client:createprivatefeeds', $context)
  93. || has_capability('block/rss_client:createsharedfeeds', $context)) {
  94. $addrsspage = $page->url_get_full(array('instanceid' => $this->instance->id,
  95. 'sesskey' => $USER->sesskey,
  96. 'blockaction' => 'config',
  97. 'currentaction' => 'managefeeds',
  98. 'id' => $id));
  99. print '&nbsp;<a href="'.$addrsspage.'">'. get_string('editnewsfeeds', 'block_rss_client') .'</a><br />';
  100. }
  101. }
  102. ?>
  103. </td>
  104. </tr>
  105. <tr valign="top">
  106. <td class="label"><?php print_string('uploadlabel'); ?></td>
  107. <?php
  108. $title = '';
  109. if (!empty($this->config) && !empty($this->config->title)) {
  110. $title = $this->config->title;
  111. }
  112. ?>
  113. <td class="value"><input type="text" name="title" size="30" value="<?php echo $title; ?>" />
  114. </td>
  115. </tr>
  116. <tr valign="top">
  117. <td class="label"><?php print_string('clientshowchannellinklabel', 'block_rss_client'); ?></td>
  118. <td class="value">
  119. <?php
  120. if (isset($this->config) && isset($this->config->block_rss_client_show_channel_link)) {
  121. $selected = $this->config->block_rss_client_show_channel_link;
  122. } else {
  123. $selected = '0';
  124. }
  125. $options = array ( '0' => get_string('no'),
  126. '1' => get_string('yes') );
  127. choose_from_menu ($options, 'block_rss_client_show_channel_link', $selected);
  128. ?>
  129. </td>
  130. </tr>
  131. <tr valign="top">
  132. <td class="label"><?php print_string('clientshowimagelabel', 'block_rss_client'); ?></td>
  133. <td class="value">
  134. <?php
  135. if (isset($this->config) && isset($this->config->block_rss_client_show_channel_image)) {
  136. $selected = $this->config->block_rss_client_show_channel_image;
  137. } else {
  138. $selected = '0';
  139. }
  140. $options = array ( '0' => get_string('no'),
  141. '1' => get_string('yes') );
  142. choose_from_menu ($options, 'block_rss_client_show_channel_image', $selected);
  143. ?>
  144. </td>
  145. </tr>
  146. <tr>
  147. <td colspan="2" class="submit">
  148. <input type="submit" value="<?php print_string('savechanges') ?>" />
  149. </td>
  150. </tr>
  151. </table>
  152. <?php
  153. print_box_end();
  154. print "<!-- code came from " . __FILE__ . " at line " . __LINE__ . ". -->\n";
  155. } else {
  156. global $act, $url, $rssid, $preferredtitle, $shared;
  157. print '</div></form></div>'; // Closes off page form
  158. if (empty($this->instance->pinned)) {
  159. $context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
  160. } else {
  161. $context = get_context_instance(CONTEXT_SYSTEM); // pinned blocks do not have own context
  162. }
  163. print_box_start();
  164. rss_display_feeds($id, $USER->id, '', $context);
  165. rss_print_form($act, $url, $rssid, $preferredtitle, $shared, $id, $context);
  166. print_box_end();
  167. print '<div><form><div>'; // Reopen page form to keep XHTML strict.
  168. }
  169. ?>