• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP basename函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中basename函数的典型用法代码示例。如果您正苦于以下问题:PHP basename函数的具体用法?PHP basename怎么用?PHP basename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: setUp

 public function setUp()
 {
     $_SERVER['REDIRECT_STATUS'] = "200";
     $_SERVER['HTTP_HOST'] = "slim";
     $_SERVER['HTTP_CONNECTION'] = "keep-alive";
     $_SERVER['HTTP_CACHE_CONTROL'] = "max-age=0";
     $_SERVER['HTTP_ACCEPT'] = "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
     $_SERVER['HTTP_USER_AGENT'] = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.63 Safari/534.3";
     $_SERVER['HTTP_ACCEPT_ENCODING'] = "gzip,deflate,sdch";
     $_SERVER['HTTP_ACCEPT_LANGUAGE'] = "en-US,en;q=0.8";
     $_SERVER['HTTP_ACCEPT_CHARSET'] = "ISO-8859-1,utf-8;q=0.7,*;q=0.3";
     $_SERVER['PATH'] = "/usr/bin:/bin:/usr/sbin:/sbin";
     $_SERVER['SERVER_SIGNATURE'] = "";
     $_SERVER['SERVER_SOFTWARE'] = "Apache";
     $_SERVER['SERVER_NAME'] = "slim";
     $_SERVER['SERVER_ADDR'] = "127.0.0.1";
     $_SERVER['SERVER_PORT'] = "80";
     $_SERVER['REMOTE_ADDR'] = "127.0.0.1";
     $_SERVER['DOCUMENT_ROOT'] = rtrim(dirname(__FILE__), '/');
     $_SERVER['SERVER_ADMIN'] = "[email protected]";
     $_SERVER['SCRIPT_FILENAME'] = __FILE__;
     $_SERVER['REMOTE_PORT'] = "55426";
     $_SERVER['REDIRECT_URL'] = "/";
     $_SERVER['GATEWAY_INTERFACE'] = "CGI/1.1";
     $_SERVER['SERVER_PROTOCOL'] = "HTTP/1.1";
     $_SERVER['REQUEST_METHOD'] = "GET";
     $_SERVER['QUERY_STRING'] = "";
     $_SERVER['REQUEST_URI'] = "/";
     $_SERVER['SCRIPT_NAME'] = basename(__FILE__);
     $_SERVER['PHP_SELF'] = '/' . basename(__FILE__);
     $_SERVER['REQUEST_TIME'] = "1285647051";
     $_SERVER['argv'] = array();
     $_SERVER['argc'] = 0;
 }
开发者ID:inscriptionweb,项目名称:lebonmail,代码行数:34,代码来源:ResponseTest.php


示例2: generatePDF

 function generatePDF()
 {
     // tempfolder
     $tmpBaseFolder = TEMP_FOLDER . '/shopsystem';
     $tmpFolder = project() ? "{$tmpBaseFolder}/" . project() : "{$tmpBaseFolder}/site";
     if (is_dir($tmpFolder)) {
         Filesystem::removeFolder($tmpFolder);
     }
     if (!file_exists($tmpFolder)) {
         Filesystem::makeFolder($tmpFolder);
     }
     $baseFolderName = basename($tmpFolder);
     //Get site
     Requirements::clear();
     $link = Director::absoluteURL($this->pdfLink() . "/?view=1");
     $response = Director::test($link);
     $content = $response->getBody();
     $content = utf8_decode($content);
     $contentfile = "{$tmpFolder}/" . $this->PublicURL . ".html";
     if (!file_exists($contentfile)) {
         // Write to file
         if ($fh = fopen($contentfile, 'w')) {
             fwrite($fh, $content);
             fclose($fh);
         }
     }
     return $contentfile;
 }
开发者ID:pstaender,项目名称:ShopSystem,代码行数:28,代码来源:ShopInvoice.php


示例3: writeMsg

/** 
 * Write a information message 
 * 
 * @param $msg Message to write to console.
 * @access public
 */
function writeMsg($msg)
{
    global $VERBOSE;
    if ($VERBOSE) {
        echo basename(__FILE__) . ": [INFO] " . $msg . "\n";
    }
}
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:13,代码来源:instrument.php


示例4: mytheme_add_admin

