Пример #1
0
 } else {
     $url = DefaultHelper::gerarLinkSeo($_POST['titulo']);
     foreach (PostController::getAll() as $post) {
         if ($post->Seo == $url) {
             $contador += 1;
         }
         foreach ($arrayNum as $num) {
             if ($post->Seo == $_POST["seo"] . "-" . $num) {
                 $contador += 1;
             }
         }
     }
     $_POST["seo"] .= "-" . $contador;
 }
 if (empty($_POST['id'])) {
     $res = PostController::insert($_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);
         }
     }