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


PHP CFile::resizeImageGet方法代码示例

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


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

示例1: prepareUserData

function prepareUserData($user)
{
    $user['DETAIL_URL'] = COption::getOptionString('intranet', 'search_user_url', '/user/#ID#/');
    $user['DETAIL_URL'] = str_replace(array('#ID#', '#USER_ID#'), array($user['ID'], $user['ID']), $user['DETAIL_URL']);
    $user['PHOTO_THUMB'] = '<img src="/bitrix/components/bitrix/main.user.link/templates/.default/images/nopic_30x30.gif" border="0" alt="" width="32" height="32">';
    if (intval($user['PERSONAL_PHOTO']) > 0) {
        $imageFile = CFile::getFileArray($user['PERSONAL_PHOTO']);
        if ($imageFile !== false) {
            $arFileTmp = CFile::resizeImageGet($imageFile, array('width' => 42, 'height' => 42), BX_RESIZE_IMAGE_EXACT, false);
            $user['PHOTO_THUMB'] = CFile::showImage($arFileTmp['src'], 32, 32);
        }
    }
    return $user;
}
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:14,代码来源:component.php

示例2: getSrc

 public static function getSrc($avatarId, $width = 21, $height = 21)
 {
     static $cache = array();
     if (empty($avatarId)) {
         return null;
     }
     $avatarId = (int) $avatarId;
     $key = $avatarId . " {$width} {$height}";
     if (!isset($cache[$key])) {
         $src = false;
         if ($avatarId > 0) {
             /** @noinspection PhpDynamicAsStaticMethodCallInspection */
             $imageFile = \CFile::getFileArray($avatarId);
             if ($imageFile !== false) {
                 /** @noinspection PhpDynamicAsStaticMethodCallInspection */
                 $fileTmp = \CFile::resizeImageGet($imageFile, array("width" => $width, "height" => $height), BX_RESIZE_IMAGE_EXACT, false);
                 $src = $fileTmp["src"];
             }
             $cache[$key] = $src;
         }
     }
     return $cache[$key];
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:23,代码来源:avatar.php

示例3: createAvatar

 /**
  * @param $fields
  * @param $params
  * @param $siteId
  * @return string|null
  */
 public static function createAvatar($fields, $params = array(), $siteId = SITE_ID)
 {
     if (!isset($params['AVATAR_SIZE'])) {
         $params['AVATAR_SIZE'] = 30;
     }
     if (CModule::IncludeModule('socialnetwork')) {
         return CSocNetLogTools::FormatEvent_CreateAvatar($fields, $params, '', $siteId);
     }
     static $cachedAvatars = array();
     if (intval($fields['PERSONAL_PHOTO']) > 0) {
         if (empty($cachedAvatars[$params['AVATAR_SIZE']][$fields['PERSONAL_PHOTO']])) {
             $imageFile = CFile::getFileArray($fields['PERSONAL_PHOTO']);
             if ($imageFile !== false) {
                 $file = CFile::resizeImageGet($imageFile, array("width" => $params['AVATAR_SIZE'], "height" => $params['AVATAR_SIZE']), BX_RESIZE_IMAGE_EXACT, false);
                 $avatarPath = $file['src'];
                 $cachedAvatars[$params['AVATAR_SIZE']][$fields['PERSONAL_PHOTO']] = $avatarPath;
             }
         }
     }
     return empty($cachedAvatars[$params['AVATAR_SIZE']][$fields['PERSONAL_PHOTO']]) ? null : $cachedAvatars[$params['AVATAR_SIZE']][$fields['PERSONAL_PHOTO']];
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:27,代码来源:utils.php

示例4: getPropsParams

 protected static function getPropsParams($iblockId)
 {
     $arRes = array();
     $bUseHLIblock = \Bitrix\Main\Loader::includeModule('highloadblock');
     $rsProps = \CIBlockProperty::getList(array('SORT' => 'ASC', 'ID' => 'ASC'), array('IBLOCK_ID' => $iblockId, 'ACTIVE' => 'Y'));
     while ($arProp = $rsProps->fetch()) {
         if ($arProp['PROPERTY_TYPE'] == 'L' || $arProp['PROPERTY_TYPE'] == 'E' || $arProp['PROPERTY_TYPE'] == 'S' && $arProp['USER_TYPE'] == 'directory') {
             if ($arProp['XML_ID'] == 'CML2_LINK') {
                 continue;
             }
             $arValues = array();
             if ($arProp['PROPERTY_TYPE'] == 'L') {
                 $arValues = array();
                 $rsPropEnums = \CIBlockProperty::getPropertyEnum($arProp['ID']);
                 while ($arEnum = $rsPropEnums->fetch()) {
                     $arValues[$arEnum['VALUE']] = array('ID' => $arEnum['ID'], 'NAME' => $arEnum['VALUE'], 'PICT' => false);
                 }
             } elseif ($arProp['PROPERTY_TYPE'] == 'E') {
                 $rsPropEnums = \CIBlockElement::getList(array('SORT' => 'ASC'), array('IBLOCK_ID' => $arProp['LINK_IBLOCK_ID'], 'ACTIVE' => 'Y'), false, false, array('ID', 'NAME', 'PREVIEW_PICTURE'));
                 while ($arEnum = $rsPropEnums->Fetch()) {
                     $arEnum['PREVIEW_PICTURE'] = \CFile::getFileArray($arEnum['PREVIEW_PICTURE']);
                     if (!is_array($arEnum['PREVIEW_PICTURE'])) {
                         $arEnum['PREVIEW_PICTURE'] = false;
                     }
                     if ($arEnum['PREVIEW_PICTURE'] !== false) {
                         $productImg = \CFile::resizeImageGet($arEnum['PREVIEW_PICTURE'], array('width' => 80, 'height' => 80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
                         $arEnum['PREVIEW_PICTURE']['SRC'] = $productImg['src'];
                     }
                     $arValues[$arEnum['NAME']] = array('ID' => $arEnum['ID'], 'NAME' => $arEnum['NAME'], 'SORT' => $arEnum['SORT'], 'PICT' => $arEnum['PREVIEW_PICTURE']);
                 }
             } elseif ($arProp['PROPERTY_TYPE'] == 'S' && $arProp['USER_TYPE'] == 'directory') {
                 if ($bUseHLIblock) {
                     $hlblock = HL\HighloadBlockTable::getList(array("filter" => array("TABLE_NAME" => $arProp["USER_TYPE_SETTINGS"]["TABLE_NAME"])))->fetch();
                     if ($hlblock) {
                         $entity = HL\HighloadBlockTable::compileEntity($hlblock);
                         $entity_data_class = $entity->getDataClass();
                         $rsData = $entity_data_class::getList();
                         while ($arData = $rsData->fetch()) {
                             $arValues[$arData['UF_XML_ID']] = array('ID' => $arData['ID'], 'NAME' => $arData['UF_NAME'], 'SORT' => $arData['UF_SORT'], 'FILE' => $arData['UF_FILE'], 'PICT' => '', 'XML_ID' => $arData['UF_XML_ID']);
                         }
                     }
                 }
             }
             if (!empty($arValues) && is_array($arValues)) {
                 $arRes[$arProp['ID']] = array('ID' => $arProp['ID'], 'CODE' => $arProp['CODE'], 'NAME' => $arProp['NAME'], 'TYPE' => $arProp['PROPERTY_TYPE'], 'ORDER' => array_keys($arValues), 'VALUES' => $arValues, 'SORT' => $arProp['SORT']);
             }
         }
         if ($arProp['PROPERTY_TYPE'] == "S" && is_array($arRes[$arProp['ID']]['VALUES'])) {
             foreach ($arRes[$arProp['ID']]['VALUES'] as $id => $value) {
                 $arTmpFile = \CFile::getFileArray($value["FILE"]);
                 $tmpImg = \CFile::resizeImageGet($arTmpFile, array('width' => 20, 'height' => 20), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
                 $arRes[$arProp['ID']]['VALUES'][$id]['PICT'] = $tmpImg['src'];
             }
         }
     }
     return $arRes;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:57,代码来源:orderbasket.php

示例5: processActionDownload

 protected function processActionDownload($showFile = false, $runResize = false)
 {
     if ($this->externalLink->hasPassword() && !$this->checkPassword()) {
         $this->showAccessDenied();
         return false;
     }
     $file = $this->externalLink->getFile();
     if (!$file) {
         $this->includeComponentTemplate('error');
         return false;
     }
     if (!$this->externalLink->isAutomatic() && !$this->checkDownloadToken($file, $this->request->getQuery('token'))) {
         $this->includeComponentTemplate('error');
         return false;
     }
     $this->externalLink->incrementDownloadCount();
     if ($this->externalLink->isSpecificVersion()) {
         $version = $file->getVersion($this->externalLink->getVersionId());
         if (!$version) {
             $this->includeComponentTemplate('error');
             return false;
         }
         $fileData = $version->getFile();
     } else {
         $fileData = $file->getFile();
     }
     if (!$fileData) {
         $this->includeComponentTemplate('error');
         return false;
     }
     if ($runResize && TypeFile::isImage($fileData['ORIGINAL_NAME'])) {
         /** @noinspection PhpDynamicAsStaticMethodCallInspection */
         $tmpFile = \CFile::resizeImageGet($fileData, array("width" => 255, "height" => 255), BX_RESIZE_IMAGE_EXACT, true, false, true);
         $fileData["FILE_SIZE"] = $tmpFile["size"];
         $fileData["SRC"] = $tmpFile["src"];
     }
     CFile::viewByUser($fileData, array('force_download' => !$showFile, 'attachment_name' => $file->getName()));
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:38,代码来源:class.php

示例6: getUserPictureSrc

 private function getUserPictureSrc($photoId, $width = 21, $height = 21)
 {
     static $cache = array();
     $photoId = (int) $photoId;
     $key = $photoId . " {$width} {$height}";
     if (isset($cache[$key])) {
         $src = $cache[$key];
     } else {
         $src = false;
         if ($photoId > 0) {
             $imageFile = \CFile::getFileArray($photoId);
             if ($imageFile !== false) {
                 $fileTmp = \CFile::resizeImageGet($imageFile, array("width" => $width, "height" => $height), BX_RESIZE_IMAGE_EXACT, false);
                 $src = $fileTmp["src"];
             }
             $cache[$key] = $src;
         }
     }
     return $src;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:20,代码来源:invitedispatcher.php

示例7: processActionDownloadFile

 protected function processActionDownloadFile()
 {
     $this->checkRequiredGetParams(array('attachedId'));
     if ($this->errorCollection->hasErrors()) {
         $this->sendJsonErrorResponse();
     }
     $fileModel = null;
     list($type, $realValue) = FileUserType::detectType($this->request->getQuery('attachedId'));
     if ($type == FileUserType::TYPE_NEW_OBJECT) {
         /** @var File $fileModel */
         $fileModel = File::loadById((int) $realValue, array('STORAGE'));
         if (!$fileModel) {
             $this->errorCollection->add(array(new Error("Could not find file")));
             $this->sendJsonErrorResponse();
         }
         if (!$fileModel->canRead($fileModel->getStorage()->getCurrentUserSecurityContext())) {
             $this->errorCollection->add(array(new Error("Bad permission. Could not read this file")));
             $this->sendJsonErrorResponse();
         }
         $fileName = $fileModel->getName();
         $fileData = $fileModel->getFile();
         if (!$fileData) {
             $this->end();
         }
         $cacheTime = 0;
         $width = $this->request->getQuery('width');
         $height = $this->request->getQuery('height');
         if (TypeFile::isImage($fileData["ORIGINAL_NAME"]) && ($width > 0 || $height > 0)) {
             $signature = $this->request->getQuery('signature');
             if (!$signature) {
                 $this->sendJsonInvalidSignResponse('Empty signature');
             }
             if (!ParameterSigner::validateImageSignature($signature, $fileModel->getId(), $width, $height)) {
                 $this->sendJsonInvalidSignResponse('Invalid signature');
             }
             /** @noinspection PhpDynamicAsStaticMethodCallInspection */
             $tmpFile = \CFile::resizeImageGet($fileData, array("width" => $width, "height" => $height), $this->request->getQuery('exact') == "Y" ? BX_RESIZE_IMAGE_EXACT : BX_RESIZE_IMAGE_PROPORTIONAL, true, false, true);
             $fileData["FILE_SIZE"] = $tmpFile["size"];
             $fileData["SRC"] = $tmpFile["src"];
             $cacheTime = 86400;
         }
         \CFile::viewByUser($fileData, array("force_download" => false, "cache_time" => $cacheTime, 'attachment_name' => $fileName));
     } else {
         $this->errorCollection->add(array(new Error('Could not find attached object')));
         $this->sendJsonErrorResponse();
     }
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:47,代码来源:controller.php

示例8: processActionShowFile

 protected function processActionShowFile()
 {
     $fileName = $this->file->getName();
     $fileData = $this->file->getFile();
     if (!$fileData) {
         $this->end();
     }
     $isImage = TypeFile::isImage($fileData["ORIGINAL_NAME"]);
     $cacheTime = $isImage ? 86400 : 0;
     $width = $this->request->getQuery('width');
     $height = $this->request->getQuery('height');
     if ($isImage && ($width > 0 || $height > 0)) {
         $signature = $this->request->getQuery('signature');
         if (!$signature) {
             $this->sendJsonInvalidSignResponse('Empty signature');
         }
         if (!ParameterSigner::validateImageSignature($signature, $this->file->getId(), $width, $height)) {
             $this->sendJsonInvalidSignResponse('Invalid signature');
         }
         /** @noinspection PhpDynamicAsStaticMethodCallInspection */
         $tmpFile = \CFile::resizeImageGet($fileData, array("width" => $width, "height" => $height), $this->request->getQuery('exact') == "Y" ? BX_RESIZE_IMAGE_EXACT : BX_RESIZE_IMAGE_PROPORTIONAL, true, false, true);
         $fileData["FILE_SIZE"] = $tmpFile["size"];
         $fileData["SRC"] = $tmpFile["src"];
     }
     \CFile::viewByUser($fileData, array('force_download' => false, 'cache_time' => $cacheTime, 'attachment_name' => $fileName));
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:26,代码来源:downloadcontroller.php

示例9: executeManagePage

    private function executeManagePage()
    {
        global $USER, $APPLICATION;
        $APPLICATION->setTitle(GetMessage('INTR_MAIL_MANAGE_PAGE_TITLE'));
        CJSCore::Init(array('admin_interface'));
        if (!$USER->isAdmin() && !$USER->canDoOperation('bitrix24_config')) {
            $APPLICATION->AuthForm(GetMessage('ACCESS_DENIED'));
            return;
        }
        $this->arParams['SERVICES'] = array();
        $services = CIntranetMailSetupHelper::getMailServices();
        foreach ($services as $service) {
            if ($service['type'] == 'controller') {
                $crDomains = CControllerClient::ExecuteEvent('OnMailControllerGetDomains', array());
                if (!empty($crDomains['result']) && is_array($crDomains['result'])) {
                    $service['domains'] = $crDomains['result'];
                    $service['users'] = array();
                    foreach ($service['domains'] as $domain) {
                        $service['users'][$domain] = array();
                    }
                    $crUsers = CControllerClient::ExecuteEvent('OnMailControllerGetUsers', array());
                    if (!empty($crUsers['result']) && is_array($crUsers['result'])) {
                        foreach ($crUsers['result'] as $email) {
                            list($login, $domain) = explode('@', $email, 2);
                            if (isset($service['users'][$domain])) {
                                $service['users'][$domain][] = $login;
                            }
                        }
                        $dbMailboxes = CMailbox::getList(array('TIMESTAMP_X' => 'ASC'), array('ACTIVE' => 'Y', '!USER_ID' => 0, 'SERVICE_ID' => $service['id']));
                        while ($mailbox = $dbMailboxes->fetch()) {
                            list($login, $domain) = explode('@', $mailbox['LOGIN'], 2);
                            if (!empty($service['users'][$domain]) && ($key = array_search($login, $service['users'][$domain])) !== false) {
                                array_splice($service['users'][$domain], $key, 1);
                            }
                        }
                    }
                    $this->arParams['SERVICES'][] = $service;
                }
            }
            if (in_array($service['type'], array('domain', 'crdomain'))) {
                $result = self::checkDomainStatus(array('type' => $service['type'], 'domain' => $service['server'], 'token' => $service['token']), $error);
                if (!empty($result['stage']) && $result['stage'] == 'added') {
                    $service['domains'] = array($service['server']);
                    $service['users'] = array($service['server'] => array());
                    if ($service['type'] == 'domain') {
                        $users = CMailDomain2::getDomainUsers($service['token'], $service['server'], $error);
                        if (!empty($users) && is_array($users)) {
                            $service['users'][$service['server']] = $users;
                        }
                    } else {
                        if ($service['type'] == 'crdomain') {
                            $crUsers = CControllerClient::ExecuteEvent('OnMailControllerGetMemberUsers', array('DOMAIN' => $service['server']));
                            if (!empty($crUsers['result']) && is_array($crUsers['result'])) {
                                $service['users'][$service['server']] = $crUsers['result'];
                            }
                        }
                    }
                    $dbMailboxes = CMailbox::getList(array('TIMESTAMP_X' => 'ASC'), array('ACTIVE' => 'Y', '!USER_ID' => 0, 'SERVICE_ID' => $service['id']));
                    while ($mailbox = $dbMailboxes->fetch()) {
                        list($login, $domain) = explode('@', $mailbox['LOGIN'], 2);
                        if (!empty($service['users'][$domain]) && ($key = array_search($login, $service['users'][$domain])) !== false) {
                            array_splice($service['users'][$domain], $key, 1);
                        }
                    }
                    $this->arParams['SERVICES'][] = $service;
                }
            }
        }
        $this->arResult['GRID_ID'] = 'manage_domain_grid';
        $gridOptions = new CGridOptions($this->arResult['GRID_ID']);
        $arSort = $gridOptions->getSorting(array('sort' => array('ID' => 'ASC'), 'vars' => array('by' => 'by', 'order' => 'order')));
        $arNav = $gridOptions->getNavParams(array('nPageSize' => 50));
        $arSortArg = each($arSort['sort']);
        $arFilter = array('ACTIVE' => 'Y', '!UF_DEPARTMENT' => false);
        if (isset($_REQUEST['act']) && $_REQUEST['act'] == 'search' && !empty($_REQUEST['FILTER'])) {
            $this->arResult['FILTER'] = $_REQUEST['FILTER'];
            $userIds = array();
            $dbMailboxes = CMailbox::getList(array('TIMESTAMP_X' => 'ASC'), array('LID' => SITE_ID, 'ACTIVE' => 'Y', '!USER_ID' => 0, 'LOGIN' => $_REQUEST['FILTER']));
            while ($mailbox = $dbMailboxes->fetch()) {
                if (in_array($mailbox['SERVER_TYPE'], array('imap', 'controller', 'domain'))) {
                    $userIds[] = $mailbox['USER_ID'];
                }
            }
            $arFilter['ID'] = empty($userIds) ? 0 : join('|', $userIds);
        }
        $dbUsers = CUser::GetList($arSortArg['key'], $arSortArg['value'], $arFilter, array('FIELDS' => array('ID', 'LOGIN', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'PERSONAL_PHOTO', 'WORK_POSITION')));
        $dbUsers->navStart($arNav['nPageSize']);
        $arRows = array();
        while ($user = $dbUsers->fetch()) {
            $user['DETAIL_URL'] = COption::getOptionString('intranet', 'search_user_url', '/user/#ID#/');
            $user['DETAIL_URL'] = str_replace(array('#ID#', '#USER_ID#'), array($user['ID'], $user['ID']), $user['DETAIL_URL']);
            $user['PHOTO_THUMB'] = '<img src="/bitrix/components/bitrix/main.user.link/templates/.default/images/nopic_30x30.gif" border="0" alt="" width="32" height="32">';
            if (intval($user['PERSONAL_PHOTO']) > 0) {
                $imageFile = CFile::getFileArray($user['PERSONAL_PHOTO']);
                if ($imageFile !== false) {
                    $arFileTmp = CFile::resizeImageGet($imageFile, array('width' => 42, 'height' => 42), BX_RESIZE_IMAGE_EXACT, false);
                    $user['PHOTO_THUMB'] = CFile::showImage($arFileTmp['src'], 32, 32);
                }
            }
            $anchor_id = RandString(8);
//.........这里部分代码省略.........
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:101,代码来源:class.php


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