function mytheme_add_admin()
{
    global $themename, $shortname, $options;
    if ($_GET['page'] == basename(__FILE__)) {
        if ('save' == $_REQUEST['action']) {
            foreach ($options as $value) {
                if ($value['type'] != 'header') {
                    update_option($value['id'], $_REQUEST[$value['id']]);
                }
            }
            foreach ($options as $value) {
                if (isset($_REQUEST[$value['id']])) {
                    update_option($value['id'], $_REQUEST[$value['id']]);
                } else {
                    delete_option($value['id']);
                }
            }
            header("Location: themes.php?page=settings.php&saved=true");
            die;
        } else {
            if ('reset' == $_REQUEST['action']) {
                foreach ($options as $value) {
                    delete_option($value['id']);
                }
                header("Location: themes.php?page=settings.php&reset=true");
                die;
            }
        }
    }
    add_theme_page($themename . " Settings", "Theme Settings", 'edit_themes', basename(__FILE__), 'mytheme_admin');
}
开发者ID:erka,项目名称:wp-blog,代码行数:31,代码来源:settings.php


示例5: template

 /**
  * Compiles a template and writes it to a cache file, which is used for inclusion.
  *
  * @param string $file The full path to the template that will be compiled.
  * @param array $options Options for compilation include:
  *        - `path`: Path where the compiled template should be written.
  *        - `fallback`: Boolean indicating that if the compilation failed for some
  *                      reason (e.g. `path` is not writable), that the compiled template
  *                      should still be returned and no exception be thrown.
  * @return string The compiled template.
  */
 public static function template($file, array $options = array())
 {
     $cachePath = Libraries::get(true, 'resources') . '/tmp/cache/templates';
     $defaults = array('path' => $cachePath, 'fallback' => false);
     $options += $defaults;
     $stats = stat($file);
     $oname = basename(dirname($file)) . '_' . basename($file, '.php');
     $oname .= '_' . ($stats['ino'] ?: hash('md5', $file));
     $template = "template_{$oname}_{$stats['mtime']}_{$stats['size']}.php";
     $template = "{$options['path']}/{$template}";
     if (file_exists($template)) {
         return $template;
     }
     $compiled = static::compile(file_get_contents($file));
     if (is_writable($cachePath) && file_put_contents($template, $compiled) !== false) {
         foreach (glob("{$options['path']}/template_{$oname}_*.php", GLOB_NOSORT) as $expired) {
             if ($expired !== $template) {
                 unlink($expired);
             }
         }
         return $template;
     }
     if ($options['fallback']) {
         return $file;
     }
     throw new TemplateException("Could not write compiled template `{$template}` to cache.");
 }
开发者ID:fedeisas,项目名称:lithium,代码行数:38,代码来源:Compiler.php


示例6: findShortestPath

 /**
  * Returns the shortest path from $from to $to
  *
  * @param  string $from
  * @param  string $to
  * @param  bool   $directories if true, the source/target are considered to be directories
  * @return string
  */
 public function findShortestPath($from, $to, $directories = false)
 {
     if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
         throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
     }
     $from = lcfirst(rtrim(strtr($from, '\\', '/'), '/'));
     $to = lcfirst(rtrim(strtr($to, '\\', '/'), '/'));
     if ($directories) {
         $from .= '/dummy_file';
     }
     if (dirname($from) === dirname($to)) {
         return './' . basename($to);
     }
     $commonPath = $to;
     while (strpos($from, $commonPath) !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath) && '.' !== $commonPath) {
         $commonPath = strtr(dirname($commonPath), '\\', '/');
     }
     if (0 !== strpos($from, $commonPath) || '/' === $commonPath || '.' === $commonPath) {
         return $to;
     }
     $commonPath = rtrim($commonPath, '/') . '/';
     $sourcePathDepth = substr_count(substr($from, strlen($commonPath)), '/');
     $commonPathCode = str_repeat('../', $sourcePathDepth);
     return $commonPathCode . substr($to, strlen($commonPath)) ?: './';
 }
开发者ID:r15ch13,项目名称:composer,代码行数:33,代码来源:Filesystem.php


