public function testRenderDownloadLinkContentByRelationModelAndFileModel() { Yii::app()->user->userModel = User::getByUsername('super'); $model = new ModelWithAttachmentTestItem(); $fileModel = ZurmoTestHelper::createFileModel(); $link = FileModelDisplayUtil::renderDownloadLinkContentByRelationModelAndFileModel($model, $fileModel); $this->assertNotNull($link); }
public static function renderFileDataDetailsWithDownloadLinksContent($model, $filesRelationName, $showHeaderLabel = false) { $content = null; if ($model->{$filesRelationName}->count() > 0) { $content .= '<ul class="attachments">'; if ($showHeaderLabel) { $content .= '<li><strong>' . Zurmo::t('ZurmoModule', 'Attachments') . '</strong></li>'; } foreach ($model->{$filesRelationName} as $fileModel) { $content .= '<li><span class="icon-attachment"></span>' . FileModelDisplayUtil::renderDownloadLinkContentByRelationModelAndFileModel($model, $fileModel) . '</li>'; } $content .= '</ul>'; } return $content; }
protected function renderControlNonEditable() { assert('$this->model instanceof Item || $this->model->getModel() instanceof Item'); $content = null; if ($this->model->files->count() > 0) { $content .= '<ul class="attachments">'; foreach ($this->model->files as $fileModel) { $content .= '<li><span class="icon-attachment"></span>'; $content .= FileModelDisplayUtil::renderDownloadLinkContentByRelationModelAndFileModel($this->model, $fileModel); $content .= ' ' . FileModelDisplayUtil::convertSizeToHumanReadableAndGet((int) $fileModel->size); $content .= '</li>'; } $content .= '</ul>'; } return $content; }