<? $cat = $_POST['cat']; if (strlen($cat) == 0) { $recipes = Recipe::getAll(); } else { if ($cat == "null") { $c = NULL; } else { $c = Category::getById($cat); if ($c == NULL) { $errMsg = Text::getText("CategoryNotFound").": ".$cat; include("error.php"); exit; } } $recipes = Recipe::getInCategory($c); } $categories = Category::getAll(); $catForId = array(); foreach ($categories as $tempCat) { $catForId[$tempCat->getId()] = $tempCat; } foreach ($recipes as $r) { $fieldName = "cat".$r->getId(); $newCatId = $_POST[$fieldName]; //print "recipe ".$r->getId().": $newCatId<br>"; if ($newCatId == "") { } else {
<? require_once("classes/Recipe.php"); ?> <? require_once("classes/Category.php"); ?> <? require_once("classes/Text.php"); ?> <? $c = NULL; $cat = $_REQUEST['cat']; if (strlen($cat) == 0) { //$all = Recipe::getAll(); $all = Recipe::getInCategory(NULL); } else { if ($cat == "null") { $all = Recipe::getInCategory(NULL); } else { $c = Category::getById($cat); $all = Recipe::getInCategory($c); } } include("header.php"); if ($cat == "") { // Include only on the very front page include("welcome.php"); } include("recipeNav.php"); $rssUrl = $baseUrl."/rss.php?cat=".(strlen($cat) == 0 ? "null" : $cat); ?> <? if ($c != NULL) { ?> <h2><?php echo $c->getName(); ?>
include("error.php"); exit; } else { if ($action == "delete") { if (strlen($newCat) > 0) { if ($newCat == NULL || $newCat == "null") { $newCategory = NULL; } else { $newCategory = Category::getById($newCat); if ($newCategory == NULL) { $errMsg = Text::getText("CategoryNotFound"); include("error.php"); exit; } } $recipesToMove = Recipe::getInCategory($thisCat); for ($i = 0; $i < count($recipesToMove); $i++) { $r2m = $recipesToMove[$i]; $r2m->setCategory($newCategory); $r2m->save(); } } $thisCat->delete(); header("Location: categoryList.php"); } else { $c = $thisCat; include("header.php"); include("categoryDeleteForm.php"); include("footer.php"); } }