示例7: load

 function load()
 {
     $this->values = array();
     if (JRequest::getCmd('from_display', false) == false) {
         $this->values[] = JHTML::_('select.option', '', JText::_('HIKA_INHERIT'));
     }
     $this->values[] = JHTML::_('select.optgroup', '-- ' . JText::_('FROM_HIKASHOP') . ' --');
     foreach ($this->default as $d) {
         $this->values[] = JHTML::_('select.option', $d, JText::_(strtoupper($d)));
     }
     if (version_compare(JVERSION, '1.6.0', '>=')) {
         $this->values[] = JHTML::_('select.optgroup', '-- ' . JText::_('FROM_HIKASHOP') . ' --');
     }
     $closeOpt = '';
     $values = $this->getLayout();
     foreach ($values as $value) {
         if (substr($value, 0, 1) == '#') {
             if (version_compare(JVERSION, '1.6.0', '>=') && !empty($closeOpt)) {
                 $this->values[] = JHTML::_('select.optgroup', $closeOpt);
             }
             $value = substr($value, 1);
             $closeOpt = '-- ' . JText::sprintf('FROM_TEMPLATE', basename($value)) . ' --';
             $this->values[] = JHTML::_('select.optgroup', $closeOpt);
         } else {
             $this->values[] = JHTML::_('select.option', $value, $value);
         }
     }
     if (version_compare(JVERSION, '1.6.0', '>=') && !empty($closeOpt)) {
         $this->values[] = JHTML::_('select.optgroup', $closeOpt);
     }
 }
开发者ID:q0821,项目名称:esportshop,代码行数:31,代码来源:quantitydisplay.php


示例8: elgg_register_classes

/**
 * Register all files found in $dir as classes
 * Need to be named MyClass.php
 *
 * @param string $dir The dir to look in
 *
 * @return void
 * @since 1.8.0
 */
function elgg_register_classes($dir)
{
    $classes = elgg_get_file_list($dir, array(), array(), array('.php'));
    foreach ($classes as $class) {
        elgg_register_class(basename($class, '.php'), $class);
    }
}
开发者ID:nhunaro,项目名称:Elgg,代码行数:16,代码来源:elgglib.php


示例9: renderAudioPlayer

 /**
  * Renders audio player for the blog
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public function renderAudioPlayer($uri, $options = array())
 {
     // Merge the options with the default options
     $options = array_replace_recursive(self::$defaultAudioOptions, $options);
     // Generate a random uid
     $uniqid = uniqid();
     $uid = 'audio-' . EBMM::getHash($uri . $uniqid);
     // Url to the audio
     $url = $this->normalizeURI($uri);
     // Get the track if there is no track provided
     if (!$options['track']) {
         $options['track'] = basename($url);
     }
     // Set a default artist if artist isn't set
     if (!$options['artist']) {
         $options['artist'] = JText::_('COM_EASYBLOG_BLOCKS_AUDIO_ARTIST');
     }
     $template = EB::template();
     $template->set('uid', $uid);
     $template->set('showTrack', $options['showTrack']);
     $template->set('showDownload', $options['showDownload']);
     $template->set('showArtist', $options['showArtist']);
     $template->set('autoplay', $options['autoplay']);
     $template->set('loop', $options['loop']);
     $template->set('artist', $options['artist']);
     $template->set('track', $options['track']);
     $template->set('url', $url);
     $output = $template->output('site/blogs/blocks/audio');
     return $output;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:38,代码来源:media.php


示例10: init_paths

 /**
  * Парсит пути
  */
 private function init_paths()
 {
     $filter = new filter();
     $this->dir = substr($filter->server('PHP_SELF'), 0, 0 - strlen(basename($filter->server('PHP_SELF'))));
     $this->root = $this->dir;
     $this->link = substr($filter->server('REQUEST_URI'), strlen($this->dir));
 }
开发者ID:TwinkleFox,项目名称:TwinkleFox_CMF,代码行数:10,代码来源:url.php


示例11: getShortName

 /**
  * Return book's short name
  *
  * @return string
  */
 public function getShortName()
 {
     if ($this->short_name === null) {
         $this->short_name = str_replace('_', '-', basename($this->path));
     }
     return $this->short_name;
 }
开发者ID:activecollab,项目名称:shade,代码行数:12,代码来源:Element.php


