Ejemplo n.º 1
0
Archivo: View.php Proyecto: sks40gb/sks
 /**
  * Read the js files from the js folder of the view page.
  * @param type $name - Name of the php view page.
  */
 private function setCSSFiles($name)
 {
     $js_directory = $this->getCurrentDirectory($name) . "/css";
     $files = \SKS\UTIL\FileUtil::getFiles($js_directory);
     $css_files = array();
     foreach ($files as $file) {
         $css_files[] = $js_directory . "/" . $file;
     }
     $this->css_files = $css_files;
 }
Ejemplo n.º 2
0
Archivo: Post.php Proyecto: sks40gb/sks
 function addPost()
 {
     \SKS\LIB\Session::checkAdminPermission();
     if (isset($_POST["action"])) {
         $form = new \SKS\LIB\Form();
         $form->post("title")->addRule("required")->post("post")->addRule("required")->post("category_id")->addRule("required");
         $errors = $form->validate();
         $postCategory = new \SKS\DB\Entity\PostCategory();
         $postCategory = $postCategory->findById($_POST["category_id"]);
         $post = new \SKS\DB\Entity\Post();
         $post->setTitle($_POST["title"]);
         $post->setPost($_POST["post"]);
         $post->setUser(\SKS\LIB\Session::getLoggedInUser());
         $post->setPostCategory($postCategory);
         $this->view->title = 'Post';
         $this->view->post = $post;
         $error = null;
         try {
             $filePath = \SKS\UTIL\FileUtil::uploadFile("fileToUpload");
             $filePath = str_replace("\\", "/", $filePath);
             $post->setBannerImagePath($filePath);
         } catch (Exception $ex) {
             $error = $ex->getMessage();
         }
         if (isset($errors)) {
             $this->view->errors = $errors;
         } elseif ($error != null) {
             $this->view->error = $error;
         } else {
             $post->update(true);
             $this->view->message = 'Posted Successfully';
             $this->index();
         }
     }
     $this->setCategories();
     $this->view->render('post/addPost');
 }