Exemple #1
0
 protected function getFileDescription(BlorgFile $file)
 {
     if ($file->description === null) {
         $description = sprintf('%s - %s', $file->filename, SwatString::byteFormat($file->filesize));
     } else {
         $description = sprintf('%s (%s) - %s', $file->description, $file->filename, SwatString::byteFormat($file->filesize));
     }
     return $description;
 }
Exemple #2
0
 protected function displayFiles(BlorgPost $post)
 {
     if ($this->getMode('files') > SiteView::MODE_NONE) {
         $files = $post->getVisibleFiles();
         if (count($files) > 0) {
             $link = $this->getLink('files');
             echo '<ul class="attachments">';
             foreach ($files as $file) {
                 $li_tag = new SwatHtmlTag('li');
                 $li_tag->class = 'type-' . $file->mime_type;
                 $li_tag->open();
                 if ($link === false) {
                     $span_tag = new SwatHtmlTag('span');
                     $span_tag->setContent($file->getDescription());
                     $span_tag->display();
                 } else {
                     $a_tag = new SwatHtmlTag('a');
                     $a_tag->href = $file->getRelativeUri($this->app->config->blorg->path, $this->path_prefix);
                     $a_tag->setContent($file->getDescription());
                     $a_tag->display();
                 }
                 echo ' ' . SwatString::byteFormat($file->filesize);
                 $li_tag->close();
             }
             echo '</ul>';
         }
     }
 }