예제 #1
0
파일: archive.php 프로젝트: rainsun/nForum
 /**
  * function getAttHtml parse the ubb code of attachment to html
  * the ubb code like [upload=\d][/upload]
  *
  * @param string $thumbnail
  * @return string html
  * @access public
  */
 public function getAttHtml($thumbnail = '')
 {
     $base = Configure::read('site.prefix');
     $list = $this->getAttList(false);
     $ret = array();
     foreach ($list as $v) {
         $v['size'] = nforum_size_format($v['size']);
         switch (strtolower(substr(strrchr($v['name'], "."), 1))) {
             case 'jpg':
             case 'jpeg':
             case 'png':
             case 'gif':
                 $ret[] = $this->_getImg($base . '/att' . $this->getAttLink($v['pos']), $v['size'], $thumbnail);
                 break;
             case 'swf':
                 $ret[] = $this->_getSwf($base . '/att' . $this->getAttLink($v['pos']), $v['name'], $v['size']);
                 break;
             case 'mp3':
             case 'wma':
                 $ret[] = $this->_getMp3($base . '/att' . $this->getAttLink($v['pos']), $v['name'], $v['size']);
                 break;
             default:
                 $ret[] = $this->_getCommon($base . '/att' . $this->getAttLink($v['pos']), $v['name'], $v['size']);
         }
     }
     return $ret;
 }
예제 #2
0
파일: wrapper.php 프로젝트: tilitala/nForum
 public function attachment($archive)
 {
     $domain = Configure::read('site.domain');
     $base = Configure::read('site.prefix');
     $abase = Configure::read('plugins.api.base');
     if (!is_array($archive)) {
         $list = $archive->getAttList(false);
         $url_prefix = $domain . $base . $abase . '/attachment';
     } else {
         $list = $archive;
         $url_prefix = '';
     }
     $ret = array();
     $size = 0;
     $num = count($list);
     foreach ($list as $v) {
         $size += intval($v['size']);
         $v['size'] = nforum_size_format($v['size']);
         $tmp = array('name' => $v['name'], 'url' => '' === $url_prefix ? '' : $url_prefix . $archive->getAttLink($v['pos']), 'size' => $v['size'], 'thumbnail_small' => '', 'thumbnail_middle' => '');
         if ('' !== $tmp['url'] && in_array(strtolower(substr(strrchr($v['name'], "."), 1)), array('jpg', 'jpeg', 'png', 'gif'))) {
             $tmp['thumbnail_small'] = $tmp['url'] . '/small';
             $tmp['thumbnail_middle'] = $tmp['url'] . '/middle';
         }
         $ret[] = $tmp;
     }
     $upload = Configure::read("article");
     return array('file' => $ret, 'remain_space' => nforum_size_format($upload['att_size'] - $size), 'remain_count' => $upload['att_num'] - $num);
 }