if (isset($editpage['pageid']) || !isset($errors['slug'])) {
             // don't try other options if editing existing page
             break;
         }
     }
 }
 //	Perform appropriate database action
 if (isset($editpage['pageid'])) {
     // changing existing page
     if ($isexternal) {
         qa_db_page_set_fields($editpage['pageid'], isset($errors['name']) ? $editpage['title'] : $inname, QA_PAGE_FLAGS_EXTERNAL | ($innewwindow ? QA_PAGE_FLAGS_NEW_WINDOW : 0), isset($errors['url']) ? $editpage['tags'] : $inurl, null, null, $inpermit);
     } else {
         $setheading = isset($errors['heading']) ? $editpage['heading'] : $inheading;
         $setslug = isset($errors['slug']) ? $editpage['tags'] : $inslug;
         $setcontent = isset($errors['content']) ? $editpage['content'] : $incontent;
         qa_db_page_set_fields($editpage['pageid'], isset($errors['name']) ? $editpage['title'] : $inname, 0, $setslug, $setheading, $setcontent, $inpermit);
         $searchmodules = qa_load_modules_with('search', 'unindex_page');
         foreach ($searchmodules as $searchmodule) {
             $searchmodule->unindex_page($editpage['pageid']);
         }
         $indextext = qa_viewer_text($setcontent, 'html');
         $searchmodules = qa_load_modules_with('search', 'index_page');
         foreach ($searchmodules as $searchmodule) {
             $searchmodule->index_page($editpage['pageid'], $setslug, $setheading, $setcontent, 'html', $indextext);
         }
     }
     qa_db_page_move($editpage['pageid'], substr($inposition, 0, 1), substr($inposition, 1));
     $reloadpages = true;
     if (empty($errors)) {
         $editpage = null;
     } else {
         } else {
             unset($errors['slug']);
         }
         if (isset($editpage['pageid']) || !isset($errors['slug'])) {
             // don't try other options if editing existing page
             break;
         }
     }
 }
 //	Perform appropriate database action
 if (isset($editpage['pageid'])) {
     // changing existing page
     if ($isexternal) {
         qa_db_page_set_fields($editpage['pageid'], isset($errors['name']) ? $editpage['title'] : $inname, QA_PAGE_FLAGS_EXTERNAL | ($innewwindow ? QA_PAGE_FLAGS_NEW_WINDOW : 0), isset($errors['url']) ? $editpage['tags'] : $inurl, null, null);
     } else {
         qa_db_page_set_fields($editpage['pageid'], isset($errors['name']) ? $editpage['title'] : $inname, 0, isset($errors['slug']) ? $editpage['tags'] : $inslug, isset($errors['heading']) ? $editpage['heading'] : $inheading, isset($errors['content']) ? $editpage['content'] : $incontent);
     }
     qa_db_page_move($editpage['pageid'], substr($inposition, 0, 1), substr($inposition, 1));
     $reloadpages = true;
     if (empty($errors)) {
         $editpage = null;
     } else {
         $editpage = @$pages[$editpage['pageid']];
     }
 } else {
     // creating a new one
     if (empty($errors)) {
         if ($isexternal) {
             $pageid = qa_db_page_create($inname, QA_PAGE_FLAGS_EXTERNAL | ($innewwindow ? QA_PAGE_FLAGS_NEW_WINDOW : 0), $inurl, null, null);
         } else {
             $pageid = qa_db_page_create($inname, 0, $inslug, $inheading, $incontent);