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


PHP DataUtil::formatNumber方法代码示例

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


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

示例1: maxSize

 /**
  * Get allowed filesize
  */
 public static function maxSize()
 {
     $maxSize = ModUtil::getVar('MUBoard', 'allowedSizeOfImages');
     $dom = ZLanguage::getModuleDomain('MUBoard');
     if ($maxSize > 0) {
         $maxSizeKB = $maxSize / 1024;
         if ($maxSizeKB < 1024) {
             $maxSizeKB = DataUtil::formatNumber($maxSizeKB);
             $allowedSize = $maxSizeKB . ' KB';
             return $allowedSize;
         }
         $maxSizeMB = $maxSizeKB / 1024;
         $maxSizeMB = DataUtil::formatNumber($maxSizeMB);
         $allowedSize = $maxSizeMB . ' MB';
         return $allowedSize;
     } else {
         $allowedSize = __('No limit');
     }
     return $allowedSize;
 }
开发者ID:rmaiwald,项目名称:MUBoard,代码行数:23,代码来源:Controller.php

示例2: smarty_modifier_formatNumber

/**
 * Format number.
 *
 * Example:
 *   {$MyVar|formatnumber}
 *
 * @param string $string         The contents to transform.
 * @param mixed  $decimal_points Desc : null=default locale, false=precision, int=precision.
 *
 * @return string The modified output.
 */
function smarty_modifier_formatNumber($string, $decimal_points = null)
{
    return DataUtil::formatNumber($string, $decimal_points);
}
开发者ID:Silwereth,项目名称:core,代码行数:15,代码来源:modifier.formatnumber.php

示例3: render

 /**
  * Render event handler.
  *
  * @param Zikula_Form_View $view Reference to Zikula_Form_View object.
  *
  * @return string The rendered output
  */
 public function render(Zikula_Form_View $view)
 {
     $this->text = DataUtil::formatNumber($this->text, $this->precision);
     return Zikula_Form_Plugin_TextInput::render($view);
 }
开发者ID:projectesIF,项目名称:Sirius,代码行数:12,代码来源:FloatInput.php

示例4: validateFileUpload

 /**
  * Check if an upload file meets all validation criteria.
  *
  * @param string $objectType Currently treated entity type.
  * @param array $file Reference to data of uploaded file.
  * @param string $fieldName  Name of upload field.
  *
  * @return boolean true if file is valid else false
  */
 protected function validateFileUpload($objectType, $file, $fieldName)
 {
     $dom = ZLanguage::getModuleDomain('MUVideo');
     $serviceManager = ServiceUtil::getManager();
     // check if a file has been uploaded properly without errors
     if (!is_array($file) || is_array($file) && $file['error'] != '0') {
         if (is_array($file)) {
             return $this->handleError($file);
         }
         return LogUtil::registerError(__('Error! No file found.', $dom));
     }
     // extract file extension
     $fileName = $file['name'];
     $fileNameParts = explode('.', $fileName);
     $extension = strtolower($fileNameParts[count($fileNameParts) - 1]);
     $extension = str_replace('jpeg', 'jpg', $extension);
     // validate extension
     $isValidExtension = $this->isAllowedFileExtension($objectType, $fieldName, $extension);
     if ($isValidExtension === false) {
         return LogUtil::registerError(__('Error! This file type is not allowed. Please choose another file format.', $dom));
     }
     // validate file size
     $maxSize = $this->allowedFileSizes[$objectType][$fieldName];
     if ($maxSize > 0) {
         $fileSize = filesize($file['tmp_name']);
         if ($fileSize > $maxSize) {
             $maxSizeKB = $maxSize / 1024;
             if ($maxSizeKB < 1024) {
                 $maxSizeKB = DataUtil::formatNumber($maxSizeKB);
                 return LogUtil::registerError(__f('Error! Your file is too big. Please keep it smaller than %s kilobytes.', array($maxSizeKB), $dom));
             }
             $maxSizeMB = $maxSizeKB / 1024;
             $maxSizeMB = DataUtil::formatNumber($maxSizeMB);
             return LogUtil::registerError(__f('Error! Your file is too big. Please keep it smaller than %s megabytes.', array($maxSizeMB), $dom));
         }
     }
     // validate image file
     $isImage = in_array($extension, $this->imageFileTypes);
     if ($isImage) {
         $imgInfo = getimagesize($file['tmp_name']);
         if (!is_array($imgInfo) || !$imgInfo[0] || !$imgInfo[1]) {
             return LogUtil::registerError(__('Error! This file type seems not to be a valid image.', $dom));
         }
     }
     return true;
 }
开发者ID:robbrandt,项目名称:MUVideo,代码行数:55,代码来源:UploadHandler.php

示例5: formatValue

 /**
  * Format the value to specific format.
  *
  * @param Zikula_Form_View $view  Reference to Zikula_Form_View object.
  * @param string           $value The value to format.
  *
  * @return string Formatted value.
  */
 function formatValue(Zikula_Form_View $view, $value)
 {
     return DataUtil::formatNumber($value, $this->precision);
 }
开发者ID:planetenkiller,项目名称:core,代码行数:12,代码来源:FloatInput.php


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