コード例 #1
0
ファイル: mpi_phpwiki.php プロジェクト: gpuenteallott/rox
function ewiki_mpi_phpwiki_allusers($action, &$args, &$iii, &$s)
{
    $authors = array();
    $result = ewiki_db::GETALL(array("author"));
    while ($row = $result->get()) {
        if ($uu = strtok($row["author"], "(")) {
            $authors[trim($uu)] = 1;
        }
    }
    $authors = array_keys($authors);
    natcasesort($authors);
    foreach ($authors as $a) {
        $o .= "· " . ewiki_link_regex_callback(array($a)) . "<br />\n";
    }
    return $o;
}
コード例 #2
0
function ewiki_page_wantedpages($id, $data, $action)
{
    $wanted = array();
    #-- collect referenced pages
    $result = ewiki_database("GETALL", array("refs"));
    while ($row = $result->get()) {
        if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $uu, "view")) {
            continue;
        }
        $refs .= $row["refs"];
    }
    #-- build array
    $refs = array_unique(explode("\n", $refs));
    #-- strip existing pages from array
    $refs = ewiki_database("FIND", $refs);
    foreach ($refs as $id => $exists) {
        if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $uu, "view")) {
            continue;
        }
        if (!$exists && !strstr($id, "://") && strlen(trim($id))) {
            $wanted[] = $id;
        }
    }
    // to prevent empty <ul></ul> getting printed out, we have to interate twice.
    // once to make sure the <ul></ul> is needed at all.
    // MDL-7861, <ul></ul> does not validate.
    $printul = false;
    foreach ($wanted as $page) {
        $link = ewiki_link_regex_callback(array($page, $page));
        if (strstr($link, "?</a>")) {
            $printul = true;
        }
    }
    #-- print out
    if ($printul) {
        $o .= "<ul>";
        foreach ($wanted as $page) {
            $link = ewiki_link_regex_callback(array($page, $page));
            if (strstr($link, "?</a>")) {
                $o .= "<li>" . $link . "</li>";
            }
        }
        $o .= "</ul>";
    }
    return $o;
}
コード例 #3
0
ファイル: ewiki.php プロジェクト: nicolasconnault/moodle2.0
function ewiki_page_info($id, &$data, $action)
{
    global $ewiki_plugins, $ewiki_config, $ewiki_links;
    global $CFG, $COURSE, $DB;
    // MOODLE HACK
    $pnum = optional_param(EWIKI_UP_PAGENUM, 0);
    $pend = optional_param(EWIKI_UP_PAGEEND, 0);
    $o = ewiki_make_title($id, ewiki_t("INFOABOUTPAGE") . " '{$id}'", 2, $action, "", "_MAY_SPLIT=1");
    $flagnames = array("TEXT", "BIN", "DISABLED", "HTML", "READONLY", "WRITEABLE", "APPENDONLY", "SYSTEM");
    $show = array("version", "author", "userid", "created", "lastmodified", "refs", "flags", "meta", "content");
    #-- versions to show
    $v_start = $data["version"];
    if ($pnum && $pnum <= $v_start) {
        $v_start = $pnum;
    }
    $v_end = $v_start - $ewiki_config["list_limit"] + 1;
    if ($pend && $pend <= $v_start) {
        $v_end = $pend;
    }
    $v_end = max($v_end, 1);
    #-- go
    # the very ($first) entry is rendered more verbosely than the others
    for ($v = $v_start, $first = 1; $v >= $v_end; $v--, $first = 0) {
        $current = ewiki_database("GET", array("id" => $id, "version" => $v));
        if (!strlen(trim($current["id"])) || !$current["version"] || !strlen(trim($current["content"]))) {
            continue;
        }
        $o .= '<table  class="version-info" cellpadding="2" cellspacing="1">' . "\n";
        #-- additional info-actions
        $commands = '';
        foreach ($ewiki_config["action_links"]["info"] as $thisaction => $title) {
            if (@$ewiki_plugins["action"][$thisaction] || @$ewiki_plugins["action_always"][$thisaction]) {
                ##### BEGIN MOODLE ADDITION #####
                if ($commands) {
                    $commands .= '&nbsp;&nbsp;';
                }
                $commands .= '<a href="' . ewiki_script($thisaction, $id, array("version" => $current["version"])) . '">' . get_string($title, "wiki") . '</a>';
                ##### END MOODLE ADDITION #####
            }
        }
        #-- print page database entry
        foreach ($show as $i) {
            $value = @$current[$i];
            #-- show database {fields} differently
            if ($i == "meta") {
                continue;
                // MOODLE DOESN'T USE IT
                $str = "";
                if ($first && $value) {
                    foreach ($value as $n => $d) {
                        $str .= s("{$n}: {$d}") . "<br />\n";
                    }
                }
                $value = $str;
            } elseif ($value >= UNIX_MILLENNIUM) {
                #-- {lastmodified}, {created}
                #### BEGIN MOODLE CHANGE
                $value = userdate($value);
                #$value = strftime("%c", $value);
                #### END MOODLE CHANGE
            } elseif ($i == "content") {
                continue;
                // MOODLE DOESN'T CARE
                $value = strlen(trim($value)) . " bytes";
                $i = "content size";
            } elseif ($first && $i == "refs" && !(EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING >= 2)) {
                $a = explode("\n", trim($value));
                $ewiki_links = ewiki_database("FIND", $a);
                ewiki_merge_links($ewiki_links);
                foreach ($a as $n => $link) {
                    $a[$n] = ewiki_link_regex_callback(array("{$link}"), "force_noimg");
                }
                $value = trim(implode(", ", $a));
                if (!$value) {
                    continue;
                }
            } elseif (strpos($value, "\n") !== false) {
                #-- also for {refs}
                $value = str_replace("\n", ", ", trim($value));
                if (!$value) {
                    continue;
                }
            } elseif ($i == "version") {
                $value = '<a href="' . ewiki_script("", $id, array("version" => $value)) . '">' . $value . '</a> ' . "({$commands})";
            } elseif ($i == "flags") {
                continue;
                // MOODLE DOESN'T USE IT
                $fstr = "";
                for ($n = 0; $n < 32; $n++) {
                    if ($value & 1 << $n) {
                        if (!($s = $flagnames[$n])) {
                            $s = "UU{$n}";
                        }
                        $fstr .= $s . " ";
                    }
                }
                $value = $fstr;
            } elseif ($i == "author") {
                continue;
                $ewiki_links = 1;
                $value = preg_replace_callback("/((\\w+:)?([" . EWIKI_CHARS_U . "]+[" . EWIKI_CHARS_L . "]+){2,}[\\w\\d]*)/", "ewiki_link_regex_callback", $value);
            } elseif ($i == "userid") {
                $i = 'author';
                if ($user = $DB->get_record('user', array('id' => $value))) {
                    if (!isset($COURSE->id)) {
                        $COURSE->id = SITEID;
                    }
                    $picture = print_user_picture($user->id, $COURSE->id, $user->picture, false, true, true);
                    $value = $picture . " <a href=\"{$CFG->wwwroot}/user/view.php?id={$user->id}&amp;course={$COURSE->id}\">" . fullname($user) . "</a>";
                } else {
                    continue;
                    //$value = @$current['author'];
                }
            }
            ##### BEGIN MOODLE ADDITION #####
            $o .= '<tr class="page-' . $i . '"><td style="vertical-align:top;text-align:right;white-space: nowrap;"><b>' . ewiki_t($i) . ':</b></td>' . '<td>' . $value . "</td></tr>\n";
            ##### END MOODLE ADDITION #####
        }
        $o .= "</table><br /><br />\n";
    }
    #-- page result split
    if ($v >= 1) {
        $o .= "<br />\n" . get_string('showversions', 'wiki') . ' ' . ewiki_chunked_page($action, $id, -1, $v, 1, 0, 0) . "\n <br />";
    }
    return $o;
}