Exemplo n.º 1
0
 /**
  * Builds XHTML to display the control
  *
  * @param string $data
  * @param string $query
  * @return string XHTML
  */
 public function output_html($data, $query = '')
 {
     global $CFG, $OUTPUT;
     $namestr = get_string('name');
     $settingsstr = get_string('settings');
     $hiddenstr = get_string('hiddenshow', 'repository');
     require_once "../webservice/lib.php";
     $protocols = webservice_lib::get_list_protocols();
     $table = new html_table();
     $table->head = array($namestr, $hiddenstr, $settingsstr);
     $table->align = array('left', 'center', 'center');
     $table->data = array();
     foreach ($protocols as $i) {
         $hidetitle = $i->get_protocolid() ? get_string('clicktohide', 'repository') : get_string('clicktoshow', 'repository');
         $hiddenshow = ' <a href="' . $this->baseurl . '&amp;hide=' . $i->get_protocolid() . '">' . '<img src="' . $OUTPUT->old_icon_url('i/' . ($i->get_enable() ? 'hide' : 'show')) . '"' . ' alt="' . $hidetitle . '" ' . ' title="' . $hidetitle . '" />' . '</a>' . "\n";
         $settingnames = $i->get_setting_names();
         if (!empty($settingnames)) {
             $settingsshow = ' <a href="' . $this->baseurl . '&amp;settings=' . $i->get_protocolid() . '">' . $settingsstr . '</a>' . "\n";
         } else {
             $settingsshow = "";
         }
         $table->data[] = array($i->get_protocolname(), $hiddenshow, $settingsshow);
         //display a grey row if the type is defined as not visible
         if (!$i->get_enable()) {
             $table->rowclasses[] = 'dimmed_text';
         } else {
             $table->rowclasses[] = '';
         }
     }
     $output = $OUTPUT->table($table);
     return highlight($query, $output);
 }
Exemplo n.º 2
0
 /**
  * Check if the Moodle site has the web service protocol enable
  * @global object $CFG
  * @param string $protocol
  */
 function display_webservices_availability($protocol)
 {
     global $CFG;
     $available = true;
     echo get_string('webservicesenable', 'webservice') . ": ";
     if (empty($CFG->enablewebservices)) {
         echo "<strong style=\"color:red\">" . get_string('fail', 'webservice') . "</strong>";
         $available = false;
     } else {
         echo "<strong style=\"color:green\">" . get_string('ok', 'webservice') . "</strong>";
     }
     echo "<br/>";
     foreach (webservice_lib::get_list_protocols() as $wsprotocol) {
         if (strtolower($wsprotocol->get_protocolid()) == strtolower($protocol)) {
             echo get_string('protocolenable', 'webservice', array($wsprotocol->get_protocolid())) . ": ";
             if (get_config($wsprotocol->get_protocolid(), "enable")) {
                 echo "<strong style=\"color:green\">" . get_string('ok', 'webservice') . "</strong>";
             } else {
                 echo "<strong style=\"color:red\">" . get_string('fail', 'webservice') . "</strong>";
                 $available = false;
             }
             echo "<br/>";
             continue;
         }
     }
     //check debugging
     if ($CFG->debugdisplay) {
         echo "<strong style=\"color:red\">" . get_string('debugdisplayon', 'webservice') . "</strong>";
         $available = false;
     }
     return $available;
 }