public function init()
 {
     if (empty($this->locale)) {
         $this->locale = Yii::app()->language;
     }
     $this->setLocale($this->locale);
     parent::init();
 }
Пример #2
0
 public function __call($name, $parameters)
 {
     if (method_exists($this, 'format' . $name)) {
         return call_user_func_array(array($this, 'format' . $name), $parameters);
     } else {
         if (function_exists($name)) {
             return call_user_func_array($name, $parameters);
         }
     }
     return parent::__call($name, $parameters);
 }
Пример #3
0
 public function formatDatetime($value)
 {
     if (!is_numeric($value)) {
         $value = strtotime($value);
     }
     if ($value < 1) {
         return '';
     } else {
         return parent::formatDateTime($value);
     }
 }
Пример #4
0
 /**
  * Calls the run formatter method when its shortcut is invoked.
  * @param string $name the method name.
  * @param array $parameters method parameters.
  * @return mixed the method return value.
  */
 public function __call($name, $parameters)
 {
     $args = $parameters;
     array_unshift($args, $name);
     if ($this->isFormatter($name)) {
         return call_user_func_array(array($this, 'runFormatter'), $args);
     } else {
         if (is_callable($name)) {
             return call_user_func_array(array($this, 'formatInline'), $args);
         } else {
             return parent::__call($name, $parameters);
         }
     }
 }
Пример #5
0
 /**
  * This test is to check whether messages get actually translated to non-english
  *
  * @dataProvider languages
  * @param $language
  */
 public function testSizeFormatTranslation($language)
 {
     $formatter = new CFormatter();
     Yii::app()->language = $language;
     $this->assertNotEquals('1 byte', $formatter->formatSize(1, true));
     $this->assertNotEquals('1 kilobyte', $formatter->formatSize(1024, true));
     $this->assertNotEquals('1 megabyte', $formatter->formatSize(1024 * 1024, true));
     $this->assertNotEquals('1 gigabyte', $formatter->formatSize(1024 * 1024 * 1024, true));
     $this->assertNotEquals('1 terabyte', $formatter->formatSize(1024 * 1024 * 1024 * 1024, true));
     // test sizeformat works with non integers
     $formatter->sizeFormat['decimals'] = 4;
     $this->assertNotEquals('1.5137 kilobytes', $formatter->formatSize(1550, true));
 }
Пример #6
0
 public function getFormattedBytes()
 {
     $formatter = new CFormatter();
     return $formatter->formatSize(filesize("upload/" . $this->filename_local));
 }
Пример #7
0
	<b><?php 
echo CHtml::encode($data->getAttributeLabel('email'));
?>
:</b>
	<?php 
echo CFormatter::formatEmail($data->email);
?>
	<br />

	<b><?php 
echo CHtml::encode($data->getAttributeLabel('webpage'));
?>
:</b>
	<?php 
echo CFormatter::formatUrl($data->webpage);
?>
	<br />

	<b><?php 
echo CHtml::encode($data->getAttributeLabel('country_id'));
?>
:</b>
	<?php 
echo CHtml::encode($data->country->name);
?>
	<br />

	<b><?php 
echo CHtml::encode($data->getAttributeLabel('eyecolor_code'));
?>
Пример #8
0
     if (is_string($value)) {
         $date = new DateTime($value);
         return $date->format('d/m/Y');
     }
     return parent::formatDate($value);
 }
 public function formatTime($value)
 {
     if ($value == '0000-00-00' || $value == '0000-00-00 00:00:00' || is_null($value)) {
         return '';
     }
Пример #9
0
 /**
  * @dataProvider providerFormatNtext
  * @param string $value
  * @param string $paragraphs
  * @param string $removeEmptyParagraphs
  * @param string $assertion
  */
 public function testFormatNtext($value, $paragraphs, $removeEmptyParagraphs, $assertion)
 {
     $formatter = new CFormatter();
     $this->assertEquals($assertion, $formatter->formatNtext($value, $paragraphs, $removeEmptyParagraphs));
 }
Пример #10
0
$form_target = Yii::App()->createUrl("file/upload", array("id" => $data->subject_id));
function GetMaxUploadFileSize()
{
    $val = trim(ini_get("post_max_size"));
    $last = strtolower($val[strlen($val) - 1]);
    switch ($last) {
        case 'g':
            $val *= 1024;
        case 'm':
            $val *= 1024;
        case 'k':
            $val *= 1024;
    }
    return $val;
}
$formatter = new CFormatter();
$UploadLimit = $formatter->formatSize(GetMaxUploadFileSize());
?>

<div class="container">
	<div class="row">
		<div class="col-xs-12">
			<h2><?php 
print $data->name;
?>
</h2>
		</div>
	</div>

	<?php 
if (Yii::app()->user->getId()) {