コード例 #1
0
ファイル: media.php プロジェクト: jaanusnurmoja/redjoomla
 /**
  * Build imagelist
  *
  * @param string $listFolder The image directory to display
  *
  * @since 1.5
  */
 public function getList()
 {
     static $list;
     $mediaHelper = new redMediahelper();
     // Only process the list once per request
     if (is_array($list)) {
         return $list;
     }
     // Get current path from request
     $current = $this->getState('folder');
     // If undefined, set to empty
     if ($current == 'undefined') {
         $current = '';
     }
     $fdownload = JRequest::getInt('fdownload');
     if ($fdownload != 1) {
         // Initialize variables
         if (strlen($current) > 0) {
             $basePath = REDSHOP_FRONT_IMAGES_RELPATH . $current;
         } else {
             $basePath = REDSHOP_FRONT_IMAGES_RELPATH;
         }
         $mediaBase = str_replace(DS, '/', REDSHOP_FRONT_IMAGES_RELPATH);
     } else {
         if (strlen($current) > 0) {
             $basePath = PRODUCT_DOWNLOAD_ROOT . '/' . $current;
         } else {
             $basePath = PRODUCT_DOWNLOAD_ROOT;
         }
         $mediaBase = str_replace(DS, '/', PRODUCT_DOWNLOAD_ROOT . '/');
     }
     $images = array();
     $folders = array();
     $docs = array();
     // Get the list of files and folders from the given folder
     $fileList = JFolder::files($basePath);
     $folderList = JFolder::folders($basePath);
     // Iterate over the files if they exist
     if ($fileList !== false) {
         foreach ($fileList as $file) {
             if (file_exists($basePath . '/' . $file) && substr($file, 0, 1) != '.' && strtolower($file) !== 'index.html') {
                 $tmp = new JObject();
                 $tmp->name = $file;
                 $tmp->path = str_replace(DS, '/', JPath::clean($basePath . '/' . $file));
                 $tmp->path_relative = str_replace($mediaBase, '', $tmp->path);
                 $tmp->size = filesize($tmp->path);
                 $ext = strtolower(JFile::getExt($file));
                 switch ($ext) {
                     // Image
                     case 'jpg':
                     case 'png':
                     case 'gif':
                     case 'xcf':
                     case 'odg':
                     case 'bmp':
                     case 'jpeg':
                         $info = @getimagesize($tmp->path);
                         $tmp->width = @$info[0];
                         $tmp->height = @$info[1];
                         $tmp->type = @$info[2];
                         $tmp->mime = @$info['mime'];
                         $filesize = $mediaHelper->parseSize($tmp->size);
                         if ($info[0] > 60 || $info[1] > 60) {
                             $dimensions = $mediaHelper->imageResize($info[0], $info[1], 60);
                             $tmp->width_60 = $dimensions[0];
                             $tmp->height_60 = $dimensions[1];
                         } else {
                             $tmp->width_60 = $tmp->width;
                             $tmp->height_60 = $tmp->height;
                         }
                         if ($info[0] > 16 || $info[1] > 16) {
                             $dimensions = $mediaHelper->imageResize($info[0], $info[1], 16);
                             $tmp->width_16 = $dimensions[0];
                             $tmp->height_16 = $dimensions[1];
                         } else {
                             $tmp->width_16 = $tmp->width;
                             $tmp->height_16 = $tmp->height;
                         }
                         $images[] = $tmp;
                         break;
                         // Non-image document
                     // Non-image document
                     default:
                         $iconfile_32 = JPATH_ADMINISTRATOR . '/components/com_redshop/assets/images/mime-icon-32/' . $ext . '.png';
                         if (file_exists($iconfile_32)) {
                             $tmp->icon_32 = 'components/com_redshop/assets/images/mime-icon-32/' . $ext . '.png';
                         } else {
                             $tmp->icon_32 = 'components/com_redshop/assets/images/con_info.png';
                         }
                         $iconfile_16 = JPATH_ADMINISTRATOR . '/components/com_redshop/assets/images/mime-icon-16/' . $ext . '.png';
                         if (file_exists($iconfile_16)) {
                             $tmp->icon_16 = 'components/com_redshop/assets/images/mime-icon-16/' . $ext . '.png';
                         } else {
                             $tmp->icon_16 = 'components/com_redshop/assets/images/con_info.png';
                         }
                         $docs[] = $tmp;
                         break;
                 }
             }
         }
     }
     // Iterate over the folders if they exist
     if ($folderList !== false) {
         foreach ($folderList as $folder) {
             $tmp = new JObject();
             $tmp->name = basename($folder);
             $tmp->path = str_replace(DS, '/', JPath::clean($basePath . '/' . $folder));
             $tmp->path_relative = str_replace($mediaBase, '', $tmp->path);
             $count = $mediaHelper->countFiles($tmp->path);
             $tmp->files = $count[0];
             $tmp->folders = $count[1];
             $folders[] = $tmp;
         }
     }
     $list = array('folders' => $folders, 'docs' => $docs, 'images' => $images);
     return $list;
 }
コード例 #2
0
					<img src="<?php 
echo $thumb_path;
?>
" width="<?php 
echo $this->_tmp_img->width_60;
?>
"
					     height="<?php 
echo $this->_tmp_img->height_60;
?>
"
					     alt="<?php 
echo $this->_tmp_img->name;
?>
 - <?php 
echo redMediahelper::parseSize($this->_tmp_img->size);
?>
"
					     border="0"/>
				</div>
			</a>
		</div>
	</div>
	<div class="imginfoBorder">
		<a href="<?php 
echo JURI::root() . "components/com_redshop/assets/images/" . $this->_tmp_img->path_relative;
?>
"
		   class="preview"
		   onclick="window.parent.jimage_insert('<?php 
echo 'components/com_redshop/assets/images/' . $this->_tmp_img->path_relative;