本文整理汇总了PHP中Ubirimi\Util::getExtension方法的典型用法代码示例。如果您正苦于以下问题:PHP Util::getExtension方法的具体用法?PHP Util::getExtension怎么用?PHP Util::getExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ubirimi\Util
的用法示例。
在下文中一共展示了Util::getExtension方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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('');
}
示例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);
}
}
}
示例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('');
}
示例4: indexAction
public function indexAction(Request $request, SessionInterface $session)
{
$userId = $session->get('user/id');
$uploadPath = UbirimiContainer::get()['asset.root_folder'] . UbirimiContainer::get()['asset.user_avatar'] . $userId;
if (!file_exists($uploadPath)) {
mkdir($uploadPath);
}
if (UPLOAD_ERR_OK == $_FILES["files"]["error"][0]) {
$tmp_name = $_FILES["files"]["tmp_name"][0];
$name = $_FILES["files"]["name"][0];
$extension = Util::getExtension($name);
if ($extension != 'png' && $extension != 'jpg' && $extension != 'jpeg') {
return new Response('error');
}
$filename = 'user_' . $userId;
$originalFileName = $filename . "." . $extension;
move_uploaded_file($tmp_name, $uploadPath . "/" . $originalFileName);
$this->getRepository(UbirimiUser::class)->updateAvatar($originalFileName, $userId);
$newFileName = $uploadPath . "/" . $originalFileName;
$newThumbnailName = $uploadPath . "/" . $filename . '_150.' . $extension;
$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);
$newThumbnailName = $uploadPath . "/" . $filename . '_33.' . $extension;
$image = new ZebraImage();
$image->jpeg_quality = 100;
$image->chmod_value = 0755;
$image->source_path = $newFileName;
$image->target_path = $newThumbnailName;
$image->resize(33, 33, ZEBRA_IMAGE_CROP_CENTER);
$session->set('user/avatar_picture', $filename . '.' . $extension);
return new Response($userId . '/' . $originalFileName);
}
}
示例5: 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);
示例6: 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);
}
}
}