$search_results = array(); $gcourse_code = ""; $gtitle = ""; $gtags = ""; $gdescr = ""; /*foreach($ACTIONS as $key => $val) if($val->wasCalled()) $action = $key;*/ /** Identify course, populate fields */ if ($ACTIONS['search']->wasCalled()) { $params = $ACTIONS['search']->getParams(); $gcourse_code = $gtitle = $params[0]; $crs = new CourseDefn($gtitle); if (!$crs->load()) { Error::generate(Error::$PRIORITY['warn'], 'Course not found.'); } $gdescr = $crs->descr; $tags = split('[,]', $gtags); $procd_descr = process_description($gdescr); foreach ($procd_descr as $descr) { array_push($search_results, array('subject' => $descr, 'google' => google_search($descr), 'youtube' => youtube_search($descr, $tags), 'itunesu' => itunesu_search($descr), 'khanacad' => khanacad_search($descr))); } } /* else if(isset($_POST['save_name'])) { $crs = new Course( urlencode($_POST['save_name']), urlencode($_POST['course_prof']), $_SESSION['google'], $_SESSION['youtube']); $crs->save(); } else if(isset($_GET['course'])) { $crs = new Course($_GET['course'], $_GET['prof'], null, null);
header("Connection:"); header("Content-length:"); echo "Could not vote."; } else { header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); header("Content-Type: text/html"); header("Connection:"); header("Content-length:"); echo "Vote successful."; Error::generate('debug', 'memcached delete ' . $params['cid']); $p = (int) $params['id']; $crs = new CourseDefn($p); $success = $crs->load(); $memcached->delete($crs->cid); } } } else { if ($action == 'post') { // post a comment if (!$params['owner'] || !User::IsAuthenticated()) { //check_perms(false); Error::generate('warn', 'Must be logged in to post a comment.', Error::$FLAGS['single']); die('Must be logged in to post a comment.'); } else { if (!($cid = Comment::Create(array('subject' => xssfilterstring($params['subject']), 'body' => xssfilterstring($params['body']), 'owner' => User::GetAuthenticatedID(), 'id' => xssfilterint($params['cid']))))) { Error::generate('warn', 'Could not create comment.', Error::$FLAGS['single']); } }
<?php } ?> <div id="sidebar_course_similarities">Similar courses:</div> <div id="sidebar_similarities_tagcloud_hidden" class="hidden"> <?php $ctr = 0; Error::setPrepend($similarities); Error::generate('debug', 'Similarity array'); $topn = 10; // limit to $topn top results foreach ($similarities as $k => $v) { if (++$ctr == $topn) { break; } // limit to $topn top results $id = intval($k); $subj = ucfirst(Comment::GetSubject($id)); $crs = new CourseDefn($subj); $crs->load(); $hrefid = $crs->id; // cloudinizr javascript is in template_end for ($i = 0; $i < (double) $similarities[$k] * 10; $i++) { echo strtoupper("{$subj} "); } } ?> </div> <div id="sidebar_similarities_tagcloud"> </div> </div>