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


PHP StringHelper::toUpperCase方法代码示例

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


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

示例1: _getIconPath

 /**
  * Get icon path for a given extension
  *
  * @param $ext
  *
  * @return string
  */
 private function _getIconPath($ext)
 {
     $sourceIconPath = craft()->path->getResourcesPath() . 'images/file.svg';
     $extLength = mb_strlen($ext);
     if ($extLength > 5) {
         // Too long; just use the blank file icon
         return $sourceIconPath;
     }
     // See if the icon already exists
     $iconPath = craft()->path->getAssetsIconsPath() . StringHelper::toLowerCase($ext) . '.svg';
     if (IOHelper::fileExists($iconPath)) {
         return $iconPath;
     }
     // Create a new one
     $svgContents = IOHelper::getFileContents($sourceIconPath);
     $textSize = $extLength <= 3 ? '26' : ($extLength == 4 ? '22' : '18');
     $textNode = '<text x="50" y="73" text-anchor="middle" font-family="sans-serif" fill="#8F98A3" ' . 'font-size="' . $textSize . '">' . StringHelper::toUpperCase($ext) . '</text>';
     $svgContents = str_replace('<!-- EXT -->', $textNode, $svgContents);
     IOHelper::writeToFile($iconPath, $svgContents);
     return $iconPath;
 }
开发者ID:JamesGibsonUK,项目名称:gibsonlearn,代码行数:28,代码来源:ResourcesService.php

示例2: _getIconPath

 /**
  * Get icon path for an extension and size
  *
  * @param $ext
  * @param $size
  *
  * @return string
  */
 private function _getIconPath($ext, $size)
 {
     if (mb_strlen($ext) > 4) {
         $ext = '';
     }
     $extAlias = array('docx' => 'doc', 'xlsx' => 'xls', 'pptx' => 'ppt', 'jpeg' => 'jpg', 'html' => 'htm');
     if (isset($extAlias[$ext])) {
         $ext = $extAlias[$ext];
     }
     $sizeFolder = craft()->path->getAssetsIconsPath() . $size;
     // See if we have the icon already
     $iconLocation = $sizeFolder . '/' . $ext . '.png';
     if (IOHelper::fileExists($iconLocation)) {
         return $iconLocation;
     }
     // We are going to need that folder to exist.
     IOHelper::ensureFolderExists($sizeFolder);
     // Determine the closest source size
     $sourceSizes = array(array('size' => 40, 'extSize' => 7, 'extY' => 32), array('size' => 350, 'extSize' => 60, 'extY' => 280));
     foreach ($sourceSizes as $sourceSize) {
         if ($sourceSize['size'] >= $size) {
             break;
         }
     }
     $sourceFolder = craft()->path->getAssetsIconsPath() . $sourceSize['size'];
     // Do we have a source icon that we can resize?
     $sourceIconLocation = $sourceFolder . '/' . $ext . '.png';
     if (!IOHelper::fileExists($sourceIconLocation)) {
         $sourceFile = craft()->path->getAppPath() . 'etc/assets/fileicons/' . $sourceSize['size'] . '.png';
         $image = imagecreatefrompng($sourceFile);
         // Text placement.
         if ($ext) {
             $color = imagecolorallocate($image, 153, 153, 153);
             $text = StringHelper::toUpperCase($ext);
             $font = craft()->path->getAppPath() . 'etc/assets/helveticaneue-webfont.ttf';
             // Get the bounding box so we can calculate the position
             $box = imagettfbbox($sourceSize['extSize'], 0, $font, $text);
             $width = $box[4] - $box[0];
             // place the text in the center-bottom-ish of the image
             imagettftext($image, $sourceSize['extSize'], 0, ceil(($sourceSize['size'] - $width) / 2), $sourceSize['extY'], $color, $font, $text);
         }
         // Preserve transparency
         imagealphablending($image, false);
         $color = imagecolorallocatealpha($image, 0, 0, 0, 127);
         imagefill($image, 0, 0, $color);
         imagesavealpha($image, true);
         // Make sure we have a folder to save to and save it.
         IOHelper::ensureFolderExists($sourceFolder);
         imagepng($image, $sourceIconLocation);
     }
     if ($size != $sourceSize['size']) {
         // Resize the source icon to fit this size.
         craft()->images->loadImage($sourceIconLocation)->scaleAndCrop($size, $size)->saveAs($iconLocation);
     }
     return $iconLocation;
 }
开发者ID:scisahaha,项目名称:generator-craft,代码行数:64,代码来源:ResourcesService.php

