[ewiki] Backlinks refactor

In the name of all that good structural programming stuff, I factored out
the common code from ewiki_page_links() and aview_backlinks.  The
replacement code for ewiki_page_links() in ewiki.php follows and the new
aview_backlinks.php is attached.

-Andy

function ewiki_page_links($id, &$data, $action) {
    $o = ewiki_make_title($id, ewiki_t("PAGESLINKINGTO",
array("title"=>$id)), 1, $action, "", "_MAY_SPLIT=1");
    $o .= ewiki_list_pages(ewiki_get_backlinks($id));
    return($o);
}

function ewiki_get_backlinks($id){
    $result = ewiki_database("SEARCH", array("refs" => $id));
    
    $pages = array();
    while ($row = $result->get()) {
        if ( strpos("\n{$row[refs]}\n", "\n$id\n") ) {
            #-- add if viewing allowed
            if (!EWIKI_PROTECTED_MODE || !EWIKI_PROTECTED_MODE_HIDING ||
ewiki_auth($row["id"], $row, "view")) {
                $pages[] = $row["id"];
            }                                   
        }
    }
    
    return($pages);
}





Other related posts: