public function post_delete_page()
 {
     if (Input::has('page_id')) {
         $pid = Input::get('page_id');
         $elements = CmsPage::find($pid)->elements;
         //CHECK IF CONTAINS ELEMENTS
         if (!empty($elements) and !Input::has('force_delete')) {
             Notification::error(LL('cms::alert.delete_page_stillelements_error', CMSLANG), 2500);
             return Redirect::to_action('cms::page', array(LANG));
         } else {
             //CHECK IF CONTAINS SUBPAGES
             $subpages = CmsPage::where_parent_id($pid)->first();
             if (!empty($subpages)) {
                 Notification::error(LL('cms::alert.delete_page_stillsubpages_error', CMSLANG), 2500);
                 return Redirect::to_action('cms::page', array(LANG));
             } else {
                 // FORCE DELETE IS FLAGGED -> DETACH ELEMENTS
                 if (Input::has('force_delete')) {
                     // Ciclo tutti gli elementi collegati alla pagina
                     foreach ($elements as $element) {
                         // Elimino il link dell'elemento con la pagina
                         DB::table('elements_pages')->where_cmspage_id($pid)->where_cmselement_id($element->id)->delete();
                         // Conto quante altre pagine hanno l'elemento
                         $n = DB::table('elements_pages')->where_cmselement_id($element->id)->count();
                         // Se ritorna 0, elimino
                         if ($n == 0) {
                             CmsElement::find($element->id)->delete();
                         }
                     }
                 }
                 $page = CmsPage::find($pid);
                 $lang = $page->lang;
                 //DELETE FILES ASSOCIATION
                 $page->files()->delete();
                 //DELETE PAGE
                 $page->delete();
                 Notification::success(LL('cms::alert.delete_page_success', CMSLANG, array('page' => $page->name)), 1500);
                 return Redirect::to_action('cms::page', array($lang));
             }
         }
     } else {
         Notification::error(LL('cms::alert.delete_page_error', CMSLANG), 1500);
         return Redirect::to_action('cms::page', array(LANG));
     }
 }