예제 #1
0
 /**
  * Show a form for adding a new page
  * @throws \Exception
  */
 public function add_page()
 {
     $this->to_tpl['success'] = false;
     $this->to_tpl['id'] = 0;
     $this->to_tpl['title'] = "";
     $this->to_tpl['errors'] = false;
     $this->template = "admin/add-page";
     if (isset($_POST['submit'])) {
         $errors = $this->check_input();
         if (is_array($errors) && !empty($errors)) {
             $this->to_tpl['errors'] = $errors;
         } else {
             $page = new Page();
             $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 ($id = $page->saveToDb()) {
                 $this->to_tpl['success'] = true;
                 $this->to_tpl['id'] = $id;
                 $this->to_tpl['title'] = $page->title_sr;
                 $_POST = array();
             }
         }
     }
     return;
 }
예제 #2
0
파일: core.php 프로젝트: mrzarkovic/advokat
 public function __construct()
 {
     $this->route = new \Route();
     $this->to_tpl = array();
     $this->msg_to_user = "";
     $this->template = "";
     static::$main_template = "main";
     $this->site_name = "Advokat Marinković";
     // Set the footer year
     $footer_year = new \DateTime("now");
     $this->to_tpl['footer_year'] = $footer_year->format('Y');
     // Get all the pages
     $pages = new Page();
     $pages->fetchAllByFieldValue("published", 1);
     $this->to_tpl['pages'] = $pages->list;
     // Set the default language
     $this->set_language("sr");
 }