function renumber($t, $prefix) { if (empty($t)) { return; } if ($prefix) { $prefix .= '.'; } foreach ($t as $i => $tuple) { $m = $tuple['meaning']; $m->breadcrumb = $prefix . ($i + 1); $m->save(); renumber($tuple['children'], $m->breadcrumb); } }
function renumber($mt, $refid, $rekursiv) { global $environment, $debugging, $db; $mtl = $mt . "_lang"; $sql = "SELECT {$mt}.mid, {$mt}.entry, {$mt}.refid, {$mt}.level, {$mt}.sort, {$mtl}.lang, {$mtl}.label, {$mtl}.exturl FROM {$mt} INNER JOIN {$mtl} ON {$mt}.mid = {$mtl}.mid WHERE ((({$mt}.refid)={$refid}) AND (({$mtl}.lang)='" . $environment["language"] . "')) order by sort, label;"; $menuresult = $db->query($sql); while ($menuarray = $db->fetch_array($menuresult, 1)) { $sort += 10; $sql = "UPDATE " . $mt . " SET sort=" . $sort . " WHERE mid='" . $menuarray["mid"] . "'"; if ($debugging["html_enable"]) { $debugging["ausgabe"] .= "sql: " . $sql . $debugging["char"]; } $db->query($sql); if ($rekursiv == -1) { renumber($mt, $menuarray["mid"], $rekursiv); } } }
c/o Werner Ammon Lerchenstr. 11c 86343 Königsbrunn URL: http://www.chaos.de */ //////////////////////////////////////////////////////////////////////////////////////////////////////////////// if ($environment["kategorie"] == "sort" && $rechte[$cfg["right"]] == -1) { if ($environment["parameter"][1] == "up") { $sql = "UPDATE " . $cfg["db"]["menu"]["entries"] . "\n SET sort=sort-11\n WHERE mid='" . $environment["parameter"][2] . "'"; if ($debugging["sql_enable"]) { $debugging["ausgabe"] .= "sql: " . $sql . $debugging["char"]; } $db->query($sql); } elseif ($environment["parameter"][1] == "down") { $sql = "UPDATE " . $cfg["db"]["menu"]["entries"] . "\n SET sort=sort+11\n WHERE mid='" . $environment["parameter"][2] . "'"; if ($debugging["sql_enable"]) { $debugging["ausgabe"] .= "sql: " . $sql . $debugging["char"]; } $db->query($sql); } // alle sollen neu numeriert werden if ($environment["parameter"][1] == "all") { $all = -1; } // ob up, down, oder all renumber funktion aufrufen renumber($cfg["db"]["menu"]["entries"], $cfg["db"]["lang"]["entries"], $environment["parameter"][3], $all); header("Location: " . $cfg["basis"] . "/list.html"); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
function renumber($mt, $mtl, $refid, $rekursiv = 0) { global $environment, $debugging, $db; $sql = "SELECT " . $mt . ".mid\n FROM " . $mt . "\n INNER JOIN " . $mtl . "\n ON " . $mt . ".mid = " . $mtl . ".mid\n WHERE (" . $mt . ".refid=" . $refid . ")\n AND (" . $mtl . ".lang='" . $environment["language"] . "')\n ORDER BY sort, label;"; $menuresult = $db->query($sql); while ($menuarray = $db->fetch_array($menuresult, 1)) { $sort += 10; $sql = "UPDATE " . $mt . "\n SET sort=" . $sort . "\n WHERE mid='" . $menuarray["mid"] . "'"; if ($debugging["sql_enable"]) { $debugging["ausgabe"] .= "sql: " . $sql . $debugging["char"]; } $db->query($sql); if ($rekursiv == -1) { renumber($mt, $mtl, $menuarray["mid"], -1); } } }
function AZSort($arr, $colname, $renumber = FALSE) { $sorted = array_msort($arr, array($colname => SORT_ASC)); if ($renumber !== FALSE) { return renumber($sorted); } return $sorted; }