function insertProcess() { $send = Request::get('send'); $valid = Validator::make(array('send.title' => 'required|min:1|slashes', 'send.parentid' => 'slashes')); if (!$valid) { throw new Exception("Error Processing Request: " . Validator::getMessage()); } if (Request::hasFile('image')) { if (Request::isImage('image')) { $send['image'] = File::upload('image'); } } if (!($id = Categories::insert($send))) { throw new Exception("Error. " . Database::$error); } }
function insertProcess() { $send = Request::get('send'); $valid = Validator::make(array('send.title' => 'min:1|slashes', 'send.keywords' => 'slashes', 'tags' => 'slashes', 'send.catid' => 'slashes', 'send.type' => 'slashes', 'send.allowcomment' => 'slashes')); if (!$valid) { throw new Exception("Error Processing Request: " . Validator::getMessage()); } $friendlyUrl = trim(String::makeFriendlyUrl($send['title'])); $getData = Post::get(array('where' => "where friendly_url='{$friendlyUrl}'")); if (isset($getData[0]['postid'])) { throw new Exception("This post exists in database."); } $uploadMethod = Request::get('uploadMethod'); switch ($uploadMethod) { case 'frompc': if (Request::hasFile('imageFromPC')) { if (Request::isImage('imageFromPC')) { $send['image'] = File::upload('imageFromPC'); } } break; case 'fromurl': if (Request::isImage('imageFromUrl')) { $url = Request::get('imageFromUrl'); $send['image'] = File::upload('uploadFromUrl'); } break; } $send['userid'] = Users::getCookieUserId(); if (!Request::has('send.catid')) { $loadCat = Categories::get(array('limitShow' => 1)); if (isset($loadCat[0]['catid'])) { $send['catid'] = $loadCat[0]['catid']; } } if (!($id = Post::insert($send))) { throw new Exception("Error. " . Database::$error); } $tags = trim(Request::get('tags')); $parse = explode(',', $tags); $total = count($parse); $insertData = array(); for ($i = 0; $i < $total; $i++) { $insertData[$i]['title'] = trim($parse[$i]); $insertData[$i]['postid'] = $id; } PostTags::insert($insertData); }
function insertProcess() { $send = Request::get('send'); $valid = Validator::make(array('send.title' => 'min:1|slashes', 'send.content' => 'min:1', 'send.keywords' => 'slashes', 'send.page_type' => 'slashes', 'send.allowcomment' => 'slashes')); if (!$valid) { throw new Exception("Error Processing Request: " . Validator::getMessage()); } $friendlyUrl = trim(String::makeFriendlyUrl($send['title'])); $getData = Pages::get(array('where' => "where friendly_url='{$friendlyUrl}'")); if (isset($getData[0]['pageid'])) { throw new Exception("This page exists in database."); } $uploadMethod = Request::get('uploadMethod'); switch ($uploadMethod) { case 'frompc': if (Request::hasFile('imageFromPC')) { if (Request::isImage('imageFromPC')) { $send['image'] = File::upload('imageFromPC'); } } break; case 'fromurl': if (Request::isImage('imageFromUrl')) { $url = Request::get('imageFromUrl'); $send['image'] = File::upload('uploadFromUrl'); } break; } if (!($id = Pages::insert($send))) { throw new Exception("Error. " . Database::$error); } }