Esempio n. 1
0
 private function add($fill, $doRedirect = false)
 {
     $fill['picture'] = photo::UploadImage($_FILES);
     if (isset($_POST['x1']) && isset($_POST['y1']) && isset($_POST['w1']) && isset($_POST['h1'])) {
         $data = array('x1' => $_POST['x1'], 'y1' => $_POST['y1'], 'w1' => $_POST['w1'], 'h1' => $_POST['h1']);
         unset($_POST['x1'], $_POST['y1'], $_POST['w1'], $_POST['h1']);
         photo::imageCrop($_POST['picture'], $data, '200x200');
     }
     if (isset($_POST['x2']) && isset($_POST['y2']) && isset($_POST['w2']) && isset($_POST['h2'])) {
         $data = array('x1' => $_POST['x2'], 'y1' => $_POST['y2'], 'w1' => $_POST['w2'], 'h1' => $_POST['h2']);
         unset($_POST['x2'], $_POST['y2'], $_POST['w2'], $_POST['h2']);
         photo::imageCrop($_POST['picture'], $data, '200x140');
     }
     if (isset($_POST['width'])) {
         unset($_POST['width']);
     }
     if (isset($_POST['height'])) {
         unset($_POST['height']);
     }
     if (empty($fill["title"])) {
         $fill["title"] = time();
     }
     $fill['type'] = 'news';
     // echo '<pre>'.print_r($fill,1).'</pre>'; exit;
     if (!empty($fill["slug"])) {
         $slug = core::generateSlug($fill["slug"]);
     } else {
         if (!empty($fill["title"])) {
             $slug = core::generateSlug($fill["title"]);
         }
     }
     $fill["slug"] = $slug;
     $savedPost = photo::writePost($fill);
     $size = getimagesize(CONTENT_PATH . '/photo/resized/' . $fill['picture']);
     $fill['width'] = $size[0];
     $fill['height'] = $size[1];
     return $savedPost;
 }