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


PHP Util::isImage方法代码示例

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


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

示例1: indexAction

 public function indexAction(Request $request, SessionInterface $session)
 {
     Util::checkUserIsLoggedInAndRedirect();
     $loggedInUserId = $session->get('user/id');
     $filenameData = apache_request_headers();
     $filename = rawurldecode($filenameData['X_FILENAME']);
     $issueId = $request->request->get('issue_id');
     if (!$session->has('added_attachments_in_screen')) {
         $session->set('added_attachments_in_screen', array());
     }
     /* every attachment has its own dedicated sub-folder, so no editing on the upload filename will be done */
     if ($filename) {
         $ext = substr($filename, strrpos($filename, '.') + 1);
         $filenameWithoutExtension = substr($filename, 0, strrpos($filename, '.'));
         $attachmentId = $this->getRepository(IssueAttachment::class)->add($issueId, Util::slugify($filenameWithoutExtension) . '.' . $ext, $loggedInUserId, Util::getServerCurrentDateTime());
         if ($issueId == null) {
             $issueId = 'user_' . $loggedInUserId;
         }
         $uploadDirectory = Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . $issueId;
         /* subfolders */
         $uploadDirSubfolder = $uploadDirectory . '/' . $attachmentId;
         if (!file_exists($uploadDirectory)) {
             mkdir($uploadDirectory);
         }
         if (!file_exists($uploadDirSubfolder)) {
             mkdir($uploadDirSubfolder);
         }
         $newFileName = $uploadDirSubfolder . '/' . Util::slugify($filenameWithoutExtension) . '.' . $ext;
         file_put_contents($newFileName, file_get_contents('php://input'));
         $size = filesize($newFileName);
         $temp = $session->get('added_attachments_in_screen');
         $temp[] = $attachmentId;
         $session->set('added_attachments_in_screen', $temp);
         $this->getRepository(IssueAttachment::class)->updateSizeById($attachmentId, $size);
         if (Util::isImage(Util::getExtension($filename))) {
             $thumbUploaddirSubfolder = $uploadDirSubfolder . '/thumbs';
             if (!file_exists($thumbUploaddirSubfolder)) {
                 mkdir($thumbUploaddirSubfolder);
             }
             $newThumbnailName = $thumbUploaddirSubfolder . '/' . Util::slugify($filenameWithoutExtension) . '.' . $ext;
             $image = new ZebraImage();
             $image->jpeg_quality = 100;
             $image->chmod_value = 0755;
             $image->source_path = $newFileName;
             $image->target_path = $newThumbnailName;
             $image->resize(150, 150, ZEBRA_IMAGE_CROP_CENTER);
         }
         return new JsonResponse($attachmentId);
     }
     return new Response('');
 }
开发者ID:spiasecki,项目名称:ubirimi,代码行数:51,代码来源:UploadTransitionAttachmentController.php

示例2: deleteByIssueId

 public function deleteByIssueId($issueId)
 {
     $attachments = IssueAttachment::getByIssueId($issueId);
     if ($attachments) {
         while ($attachment = $attachments->fetch_array(MYSQLI_ASSOC)) {
             $attachmentId = $attachment['id'];
             unlink(Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . $issueId . '/' . $attachmentId . '/' . $attachment['name']);
             if (Util::isImage(Util::getExtension($attachment['name']))) {
                 unlink(Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . $issueId . '/' . $attachmentId . '/thumbs/' . $attachment['name']);
                 Util::deleteDir(Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . $issueId . '/' . $attachmentId . '/thumbs');
             }
             Util::deleteDir(Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . $issueId . '/' . $attachmentId);
         }
         // also delete the folder
         if (file_exists(Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . $issueId)) {
             Util::deleteDir(Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . $issueId);
         }
     }
 }
开发者ID:spiasecki,项目名称:ubirimi,代码行数:19,代码来源:IssueAttachment.php

示例3: indexAction

 public function indexAction(Request $request, SessionInterface $session)
 {
     Util::checkUserIsLoggedInAndRedirect();
     $attachmentId = $request->request->get('att_id');
     $attachment = $this->getRepository(IssueAttachment::class)->getById($attachmentId);
     $this->getRepository(IssueAttachment::class)->deleteById($attachmentId);
     $pathToAttachment = UbirimiContainer::get()['asset.root_folder'] . UbirimiContainer::get()['asset.yongo_issue_attachments'];
     unlink($pathToAttachment . $attachment['issue_id'] . '/' . $attachment['id'] . '/' . $attachment['name']);
     if (Util::isImage(Util::getExtension($attachment['name']))) {
         unlink($pathToAttachment . $attachment['issue_id'] . '/' . $attachment['id'] . '/thumbs/' . $attachment['name']);
         Util::deleteDir($pathToAttachment . $attachment['issue_id'] . '/' . $attachment['id'] . '/thumbs');
     }
     Util::deleteDir($pathToAttachment . $attachment['issue_id'] . '/' . $attachment['id']);
     // delete the issue folder if necessary
     if (2 == count(scandir($pathToAttachment . $attachment['issue_id']))) {
         Util::deleteDir($pathToAttachment . $attachment['issue_id']);
     }
     return new Response('');
 }
