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


PHP rex_file::extension方法代码示例

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


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

示例1: getArchive

 public static function getArchive($url)
 {
     global $I18N;
     try {
         $socket = rex_socket::factoryUrl($url);
         $response = $socket->doGet();
         if ($response->isOk()) {
             $filename = basename($url);
             $file = rex_path::addonCache('install', md5($filename) . '.' . rex_file::extension($filename));
             $response->writeBodyTo($file);
             return $file;
         }
     } catch (rex_socket_exception $e) {
     }
     throw new rex_install_functional_exception($I18N->msg('install_archive_unreachable'));
 }
开发者ID:eaCe,项目名称:redaxo4,代码行数:16,代码来源:webservice.php

示例2: execute

 public function execute()
 {
     // error_reporting(E_ALL);ini_set("display_errors",1);
     if (!isset(self::$convert_to[$this->params['convert_to']])) {
         $convert_to = self::$convert_to[self::$convert_to_default];
     } else {
         $convert_to = self::$convert_to[$this->params['convert_to']];
     }
     $density = (int) $this->params['density'];
     if (!in_array($density, self::$densities)) {
         $density = self::$density_default;
     }
     $from_path = realpath($this->media->getMediapath());
     $ext = rex_file::extension($from_path);
     if (!$ext) {
         return;
     }
     if (!in_array(strtolower($ext), self::$convert_types)) {
         return;
     }
     $convert_path = self::getConvertPath();
     if ($convert_path == '') {
         return;
     }
     $filename = $this->media->getMediaFilename();
     $filename_wo_ext = substr($filename, 0, strlen($filename) - strlen($ext));
     $to_path = rex_path::addonCache('media_manager', 'media_manager__convert2img_' . md5($this->media->getMediapath()) . '_' . $filename_wo_ext . $convert_to['ext']);
     $cmd = $convert_path . ' -density ' . $density . ' "' . $from_path . '[0]" -colorspace RGB "' . $to_path . '"';
     exec($cmd, $out, $ret);
     if ($ret != 0) {
         return false;
     }
     $image_src = call_user_func($convert_to['createfunc'], $to_path);
     if (!$image_src) {
         return;
     }
     $this->media->setImage($image_src);
     $this->media->refreshImageDimensions();
     $this->media->setFormat($convert_to['ext']);
     $this->media->setMediaFilename($filename);
     $this->media->setHeader('Content-Type', $convert_to['content-type']);
     unlink($to_path);
 }
开发者ID:DECAF,项目名称:redaxo,代码行数:43,代码来源:effect_convert2img.php

示例3: asImage

 public function asImage()
 {
     if ($this->asImage) {
         return;
     }
     $this->asImage = true;
     $this->image = [];
     $this->image['format'] = strtolower(rex_file::extension($this->getMediapath()));
     $this->image['src'] = false;
     // if mimetype detected and in imagemap -> change format
     if (class_exists('finfo') && ($finfo = new finfo(FILEINFO_MIME_TYPE))) {
         if ($ftype = @$finfo->file($this->image['filepath'])) {
             if (array_key_exists($ftype, $this->mimetypeMap)) {
                 $this->image['format'] = $this->mimetypeMap[$ftype];
             }
         }
     }
     if ($this->image['format'] == 'jpg' || $this->image['format'] == 'jpeg') {
         $this->image['format'] = 'jpeg';
         $this->image['src'] = @imagecreatefromjpeg($this->getMediapath());
     } elseif ($this->image['format'] == 'gif') {
         $this->image['src'] = @imagecreatefromgif($this->getMediapath());
     } elseif ($this->image['format'] == 'wbmp') {
         $this->image['src'] = @imagecreatefromwbmp($this->getMediapath());
     } else {
         $this->image['src'] = @imagecreatefrompng($this->getMediapath());
         if ($this->image['src']) {
             imagealphablending($this->image['src'], false);
             imagesavealpha($this->image['src'], true);
             $this->image['format'] = 'png';
         }
     }
     if (!$this->image['src']) {
         $this->setMediapath(rex_path::addon('media_manager', 'media/warning.jpg'));
         $this->asImage();
     } else {
         $this->refreshImageDimensions();
     }
 }
