/*
  Reads the recently updated pages list from the database (like
  "UpdatedPages") and tries to save it in another database table
  (this example does so in my privately used webcms for speed purposes).
*/


#-- save newest pages
function save_newest_pages()
{
   $sorted = array();
   $result = ewiki_db::GETALL(array("lastmodified", "flags", "version"));
   while ($row = $result->get()) {
      if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) {
         $sorted[$row["id"]] = $row["lastmodified"];
      }
   }
   arsort($sorted);
   $n = 0;
   $o = "";
   foreach ($sorted as $id=>$uu) {
      $o .= '·<a href="/wiki/?id=' . urlencode($id) . '">' .
            preg_replace('/(\w{15}[a-zäöüß]*)(\w{3,5})/', '$1&shy;$2', $id) . "</a><br>\n";
      if ($n++ >= 15) break;
   }
   $o = addslashes($o);

   mysql_query("UPDATE text_table SET html='$o' WHERE filename='wiki-updated' ")
   or
   return($o);
}

