/** * Render */ public function render() { $this->prepareOptions(); if (NULL == $this->options->value) { if ($this->options->allowed_types) { $this->notice(t('Следующие типы файлов разрешены к загрузке: <b>%s</b>.', $this->options->allowed_types->toString('</b>, <b>'))); } if ($this->options->maxsize) { $this->notice(t('Максимальный размер файла <b>%s</b>.', File::fromBytes(File::toBytes($this->options->maxsize), NULL, 2))); } if ($this->notices->count()) { $this->options->description .= '<ul class="file-notice"><li>' . $this->notices->toString('</li><li>') . '</li></ul>'; } } $tpl = new Template($this->template); $tpl->assign($this->options); $this->code = $tpl->render(); $this->decorate(); return $this->code; }
/** * Check file size * @param string $size * @param string $maxsize * @return */ public function checkMaxSize($size, $maxsize) { $maxsize = File::toBytes($maxsize); if ($size > $maxsize) { $this->error(t('Максимально разрешенный размер загружаемого файла составляет <b>%s</b>. Вы же пытаетесь загрузкить файл размером <b>%s</b>.', File::fromBytes($maxsize, 'auto', 2), File::fromBytes($size, 'auto', 2))); return FALSE; } return TRUE; }