function ewiki_page_since_updates($id = 0, $data = 0) { $orderby = "lastmodified"; $asc = -1; $print = "%02dT %02dH %02dM %02dS"; $title = "Aktualisierung seit"; $sorted = array(); $result = ewiki_db::GETALL(array($orderby, "flags", "version")); while ($row = $result->get()) { if (EWIKI_DB_F_TEXT == ($row["flags"] & EWIKI_DB_F_TYPE)) { $sorted[$row["id"]] = $row[$orderby]; } } if ($asc != 0) { arsort($sorted); } else { asort($sorted); } foreach ($sorted as $name => $value) { $x = time() - $value; $dy = (int) ($x / 86400); $hr = (int) ($x % 86400 / 3600); $mn = (int) ($x % 86400 % 3600 / 60); $se = $x % 86400 % 3600 % 60; $sorted[$name] = sprintf($print, $dy, $hr, $mn, $se); } $o .= ewiki_list_pages($sorted); return $o; }
function ewiki_mpi_backlinks($action, &$args, &$iii, &$s) { $id = $args["page"] or $id = $GLOBALS["ewiki_id"]; if ($pages = ewiki_get_backlinks($id)) { return ewiki_list_pages($pages); } }
function ewiki_page_wordindex($id, $data, $action) { global $ewiki_plugins; $o = ewiki_make_title($id, $id, 2); $src = ""; $result = ewiki_db::GETALL(array("flags")); while ($row = $result->get()) { if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $uu, "view")) { continue; } if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) { $src .= " " . $row["id"]; } } $src = ewiki_split_title($src, "SPLIT", 0); $chars = strtr(EWIKI_CHARS_U . EWIKI_CHARS_L, "_", " "); $src = preg_replace("/[^{$chars}]/", " ", $src); $src = explode(" ", $src); $src = array_unique($src); //@ADD: word counting unset($src[""]); natcasesort($src); $sorted = array(); foreach ($src as $i => $word) { if (strlen($word) >= 2) { $sorted[] = array(EWIKI_PAGE_POWERSEARCH, array("where" => "id", "q" => $word), $word, ""); } } unset($src); $pf_list_pages = $ewiki_plugins["list_dict"][0]; $o .= ewiki_list_pages($sorted, $limit = 0, $vat = 1, $pf_list_pages); return $o; }
function ewiki_view_append_subpages($id, $data, $action, $title = "SUBPAGES", $class = "subpages") { $pages = ewiki_subpage_list($id); if (0 == count($pages)) { return ""; } $o = '<div class="' . $class . '"><small>' . ewiki_t($title) . ":</small><br />"; $o .= ewiki_list_pages($pages) . "</div>\n"; return $o; }
function ewiki_page_like($id, $data, $action) { preg_match_all("/([" . EWIKI_CHARS_U . "][" . EWIKI_CHARS_L . "]+)/", $id, $words); $pages = array(); foreach ($words[1] as $find) { $result = ewiki_db::SEARCH("id", $find); while ($row = $result->get()) { if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $row, "view")) { continue; } $pages[$row["id"]] = ""; } } $o = ewiki_make_title($id, ewiki_t(strtoupper($action) . "_TITLE"), 3); $o .= ewiki_list_pages($pages, 0); return $o; }
function ewiki_action_calendar_list($id, $data, $action) { $pages = ewiki_subpage_list($id, CALENDAR_NAME_SEP); foreach ($pages as $pageId => $uu) { if (!ewiki_isCalendarId($pageId)) { unset($pages[$pageId]); } } if (0 == count($pages)) { return ewiki_t("NOCALENDAR"); } else { //ksort($pages); $o = '<div class="calendar_list"><small>' . ewiki_t('CALENDERFOR') . " {$id}:</small><br />"; $o .= ewiki_list_pages($pages) . "</div>\n"; } return $o; }
function ewiki_mpi_removedlinks($action, &$args, &$iii, &$s) { $id = $args["id"] or $id = $args["page"] or $id = $GLOBALS["ewiki_id"]; $data = ewiki_db::GET($id); $ver = $cdata["version"]; $clinks = explode("\n", trim($data["refs"])); $rm = array(); while (--$ver >= 1) { $data = ewiki_db::GET($id, $ver); $refs = explode("\n", trim($data["refs"])); $rm = $rm + array_diff($refs, $clinks, $rm); } if ($rm) { return ewiki_list_pages($rm, 0); } else { return " "; } }
function ewiki_view_append_threads($id, $data, $action) { if (isThread($id)) { return ""; } $result = ewiki_db::SEARCH("id", $id . EWIKI_THREAD_SEPARATOR); while ($row = $result->get()) { if (!isPost($row["id"])) { $pages[$row["id"]] = ""; } } if (0 != count($pages)) { $o = "<div class='wiki_threads'><small>" . ewiki_t('THREADS') . ":</small><br />"; $o .= ewiki_list_pages($pages) . "</div>\n"; } $o .= "<form action='" . ewiki_script('addthread', $id) . "' method='POST'>" . ewiki_t("NEWTHREAD") . ": <input type='text' name='threadname'>" . "<input type='submit' value='Add Thread'>" . "</form>"; return "<div class='wiki aview threads'>" . $o . '</div>'; }
function ewiki_page_orphanedpages($id, $data, $action) { global $ewiki_links; $o = ewiki_make_title($id, ewiki_t($id), 2); $pages = array(); $refs = array(); $orphaned = array(); #-- read database $db = ewiki_database("GETALL", array("refs", "flags")); $n = 0; while ($row = $db->get()) { $p = $row["id"]; #-- remove self-reference $row["refs"] = str_replace("\n{$p}\n", "\n", $row["refs"]); #-- add to list of referenced pages $rf = explode("\n", trim($row["refs"])); $refs = array_merge($refs, $rf); if ($n++ > 299) { $refs = array_unique($refs); $n = 0; } // (clean-up only every 300th loop) #-- add page name if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) { $pages[] = $row["id"]; } } $refs = array_unique($refs); #-- check pages to be referenced from somewhere foreach ($pages as $p) { if (!ewiki_in_array($p, $refs)) { if (!EWIKI_PROTECTED_MODE || EWIKI_PROTECTED_MODE_HIDING || ewiki_auth($p, $uu, "view")) { $orphaned[] = $p; } } } #-- output $o .= ewiki_list_pages($orphaned, 0); return $o; }
function ewiki_page_index($id = 0, $data = 0, $action = 0, $args = array()) { global $ewiki_plugins; $o = ewiki_make_title($id, ewiki_t($id), 2); $sorted = array(); $sorted = array_merge($sorted, array_keys($ewiki_plugins["page"])); $exclude = "\n" . implode("\n", preg_split("/\\s*[,;:\\|]\\s*/", $args["exclude"])) . "\n"; $result = ewiki_database("GETALL", array("flags")); while ($row = $result->get()) { if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $uu, "view")) { continue; } if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) { if (!stristr($exclude, "\n" . $row["id"] . "\n")) { $sorted[] = $row["id"]; } } } natcasesort($sorted); $o .= ewiki_list_pages($sorted, 0, 0, $ewiki_plugins["list_dict"][0]); return $o; }
function ewiki_page_search($id, &$data, $action) { global $CFG; $q = optional_param('q', ''); $o = ewiki_make_title($id, $id, 2, $action); if ($q == '') { $o .= '<form action="' . ewiki_script("", $id) . '" method="post">'; $o .= '<fieldset class="invisiblefieldset">'; $o .= '<input name="q" size="30" /><br /><br />'; $o .= '<input type="submit" value="' . $id . '" />'; $o .= '</fieldset>'; $o .= '</form>'; } else { $found = array(); if ($CFG->unicodedb) { $q = preg_replace('/\\s*[\\W]+\\s*/u', ' ', $q); } else { $q = preg_replace('/\\s*[^\\w]+\\s*/', ' ', $q); } foreach (explode(" ", $q) as $search) { if (empty($search)) { continue; } $result = ewiki_database("SEARCH", array("content" => $search)); while ($row = $result->get()) { #-- show this entry in page listings? if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $row, "view")) { continue; } $found[] = $row["id"]; } } $o .= ewiki_list_pages($found); } return $o; }
/* Lists all used words inside WikiPageNames and shows a list of them (similar to PageIndex) - but it redirects the words to PowerSearch, which also needs to be installed therefore! */ global $ewiki_plugins; echo ewiki_make_title($id, $id, 2); $result = ewiki_db::GETALL(array("flags")); $src = ""; while ($row = $result->get(0, 0x37, EWIKI_DB_F_TEXT)) { $src .= " " . $row["id"]; } $src = ewiki_split_title($src, "SPLIT", 0); $chars = strtr(EWIKI_CHARS_U . EWIKI_CHARS_L, "_", " "); $src = preg_replace("/[^{$chars}]/", " ", $src); $src = explode(" ", $src); $src = array_unique($src); //@ADD: word counting unset($src[""]); natcasesort($src); $sorted = array(); foreach ($src as $i => $word) { if (strlen($word) >= 2) { $sorted[] = array(EWIKI_PAGE_POWERSEARCH, array("where" => "id", "q" => $word), $word, ""); } } unset($src); $pf_list_pages = $ewiki_plugins["list_dict"][0]; echo ewiki_list_pages($sorted, $limit = 0, $vat = 1, $pf_list_pages);
$db = ewiki_db::GETALL(array("refs", "flags")); $n = 0; while ($row = $db->get()) { $p = $row["id"]; #-- remove self-reference $row["refs"] = str_replace("\n{$p}\n", "\n", $row["refs"]); #-- add to list of referenced pages $rf = explode("\n", trim($row["refs"])); $refs = array_merge($refs, $rf); if ($n++ > 299) { $refs = array_unique($refs); $n = 0; } // (clean-up only every 300th loop) #-- add page name if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) { $pages[] = $row["id"]; } } $refs = array_unique($refs); #-- check pages to be referenced from somewhere foreach ($pages as $p) { if (!ewiki_in_array($p, $refs)) { if (!EWIKI_PROTECTED_MODE || !EWIKI_PROTECTED_MODE_HIDING || ewiki_auth($p, $uu, "view")) { $orphaned[] = $p; } } } #-- output echo ewiki_list_pages($orphaned, 0);
<?php /* orders pages by count of links they have */ echo ewiki_make_title($id, $id, 2); #-- fetch all pages $list = array(); $result = ewiki_db::GETALL(array("refs")); while ($r = $result->get(0, 0x137, EWIKI_DB_F_TEXT)) { $list[$r["id"]] = count(explode("\n", trim($r["refs"]))); } #-- beatify list if (isset($_REQUEST["desc"])) { asort($list); } else { arsort($list); } $r = array(); foreach ($list as $id => $num) { $r[] = array($id, "", "", "({$num})"); } unset($list); #-- output echo ewiki_list_pages($r, 0);
<?php /* shows up pages that don't link to anywhere */ #-- title echo ewiki_make_title($id, $id, 2); echo "\n<p>Pages without links to anywhere else. Often this are unwanted ShallowPages.</p>\n"; #-- find / analyze db $result = ewiki_db::GETALL(array("refs")); $ll = array(); while ($row = $result->get(0, 0x137, EWIKI_DB_F_TEXT)) { $id = $row["id"]; $refs = trim($row["refs"]); #-- no links to anywhere else? if (!$refs || strtolower($refs) == strtolower($id)) { $ll[] = $id; } } #-- bring up list echo ewiki_list_pages($ll, 0, 0, 0);