示例12: onParseContentBlock

 function onParseContentBlock($page, $name, $text, $shortcut)
 {
     $output = NULL;
     if ($name == "fotorama" && $shortcut) {
         list($pattern, $style, $nav, $autoplay) = $this->yellow->toolbox->getTextArgs($text);
         if (empty($style)) {
             $style = $this->yellow->config->get("fotoramaStyle");
         }
         if (empty($nav)) {
             $nav = $this->yellow->config->get("fotoramaNav");
         }
         if (empty($autoplay)) {
             $autoplay = $this->yellow->config->get("fotoramaAutoplay");
         }
         if (empty($pattern)) {
             $files = $page->getFiles(true);
         } else {
             $images = $this->yellow->config->get("imageDir");
             $files = $this->yellow->files->index(true, true)->match("#{$images}{$pattern}#");
         }
         if (count($files)) {
             $page->setLastModified($files->getModified());
             $output = "<div class=\"" . htmlspecialchars($style) . "\" data-nav=\"" . htmlspecialchars($nav) . "\" data-autoplay=\"" . htmlspecialchars($autoplay) . "\" data-loop=\"true\">\n";
             foreach ($files as $file) {
                 list($width, $height) = $this->yellow->toolbox->detectImageInfo($file->fileName);
                 $output .= "<img src=\"" . htmlspecialchars($file->getLocation()) . "\" width=\"" . htmlspecialchars($width) . "\" height=\"" . htmlspecialchars($height) . "\" alt=\"" . basename($file->getLocation()) . "\" title=\"" . basename($file->getLocation()) . "\" />\n";
             }
             $output .= "</div>";
         } else {
             $page->error(500, "Fotorama '{$pattern}' does not exist!");
         }
     }
     return $output;
 }
开发者ID:rainkarnichi,项目名称:yellow-extensions,代码行数:34,代码来源:fotorama.php


示例13: clearCache

 public static function clearCache()
 {
     if (!is_dir(CACHE_PATH)) {
         return;
     }
     try {
         $dirIterator = new RecursiveDirectoryIterator(CACHE_PATH);
         $iterator = new RecursiveIteratorIterator($dirIterator, RecursiveIteratorIterator::CHILD_FIRST);
         foreach ($iterator as $path) {
             switch (true) {
                 case '.' == basename($path->__toString()):
                 case '..' == basename($path->__toString()):
                 case '...' == basename($path->__toString()):
                     break;
                 case $path->isDir():
                     rmdir($path->__toString());
                     break;
                 default:
                     unlink($path->__toString());
                     break;
             }
         }
         rmdir(CACHE_PATH);
     } catch (Exception $e) {
         throw $e;
     }
 }
开发者ID:HuyTran0424,项目名称:noeavrsev345452dfgdfgsg,代码行数:27,代码来源:App.php


示例14: upload

 function upload($source, $target)
 {
     if ($this->error()) {
         return 0;
     }
     $old_dir = $this->ftp_pwd();
     $dirname = dirname($target);
     $filename = basename($target);
     if (!$this->ftp_chdir($dirname)) {
         if ($this->ftp_mkdir($dirname)) {
             $this->ftp_chmod($dirname);
             if (!$this->ftp_chdir($dirname)) {
                 $this->set_error(FTP_ERR_CHDIR);
             }
             $this->ftp_put('index.htm', getglobal('setting/attachdir') . '/index.htm', FTP_BINARY);
         } else {
             $this->set_error(FTP_ERR_MKDIR);
         }
     }
     $res = 0;
     if (!$this->error()) {
         if ($fp = @fopen($source, 'rb')) {
             $res = $this->ftp_fput($filename, $fp, FTP_BINARY);
             @fclose($fp);
             !$res && $this->set_error(FTP_ERR_TARGET_WRITE);
         } else {
             $this->set_error(FTP_ERR_SOURCE_READ);
         }
     }
     $this->ftp_chdir($old_dir);
     return $res ? 1 : 0;
 }
开发者ID:softhui,项目名称:discuz,代码行数:32,代码来源:discuz_ftp.php


示例15: importTranslations

 public function importTranslations($replace = false)
 {
     $counter = 0;
     foreach ($this->files->directories($this->app->langPath()) as $langPath) {
         $locale = basename($langPath);
         foreach ($this->files->files($langPath) as $file) {
             $info = pathinfo($file);
             $group = $info['filename'];
             if (in_array($group, $this->config['exclude_groups'])) {
                 continue;
             }
             $translations = \Lang::getLoader()->load($locale, $group);
             if ($translations && is_array($translations)) {
                 foreach (array_dot($translations) as $key => $value) {
                     $value = (string) $value;
                     $translation = Translation::firstOrNew(array('locale' => $locale, 'group' => $group, 'key' => $key));
                     // Check if the database is different then the files
                     $newStatus = $translation->value === $value ? Translation::STATUS_SAVED : Translation::STATUS_CHANGED;
                     if ($newStatus !== (int) $translation->status) {
                         $translation->status = $newStatus;
                     }
                     // Only replace when empty, or explicitly told so
                     if ($replace || !$translation->value) {
                         $translation->value = $value;
                     }
                     $translation->save();
                     $counter++;
                 }
             }
         }
     }
     return $counter;
 }
