Chris Pollett > Students > Kamboj

    Print View

    [Bio]

    [Blog]

    [CS297 Proposal]

    [CS297 Del #01 (study of wiki systems) - PDF]

    [CS297 Del #02 (adding multiple users)]

    [CS297 Del #03 (fetch links)]

    [CS297 Del #04 (what links here)]

    [CS297 Report - PDF]

    [CS298 Proposal]

    [CS298 Del #01 (getting relationship types)]

    [CS298 Del #02 (displaying to and from links)]

    [CS298 Del #03 (advanced search)]

    [CS298 Report - PDF]

    [CS298 Presentation - PDF]

























CS 298 Deliverable 02

Adding a feature to explore "to" and "from" relationship types

Description

This feature adds to the "What Relates Here" feature added to Yioop, as discussed in CS298 Del 01. This feature lists all pages with which a particular wiki page is connected. The linkage can be obtained in two ways: links "to" the current page, and links "from" the current page. "To" relationships refer to all wiki pages that are connected to the current page using the relationship type under consideration. The "from" relationship, on the other hand, refers to all wiki pages that the current page is connected to using the relationship type specified.

Steps to be followed

Step 01

the first step is to obtain the page id of the current page and then obtain pages connected to the current page in two different arrays: connected to the current page and connected from the current page.

Step 02

The results are displayed in a particular way. The relationship types with which a page is connected are displayed as hyperlinks. Click on any hyperlink which opens a new page with a tabular structure providing a list of wiki pages that the page is connected to towards the left and a list of wiki pages connected from towards the right with the particular relationship.

Step 03

In the middle, the link to current page is displayed. Each wiki page displayed on the new page, in turn, can be explored further in the same way just by a single click.

Deliverables

Mantis Bug ID:0000184

Files Modified

Code Snippet

Code added to the controller:
//checking argument 2
        if (isset($_REQUEST["reltype"])) {
            $rel_type = $_REQUEST["reltype"];
            $data["REL-TYPE"] = $rel_type;
            $data["GROUP_ID"] = $group_id;
            //clean up
            if (!empty($page_id)) {
                $data["MODE"] = "rel-type";
                $page_info = $group_model->getPageInfoByPageId(
                    $page_id);
                if (!isset($page_name)) {
                        $page_name = empty($page_info['PAGE_NAME'])
                            ? "rel-types" : $page_info['PAGE_NAME'];
                }
                $limit = isset($limit) ? $limit : 0;
                $num = (isset($_SESSION["MAX_PAGES_TO_SHOW"])) ?
                    $_SESSION["MAX_PAGES_TO_SHOW"] :
                    C\DEFAULT_ADMIN_PAGING_NUM;
                $data["PAGE_ID"] = $page_id;
                $data["PAGE_NAME"] = $page_name;
                $data["DISCUSS_THREAD"] = empty($page_info["DISCUSS_THREAD"]
                    ) ? -1 : $page_info['DISCUSS_THREAD'];
                $data["GROUP_ID"] = $page_info["GROUP_ID"];
                $data["LIMIT"] = $limit;
                $data["RESULTS_PER_PAGE"] = $num;
                list($data["TOTAL_TO_PAGES"], $data["PAGES_THAT_LINK_TO"],
                    $data["TOTAL_FROM_PAGES"], $data["PAGES_THAT_LINK_FROM"]) =
                    $group_model->pagesLinkedWithRelationship($page_id, $rel_type,
                    $limit, $num);
            }

Code that interacts with the database:

public function pagesLinkedWithRelationship($page_id, $relationship, $limit, $num)
    {
        $db = $this->db;
        //get the count of pages that link to the given page
        $sql = "SELECT COUNT(*) AS NUM FROM GROUP_PAGE_LINK L, PAGE_RELATIONSHIP P
            WHERE L.TO_ID = ? AND P.NAME = ? AND (L.LINK_TYPE_ID = P.ID)";
        $result = $db->execute($sql, [$page_id, $relationship]);
        if ($result) {
            $row = $db->fetchArray($result);
            $total_to_pages = $row['NUM'];
        }
        //get the count of pages that link from the given page
        $sql = "SELECT COUNT(*) AS NUM FROM GROUP_PAGE_LINK L, PAGE_RELATIONSHIP P
            WHERE L.FROM_ID = ? AND P.NAME = ? AND (L.LINK_TYPE_ID = P.ID)";
        $result = $db->execute($sql, [$page_id, $relationship]);
        if ($result) {
            $row = $db->fetchArray($result);
            $total_from_pages = $row['NUM'];
        }
        //get the array of all pages linking to this page
        $pages_that_link_to = [];
        $sql = "SELECT G.TITLE AS PAGES_LINKING_TO, G.ID AS PAGE_ID
            FROM GROUP_PAGE_LINK L, GROUP_PAGE G, PAGE_RELATIONSHIP P
            where L.TO_ID = ? AND P.NAME = ? AND (L.FROM_ID = G.ID)
            AND (L.LINK_TYPE_ID = P.ID)"
            .$db->limitOffset($limit, $num);
        $result = $db->execute($sql, [$page_id, $relationship]);
        if ($result) {
            while ($tmp = $db->fetchArray($result)) {
                $pages_that_link_to[] = $tmp;
            }
        }
        // get the array of all pages that link from
        $pages_that_link_from = [];
        $sql = "SELECT G.TITLE AS PAGES_LINKING_FROM, G.ID AS PAGE_ID
            FROM GROUP_PAGE_LINK L, GROUP_PAGE G, PAGE_RELATIONSHIP P
            where L.FROM_ID = ? AND P.NAME = ? AND (L.TO_ID = G.ID)
            AND (L.LINK_TYPE_ID = P.ID)"
            .$db->limitOffset($limit, $num);
        $result = $db->execute($sql, [$page_id, $relationship]);
        if ($result) {
            while ( $tmp = $db->fetchArray($result)) {
                $pages_that_link_from[] = $tmp;
            }
        }
        return [$total_to_pages, $pages_that_link_to, $total_from_pages,
            $pages_that_link_from];
    }

References

Yioop Documentation: Link