Esempio n. 1
0
 public static function process($args)
 {
     /* use CoursefinderFinder to sanitise options and get data */
     $options = CourseFinder::get_options($args);
     if ($options) {
         $data = CourseFinder::get_data($options);
         if (false !== $data) {
             if ($options['field'] !== '') {
                 return self::get_field($data, $options['field']);
             } else {
                 return self::get_page($data, $options);
             }
         }
     }
     return '';
 }
Esempio n. 2
0
print_r($_POST);
require_once dirname(__FILE__) . '/CourseDisplay.php';
// make cache dir if not present
$cache_dir = dirname(__FILE__) . '/cache';
if (!file_exists($cache_dir)) {
    @mkdir($cache_dir);
}
// default options
$options = array();
$options['cacheDir'] = $cache_dir;
$options['jsonURI'] = "http://courses.leeds.ac.uk/api/v1";
$options['jsonKey'] = "1c2ef953e8550b31cb58da892965a9e1";
$options['xmlURI'] = "http://www.leeds.ac.uk/coursefinder/api";
$options['xmlKey'] = "1c2ef953e8550b31cb58da892965a9ee";
/* get defaults */
$opts = CourseFinder::get_options($options);
/* output a form with all configuration options */
printf('<form action="%s" id="toolbox_form" method="post">', $_SERVER["REQUEST_URI"]);
/* UCAS code */
$opts['ucas_code'] = isset($_POST["ucas_code"]) && $_POST["ucas_code"] !== '' ? $_POST["ucas_code"] : '';
printf('<p><label for="ucas_code">UCAS code:</label><input type="text" name="ucas_code", id="ucas_code" value="%s"></p>', $opts['ucas_code']);
/* major code */
$opts['major_code'] = isset($_POST["major_code"]) && $_POST["major_code"] !== '' ? $_POST["major_code"] : '';
printf('<p><label for="major_code">Major code:</label><input type="text" name="major_code" id="major_code" value="%s"></p>', $opts['major_code']);
/* whether or not to display the term */
$opts['display_term'] = isset($_POST["display_term"]);
$chckd = $opts['display_term'] ? ' checked="checked"' : '';
printf('<p><label for="display_term">Display term in output?</label><input type="checkbox" name="display_term" id="display_term"%s></p>', $chckd);
/* term */
$opts['term'] = isset($_POST["term"]) && preg_match('/^[0-9]{6}$/', $_POST["term"]) ? $_POST["term"] : '201718';
printf('<p><label for="term">Term:</label><input type="text" name="term" id="term" value="%s"></p>', $opts['term']);