コード例 #1
0
 /**
  * Wysyłanie plików na serwer,
  * Zapis do bazy metadanych
  * 
  */
 public function katalogowanieAction()
 {
     $id_katalogu = $this->getRequest()->getParam('katalog');
     $catalogMapper = Model_CatalogMapper::getInstance();
     $katalog = $catalogMapper->katalog($id_katalogu);
     $sciezka = $katalog->getPath();
     $this->view->sciezka = $sciezka;
     if (!empty($_FILES)) {
         $tempFile = $_FILES['Filedata']['tmp_name'];
         $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
         //nazwy plików: tymczasowego i oryginalnego
         $file = $_FILES['Filedata']['tmp_name'];
         $filename = $_FILES['Filedata']['name'];
         //sprawdzenie czy istnieje taka nazwa w bazie
         $photoMapper = Model_PhotoMapper::getInstance();
         $filename_tmp = $filename;
         $i = 1;
         do {
             $nazwa_spr = $photoMapper->sprawdzNazwe($id_katalogu, $filename_tmp);
             if ($nazwa_spr) {
                 if ($i == 1) {
                     $filename = substr($filename_tmp, 0, -4);
                 } else {
                     if ($i < 10) {
                         $filename = substr($filename_tmp, 0, -8);
                     } else {
                         $filename = substr($filename_tmp, 0, -9);
                     }
                 }
                 $filename_tmp = $filename . ' (' . $i . ')' . '.jpg';
                 $i++;
                 $a = true;
             } else {
                 $a = false;
             }
         } while ($a);
         $targetFile = str_replace('//', '/', $targetPath) . $filename_tmp;
         //pobranie metadanych ze zdjęcia i zapis do bazy
         $zdjecie = new Model_Photo();
         $zdjecie->pobierzMetadane($file, $filename_tmp, $id_katalogu);
         $mapper = Model_PhotoMapper::getInstance();
         $mapper->save($zdjecie);
         //przesłanie zdjęcia na serwer
         move_uploaded_file($tempFile, $targetFile);
         echo str_replace($_SERVER['DOCUMENT_ROOT'], '', $targetFile);
         //generowanie miniatury do exifa (jeśli nie ma)
         $miniatura = new Model_Thumbnail();
         $miniatura->generujMiniature($targetFile);
     }
 }
コード例 #2
0
 protected function _populate($data)
 {
     $obj = new Model_Photo();
     $obj->setId($data['id']);
     $obj->setCatalogsId($data['catalogs_id']);
     $obj->setFilename($data['filename']);
     $obj->setFilesize($data['filesize']);
     $obj->setMimeType($data['mimeType']);
     $obj->setHeight($data['height']);
     $obj->setWidth($data['width']);
     $obj->setDateTimeOriginal($data['dateTimeOriginal']);
     $obj->setMake($data['make']);
     $obj->setModel($data['model']);
     $obj->setOrientation($data['orientation']);
     $obj->setXResolution($data['xResolution']);
     $obj->setYResolution($data['yResolution']);
     $obj->setExposureTime($data['exposureTime']);
     $obj->setExposureProgram($data['exposureProgram']);
     $obj->setExposureMode($data['exposureMode']);
     $obj->setFNumber($data['fNumber']);
     $obj->setFocalLength($data['focalLength']);
     $obj->setIsoSpeedRatings($data['speedRatings']);
     $obj->setLightSource($data['lightSource']);
     $obj->setWhiteBalance($data['whiteBalance']);
     $obj->setFlash($data['flash']);
     $obj->setDigitalZoomRatio($data['digitalZoomRatio']);
     $obj->setGpsLatitudeRef($data['gpsLatitudeRef']);
     $obj->setGpsLatitude($data['gpsLatitude']);
     $obj->setGpsLongitudeRef($data['gpsLongitudeRef']);
     $obj->setGpsLongitude($data['gpsLongitude']);
     $obj->setHeadline($data['headline']);
     $obj->setCaption($data['caption']);
     $obj->setWriter($data['writer']);
     $obj->setCopyrightNotice($data['copyrightNotice']);
     $obj->setContact($data['contact']);
     $obj->setObjectName($data['objectName']);
     $obj->setByLineTitle($data['byLineTitle']);
     $obj->setCity($data['city']);
     $obj->setSubLocation($data['subLocation']);
     $obj->setProvince($data['province']);
     $obj->setCountryCode($data['countryCode']);
     $obj->setCountry($data['country']);
     $obj->setKeywords($data['keywords']);
     return $obj;
 }