开发者ID:DECAF,项目名称:redaxo,代码行数:39,代码来源:managed_media.php

示例4: getExtension

 /**
  * @return string
  */
 public function getExtension()
 {
     return rex_file::extension($this->name);
 }
开发者ID:DECAF,项目名称:redaxo,代码行数:7,代码来源:media.php

示例5: elseif

         if ($media_manager) {
             $thumbnail = '<img class="thumbnail" src="' . rex_url::backendController(['rex_media_type' => 'rex_mediapool_preview', 'rex_media_file' => $encoded_file_name]) . '" alt="' . $alt . '" title="' . $alt . '" />';
         }
     }
 }
 // ----- get file size
 $size = $file_size;
 $file_size = rex_formatter::bytes($size);
 if ($file_title == '') {
     $file_title = '[' . rex_i18n::msg('pool_file_notitle') . ']';
 }
 $file_title .= ' [' . $file_id . ']';
 // ----- opener
 $opener_link = '';
 if ($opener_input_field == 'TINYIMG') {
     if (rex_media::isImageType(rex_file::extension($file_name))) {
         $opener_link .= '<a class="btn btn-select" href="javascript:insertImage(\'$file_name\',\'' . $files->getValue('title') . '\')">' . rex_i18n::msg('pool_image_get') . '</a>';
     }
 } elseif ($opener_input_field == 'TINY') {
     $opener_link .= '<a class="btn btn-select" href="javascript:insertLink(\'' . $file_name . '\');"">' . rex_i18n::msg('pool_link_get') . '</a>';
 } elseif ($opener_input_field != '') {
     $opener_link = '<a class="btn btn-xs btn-select" href="javascript:selectMedia(\'' . $file_name . '\', \'' . addslashes(htmlspecialchars($files->getValue('title'))) . '\');">' . rex_i18n::msg('pool_file_get') . '</a>';
     if (substr($opener_input_field, 0, 14) == 'REX_MEDIALIST_') {
         $opener_link = '<a class="btn btn-xs btn-select" href="javascript:selectMedialist(\'' . $file_name . '\');">' . rex_i18n::msg('pool_file_get') . '</a>';
     }
 }
 $ilink = rex_url::currentBackendPage(array_merge(['file_id' => $file_id, 'rex_file_category' => $rex_file_category], $arg_url));
 $add_td = '<td></td>';
 if ($PERMALL) {
     $add_td = '<td><input type="checkbox" name="selectedmedia[]" value="' . $file_name . '" /></td>';
 }
开发者ID:alsahh,项目名称:redaxo,代码行数:31,代码来源:media.php

示例6: rex_mediapool_isAllowedMediaType

/**
 * check if mediatpye(extension) is allowed for upload.
 *
 * @param string $filename
 * @param array  $args
 *
 * @return bool
 */
function rex_mediapool_isAllowedMediaType($filename, array $args = [])
{
    $file_ext = rex_file::extension($filename);
    if ($filename === '' || strpos($file_ext, ' ') !== false || $file_ext === '') {
        return false;
    }
    $blacklist = rex_mediapool_getMediaTypeBlacklist();
    $whitelist = rex_mediapool_getMediaTypeWhitelist($args);
    if (in_array($file_ext, $blacklist)) {
        return false;
    }
    if (count($whitelist) > 0 && !in_array($file_ext, $whitelist)) {
        return false;
    }
    return true;
}
开发者ID:skerbis,项目名称:redaxo,代码行数:24,代码来源:function_rex_mediapool.php

示例7: testExtension

 /**
  * @dataProvider dataTestExtension
  */
 public function testExtension($file, $expectedExtension)
 {
     $this->assertEquals($expectedExtension, rex_file::extension($file), 'extension() returns file extension');
 }
开发者ID:staabm,项目名称:redaxo,代码行数:7,代码来源:file_test.php

示例8: rex_request

<?php

