$contentid) { $DB -> Exec("UPDATE pages_content SET position = ".$index." WHERE id = ".$contentid); } } } if ($task == 'delete-content') { $id = Tools_Http::Request('id',true); $Page = new Common_Page(); $Page->removeContent($id); } if ($task == 'savepage') { $title = $_POST['title']; $text = isset($_POST['content']) ? $_POST['content'] : Tools_Http::Post('text_editor'); $type = $DB->Escape(Tools_Http::Post('type')); $location= Tools_Http::Post('location',true); //print_r($text); $contentid = Tools_Http::Post('pageid',true); $sectionid = Tools_Http::Post('sectionid',true); $Page = new Common_Page(); $Page->saveContent($contentid,$sectionid, $title, $text,$type,$location); ?> addContent($type, $location, $pageid); echo json_encode(array('id'=>$id)); } if ($task == 'addPage') { $title = $_POST['title']; $parentid = Tools_Http::Post('parentid',true); $pageid = Tools_Http::Post('pageid',true); $active = Tools_Http::Post('active',true); $index = Tools_Http::Post('index',true); $subindex = Tools_Http::Post('subindex',true); $locationid = Tools_Http::Post('locationid',true); $subsection = Tools_Http::Post('subsection',true); $nav = Tools_Http::Post('nav',true); $link = $DB->Escape(Tools_Http::Post('link')); $template = $DB->Escape(Tools_Http::Post('template')); $bodyid = $DB->Escape(Tools_Http::Post('bodyid')); $Page = new Common_Page(); $result = $Page->addPage($pageid, $template, $title, $parentid, $active, $index, $link, $locationid, $subindex, $subsection,$nav,$bodyid); if ($result) { if ($pageid) { echo 'OK|'.$L->Str('Lapa saglabāta!').'|self.close(); window.opener.location.href=window.opener.location.href;'; } else { echo 'OK|'.$L->Str('Lapa izveidota!').'|self.reloadPage(); window.opener.location.href=window.opener.location.href;'; } } else { $error = $Page->getLastError(); switch ($error) { case Common_Page::err_no_title: { array_push($errors,'title'); $err_msg = $L->Str('Ievadiet lapas nosaukumu!'); break; } case Common_Page::err_max_depth_reached: { array_push($errors,'parentid'); $err_msg = $L->Str('Nevar izveidot vairāk apakšsadaļas!'); break; } case Common_Page::err_index_wrong: { array_push($errors,'parentid'); $err_msg = $L->Str('Index page must not be child section.'); break; } case Common_Page::err_loop: { array_push($errors,'parentid'); $err_msg = $L->Str('Nevar pārvietot šo sadaļu izvēlētā vietā.'); break; } case Common_Page::err_bad_link: { array_push($errors,'link'); $err_msg = $L->Str('Nekorekta saite.'); break; } case Common_Page::err_bad_name: { array_push($errors,'title'); $err_msg = $L->Str('Lapa ar šādu nosaukumu jau eksistē!'); break; } } } } if (!empty($errors)) { echo 'ER|'.$err_msg.'|'.implode(',',$errors); } ?>