PHP 主题是Drupal附件表

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP 主题是Drupal附件表相关的知识,希望对你有一定的参考价值。

<?php 
/**
 * Themed attachments table
 */
  $header = array(t('File name'), t('Size'));
  $rows = array();
  foreach ($files as $file) {
    if ($file->list) {
      $type = explode('/', $file->filemime);
      // Quick fix. Should use some kind of make_safe_for_css() function.
      $type = str_replace('.', '-'. $type[1]);
      $href = check_url(($file->fid ? file_create_url($file->filepath) : url(file_create_filename($file->filename, file_create_path()))));
      /* To do:
      if (!empty($file->description)) {
        $text = check_plain($file->description) . '<br /><span class="filename">'.$file->filename.'</span>';
      }
      else {
        $text = check_plain($file->filename);
      }
      */
       $text = check_plain($file->description ? $file->description : $file->filename);
      // Because the drupal format_size function doesn't round far enough to be smooth.
      $size = $file->filesize;
      $suffix = t('bytes'); 
      if ($size >= 1024) { 
        $size = round($size / 1024, 0);
        $suffix = t('KB'); 
      } 
      if ($size >= 1024) { 
        $size = round($size / 1024, 0);
        $suffix = t('MB'); 
      } 

      $size = array('data' => t('%size %suffix', array('%size' => $size, '%suffix' => $suffix)), 'class' => 'size');
      
      if ($type == 'jpeg' ) {
        $text = array('data' => l($text, $href, array('title' => 'Right click to download', 'class' => 'thickbox'), $query = NULL, $fragment = NULL, $absolute = FALSE, $html = TRUE), 'class' => $type);
      }
      else {
        $text = array('data' => l($text, $href, array('title' => 'Right click to download'), $query = NULL, $fragment = NULL, $absolute = FALSE, $html = TRUE), 'class' => $type);
      }
      $rows[] = array($text, $size);
    }
  }

  if (count($rows)) {
    print '<div class="attachments">'. theme('table', $header, $rows, array('class' => 'attachments'), 'Downloadable files') .'</div>';
  }

以上是关于PHP 主题是Drupal附件表的主要内容,如果未能解决你的问题,请参考以下文章

上传附件表的Drupal自定义样式

PHP Drupal - 主题表与columstriping

PHP Drupal - 取消设置(不包括)所有核心样式表 - 主题变量覆盖。

Drupal-取消设置(不包括)所有核心样式表-主题变量覆盖。

CSS 上传附件表的Drupal自定义样式

在drupal 7中,由于多个附件,将表单添加到视图会产生多个相同的表单,如何只保留一个?