コード例 #3
0
ファイル: photo.php プロジェクト: lz1988/stourwebcms
 public function action_show()
 {
     $id = $this->params['id'];
     if (empty($id)) {
         exit;
     }
     //详细信息
     $row = ORM::factory('photo')->where("id={$id}")->find()->as_array();
     $picturelist = Model_Photo::handlePicture($row['id']);
     $this->assign('info', $row);
     $this->assign('picturelist', $picturelist);
     $this->display('photo/show');
 }
コード例 #4
0
ファイル: product.php プロジェクト: khoapld/wjshop
 public function post_delete_sub_photo()
 {
     $val = Validation::forge();
     $val->add_callable('MyRules');
     $val->add_field('photo_id', Lang::get('label.photo'), 'required|valid_photo');
     $val->add_field('product_id', Lang::get('label.product'), 'required|valid_product');
     if ($val->run()) {
         $photo_id = $val->validated('photo_id');
         $photo_name = Model_Photo::find($photo_id)->photo_name;
         if (Model_Base_Photo::delete($photo_id)) {
             Model_Service_Upload::delete_photo('photo', $photo_name);
             $this->data['success'] = true;
         }
     } else {
         $this->data['errors'] = $val->error_message();
     }
     return $this->response($this->data);
 }
コード例 #5
0
ファイル: Photo.php プロジェクト: rosko/workapp
 public function index()
 {
     $this->view->setTitle("Фотографии");
     $file = new Model_Photofile();
     $file->showTree(0);
     if (isset($_GET["id"])) {
         $fm =& $_SESSION["fm"];
         if ($_GET["id"] == "0") {
             $fm["dir"] = 0;
             $fm["dirname"] = "/";
         } else {
             if (is_numeric($_GET["id"])) {
                 $fm["dir"] = $_GET["id"];
                 $dirname = $file->getNameFromDir($_GET["id"]);
                 $fm["dirname"] = $dirname[0]["name"];
             } else {
                 $fm["dir"] = 0;
                 $fm["dirname"] = "/";
             }
         }
         $this->view->index(array("session_name" => session_name(), "session_id" => session_id(), "config" => $this->config["photo"]));
     } else {
         if (isset($_GET["group"])) {
             if ($_GET["group"] == "sel") {
                 $mphoto = new Model_Photo();
                 $sels = $mphoto->getAllSels();
                 $this->view->fm_sels(array("data" => $sels));
             } else {
                 if ($_GET["group"] == "tags") {
                     $mphoto = new Model_Photo();
                     $tags = $mphoto->getAllTags();
                     $this->view->fm_tags(array("data" => $tags));
                 }
             }
         } else {
             if (!isset($_GET["id"])) {
                 $this->view->index(array("session_name" => session_name(), "session_id" => session_id(), "config" => $this->config["photo"]));
             }
         }
     }
     $sess = 0;
     $fav = 0;
     $sel = 0;
     $sphoto =& $_SESSION["photo"];
     if (isset($sphoto["tag"])) {
         if (count($sphoto["tag"]) > 0) {
             $sess = 1;
             $sel = 1;
         }
     }
     if (isset($sphoto["sel"])) {
         if (count($sphoto["sel"]) > 0) {
             $sess = 1;
             $sel = 1;
         }
     }
     if (isset($sphoto["fav"])) {
         if ($sphoto["fav"] == 1) {
             $sess = 1;
             $fav = 1;
         }
     }
     $render = "";
     if ($sess) {
         $this->view->setLeftContent($this->view->render("block_leftsort", array("fav" => $fav, "sel" => $sel)));
     } else {
         $this->view->setLeftContent($this->view->render("block_left", array("tree" => $file->getTree())));
     }
     $this->view->setLeftContent($this->view->render("block_leftmenu", array()));
     $this->view->setAdvBottomPanel($this->view->render("block_bottom", array()));
     $this->view->showPage();
 }
コード例 #6
0
ファイル: photo.php プロジェクト: khoapld/wjshop
 public static function valid_field($field, $val)
 {
     $result = Model_Photo::query()->where(array($field => $val));
     return $result->count() > 0;
 }
コード例 #7
0
ファイル: product.php プロジェクト: khoapld/wjshop
 public static function get_sub_photo($id)
 {
     $data = array();
     $sub_photo = Model_Photo::query()->select('photo_name')->where(array('product_id' => $id))->order_by(array('rank' => 'asc'))->get();
     foreach ($sub_photo as $photo) {
         $data[$photo->id]['l'] = _PATH_ROOT_PHOTO_ . 'l/' . $photo->photo_name;
         $data[$photo->id]['m'] = _PATH_ROOT_PHOTO_ . 'm/' . $photo->photo_name;
         $data[$photo->id]['s'] = _PATH_ROOT_PHOTO_ . 's/' . $photo->photo_name;
     }
     return $data;
 }