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


PHP Image::setName方法代码示例

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


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

示例1: getPdfPreviewImage

 public function getPdfPreviewImage()
 {
     $pdfFile = Director::getAbsFile($this->owner->getFileName());
     $pathInfo = pathinfo($pdfFile);
     if (strtolower($pathInfo['extension']) != 'pdf') {
         //@Todo if dev then exception? else fail silently
         return null;
     }
     $fileName = $pathInfo['filename'];
     $savePath = __DIR__ . '/../../';
     $saveImage = $this->imagePrefix . '-' . $fileName . '.jpg';
     // Fix illegal characters
     $filter = FileNameFilter::create();
     $saveImage = $filter->filter($saveImage);
     $saveTo = $savePath . $this->folderToSave . $saveImage;
     $image = DataObject::get_one('Image', "`Name` = '{$saveImage}'");
     if (!$image) {
         $folderObject = DataObject::get_one("Folder", "`Filename` = '{$this->folderToSave}'");
         if ($folderObject) {
             if ($this->generator->generatePreviewImage($pdfFile, $saveTo)) {
                 $image = new Image();
                 $image->ParentID = $folderObject->ID;
                 $image->setName($saveImage);
                 $image->write();
             }
         }
     } else {
         //check LastEdited to update
         $cacheInValid = false;
         if (strtotime($image->LastEdited) < strtotime($this->owner->LastEdited)) {
             $cacheInValid = true;
         }
         if ($cacheInValid) {
             $this->generator->generatePreviewImage($pdfFile, $saveTo);
             $image->setName($saveImage);
             $image->write(false, false, true);
         }
     }
     return $image;
 }
开发者ID:helpfulrobot,项目名称:ivoba-silverstripe-simple-pdf-preview,代码行数:40,代码来源:SimplePdfPreviewImageExtension.php

示例2: create

 /**
  * Upload new Images
  *
  * Also updates Category & Album modification times
  *
  * @param int $categoryId
  * @param int $albumId
  */
 public function create($categoryId, $albumId)
 {
     $category = $this->getCategoryFinder()->findOneBy('id', $categoryId);
     $album = $this->getAlbumFinder()->findOneBy('id', $albumId);
     if ($this->slim->request->isGet()) {
         $this->slim->render('image/create.html.twig', ['category' => $category, 'album' => $album, 'sessionUser' => $this->getSessionUser(), 'allowedExtensions' => Image::getAllowedExtensions(true)]);
     } elseif ($this->slim->request->isPost()) {
         $uploadHandler = new CustomUploadHandler(['upload_dir' => ROOT . '/files/', 'upload_url' => null, 'access_control_allow_methods' => ['POST'], 'accept_file_types' => '/\\.(' . Image::getAllowedExtensions(true) . ')$/i', 'image_library' => 0, 'image_versions' => ['' => ['auto_orient' => false], 'thumb' => ['upload_dir' => ROOT . '/files/thumbs/', 'upload_url' => null, 'crop' => true, 'max_width' => 252, 'max_height' => 252]]]);
         $newImage = new Image($this->slim->db);
         $newImage->setAlbumId($album->getId());
         $newImage->setName($uploadHandler->getUploadedFileName());
         $newImage->insert();
         $album->update();
         $category->update();
     }
 }
开发者ID:lagut-in,项目名称:Slim-Image-Archive,代码行数:24,代码来源:ImageController.php

示例3: getFileByURL

 private function getFileByURL($url, $fileName)
 {
     $folder = Folder::find_or_make(self::$media_upload_folder);
     // relative to assets
     // create the file in database (sets title and safely names)
     $file = new Image();
     $file->ParentID = $folder->ID;
     $file->setName($fileName);
     $file->write();
     // download the file
     $fp = fopen($file->getFullPath(), 'w');
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_FILE, $fp);
     $data = curl_exec($ch);
     curl_close($ch);
     fclose($fp);
     return $file;
 }
开发者ID:helpfulrobot,项目名称:briceburg-silverstripe-sitemedia,代码行数:18,代码来源:SiteYouTubeVideo.php

