Пример #1
0
     }
 } else {
     $res = PostController::update($_POST);
     //Tags
     $tags = array();
     if (count($_POST["tags"]) > 0) {
         $tags = explode(",", $_POST["tags"]);
     }
     $newTags = array();
     if (count($_POST["newTags"]) > 0 && !empty($_POST["newTags"])) {
         $newTags = explode(",", $_POST["newTags"]);
     }
     if (!empty($newTags) && count($newTags) > 0) {
         foreach ($newTags as $newTag) {
             $arr = array("nome" => $newTag, "seo" => "");
             $tags[] = TagController::insert($arr);
         }
     }
     $tagsPost = PostController::getAllPostTag($_POST['id'], "", "");
     if (count($tagsPost) > 0) {
         foreach ($tagsPost as $tag) {
             $tagsPostList[] = $tag->IdTag;
         }
         $array = array();
         foreach ($tags as $tag) {
             error_log($tag);
             if (!in_array($tag, $tagsPostList)) {
                 $arr = array("idTag" => $tag, "idPost" => $_POST['id']);
                 PostController::insertPostTag($arr);
             }
         }
Пример #2
0
<?php

if ($_POST['action'] == "save") {
    if (empty($_POST['id'])) {
        $res = TagController::insert($_POST);
        if ($res) {
            header("Location: blog-tags");
            exit;
        } else {
            die("ERRO");
        }
    } else {
        $res = TagController::update($_POST);
        if ($res) {
            header("Location: blog-tags");
            exit;
        } else {
            die("ERRO");
        }
    }
} elseif ($_POST['action'] == "del") {
    if (TagController::delete($_POST)) {
        die("OK");
    } else {
        die("ERRO");
    }
}