/** * Returns all information about a paper * * @param int $code code of the paper to look for * * @return array all the information in array form splited in 3 categories, * [paper], [author], [tutor] */ function getPaper($code) { /* paper information but keyword */ $result = mysql_fetch_array(mysql_query("select paper_title title, course.course_name course, \n des_spanish, des_english, des_portuguese \n from paper, course \n where paper.code = " . $code . " and\n paper_course = course.code")); $paper = new Paper($code, $result['title'], $result['course']); $paper->addAbstract('spanish', $result['des_spanish']); $paper->addAbstract('english', $result['des_english']); $paper->addAbstract('portuguese', $result['des_portuguese']); /* paper keywords */ $result = mysql_query("select k.keyword_spanish spanish, k.keyword_english english\n from keyword k, terms t\n where t.code_keyword = k.code and\n t.code_paper = " . $code); for ($i = 0; $row = mysql_fetch_array($result); $i++) { $paper->addkeyword(array('spanish' => $row['spanish'], 'english' => $row['english'])); } /* author(s) information but membership(s) */ $result = mysql_query("select a.code code, a.author_name name, \n a.author_lastname lastname, a.author_mail mail, \n a.author_webpage webpage \n from author a, authoring at \n where at.code_author = a.code and at.code_paper = " . $code . "\n order by author_order"); for ($i = 0; $row = mysql_fetch_array($result); $i++) { $author[$i] = array('order' => $i + 1, 'code' => $row['code'], 'name' => $row['name'], 'lastname' => $row['lastname'], 'mail' => $row['mail'], 'webpage' => $row['webpage']); } /* author(s) membership(s) */ for ($i = 0; isset($author[$i]); $i++) { $result = mysql_query("select i.code code, i.institution_name name, \n i.institution_webpage webpage, cit.city_name city, \n cou.country_name country \n from institution i, city cit, country cou, membership mem \n where cit.city_country = cou.code and \n i.institution_city = cit.code and \n mem.code_institution = i.code and \n mem.code_person = " . $author[$i]['code']); for ($j = 0; $row = mysql_fetch_array($result); $j++) { $author[$i]['institution'][$j] = array('code' => $row['code'], 'name' => $row['name'], 'webpage' => $row['webpage'], 'city' => $row['city'], 'country' => $row['country']); } } foreach ($author as $val) { $paper->addAuthor($val['order'], $val['code'], $val['name'], $val['lastname'], $val['mail'], $val['webpage'], $val['institution']); } /* tutor(s) information but membership(s) */ $result = mysql_query("select t.code code, t.tutor_name name, t.tutor_lastname lastname, \n t.tutor_mail mail, t.tutor_webpage webpage \n from tutor t, tutoring tu \n where tu.code_tutor = t.code and tu.code_paper = " . $code); for ($i = 0; $row = mysql_fetch_array($result); $i++) { $tutor[$i] = array('code' => $row['code'], 'name' => $row['name'], 'lastname' => $row['lastname'], 'mail' => $row['mail'], 'webpage' => $row['webpage']); } /* tutor(s) membership(s) */ for ($i = 0; isset($tutor[$i]); $i++) { $result = mysql_query("select i.code code, i.institution_name name, \n i.institution_webpage webpage, cit.city_name city, \n cou.country_name country \n from institution i, city cit, country cou, membership mem \n where cit.city_country = cou.code and \n i.institution_city = cit.code and \n mem.code_institution = i.code and \n mem.code_person = " . $tutor[$i]['code']); for ($j = 0; $row = mysql_fetch_array($result); $j++) { $tutor[$i]['institution'][$j] = array('code' => $row['code'], 'name' => $row['name'], 'webpage' => $row['webpage'], 'city' => $row['city'], 'country' => $row['country']); } } if (isset($tutor)) { foreach ($tutor as $val) { $paper->addTutor($val['code'], $val['name'], $val['lastname'], $val['mail'], $val['webpage'], $val['institution']); } } return $paper; }