示例4: req

 private function req()
 {
     $files = array_unique(array_filter($_FILES[$this->varname]['name']));
     $this->filenums = count($files);
     if ($files) {
         foreach ($files as $k => $v) {
             $img = new Image();
             $img->setName($v);
             $img->setSize($_FILES[$this->varname]['size'][$k]);
             $img->setTmp_name($_FILES[$this->varname]['tmp_name'][$k]);
             $img->setType($_FILES[$this->varname]['type'][$k]);
             $img->setErr($_FILES[$this->varname]['error'][$k]);
             array_push($this->container, $img);
             if ($_FILES[$this->varname]['error'][$k] != 0) {
                 $this->err[$k] = $_FILES[$this->varname]['error'][$k];
             }
             if (!$img->verifSuffix()) {
                 $this->err[$k] = 20001;
             }
         }
     }
 }
开发者ID:tiger2soft,项目名称:LycPHP,代码行数:22,代码来源:Upload.class.php

示例5: createImageFile

 public function createImageFile($photo, $url, $item)
 {
     $tmpImage = tmpfile();
     $fileContents = file_get_contents($url);
     fwrite($tmpImage, $fileContents);
     // check if this is a valid image
     $metaData = stream_get_meta_data($tmpImage);
     $imageSizeInfo = getimagesize($metaData['uri']);
     if (!$imageSizeInfo) {
         continue;
     }
     $imageFolder = Folder::find_or_make($this->folder . '/' . $item->getId());
     $name = basename($url);
     $fileSize = filesize($metaData['uri']);
     $tmpName = $metaData['uri'];
     $relativeImagePath = $imageFolder->getRelativePath() . $name;
     $imagePath = BASE_PATH . '/' . $relativeImagePath;
     fclose($tmpImage);
     if (file_exists($imagePath)) {
         $pathInfo = pathinfo($url);
         if (isset($pathInfo['extension'])) {
             $name = basename($tmpName) . '.' . $pathInfo['extension'];
             $relativeImagePath = $imageFolder->getRelativePath() . $name;
             $imagePath = BASE_PATH . '/' . $relativeImagePath;
         }
     }
     $image = fopen($imagePath, 'w');
     fwrite($image, $fileContents);
     fclose($image);
     $image = new Image();
     $image->setParentID($imageFolder->ID);
     $image->setName($name);
     $image->Title = $photo->getAlt();
     $image->setFilename($relativeImagePath);
     $image->write();
     return $image;
 }
开发者ID:textagroup,项目名称:brafton-api,代码行数:37,代码来源:BraftonService.php

示例6: executeImportRestApi


