Exemple #1
0
function ewiki_intermap_walking($id, &$data, $action)
{
    if (empty($data["version"]) && ($href = ewiki_interwiki($id, $uu))) {
        header("Location: {$href}");
        return "<a href=\"{$href}\">{$href}</a>";
    }
}
Exemple #2
0
function ewiki_handler_jump(&$id, &$data, &$action)
{
    global $ewiki_config;
    static $redirect_count = 5;
    $jump_markup = array("jump", "goto", "redirect", "location");
    #-- we only care about "view" action
    if ($action != "view") {
        return;
    }
    #-- escape from loop
    if (isset($_REQUEST[EWIKI_UP_REDIRECT_COUNT])) {
        $redirect_count = $_REQUEST[EWIKI_UP_REDIRECT_COUNT];
    }
    if ($redirect_count-- <= 0) {
        return ewiki_t("REDIRECTION_LOOP", array("id" => $id));
    }
    #-- search for [jump:...]
    if ($links = explode("\n", trim($data["refs"]))) {
        foreach ($links as $link) {
            if (strlen($link) && strpos($link, ":") && in_array(strtolower(strtok($link, ":")), $jump_markup) && ($dest = trim(strtok("\n")))) {
                #-- URL
                $url = "";
                if (strpos($dest, "://")) {
                    $url = $dest;
                } else {
                    $url = ewiki_interwiki($dest, $uu, $uu2);
                }
                #-- Location:
                if (EWIKI_JUMP_HTTP && EWIKI_HTTP_HEADERS && !headers_sent()) {
                    #-- simple PageLink
                    if (empty($url)) {
                        $url = ewiki_script("", $dest, array(EWIKI_UP_REDIRECT_COUNT => $redirect_count), 0, 0, ewiki_script_url());
                        $url .= defined("SID") ? EWIKI_ADDPARAMDELIM . SID : "";
                    }
                    header("Location: {$url}");
                    die;
                } elseif ($url) {
                    return "";
                    # the rendering kernel will just show up the [jump:]!
                    # (without the jump: of course)
                } else {
                    #-- we'll just restart ewiki
                    $data = array();
                    $id = $dest;
                    return ewiki_page("view/" . $id);
                }
            }
        }
    }
    #-search
}
Exemple #3
0
function ewiki_neighbor_links(&$str, &$type, &$href, &$title)
{
    global $ewiki_metadb;
    if (!isset($ewiki_metadb)) {
        ewiki_metadb::LOAD();
    }
    if (!$ewiki_metadb) {
        return;
    }
    #-- check for alternate universes
    if ($alt = $ewiki_metadb[strtolower($href)]) {
        $inj = array();
        $real = $alt[0];
        foreach ($alt[1] as $iw) {
            $url = ewiki_interwiki("{$iw}:{$real}");
            $inj[] = "<a href=\"{$url}\">{$iw}:</a>";
        }
        $str .= " (" . implode(", ", $inj) . ")";
    }
}
Exemple #4
0
function ewiki_linking_near1(&$wsrc)
{
    global $ewiki_metadb, $ewiki_links;
    #-- select not-found links
    $nf = array();
    foreach ($ewiki_links as $id => $state) {
        if (!$state) {
            $nf[] = $id;
        }
    }
    #-- load metadb, inject URLs into $ewiki_links
    if (count($nf) && ewiki_metadb::LOAD()) {
        $nf = ewiki_metadb::FIND($nf);
        foreach ($nf as $id => $found) {
            if ($found) {
                $ewiki_links[$id] = ewiki_interwiki($found[0]);
            }
        }
        ewiki_metadb::UNLOAD();
    }
}
Exemple #5
0
function ewiki_page_final_sisterpages(&$o, $id, &$data, $action)
{
    global $ewiki_metadb, $ewiki_links;
    #-- only on edit/ pages?
    if (EWIKI_SISTER_ONLY_NONEXIST && $action != "edit") {
        return;
    }
    #-- load metadb, inject URLs into $ewiki_links
    if (ewiki_metadb::LOAD()) {
        #-- search for alternatives
        if ($alt = $ewiki_metadb[strtolower($id)]) {
            $inj = array();
            $real = $alt[0];
            foreach ($alt[1] as $iw) {
                $href = ewiki_interwiki("{$iw}:{$real}");
                $inj[] = "<a href=\"{$href}\">{$iw}:{$id}</a>";
            }
            if ($inj) {
                $o = ($action != "edit" ? ewiki_t("SISTER") : "") . implode(", ", $inj) . "<br />\n" . $o;
            }
        }
        ewiki_metadb::UNLOAD();
    }
}
Exemple #6
0
function ewiki_format_man_linkrxcb($uu)
{
    global $ewiki_man_links, $mancat;
    $str = $uu[0];
    if ($str[0] == "!" or $str[0] == "~" or $str[0] == "\\") {
        return substr($str, 1);
    }
    if ($str[0] == "[") {
        $str = substr($str, 1, strlen($str) - 2);
    }
    if (strpos($str, '"') and (preg_match('/^\\s*"(1:.+?)"\\s*(2:.+?)\\s*$/', $str, $uu) or preg_match('/^\\s*(2:.+?)\\s*"(1:.+?)"\\s*$/', $str, $uu))) {
        list($uu2, $title, $href) = $uu;
    } elseif (strpos($str, '"')) {
        list($title, $href) = explode("|", $str, 2);
    } else {
        $href = $title = $str;
        if (strpos($href, "://") && strpos($href, " ")) {
            $href = strtok($str, " ");
            $title = strtok("]");
        } elseif (!$ewiki_man_links[$href]) {
            $href = "?";
        } else {
            $href = "{$mancat}";
        }
        if (strpos($title, "://")) {
            $href = 0;
        } elseif (strpos($title, ":")) {
            $href = ewiki_interwiki($href, $uu, $uu);
        }
    }
    return "\n.BI \"" . addslashes($title) . "\"" . ($href ? $href == "?" ? "?" : " \"(" . addslashes($href) . ")\"" : "") . "\n";
}