开发者ID:txandy,项目名称:laravel-translation-manager,代码行数:33,代码来源:Manager.php


示例16: dwld

 public function dwld()
 {
     $this->min();
     if (is_numeric($this->getParam("id"))) {
         $this->download->newDownload();
         if ($this->download->getIsLocal()) {
             $url = OWEB_DIR_DATA . "/downloads/" . $this->download->getUrl();
             header('Content-Description: File Transfer');
             header('Content-Type: application/octet-stream');
             header('Content-Disposition: attachment; filename="' . basename($url) . '";');
             readfile($url);
         } else {
             $url = OWEB_DIR_DATA . "/downloads/" . $this->download->getUrl();
             header("Content-Disposition: attachment; filename=" . basename($url));
             header("Content-Type: application/force-download");
             header("Content-Type: application/octet-stream");
             header("Content-Type: application/download");
             header("Content-Description: File Transfer");
             header("Content-Length: " . filesize($url));
             flush();
             // this doesn't really matter.
             $fp = fopen($url, "r");
             while (!feof($fp)) {
                 echo fread($fp, 65536);
                 flush();
                 // this is essential for large downloads
             }
             fclose($fp);
         }
     } else {
         throw new \Model\downloads\exception\DownloadCantBeFind("No Download ID given");
     }
 }
开发者ID:oliverde8,项目名称:oweb-framework,代码行数:33,代码来源:Download.php


示例17: getTestFiles

 /**
  * Get Test Files
  *
  * @param null $directory
  * @param null $excludes
  * @return array
  */
 public static function getTestFiles($directory = null, $excludes = null)
 {
     if (is_array($directory)) {
         $files = array();
         foreach ($directory as $d) {
             $files = array_merge($files, self::getTestFiles($d, $excludes));
         }
         return array_unique($files);
     }
     if ($excludes !== null) {
         $excludes = self::getTestFiles((array) $excludes);
     }
     if ($directory === null || $directory !== realpath($directory)) {
         $basePath = App::pluginPath('DebugKit') . 'Test' . DS . 'Case' . DS;
         $directory = str_replace(DS . DS, DS, $basePath . $directory);
     }
     $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory));
     $files = array();
     while ($it->valid()) {
         if (!$it->isDot()) {
             $file = $it->key();
             if (preg_match('|Test\\.php$|', $file) && $file !== __FILE__ && !preg_match('|^All.+?\\.php$|', basename($file)) && ($excludes === null || !in_array($file, $excludes))) {
                 $files[] = $file;
             }
         }
         $it->next();
     }
     return $files;
 }
开发者ID:SebFav,项目名称:ApplicationInternet2,代码行数:36,代码来源:DebugkitGroupTestCase.php


示例18: getAccessibilityScope

 /**
  * Get Global Application CMS accessibility scope.
  *
  * @access public
  * @static
  * @uses   Core\Config()
  *
  * @return array
  */
 public static function getAccessibilityScope()
 {
     $scope = glob(Core\Config()->paths('mode') . 'controllers' . DIRECTORY_SEPARATOR . '*.php');
     $builtin_scope = array('CMS\\Controllers\\CMS');
     $builtin_actions = array();
     $accessibility_scope = array();
     foreach ($builtin_scope as $resource) {
         $builtin_actions = array_merge($builtin_actions, get_class_methods($resource));
     }
     $builtin_actions = array_filter($builtin_actions, function ($action) {
         return !in_array($action, array('create', 'show', 'edit', 'delete', 'export'), true);
     });
     foreach ($scope as $resource) {
         $resource = basename(str_replace('.php', '', $resource));
         if ($resource !== 'cms') {
             $controller_name = '\\CMS\\Controllers\\' . $resource;
             $controller_class = new \ReflectionClass($controller_name);
             if (!$controller_class->isInstantiable()) {
                 continue;
             }
             /* Create instance only if the controller class is instantiable */
             $controller_object = new $controller_name();
             if ($controller_object instanceof CMS\Controllers\CMS) {
                 $accessibility_scope[$resource] = array_diff(get_class_methods($controller_name), $builtin_actions);
                 array_push($accessibility_scope[$resource], 'index');
                 foreach ($accessibility_scope[$resource] as $key => $action_with_acl) {
                     if (in_array($action_with_acl, $controller_object->skipAclFor, true)) {
                         unset($accessibility_scope[$resource][$key]);
                     }
                 }
             }
         }
     }
     return $accessibility_scope;
 }