//.........这里部分代码省略.........
     // Retrieve project_to_product_id, relying on project_id, project_group_id, and product_id
     $query = "SELECT ptp.id AS ptp_id\n\t\t\t\t\tFROM " . $qa_generic . ".project_to_product ptp\n\t\t\t\t\tWHERE ptp.project_id = " . $project_id . "\n\t\t\t\t\t\tAND ptp.project_group_id = " . $project_group_id . "\n\t\t\t\t\t\tAND ptp.product_id = " . $product_id;
     $result = Doctrine_Manager::getInstance()->getCurrentConnection()->execute($query)->fetch(PDO::FETCH_ASSOC);
     if (empty($result["ptp_id"])) {
         echo "{\"ok\":\"0\",\"errors\":{\"project_to_product\":\"Cannot find project_to_product_id\"}}\n";
         exit;
     }
     $project_to_product_id = $result["ptp_id"];
     // Retrieve user_id, relying on auth_token
     $query = "SELECT up.user_id\n\t\t\t\t\tFROM " . $qa_core . ".sf_guard_user_profile up\n\t\t\t\t\tWHERE up.token = '" . $get_params['auth_token'] . "'";
     $result = Doctrine_Manager::getInstance()->getCurrentConnection()->execute($query)->fetch(PDO::FETCH_ASSOC);
     if (empty($result["user_id"])) {
         echo "{\"ok\":\"0\",\"errors\":{\"auth_token\":\"Authorized token is not valid\"}}\n";
         exit;
     }
     $user_id = $result["user_id"];
     // Customize database connection to begin a transactionnal query
     $conn = Doctrine_Manager::getInstance()->getConnection("qa_generic");
     $conn->setAttribute(Doctrine_Core::ATTR_AUTOCOMMIT, FALSE);
     $conn->beginTransaction();
     // If test_environment_name exists, retrieve id, else, create new entry and retrieve id
     $query = "SELECT te.id AS test_environment_id\n\t\t\t\t\tFROM " . $qa_generic . ".test_environment te\n\t\t\t\t\tWHERE te.name = '" . $get_params['hwproduct'] . "'";
     $result = Doctrine_Manager::getInstance()->getCurrentConnection()->execute($query)->fetch(PDO::FETCH_ASSOC);
     if (empty($result["test_environment_id"])) {
         // Check if creation of a new entry is allowed
         if (sfConfig::get("app_rest_configuration_creation", false) == false) {
             $conn->rollback();
             $conn->setAttribute(Doctrine_Core::ATTR_AUTOCOMMIT, TRUE);
             echo "{\"ok\":\"0\",\"errors\":{\"test_environment\":\"Creation of new test environment is forbidden\"}}\n";
             exit;
         } else {
             // Add new environment
             $environment = new TestEnvironment();
             $environment->setName($get_params['hwproduct']);
             $environment->setNameSlug(MiscUtils::slugify($get_params['hwproduct']));
             // Add hwproduct additional fields if given as parameters
             if (isset($get_params['te_desc'])) {
                 $environment->setDescription($get_params['te_desc']);
             }
             if (isset($get_params['te_cpu'])) {
                 $environment->setCpu($get_params['te_cpu']);
             }
             if (isset($get_params['te_board'])) {
                 $environment->setBoard($get_params['te_board']);
             }
             if (isset($get_params['te_gpu'])) {
                 $environment->setGpu($get_params['te_gpu']);
             }
             if (isset($get_params['te_hw'])) {
                 $environment->setOtherHardware($get_params['te_hw']);
             }
             // Save new environment
             $environment->save($conn);
             $environmentId = $environment->getId();
         }
     } else {
         $environmentId = $result["test_environment_id"];
     }
     // If image_name exists, retrieve id, else, create new entry and retrieve id
     $query = "SELECT i.id AS image_id\n\t\t\t\t\tFROM " . $qa_generic . ".image i\n\t\t\t\t\tWHERE i.name = '" . $get_params['image'] . "'";
     $result = Doctrine_Manager::getInstance()->getCurrentConnection()->execute($query)->fetch(PDO::FETCH_ASSOC);
     if (empty($result["image_id"])) {
         // Check if creation of a new entry is allowed
         if (sfConfig::get("app_rest_configuration_creation", false) == false) {
             $conn->rollback();
             $conn->setAttribute(Doctrine_Core::ATTR_AUTOCOMMIT, TRUE);
开发者ID:alex1818,项目名称:TestReportCenter,代码行数:67,代码来源:actions.class.php

示例7: processEdit

 /**
  * Process the form to edit an existing test session.
  *
  * @param sfWebRequest $request
  * @param SessionForm $form
  */
 protected function processEdit(sfWebRequest $request, SessionForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $qa_generic = sfConfig::get("app_table_qa_generic");
         // Get sent values and uploaded files
         $values = $form->getValues();
         $files = $request->getFiles();
         // Retrieve values from form
         $projectGroupId = $values["project_group_id"];
         $projectId = $values["project"];
         $productId = $values["product"];
         // Get test environment and image names
         $environmentForm = $form->getValue("environmentForm");
         $imageForm = $form->getValue("imageForm");
         // Create a new relationship between project group, project and product if needed
         $projectToProductId = Doctrine_Core::getTable("ProjectToProduct")->getProjectToProductId($projectGroupId, $projectId, $productId);
         if ($projectToProductId == null) {
             $projectToProduct = new ProjectToProduct();
             $projectToProduct->setProjectGroupId($projectGroupId);
             $projectToProduct->setProjectId($projectId);
             $projectToProduct->setProductId($productId);
             $projectToProduct->save($conn);
             $projectToProductId = $projectToProduct->getId();
         }
         // Create a new environment if needed
         $environment = Doctrine_Core::getTable("TestEnvironment")->findByArray($environmentForm);
         if ($environment == null) {
             // Add new environment
             $environment = new TestEnvironment();
             $environment->setName($environmentForm["name"]);
             $environment->setDescription($environmentForm["description"]);
             $environment->setCpu($environmentForm["cpu"]);
             $environment->setBoard($environmentForm["board"]);
             $environment->setGpu($environmentForm["gpu"]);
             $environment->setOtherHardware($environmentForm["other_hardware"]);
             // Check if its slug does not already exist and generate a new one if needed
             $slug = MiscUtils::slugify($environmentForm["name"]);
             $size = 1;
             while (Doctrine_Core::getTable("TestEnvironment")->checkSlug($slug)) {
                 $slug = MiscUtils::slugify($environmentForm["name"]) . substr(microtime(), -$size);
                 $size++;
             }
             $environment->setNameSlug($slug);
             $environment->save($conn);
             // Convert object into associative array
             $environment = $environment->toArray();
         }
         // Create a new image if needed
         $image = Doctrine_Core::getTable("Image")->findByArray($imageForm);
         if ($image == null) {
             // Add new image
             $image = new Image();
             $image->setName($imageForm["name"]);
             $image->setDescription($imageForm["description"]);
             $image->setOs($imageForm["os"]);
             $image->setDistribution($imageForm["distribution"]);
             $image->setVersion($imageForm["version"]);
             $image->setKernel($imageForm["kernel"]);
             $image->setArchitecture($imageForm["architecture"]);
             $image->setOtherFw($imageForm["other_fw"]);
             $image->setBinaryLink($imageForm["binary_link"]);
             $image->setSourceLink($imageForm["source_link"]);
             // Check if its slug does not already exist and generate a new one if needed
             $slug = MiscUtils::slugify($imageForm["name"]);
             $size = 1;
             while (Doctrine_Core::getTable("Image")->checkSlug($slug)) {
                 $slug = MiscUtils::slugify($imageForm["name"]) . substr(microtime(), -$size);
                 $size++;
             }
             $image->setNameSlug(MiscUtils::slugify($slug));
             $image->save($conn);
             // Convert object into associative array
             $image = $image->toArray();
         }
         // Create a new configuration relationship if needed
         $configurationId = Doctrine_Core::getTable("Configuration")->getConfigurationId($projectToProductId, $environment["id"], $image["id"]);
         if ($configurationId == null) {
             $configuration = new Configuration();
             $configuration->setProjectToProductId($projectToProductId);
             $configuration->setTestEnvironmentId($environment["id"]);
             $configuration->setImageId($image["id"]);
             $configuration->save($conn);
             $configurationId = $configuration->getId();
         }
         // Edit the session into DB
         $testSession = Doctrine_Core::getTable("TestSession")->find($values["id"]);
         $testSession->setId($values["id"]);
         $testSession->setBuildId($values["build_id"]);
         $testSession->setTestset($values["testset"]);
         $testSession->setName($values["name"]);
         $testSession->setTestObjective($values["test_objective"]);
         $testSession->setQaSummary($values["qa_summary"]);
         $testSession->setUserId($values["user_id"]);
//.........这里部分代码省略.........
开发者ID:alex1818,项目名称:TestReportCenter,代码行数:101,代码来源:actions.class.php

示例8: store_files

 public function store_files($file_path, $file)
 {
     $is_image = getimagesize($file_path);
     $gallery_data = $this->options['gallery_data'];
     $base = new Base();
     if ($is_image != 0 and $gallery_data['id'] != null) {
         $image_entity = new Image();
         $image_entity->setName($file->name);
         $image_entity->setTitle($file->name);
         $image_entity->setPath($file_path);
         $base->audit_fields($image_entity, 'create');
         $image_entity->save();
         $gallery_image = new GalleryImage();
         $gallery_image->setGalleryid($gallery_data['id']);
         $gallery_image->setImageid($image_entity->id);
         $base->audit_fields($gallery_image, 'create');
         $gallery_image->save();
     } else {
         $this->save_file_data($file->name, $file->type, $file->size, $file_path);
     }
 }
开发者ID:andresfranco,项目名称:Phalcontest,代码行数:21,代码来源:UploadHandlerController.php

示例9: createLogoImageObjects

 /**
  * Creates the upload folder for payment images if it doesn't exist.
  *
  * @param array  $paymentLogos      The payment logos as associative array:
  *                                  ['LogoName' => 'PATH_TO_FILE', ....]
  * @param string $paymentModuleName The name of the payment module
  *
  * @return void
  *
  * @author Sebastian Diel <sdiel@pixeltricks.de>,
  *         Sascha Koehler <skoehler@pixeltricks.de>
  * @since 16.06.2014
  */
 public function createLogoImageObjects($paymentLogos, $paymentModuleName)
 {
     //make sure that the folder "Uploads" exists
     Folder::find_or_make('Uploads');
     $paymentModule = SilvercartPaymentMethod::get()->filter(array("ClassName" => $paymentModuleName))->sort(array("ID" => "ASC"))->first();
     if ($paymentModule) {
         if (count($this->getPossiblePaymentChannels()) > 0) {
             // Multiple payment channels
             foreach ($paymentLogos as $paymentChannel => $logos) {
                 $paymentChannelMethod = DataObject::get_one($paymentModuleName, sprintf("\"PaymentChannel\"='%s'", $paymentChannel), true, $paymentModuleName . ".ID");
                 if ($paymentChannelMethod) {
                     if (!$paymentChannelMethod->PaymentLogos()->exists()) {
                         foreach ($logos as $title => $logo) {
                             $paymentLogo = new SilvercartImage();
                             $paymentLogo->Title = $title;
                             $storedLogo = Image::get()->filter('Name', basename($logo))->first();
                             if ($storedLogo) {
                                 $paymentLogo->ImageID = $storedLogo->ID;
                             } else {
                                 file_put_contents(Director::baseFolder() . '/' . $this->uploadsFolder->Filename . basename($logo), file_get_contents(Director::baseFolder() . $logo));
                                 $image = new Image();
                                 $image->setFilename($this->uploadsFolder->Filename . basename($logo));
                                 $image->setName(basename($logo));
                                 $image->Title = basename($logo, '.png');
                                 $image->ParentID = $this->uploadsFolder->ID;
                                 $image->write();
                                 $paymentLogo->ImageID = $image->ID;
                             }
                             $paymentLogo->write();
                             $paymentChannelMethod->PaymentLogos()->add($paymentLogo);
                         }
                     }
                 }
             }
         } else {
             // Single payment channels
             foreach ($paymentLogos as $title => $logo) {
                 if (!$paymentModule->PaymentLogos()->exists()) {
                     $paymentLogo = new SilvercartImage();
                     $paymentLogo->Title = $title;
                     $storedLogo = Image::get()->filter('Name', basename($logo))->first();
                     if ($storedLogo) {
                         $paymentLogo->ImageID = $storedLogo->ID;
                     } else {
                         file_put_contents(Director::baseFolder() . '/' . $this->uploadsFolder->Filename . basename($logo), file_get_contents(Director::baseFolder() . $logo));
                         $image = new Image();
                         $image->setFilename($this->uploadsFolder->Filename . basename($logo));
                         $image->setName(basename($logo));
                         $image->Title = basename($logo, '.png');
                         $image->ParentID = $this->uploadsFolder->ID;
                         $image->write();
                         $paymentLogo->ImageID = $image->ID;
                     }
                     $paymentLogo->write();
                     $paymentModule->PaymentLogos()->add($paymentLogo);
                 }
             }
         }
     }
 }
开发者ID:silvercart,项目名称:silvercart,代码行数:73,代码来源:SilvercartPaymentMethod.php

示例10: requireDefaultRecords

 function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     $bt = defined('DB::USE_ANSI_SQL') ? '"' : '`';
     $update = array();
     $siteConfig = DataObject::get_one('SiteConfig');
     $folder = Folder::findOrMake(self::get_folder_name());
     if ($siteConfig && $folder) {
         $fullArray = self::get_images_to_replace();
         //copying ....
         if ($fullArray) {
             foreach ($fullArray as $key => $array) {
                 $className = $array["ClassName"];
                 $fieldName = $array["FieldName"] . "ID";
                 if (class_exists($className)) {
                     $dataObject = singleton($className);
                     $dbFieldName = $array["DBFieldName"];
                     $fileName = basename($array["CopyFromPath"]);
                     $fromLocationLong = Director::baseFolder() . '/' . $array["CopyFromPath"];
                     $toLocationShort = "assets/" . self::get_folder_name() . "/{$fileName}";
                     $toLocationLong = Director::baseFolder() . '/' . $toLocationShort;
                     $image = DataObject::get_one('Image', "Filename='{$toLocationShort}' AND ParentID = " . $folder->ID);
                     if (!$image) {
                         if (!file_exists($toLocationLong)) {
                             copy($fromLocationLong, $toLocationLong);
                         }
                         $image = new Image();
                         $image->ParentID = $folder->ID;
                         $image->FileName = $toLocationShort;
                         $image->setName($fileName);
                         $image->write();
                     } elseif (!$image && file_exists($toLocationLong)) {
                         debug::show("need to update files");
                     }
                     if ($image && $image->ID) {
                         if (!$siteConfig->{$dbFieldName}) {
                             $siteConfig->{$dbFieldName} = $image->ID;
                             $update[] = "created placeholder image for {$key}";
                         }
                         $updateSQL = " UPDATE {$bt}" . $className . "{$bt}";
                         if (isset($_GET["removeplaceholderimages"])) {
                             $setSQL = " SET {$bt}" . $fieldName . "{$bt} = 0";
                             $whereSQL = " WHERE {$bt}" . $fieldName . "{$bt}  = " . $image->ID;
                             DB::alteration_message("removing " . $className . "." . $fieldName . " placeholder images", 'deleted');
                         } else {
                             DB::alteration_message("adding " . $className . "." . $fieldName . " placeholder images", 'created');
                             $setSQL = " SET {$bt}" . $fieldName . "{$bt} = " . $image->ID;
                             if (!isset($_GET["forceplaceholder"])) {
                                 $whereSQL = " WHERE {$bt}" . $fieldName . "{$bt} IS NULL OR {$bt}" . $fieldName . "{$bt} = 0";
                             } else {
                                 $whereSQL = '';
                             }
                         }
                         $sql = $updateSQL . $setSQL . $whereSQL;
                         DB::query($sql);
                         $versioningPresent = false;
                         $array = $dataObject->stat('extensions');
                         if (is_array($array) && count($array)) {
                             if (in_array("Versioned('Stage', 'Live')", $array)) {
                                 $versioningPresent = true;
                             }
                         }
                         if ($dataObject->stat('versioning')) {
                             $versioningPresent = true;
                         }
                         if ($versioningPresent) {
                             $sql = str_replace("{$bt}{$className}{$bt}", "{$bt}{$className}_Live{$bt}", $sql);
                             DB::query($sql);
                         }
                     } else {
                         debug::show("could not create image!" . print_r($array));
                     }
                 } else {
                     debug::show("bad classname reference " . $className);
                 }
             }
         }
         if (count($update)) {
             $siteConfig->write();
             DB::alteration_message($siteConfig->ClassName . " created/updated: " . implode(" --- ", $update), 'created');
         }
     } elseif (!$folder) {
         debug::show("COULD NOT CREATE FOLDER: " . self::get_folder_name());
     }
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-image-placeholder-replacer,代码行数:85,代码来源:ImagePlaceHolderReplacer.php


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