@@ -3,27 +3,27 @@ |
||
| 3 | 3 | require_once('common.inc.php'); |
| 4 | 4 | |
| 5 | 5 | if (isset($_REQUEST['course_url'])) { |
| 6 | - $courseId = preg_replace('|.*/courses/(\d+)/?.*|', '$1', parse_url($_REQUEST['course_url'], PHP_URL_PATH)); |
|
| 7 | - $course = $api->get("/courses/$courseId"); |
|
| 8 | - if ($course) { |
|
| 9 | - $webcalFeed = str_replace('https://', 'webcal://', $course['calendar']['ics']); |
|
| 10 | - $smarty->assign('content', ' |
|
| 6 | + $courseId = preg_replace('|.*/courses/(\d+)/?.*|', '$1', parse_url($_REQUEST['course_url'], PHP_URL_PATH)); |
|
| 7 | + $course = $api->get("/courses/$courseId"); |
|
| 8 | + if ($course) { |
|
| 9 | + $webcalFeed = str_replace('https://', 'webcal://', $course['calendar']['ics']); |
|
| 10 | + $smarty->assign('content', ' |
|
| 11 | 11 | <h3>Course Calendar ICS Feed</h3> |
| 12 | 12 | <p>You can subscribe to the calendar for <a href="https://' . |
| 13 | - parse_url(CANVAS_API_URL, PHP_URL_HOST) . '/courses/' . $courseId . |
|
| 14 | - '">' . $course['name'] . '</a> at <a href="' . |
|
| 15 | - $webcalFeed . '">' . $webcalFeed . |
|
| 16 | - '</a> in any calendar application that supports external ICS feeds.</p>' |
|
| 17 | - ); |
|
| 18 | - } else { |
|
| 19 | - $messages[] = array( |
|
| 20 | - 'class' => 'error', |
|
| 21 | - 'title' => 'Canvas API Error', |
|
| 22 | - 'content' => 'The course you requested could not be accessed.<pre>' . print_r($json, false) . '</pre>' |
|
| 23 | - ); |
|
| 24 | - } |
|
| 13 | + parse_url(CANVAS_API_URL, PHP_URL_HOST) . '/courses/' . $courseId . |
|
| 14 | + '">' . $course['name'] . '</a> at <a href="' . |
|
| 15 | + $webcalFeed . '">' . $webcalFeed . |
|
| 16 | + '</a> in any calendar application that supports external ICS feeds.</p>' |
|
| 17 | + ); |
|
| 18 | + } else { |
|
| 19 | + $messages[] = array( |
|
| 20 | + 'class' => 'error', |
|
| 21 | + 'title' => 'Canvas API Error', |
|
| 22 | + 'content' => 'The course you requested could not be accessed.<pre>' . print_r($json, false) . '</pre>' |
|
| 23 | + ); |
|
| 24 | + } |
|
| 25 | 25 | } else { |
| 26 | - $smarty->assign('content', ' |
|
| 26 | + $smarty->assign('content', ' |
|
| 27 | 27 | <form method="post" action="' . $_SERVER['PHP_SELF'] . '"> |
| 28 | 28 | <label for="course_url">Course URL <span class="comment">The URL to the course whose calendar you would like to export as an ICS feed</span></label> |
| 29 | 29 | <input id="course_url" name="course_url" type="text" /> |