Chris Pollett > Students > Kamboj
[Bio] [Blog] [CS297 Del #01 (study of wiki systems) - PDF] [CS297 Del #02 (adding multiple users)] [CS297 Del #04 (what links here)] [CS298 Del #01 (getting relationship types)] [CS298 Del #02 (displaying to and from links)] [CS298 Del #03 (advanced search)] |
CS 298 Deliverable 03Adding a feature "Advanced Search features" added to YioopDescriptionThe Group Page list in Yioop displays all the pages in a particular group. In addition to this, a search box is also present which can be used to filter out pages displayed in that group. Another feature has been added here, which enables search on the basis of relationship type and any particular page. The user can choose multiple relationship types and the results would display all transitive relationship results to that particular page. To perform this action, the following steps needs to be followed: 1. List all relationship types and display a text box for the user to enter a page name. 2. The page id of the entered page name is obtained and with all the relationship types chosen by the user, a list of related pages is obtained and displayed. 3. The list of page names obtained in Step 02 can be further explored to find their transitive relations with the already selected relationship types. Steps to be followedStep 01The first step, here, is to get a list of all relationship types existing in the system and display them with a text box for the user to enter a page name. The user inputs a page name and obtains result for all relationships chosen. Step 02Append the values that user inputs to the URL and send to the controller.The values are fetched from the request variables present in the URL by the controller and the appropriate actions taken by the model which interacts with the database. Step 03The results include names of all wiki pages that the entered page is connected to and from using the relationship(s) selected in the drop down box. The results are hyperlinks and direct user to explore the linkage of chosen page using the selected relationship. DeliverablesMantis Bug ID:0000187 src/controllers/components/SocialComponent.php src/locale/en_US/configure.ini src/models/GroupModel.php src/scripts/basic.js src/views/elements/WikiElement.php Code SnippetCode added to the controller:list($data["RELATIONSHIP_ROWS"], $data["ALL_RELATIONSHIPS"]) = $group_model->getAllRelationships($limit, $num); $data["FINAL_PAGES_THAT_LINK_TO"] =[]; $data["FINAL_PAGES_THAT_LINK_FROM"] =[]; if (isset($_REQUEST["select_reltype"]) && isset($_REQUEST ["advancedsearchtextbox"])) { $data["search"] = "yes"; $page_name = $_REQUEST["advancedsearchtextbox"]; $search_page_info = $group_model->getPageInfoByName( $group_id, $page_name, $data['CURRENT_LOCALE_TAG'], "read"); if($search_page_info) { $page_id = $search_page_info['ID']; foreach($_REQUEST["select_reltype"] as $relationship_type) { list($data["TOTAL_TO_PAGES"], $data["PAGES_THAT_LINK_TO"], $data["TOTAL_FROM_PAGES"], $data["PAGES_THAT_LINK_FROM"])= $group_model->pagesLinkedWithRelationship( $page_id, $group_id, $page_name, $relationship_type, $limit, $num); $data["FINAL_PAGES_THAT_LINK_TO"] = array_merge( $data["FINAL_PAGES_THAT_LINK_TO"], $data["PAGES_THAT_LINK_TO"]); $data["FINAL_PAGES_THAT_LINK_FROM"] = array_merge( $data["FINAL_PAGES_THAT_LINK_FROM"], $data["PAGES_THAT_LINK_FROM"]); } } } Code added to fetch all relationships from the database public function getAllRelationships($limit, $num) { $db = $this->db; $sql = "SELECT COUNT(*) AS NUM_RELATIONSHIPS FROM PAGE_RELATIONSHIP"; $result = $db->execute($sql); if ($result) { $row = $db->fetchArray($result); $total = $row['NUM_RELATIONSHIPS']; } $i=0; $rel_names=[]; $sql = "SELECT DISTINCT R.NAME AS RELATIONSHIP_NAME FROM PAGE_RELATIONSHIP R"; $result = $db->execute($sql); if ($result) { while ($rel_names[$i] = $db->fetchArray($result)) { if($rel_names[$i]['RELATIONSHIP_NAME'] == 'generic_link') { unset($rel_names[$i]['RELATIONSHIP_NAME']); $i--; $total--; } $i++; } } return [$total, $rel_names]; } ReferencesYioop Documentation: Link |