开发者ID:weareathlon,项目名称:silla.io,代码行数:44,代码来源:cmsusers.php


示例19: execute

 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     if (count($arguments['name'])) {
         $files = array();
         foreach ($arguments['name'] as $name) {
             $finder = sfFinder::type('file')->follow_link()->name(basename($name) . 'Test.php');
             $files = array_merge($files, $finder->in(sfConfig::get('sf_test_dir') . '/unit/' . dirname($name)));
         }
         if ($allFiles = $this->filterTestFiles($files, $arguments, $options)) {
             foreach ($allFiles as $file) {
                 include $file;
             }
         } else {
             $this->logSection('test', 'no tests found', null, 'ERROR');
         }
     } else {
         require_once __DIR__ . '/sfLimeHarness.class.php';
         $h = new sfLimeHarness(array('force_colors' => isset($options['color']) && $options['color'], 'verbose' => isset($options['trace']) && $options['trace'], 'test_path' => sfConfig::get('sf_cache_dir') . '/lime'));
         $h->addPlugins(array_map(array($this->configuration, 'getPluginConfiguration'), $this->configuration->getPlugins()));
         $h->base_dir = sfConfig::get('sf_test_dir') . '/unit';
         // filter and register unit tests
         $finder = sfFinder::type('file')->follow_link()->name('*Test.php');
         $h->register($this->filterTestFiles($finder->in($h->base_dir), $arguments, $options));
         $ret = $h->run() ? 0 : 1;
         if ($options['xml']) {
             file_put_contents($options['xml'], $h->to_xml());
         }
         return $ret;
     }
 }
开发者ID:Phennim,项目名称:symfony1,代码行数:33,代码来源:sfTestUnitTask.class.php


示例20: resize

 /**
  * {@inheritdoc}
  */
 public function resize($imagePath, array $size, $mode, $force = false)
 {
     $cacheKey = $this->getCacheKey($size, $mode);
     $filename = basename($imagePath);
     if (false === $force && $this->imageCache->contains($filename, $cacheKey)) {
         return $this->imageCache->getRelativePath($filename, $cacheKey);
     }
     $cacheAbsolutePath = $this->imageCache->getAbsolutePath($filename, $cacheKey);
     $imagine = new Imagine();
     $imagineImage = $imagine->open($this->filesystem->getRootDir() . $imagePath);
     $imageSize = array($imagineImage->getSize()->getWidth(), $imagineImage->getSize()->getHeight());
     $boxSize = $this->resizeHelper->getBoxSize($imageSize, $size);
     $box = $this->getBox($boxSize[0], $boxSize[1]);
     if (ImageResizerInterface::INSET === $mode) {
         $imageSizeInBox = $this->resizeHelper->getImageSizeInBox($imageSize, $boxSize);
         $imagineImage->resize($this->getBox($imageSizeInBox[0], $imageSizeInBox[1]));
         $palette = new RGB();
         $box = $imagine->create($box, $palette->color($this->color, $this->alpha));
         $imagineImage = $box->paste($imagineImage, $this->getPointInBox($imageSizeInBox, $boxSize));
     } else {
         $imagineImage = $imagineImage->thumbnail($box);
     }
     $this->filesystem->mkdir(dirname($cacheAbsolutePath));
     $imagineImage->save($cacheAbsolutePath, ImageOptionHelper::getOption($filename));
     return $this->imageCache->getRelativePath($filename, $cacheKey);
 }
开发者ID:silvestra,项目名称:media,代码行数:29,代码来源:GdImageResizer.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP baseurl函数代码示例发布时间:2022-05-24
下一篇:
PHP base_url函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap