当前位置: 首页>>代码示例>>PHP>>正文


PHP Photo::setDescription方法代码示例

本文整理汇总了PHP中Photo::setDescription方法的典型用法代码示例。如果您正苦于以下问题:PHP Photo::setDescription方法的具体用法?PHP Photo::setDescription怎么用?PHP Photo::setDescription使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Photo的用法示例。


在下文中一共展示了Photo::setDescription方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: PhotoDAO

$photoDao = new PhotoDAO();
$showPhotos = $photoDao->showPhotos();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $photoObj = new Photo();
    if (isset($_POST['is_item'])) {
        $is_item = '1';
    } else {
        $is_item = '0';
    }
    if (isset($_POST['is_photo'])) {
        $is_photo = '1';
    } else {
        $is_photo = '0';
    }
    $photoObj->setID($_POST['id']);
    $photoObj->setDescription($_POST['description']);
    $photoObj->setIsItem($is_item);
    $photoObj->setIsPhoto($is_photo);
    $rowphoto = $photoDao->editOne($photoObj->getId(), $photoObj->getDescription(), $photoObj->getIsItem(), $photoObj->getIsPhoto());
}
?>

<div class="main container-fluid">
    <!--div class="section"-->
        <?php 
while ($row = $showPhotos->fetch_assoc()) {
    ?>
            <div class="secolPhoto">
                <table class="table datagrid" style="width: 25%">
                    <tr style="background-color: chocolate">
                        <th style="width: 25%"><?php 
开发者ID:GoranSubic,项目名称:smart-restoran,代码行数:31,代码来源:showPhotos.php

示例2: setPhotoDescription

 private function setPhotoDescription()
 {
     Module::dependencies(isset($_POST['photoID'], $_POST['description']));
     $photo = new Photo($this->database, $this->plugins, null, $_POST['photoID']);
     echo $photo->setDescription($_POST['description']);
 }
开发者ID:fredrikcarno,项目名称:Lychee,代码行数:6,代码来源:Admin.php

示例3: run

 /**
  * Run method with main page logic
  * 
  * Populate template and display form for creating a new photo entry. For POST request,
  * validate form data and save information to database. Available to admins only
  * @access public
  */
 public function run()
 {
     $session = Session::getInstance();
     $user = $session->getUser();
     if (!$user || !$user->isAdmin()) {
         $session->setMessage("Do not have permission to access", Session::MESSAGE_ERROR);
         header("Location: " . BASE_URL);
         return;
     }
     $photoDAO = PhotoDAO::getInstance();
     $albumDAO = AlbumDAO::getInstance();
     $photo = null;
     $form_errors = array();
     $form_values = array("albumid" => "", "title" => "", "description" => "");
     if (!empty($_POST)) {
         $form_values["albumid"] = isset($_POST["albumid"]) && is_numeric($_POST["albumid"]) ? intval($_POST["albumid"]) : "";
         $form_values["title"] = isset($_POST["title"]) ? trim($_POST["title"]) : "";
         $form_values["description"] = isset($_POST["description"]) ? trim($_POST["description"]) : "";
         if (empty($form_values["albumid"])) {
             $form_errors["albumid"] = "No albumid specified";
         } else {
             if (!$albumDAO->load($form_values["albumid"])) {
                 $form_errors["albumid"] = "Album does not exist";
             }
         }
         if (empty($form_values["title"])) {
             $form_errors["title"] = "No title specified";
         }
         if (empty($form_values["description"])) {
             $form_errors["description"] = "No description specified";
         }
         $upload_path = "";
         if (empty($_FILES["imagefile"]) || $_FILES["imagefile"]["error"] == UPLOAD_ERR_NO_FILE) {
             $form_errors["imagefile"] = "No image file chosen";
         } else {
             if ($_FILES["imagefile"]["error"] != UPLOAD_ERR_OK) {
                 $form_errors["imagefile"] = "File upload failed";
             } else {
                 $info = getimagesize($_FILES["imagefile"]["tmp_name"]);
                 $path = pathinfo($_FILES["imagefile"]["name"]);
                 $upload_path = joinPath(Photo::UPLOAD_DIR, strftime("%Y_%m"), basename($_FILES['imagefile']['name']));
                 $thumbLoc = joinPath(Photo::THUMBNAIL_DIR, strftime("%Y_%m"), $path["filename"] . "_thumb.jpg");
                 $smallThumbLoc = joinPath(Photo::THUMBNAIL_DIR, strftime("%Y_%m"), $path["filename"] . "_thumb_small.jpg");
                 if (!$info || !(strtolower($path["extension"]) != ".png" && strtolower($path["extension"]) != ".jpg" && strtolower($path["extension"]) != ".jpeg")) {
                     $form_errors["imagefile"] = "An invalid file was uploaded";
                 } else {
                     if (file_exists($upload_path)) {
                         unlink($upload_path);
                         if (file_exists($thumbLoc)) {
                             unlink($thumbLoc);
                         }
                         if (file_exists($smallThumbLoc)) {
                             unlink($smallThumbLoc);
                         }
                         //$form_errors["imagefile"] = "Filename already exists.  Please choose different name or delete file first";
                     }
                 }
             }
         }
         if (empty($form_errors)) {
             $photo = new Photo();
             $photo->setAlbumId($form_values["albumid"]);
             $photo->setTitle($form_values["title"]);
             $photo->setDescription($form_values["description"]);
             if (!file_exists(dirname($upload_path))) {
                 mkdir(dirname($upload_path));
             }
             if (move_uploaded_file($_FILES["imagefile"]["tmp_name"], $upload_path)) {
                 $photo->setFileLoc($upload_path);
                 // Create thumbnail
                 if ($info[0] > Photo::MAX_WIDTH) {
                     $phpThumb = new phpThumb();
                     $phpThumb->setSourceFilename($photo->getFileLoc());
                     $phpThumb->setParameter('w', Photo::MAX_WIDTH);
                     $phpThumb->setParameter('config_output_format', 'jpeg');
                     if (!file_exists(dirname($thumbLoc))) {
                         mkdir(dirname($thumbLoc));
                     }
                     if ($phpThumb->GenerateThumbnail() && $phpThumb->RenderToFile($thumbLoc)) {
                         $photo->setThumbLoc($thumbLoc);
                         $phpThumb = new phpThumb();
                         $phpThumb->setSourceFilename($photo->getFileLoc());
                         $phpThumb->setParameter('h', Photo::SMALL_THUMB_HEIGHT);
                         $phpThumb->setParameter('config_output_format', 'jpeg');
                         $phpThumb->GenerateThumbnail();
                     } else {
                         if (file_exists($photo->getFileLoc())) {
                             unlink($photo->getFileLoc());
                         }
                         $form_errors["imagefile"] = "Image larger than " . Photo::MAX_WIDTH . "x" . Photo::MAX_HEIGHT . " and thumbnail generation failed";
                     }
                 }
             } else {
//.........这里部分代码省略.........
开发者ID:Ryochan7,项目名称:UGA-Proposal-Website,代码行数:101,代码来源:create_photo.php

示例4: Add

 /**
  *@Route("/add")
  */
 public function Add(Request $request)
 {
     $message = [];
     $repository = $this->getDoctrine()->getRepository('AppBundle:categories');
     $query = $repository->createQueryBuilder('p')->getQuery();
     $category = $query->getResult();
     $user = $this->get('security.token_storage')->getToken()->getUser();
     $title = $request->get('title');
     $description = $request->get('description');
     $categories = $request->get('categories');
     $image = $request->get('image');
     function is_valid_type($file)
     {
         $valid_types = array("image/jpg", "image/jpeg", "image/bmp", "image/gif", "image/png");
         if (in_array($file['type'], $valid_types)) {
             return 1;
         }
         return 0;
     }
     if (isset($_FILES['image'])) {
         if (!empty($_FILES['image'])) {
             if (is_valid_type($_FILES['image'])) {
                 if (!file_exists($_FILES['image']['name'])) {
                     $extension = strtolower(substr(strrchr($_FILES['image']['name'], '.'), 1));
                     $filename = DFileHelper::getRandomFileName($extension);
                     $target = 'img/' . $filename . '.' . $extension;
                     if (move_uploaded_file($_FILES['image']['tmp_name'], $target)) {
                         $photo = new Photo();
                         $em = $this->getDoctrine()->getManager();
                         $photo->setUsername($user);
                         $photo->setDescription($description);
                         $photo->setTitle($title);
                         $photo->setCategories($em->getRepository("AppBundle:categories")->find($categories));
                         $photo->setImage('img/' . $filename . '.' . $extension);
                         $em->persist($photo);
                         $em->flush();
                         $message['success'] = "Photo added";
                     } else {
                         $message['danger'] = "You can not download the file. Check permissions to the directory ( read / write)";
                     }
                 } else {
                     $message['danger'] = "File with this name already exists";
                 }
             } else {
                 $message['danger'] = "You can upload files : JPEG, GIF, BMP, PNG";
             }
         }
     }
     $user = $this->get('security.token_storage')->getToken()->getUser();
     if ($user) {
         $repo = $this->getDoctrine()->getManager()->getRepository('AppBundle:photo');
         $qb = $repo->createQueryBuilder('a');
         $qb->select('COUNT(a)');
         $qb->where('a.username = :usernameId');
         $qb->setParameter('usernameId', $user);
         $photos = $qb->getQuery()->getSingleScalarResult();
     }
     return $this->render('site/img_add.html.twig', array('title' => 'Add photo', 'url' => 'add', 'message' => $message, 'photos' => $photos, 'var' => $image, 'category' => $category, 'base_dir' => realpath($this->container->getParameter('kernel.root_dir') . '/..')));
 }
开发者ID:omggris,项目名称:Gallery,代码行数:62,代码来源:ImgController.php

示例5: setPhotoDescription

 private function setPhotoDescription()
 {
     Module::dependencies(isset($_POST['photoID'], $_POST['description']));
     $photo = new Photo(null, $_POST['photoID']);
     echo $photo->setDescription($_POST['description']);
 }
开发者ID:waitman,项目名称:Lychee,代码行数:6,代码来源:Admin.php

示例6: basename

} else {
    if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
        // ajouter la photo dans le dossier PHOTOS
        echo "L'image " . basename($_FILES["fileToUpload"]["name"]) . " a &eacute;t&eacute; ajout&eacute;. ";
        // Insérer un nouveau enregistrement dans la table PHOTO
        $category = "no category";
        $season = "no season";
        $title = basename($_FILES["fileToUpload"]["name"]);
        $description = "no description";
        $link = $target_file;
        $unePhoto = new Photo();
        //$unePhoto->setId( $_REQUEST['id'] );
        $unePhoto->setCategory($category);
        $unePhoto->setSeason($season);
        $unePhoto->setTitle($title);
        $unePhoto->setDescription($description);
        $unePhoto->setLink($link);
        $unePhoto->setHidden(0);
        $dao = new PhotoDao();
        $dao->create($unePhoto);
    } else {
        echo "D&eacute;sol&eacute;, une erreur s'est produite.";
    }
}
// Source de : http://www.w3schools.com/
?>
		<br/>
		<br/>
		<a href="./admin.php?what=photo"><b><u>Retourner &agrave; la gestion des photos</u></b></a>
		
	</div>
开发者ID:sisowath,项目名称:TP_PHP,代码行数:31,代码来源:upload.php


注:本文中的Photo::setDescription方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。