本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}