示例3: _processFrameworkData

 /**
  * @param $localeId
  *
  * @return array
  */
 private function _processFrameworkData($localeId)
 {
     $wideMonthKeys = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
     $abbreviatedMonthKeys = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
     $wideWeekdayNameKeys = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
     $abbreviatedWeekdayNameKeys = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
     $formattedFrameworkData = array();
     $locale = \CLocale::getInstance($localeId);
     $formattedFrameworkData = array_merge($formattedFrameworkData, array_combine($wideMonthKeys, $locale->getMonthNames()));
     $formattedFrameworkData = array_merge($formattedFrameworkData, array_combine($abbreviatedMonthKeys, $locale->getMonthNames('abbreviated')));
     $formattedFrameworkData = array_merge($formattedFrameworkData, array_combine($wideWeekdayNameKeys, $locale->getWeekDayNames()));
     $formattedFrameworkData = array_merge($formattedFrameworkData, array_combine($abbreviatedWeekdayNameKeys, $locale->getWeekDayNames('abbreviated')));
     // Because sometimes Twig (ultimately PHP) will return 'pm' or 'am' and sometimes it will return 'PM' or 'AM'
     // and array indexes are case sensitive.
     $amName = $locale->getAMName();
     $pmName = $locale->getPMName();
     $formattedFrameworkData['AM'] = StringHelper::toUpperCase($amName);
     $formattedFrameworkData['am'] = StringHelper::toLowerCase($amName);
     $formattedFrameworkData['PM'] = StringHelper::toUpperCase($pmName);
     $formattedFrameworkData['pm'] = StringHelper::toLowerCase($pmName);
     return $formattedFrameworkData;
 }
开发者ID:mrpaulphan,项目名称:mrpaulphan,代码行数:27,代码来源:PhpMessageSource.php

示例4: _getIconPath

 /**
  * Get icon path for an extension and size
  *
  * @param $ext
  * @param $size
  *
  * @return string
  */
 private function _getIconPath($ext, $size)
 {
     if (mb_strlen($ext) > 4) {
         $ext = '';
     }
     $extAlias = array('docx' => 'doc', 'xlsx' => 'xls', 'pptx' => 'ppt', 'jpeg' => 'jpg', 'html' => 'htm');
     if (isset($extAlias[$ext])) {
         $ext = $extAlias[$ext];
     }
     $sizeFolder = craft()->path->getAssetsIconsPath() . $size;
     // See if we have the icon already
     $iconLocation = $sizeFolder . '/' . $ext . '.png';
     if (IOHelper::fileExists($iconLocation)) {
         return $iconLocation;
     }
     // We are going to need that folder to exist.
     IOHelper::ensureFolderExists($sizeFolder);
     // Determine the closest source size
     $sourceSizes = array(array('size' => 40, 'extSize' => 7, 'extY' => 25), array('size' => 350, 'extSize' => 60, 'extY' => 220));
     foreach ($sourceSizes as $sourceSize) {
         if ($sourceSize['size'] >= $size) {
             break;
         }
     }
     $sourceFolder = craft()->path->getAssetsIconsPath() . $sourceSize['size'];
     // Do we have a source icon that we can resize?
     $sourceIconLocation = $sourceFolder . '/' . $ext . '.png';
     if (!IOHelper::fileExists($sourceIconLocation)) {
         $sourceFile = craft()->path->getAppPath() . 'etc/assets/fileicons/' . $sourceSize['size'] . '.png';
         $image = craft()->images->loadImage($sourceFile);
         // Text placement.
         if ($ext) {
             $font = craft()->path->getAppPath() . 'etc/assets/helveticaneue-webfont.ttf';
             $image->setFontProperties($font, $sourceSize['extSize'], "#999");
             $text = StringHelper::toUpperCase($ext);
             $box = $image->getTextBox($text);
             $width = $box->getWidth();
             // place the text in the center-bottom-ish of the image
             $x = ceil(($sourceSize['size'] - $width) / 2);
             $y = $sourceSize['extY'];
             $image->writeText($text, $x, $y);
         }
         // Make sure we have a folder to save to and save it.
         IOHelper::ensureFolderExists($sourceFolder);
         $image->saveAs($sourceIconLocation);
     }
     if ($size != $sourceSize['size']) {
         // Resize the source icon to fit this size.
         craft()->images->loadImage($sourceIconLocation, $size, $size)->scaleAndCrop($size, $size)->saveAs($iconLocation);
     }
     return $iconLocation;
 }
开发者ID:nathanedwards,项目名称:cowfields.craft,代码行数:60,代码来源:ResourcesService.php


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