开发者ID:spiasecki,项目名称:ubirimi,代码行数:19,代码来源:DeleteController.php

示例4: round

    }
    ?>
                            <?php 
}
?>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        <table width="100%">
                            <?php 
foreach ($attachments as $attachment) {
    ?>
                                <?php 
    if (!Util::isImage(Util::getExtension($attachment['name']))) {
        ?>
                                    <tr>
                                        <td width="75%">
                                            <a target="_blank" href="/assets<?php 
        echo UbirimiContainer::get()['asset.yongo_issue_attachments'] . $attachment['issue_id'] . '/' . $attachment['id'] . '/' . $attachment['name'];
        ?>
">
                                                <?php 
        echo $attachment['name'];
        ?>
                                            </a>
                                        </td>
                                        <td>
                                            <?php 
        echo round($attachment['size'] / 1024, 2);
开发者ID:spiasecki,项目名称:ubirimi,代码行数:31,代码来源:_attachments.php

示例5: manageModalAttachments

 public static function manageModalAttachments($issueId, $loggedInUserId, $attachIdsToBeKept)
 {
     if (null != UbirimiContainer::get()['session']->has('added_attachments_in_screen')) {
         $attIdsSession = UbirimiContainer::get()['session']->get('added_attachments_in_screen');
         $uploadDirectory = Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . $issueId;
         for ($i = 0; $i < count($attIdsSession); $i++) {
             $attachmentId = $attIdsSession[$i];
             $attachment = UbirimiContainer::get()['repository']->get(IssueAttachment::class)->getById($attachmentId);
             if (!in_array($attachmentId, $attachIdsToBeKept)) {
                 // the attachment must be deleted
                 UbirimiContainer::get()['repository']->get(IssueAttachment::class)->deleteById($attachmentId);
                 if (file_exists(Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . $attachment['issue_id'] . '/' . $attachment['id'] . '/' . $attachment['name'])) {
                     unlink(Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . $attachment['issue_id'] . '/' . $attachment['id'] . '/' . $attachment['name']);
                     if (Util::isImage(Util::getExtension($attachment['name']))) {
                         if (file_exists(Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . $attachment['issue_id'] . '/' . $attachment['id'] . '/thumbs/' . $attachment['name'])) {
                             unlink(Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . $attachment['issue_id'] . '/' . $attachment['id'] . '/thumbs/' . $attachment['name']);
                             Util::deleteDir(Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . $attachment['issue_id'] . '/' . $attachment['id'] . '/thumbs');
                         }
                     }
                 }
                 if (file_exists(Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . $attachment['issue_id'] . '/' . $attachment['id'])) {
                     Util::deleteDir(Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . $attachment['issue_id'] . '/' . $attachment['id']);
                 }
                 // deal with the user_ folders
                 if (file_exists(Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . 'user_' . $loggedInUserId . '/' . $attachment['id'] . '/' . $attachment['name'])) {
                     unlink(Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . 'user_' . $loggedInUserId . '/' . $attachment['id'] . '/' . $attachment['name']);
                     if (Util::isImage(Util::getExtension($attachment['name']))) {
                         if (file_exists(Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . 'user_' . $loggedInUserId . '/' . $attachment['id'] . '/thumbs/' . $attachment['name'])) {
                             unlink(Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . 'user_' . $loggedInUserId . '/' . $attachment['id'] . '/thumbs/' . $attachment['name']);
                             Util::deleteDir(Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . 'user_' . $loggedInUserId . '/' . $attachment['id'] . '/thumbs');
                         }
                     }
                 }
                 if (file_exists(Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . 'user_' . $loggedInUserId . '/' . $attachment['id'])) {
                     Util::deleteDir(Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . 'user_' . $loggedInUserId . '/' . $attachment['id']);
                 }
             } else {
                 if (file_exists(Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . 'user_' . $loggedInUserId . '/' . $attachment['id'] . '/' . $attachment['name'])) {
                     if (!file_exists(Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . $issueId)) {
                         // create the moder
                         mkdir(Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . $issueId);
                     }
                     // move the attachment
                     rename(Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . 'user_' . $loggedInUserId . '/' . $attachment['id'], Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . $issueId . '/' . $attachment['id']);
                     // update the attachment
                     UbirimiContainer::get()['repository']->get(IssueAttachment::class)->updateByIdAndIssueId($attachmentId, $issueId);
                 }
             }
         }
         if (file_exists($uploadDirectory) && count(scandir($uploadDirectory)) == 2) {
             Util::deleteDir($uploadDirectory);
         }
         if (file_exists(Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . 'user_' . $loggedInUserId)) {
             Util::deleteDir(Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . 'user_' . $loggedInUserId);
         }
     }
 }
开发者ID:spiasecki,项目名称:ubirimi,代码行数:57,代码来源:Util.php


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