function commentform($pageid) { //global $session; $process = new ProcessForm(); $validate = $process::validate(); $postcomment = new Table("Comments"); //Process Page Form if ($process->submitForm()) { /*@setting validation rules*/ $required = array("name", "comment"); $process->errorinfo = array_merge($process->errorinfo, $validate->check_requiredFields($required)); $massage = $process->message("Comment has been successfully submmited."); //$sucessmsg = $_REQUEST["msg"]=$massage; if ($process->successflag) { //put database table here $postcomment::$tablefields = array("Name" => $process->post("name"), "Comment" => $process->post("comment"), "Pageid" => $pageid); /*saved to database*/ $postcomment->save(); //echo "new recored was added with id=".$postcomment->lastInsertedId(); //echo "<br> success happened and all fields are sent to database, Thank you ! :)"; } } $form = new Form("commentform", filter_var($_SERVER['PHP_SELF']) . "?" . filter_var($_SERVER['QUERY_STRING']), "post"); //Company; $form->startForm(); $form->setFormField("", $form->addFormInfo("<h2>Comment Form</h2>")); //Page Title $form->setFormField($form->inputLabel("name", "*Name"), $form->inputField("text", "name", $process->post("name")), $validate->displayErrorField($process->errorinfo, "name")); // Page Content $form->setFormField($form->inputLabel("comment", "*Comment (HTML is not allowed)"), $form->textAreaField("comment", $process->post("comment"), 10, 45, 'placeholder="Type comment here"'), $validate->displayErrorField($process->errorinfo, "comment")); //Submit Form $form->setFormField(null, $form->inputField("hidden", "userid", $process->post("userid", $authorid = "")) . $form->inputField("submit", "submit", "Add Comment")); $form->endForm(); return $form->DisplayFields($GLOBALS["form_labling"], $process->message); }
function businessdirform() { //put contents here //include_once"../../includes/initialize.inc.php"; $process = new ProcessForm(); $validate = $process::validate(); if (isset($GLOBALS["action"]) == "edit") { //$id = $GLOBALS["id"]; //$editbiz = BusinessDirectory::findById($id); } if ($process->submitForm()) { /*@setting validation rules*/ $required = array("company", "address", "website", "email_address", "location", "cellphone", "business_description"); $process->errorinfo = array_merge($process->errorinfo, $validate->check_requiredFields($required)); $check_invalidchars = array("company", "address", "website", "location", "description"); $process->errorinfo = array_merge($process->errorinfo, $validate->check_invalidChars($check_invalidchars)); $requiredlen = array("company" => 80, "address" => 50, "website" => 255, "location" => 50, "phone" => 15); $process->errorinfo = array_merge($process->errorinfo, $validate->check_FieldLength($requiredlen)); $selectedindex = array("category" => "--Select Category--", "region" => "--Select Region--"); $process->errorinfo = array_merge($process->errorinfo, $validate->check_selectField($selectedindex)); $process->errorinfo = array_merge($process->errorinfo, $validate->check_number("cellphone", "phone")); $process->errorinfo = array_merge($process->errorinfo, $validate->check_number("fax", "phone")); //Sucess $process->message("Hey successfully submmited the form"); if ($process->successflag) { echo "success happened and all fields are sent to database, Thank you ! :)"; //put database table here } } $form = new Form("Addbusiness", $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'], "post", "enctype=\"application/x-www-form-urlencoded\"\n"); //Company); $form->startForm(); $form->setFormField("", $form->addFormInfo("<h2>Use this form to add Bussiness Profiles..</h2>")); $form->setFormField($form->inputLable("company", "Company"), $form->inputField("text", "company", $process->post("company")), $validate->displayErrorField($process->errorinfo, "company")); //Category $bizcategory = function () { $category = new GetTableRecord("bizcategory"); $category_options = $category::findAllRecords(); $options[] = "--Select Category--"; foreach ($category_options as $opt) { $options[] = $opt->Category; } return $options; }; //$category_options = array('--Select Category--',"IT"); $form->setFormField($form->inputLable("category", "Category"), $form->selectOptions("category", $bizcategory(), $process->post("category")), $validate->displayErrorField($process->errorinfo, "category")); //Location Address $form->setFormField($form->inputLable("address", "Address"), $form->textAreaField("address", $process->post("address"), "2", "20"), $validate->displayErrorField($process->errorinfo, "address")); //Regions, this fn returns db object into an array $regions = function () { $region = new GetTableRecord("Regions"); $region_options = $region::findAllRecords(); $options[] = "--Select Region--"; foreach ($region_options as $opt) { $options[] = $opt->Region; } return $options; }; $form->setFormField($form->inputLable("region", "Region"), $form->selectOptions("region", $regions(), $process->post("region")), $validate->displayErrorField($process->errorinfo, "region")); //Website Address $form->setFormField($form->inputLable("website", "Website (URL)"), $form->inputField("url", "website", $process->post("website")), $validate->displayErrorField($process->errorinfo, "website")); //Email Address $form->setFormField($form->inputLable("email", "Email"), $form->inputField("email", "email_address", $process->post("email_address")), $validate->displayErrorField($process->errorinfo, "email_address")); // Location Address $form->setFormField($form->inputLable("location", "Location"), $form->inputField("text", "location", $process->post("location")), $validate->displayErrorField($process->errorinfo, "location")); //Cellphone $form->setFormField($form->inputLable("cellphone", "Cellphone"), $form->inputField("tel", "cellphone", $process->post("cellphone")), $validate->displayErrorField($process->errorinfo, "cellphone")); //Fax $form->setFormField($form->inputLable("fax", "Fax (Optional)"), $form->inputField("tel", "fax", $process->post("fax")), $validate->displayErrorField($process->errorinfo, "fax")); // Business Description $form->setFormField($form->inputLable("business_description", "Business Description"), $form->textAreaField("business_description", $process->post("business_description"), "10", "40"), $validate->displayErrorField($process->errorinfo, "business_description")); //Submit Form $form->setFormField(null, $form->inputField("submit", "send", "Add Bussiness Directory")); $form->endForm(); return $form->DisplayFields($GLOBALS["form_labling"], $process->message); }
//put database table here } } //Create form //array("company","address","website","location","cellphone","fax","description"); // $process->successmsg ="Hey successfully submmited the form"; echo $process->message(); //if(strlen(@$msg) > 0) echo "<p class=\"error\">".$msg."</p>"; $form->startForm("Addbusiness", $_SERVER['PHP_SELF'], "post", "enctype=\"application/x-www-form-urlencoded\"") . "\n"; //Company $form->setFormField($form->inputLable("company", "Company"), $form->inputField("text", "company", $process->post("company")), $validate->displayErrorField($process->errorinfo, "company")); //Category $category_options = array('--Select Category--', "IT"); $form->setFormField($form->inputLable("category", "Category"), $form->selectOptions("category", $category_options, $process->post("category")), $validate->displayErrorField($process->errorinfo, "category")); //Location Address $form->setFormField($form->inputLable("address", "Address"), $form->textAreaField("address", $process->post("address"), "2", "20"), $validate->displayErrorField($process->errorinfo, "address")); //Region $region_options = array('--Select Region--', "GT"); $form->setFormField($form->inputLable("region", "Region"), $form->selectOptions("region", $region_options, $process->post("region")), $validate->displayErrorField($process->errorinfo, "region")); //Website Address $form->setFormField($form->inputLable("website", "Website (URL)"), $form->inputField("url", "website", $process->post("website")), $validate->displayErrorField($process->errorinfo, "website")); //Email Address $form->setFormField($form->inputLable("email", "Email"), $form->inputField("email", "email_address", $process->post("email_address")), $validate->displayErrorField($process->errorinfo, "email_address")); // Location Address $form->setFormField($form->inputLable("location", "Location"), $form->inputField("text", "location", $process->post("location")), $validate->displayErrorField($process->errorinfo, "location")); //Cellphone $form->setFormField($form->inputLable("cellphone", "Cellphone"), $form->inputField("tel", "cellphone", $process->post("cellphone")), $validate->displayErrorField($process->errorinfo, "cellphone")); //Fax $form->setFormField($form->inputLable("fax", "Fax (Optional)"), $form->inputField("tel", "fax", $process->post("fax")), $validate->displayErrorField($process->errorinfo, "fax")); // Location Address $form->setFormField($form->inputLable("description", "Business Description"), $form->textAreaField("description", $process->post("description"), 10, 40), $validate->displayErrorField($process->errorinfo, "description"));
function pageform() { global $session; $process = new ProcessForm(); $validate = $process::validate(); $postdata = new Page("pages"); $user = new User("users"); $uid = $user::findRow("Id={$session->userid}"); //change this to login session id when login is activated $id = $postdata::$id = isset($GLOBALS["id"]) ? "Id=" . $GLOBALS["id"] : null; //id recieved form querystring if ($GLOBALS["action"] == "editpage") { $edit = $postdata::findRow($id); // $title = $edit->Title; $category = $edit->Position; $source = $edit->Source; $pgcontent = $edit->Content; $published = $edit->Published; $featured = $edit->Featured; $authorid = $uid->Id; //image to upload $pgimage = ""; $imgcaption = ""; } else { $title = ""; $category = ""; $source = ""; $pgcontent = ""; $published = ""; $featured = ""; $authorid = $uid->Id; //image to upload $pgimage = ""; $imgcaption = ""; //debug($authorid); } //Process Page Form //Process Image Uploads here $upload_path = "../"; $upload = new UploadFiles($upload_path . PAGEIMG_DIR, $upload_path . TEMP_DIR); if ($process->submitForm()) { /*@setting validation rules*/ $upload->Mimetype = array('image/pjpeg' => "jpeg", 'image/jpeg' => "jpeg", 'image/png' => "png", 'image/gif' => "gif"); $required = array("title", "page_content", "source"); $process->errorinfo = array_merge($process->errorinfo, $validate->check_requiredFields($required)); $check_invalidchars = array("title", "source"); $process->errorinfo = array_merge($process->errorinfo, $validate->check_invalidChars($check_invalidchars)); $requiredlen = array("title" => 100); $process->errorinfo = array_merge($process->errorinfo, $validate->check_FieldLength($requiredlen)); $selectedindex = array("category" => "--Select Category--"); $process->errorinfo = array_merge($process->errorinfo, $validate->check_selectField($selectedindex)); if ($id == null) { $getrow = $postdata::fieldExists("Title={$_POST["title"]}"); if ($getrow) { $process->errorinfo["title"] = $_POST["title"] . " already exist"; } } /* upload info on validation ,//Sucess*/ $massage = $process->message("Page has been successfully submmited."); if ($process->successflag) { //put database table here $postdata::$tablefields = array("Title" => $_POST["title"], "Content" => $_POST["page_content"], "Source" => $_POST["source"], "Postedby" => $_POST["authorid"], "Position" => $_POST["category"], "Published" => $_POST["publish"], "Featured" => $_POST["feature"]); /*saved to database*/ $postdata->save(); //echo "new recored was added with id=".$postdata->lastInsertedId(); //echo "<br> success happened and all fields are sent to database, Thank you ! :)"; /*uploads info*/ $upload->uploadFile("uploadimg"); //upolads an image if ($upload->Upload_status == true) { $postimg = new Image("pageimgs"); $pageid = $id != null ? $id : $postdata->lastInsertedId(); $postimg::$tablefields = array("Imgname" => $upload->Newfilename, "Width" => $upload->Width, "Height" => $upload->Height, "Imgcaption" => $_POST["imgcaption"], "Mimetype" => $upload->Filetype, "Extention" => $upload->File_ext, "Pageid" => $pageid); //check and delete old image record in pageimg table $pid = $postimg->findRow("Pageid=" . $pageid); if ($pid != null) { //if(file_exists($upload_path.PAGEIMG_DIR.$pid->Imgname.".".$pid->Extention)){ $upload->deleteFile($upload_path . PAGEIMG_DIR . $pid->Imgname . "." . $pid->Extention); $upload->deleteFile($upload_path . PAGEIMG_DIR . "thumbnails/" . $pid->Imgname . "." . $pid->Extention); } // } $postimg->save(); } } //upload image } $form = new Form("Pageform", filter_var($_SERVER['PHP_SELF']) . "?" . filter_var($_SERVER['QUERY_STRING']), "post", "enctype=\"multipart/form-data\"\n"); //Company; $form->startForm(); $form->setFormField("", $form->addFormInfo("<h2>Use this form add new Page..</h2><p>Required Fields are labelled with asterics (*)</p><hr/>")); //Page Title $form->setFormField($form->inputLabel("title", "*Title"), $form->inputField("text", "title", $process->post("title", $title)), $validate->displayErrorField($process->errorinfo, "title")); //Category $pgcategory = function () { $category = new GetTableRecord("pagecategory"); $category_options = $category::findAllRecords(); $options[] = "--Select Category--"; foreach ($category_options as $opt) { $options[$opt->Position] = $opt->Category; } return $options; }; $form->setFormField($form->inputLabel("category", "*Category"), $form->selectOptions("category", $pgcategory(), $process->post("category", $category)), $validate->displayErrorField($process->errorinfo, "category")); //Page Source $form->setFormField($form->inputLabel("source", "*Source"), $form->inputField("text", "source", $process->post("source", $source)), $validate->displayErrorField($process->errorinfo, "source")); // Page Content $form->setFormField($form->inputLabel("page_content", "*Content"), $form->textAreaField("page_content", $process->post("page_content", $pgcontent), "10", "50", "class=\"ckeditor\""), $validate->displayErrorField($process->errorinfo, "page_content")); //Upload Image $form->setFormField($form->inputLabel("uploadimg", "Upload Image"), $form->uploadField("uploadimg[]", "uploadimg") . "<br>" . $form->textAreaField("imgcaption", $process->post("imgcaption", $imgcaption), "1", "45", 'placeholder="Image Caption"') . $form->inputField("hidden", "MAX_FILE_SIZE", "40000000"), $validate->displayErrorField($process->errorinfo, "uploadimg")); //Radio for Visible/ $form->setFormField($form->inputLabel("publish", "Publish"), $form->radioButton("Yes", "publish", "Y", $process->post("publish", $published) == "Y" ? true : false) . $form->radioButton("No", "publish", "N", $process->post("publish", $published) == "N" ? true : false)); //Featured Page $form->setFormField($form->inputLabel("feature", "Feature"), $form->radioButton("Yes", "feature", "Y", $process->post("feature", $featured) == "Y" ? true : false) . $form->radioButton("No", "feature", "N", $process->post("feature", $featured) == "N" ? true : false)); //Submit Form $form->setFormField(null, $form->inputField("hidden", "authorid", $process->post("authorid", $authorid)) . $form->inputField("submit", "send", "Save")); $form->endForm(); return $form->DisplayFields($GLOBALS["form_labling"], $process->message); }