// *************************************** Subpage: ADD FILE
$media_method = rex_request('media_method', 'string');
// ----- METHOD ADD FILE
if ($media_method == 'add_file') {
    if (rex_post('save', 'boolean') || rex_post('saveandexit', 'boolean')) {
        if ($_FILES['file_new']['name'] != '' && $_FILES['file_new']['name'] != 'none') {
            if (!rex_mediapool_isAllowedMediaType($_FILES['file_new']['name'], rex_post('args', 'array'))) {
                $warning = rex_i18n::msg('pool_file_mediatype_not_allowed') . ' <code>' . rex_file::extension($_FILES['file_new']['name'] . '</code>');
                $whitelist = rex_mediapool_getMediaTypeWhitelist(rex_post('args', 'array'));
                $warning .= count($whitelist) > 0 ? '<br />' . rex_i18n::msg('pool_file_allowed_mediatypes') . ' <code>' . rtrim(implode('</code>, <code>', $whitelist), ', ') . '</code>' : '<br />' . rex_i18n::msg('pool_file_banned_mediatypes') . ' <code>' . rtrim(implode('</code>, <code>', rex_mediapool_getMediaTypeBlacklist()), ', ') . '</code>';
            } else {
                $FILEINFOS['title'] = rex_request('ftitle', 'string');
                if (!$PERMALL && !rex::getUser()->getComplexPerm('media')->hasCategoryPerm($rex_file_category)) {
                    $rex_file_category = 0;
                }
                // function in function.rex_mediapool.php
                $return = rex_mediapool_saveMedia($_FILES['file_new'], $rex_file_category, $FILEINFOS, rex::getUser()->getValue('login'));
                $info = $return['msg'];
                $subpage = '';
                // ----- EXTENSION POINT
                if ($return['ok'] == 1) {
                    rex_extension::registerPoint(new rex_extension_point('MEDIA_ADDED', '', $return));
                }
                if (rex_post('saveandexit', 'boolean') && $return['ok'] == 1) {
                    $file_name = $return['filename'];
                    $ffiletype = $return['type'];
                    $title = $return['title'];
                    if ($opener_input_field != '') {
                        if (substr($opener_input_field, 0, 14) == 'REX_MEDIALIST_') {
开发者ID:DECAF,项目名称:redaxo,代码行数:31,代码来源:upload.php

示例9: substr

         break;
     }
 }
 // wenn datei fehlt
 if (!file_exists(rex_path::media($file_name))) {
     $thumbnail = '<i class="rex-mime rex-mime-error" title="' . rex_i18n::msg('pool_file_does_not_exist') . '"></i><span class="sr-only">' . $file_name . '</span>';
 } else {
     $file_ext = substr(strrchr($file_name, '.'), 1);
     $icon_class = ' rex-mime-default';
     if (rex_media::isDocType($file_ext)) {
         $icon_class = ' rex-mime-' . $file_ext;
     }
     $thumbnail = '<i class="rex-mime' . $icon_class . '" title="' . $alt . '" data-extension="' . $file_ext . '"></i><span class="sr-only">' . $file_name . '</span>';
     if (rex_media::isImageType(rex_file::extension($file_name))) {
         $thumbnail = '<img class="thumbnail" src="' . rex_url::media($file_name) . '" width="80" height="80" alt="' . $alt . '" title="' . $alt . '" />';
         if ($media_manager && rex_file::extension($file_name) != 'svg') {
             $thumbnail = '<img class="thumbnail" src="' . rex_url::backendController(['rex_media_type' => 'rex_mediapool_preview', 'rex_media_file' => $encoded_file_name]) . '" alt="' . $alt . '" title="' . $alt . '" />';
         }
     }
 }
 // ----- get file size
 $size = $file_size;
 $file_size = rex_formatter::bytes($size);
 if ($file_title == '') {
     $file_title = '[' . rex_i18n::msg('pool_file_notitle') . ']';
 }
 $file_title .= ' [' . $file_id . ']';
 // ----- opener
 $opener_link = '';
 if ($opener_input_field != '') {
     $opener_link = '<a class="btn btn-xs btn-select" href="javascript:selectMedia(\'' . $file_name . '\', \'' . addslashes(htmlspecialchars($files->getValue('title'))) . '\');">' . rex_i18n::msg('pool_file_get') . '</a>';
开发者ID:DECAF,项目名称:redaxo,代码行数:31,代码来源:media.php


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