Ejemplo n.º 1
0
 /**
  * Edit a service
  * @param int $id
  */
 public function edit_service($id = 0)
 {
     $this->to_tpl['success'] = false;
     $this->to_tpl['errors'] = false;
     $service = new Service();
     if ($service = $service->getById($id)) {
         $this->to_tpl['service'] = $service;
         $this->template = "admin/edit-service";
         if (isset($_POST['submit'])) {
             $errors = $this->check_input();
             if (is_array($errors) && !empty($errors)) {
                 $this->to_tpl['errors'] = $errors;
             } else {
                 $service->title_sr = post_string('title_sr');
                 $service->body_sr = post_string('body_sr');
                 $service->title_en = post_string('title_en');
                 $service->body_en = post_string('body_en');
                 $service->date_created = new \DateTime("now");
                 $service->published = post_bool('published');
                 if ($service->updateInDb()) {
                     $this->to_tpl['success'] = true;
                 }
             }
         }
     } else {
         header('Location: /admin/manage-services');
     }
     return;
 }
Ejemplo n.º 2
0
 /**
  * Edit a page
  * @param int $id
  * @throws \Exception
  */
 public function edit_page($id = 0)
 {
     $this->to_tpl['success'] = false;
     $this->to_tpl['errors'] = false;
     $page = new Page();
     if ($page = $page->getById($id)) {
         $this->to_tpl['page'] = $page;
         $this->template = "admin/edit-page";
         if (isset($_POST['submit'])) {
             $errors = $this->check_input();
             if (is_array($errors) && !empty($errors)) {
                 $this->to_tpl['errors'] = $errors;
             } else {
                 $page->title_sr = post_string('title_sr');
                 $page->body_sr = post_string('body_sr');
                 $page->title_en = post_string('title_en');
                 $page->body_en = post_string('body_en');
                 $page->permalink_sr = $page->check_permalink(generate_permalink($page->title_sr), "sr");
                 $page->permalink_en = $page->check_permalink(generate_permalink($page->title_en), "en");
                 $page->date_created = new \DateTime("now");
                 $page->published = post_bool('published');
                 if ($page->updateInDb()) {
                     $this->to_tpl['success'] = true;
                 }
             }
         }
     } else {
         header('Location: /admin/manage-pages');
     }
     return;
 }
Ejemplo n.º 3
0
 /**
  * Edit a client
  * @param int $id
  */
 public function edit_client($id = 0)
 {
     $this->to_tpl['success'] = false;
     $this->to_tpl['errors'] = false;
     $client = new Client();
     if ($client = $client->getById($id)) {
         $this->to_tpl['client'] = $client;
         $this->template = "admin/edit-client";
         if (isset($_POST['submit'])) {
             $errors = $this->check_input();
             if (!empty($_FILES['logo_path']["tmp_name"])) {
                 $logo_path = $this->upload_image('logo_path');
             } else {
                 $logo_path = $client->logo_path;
             }
             if (is_array($errors) && !empty($errors)) {
                 $this->to_tpl['errors'] = $errors;
             } else {
                 if (is_array($logo_path) && !empty($logo_path)) {
                     $this->to_tpl['errors']['logo_path'] = $logo_path;
                 } else {
                     $client->name_sr = post_string('name_sr');
                     $client->name_en = post_string('name_en');
                     $client->logo_path = $logo_path;
                     $client->date_created = new \DateTime("now");
                     $client->published = post_bool('published');
                     if ($client->updateInDb()) {
                         $this->to_tpl['success'] = true;
                     }
                 }
             }
         }
     } else {
         header('Location: /admin/manage-clients');
     }
     return;
 }