Changeset 4132

Show
Ignore:
Timestamp:
Tue Dec 6 21:56:42 2005
Author:
paul
Message:

Applied patch given in ticket:1534. Got rid of the question marks that show in the display when it cant figure out the size of the image, cause they make it look like there is a big problem when there isnt. Removed commented-out code.

Files:

Legend:

Unmodified
Added
Removed
Modified
  • trunk/campsite/implementation/management/javascript/xinha/plugins/ImageManager/images.php

    r3279 r4132  
    1   <?php  
    2   /**  
    3    * Show a list of images in a long horizontal table.  
    4    * @author $Author: paul $  
    5    * @version $Id: images.php,v 1.1 2005/05/02 17:39:57 paul Exp $  
    6    * @package ImageManager  
    7    */  
    8    
    9   require_once('config.inc.php');  
    10   require_once('Classes/ImageManager.php');  
    11    
    12   //default path is /  
    13   $relative = '/';  
    14   $manager = new ImageManager($IMConfig);  
    15    
    16   //process any file uploads  
    17   //$manager->processUploads();  
    18    
    19   //$manager->deleteFiles();  
    20    
    21   $refreshDir = false;  
    22   //process any directory functions  
    23   //if ($manager->deleteDirs() || $manager->processNewDir()) {  
    24   //  $refreshDir = true;  
    25   //}  
    26    
    27   // Check for any sub-directory request.  
    28   // Check that the requested sub-directory exists and valid.  
    29   if (isset($_REQUEST['dir'])) {  
    30       $path = rawurldecode($_REQUEST['dir']);  
    31       if ($manager->validRelativePath($path)) {  
    32           $relative = $path;  
    33       }  
    34   }  
    35    
    36   $manager = new ImageManager($IMConfig);  
    37    
    38   // Get the list of files and directories  
    39   $list = $manager->getFiles($relative, $_REQUEST['article_id']);  
    40    
    41    
    42   /* ================= OUTPUT/DRAW FUNCTIONS ======================= */  
    43    
    44   /**  
    45    * Draw the files in an table.  
    46    */  
    47   function drawFiles($list, &$manager)  
    48   {  
    49       global $relative;  
    50    
    51       foreach($list as $entry => $file)  
    52       { ?>  
    53           <td>  
    54               <table width="100" cellpadding="0" cellspacing="0">  
    55               <tr>  
    56                   <td class="block" onclick="selectImage('<?php echo $file['image_object']->getImageUrl(); //$file['relative'];?>', '<?php echo $file['alt']; ?>', <?php echo $file['image'][0];?>, <?php echo $file['image'][1]; ?>);">  
    57           <a href="javascript:;" onclick="selectImage('<?php echo $file['image_object']->getImageUrl(); //$file['relative'];?>', '<?php echo $file['alt']; ?>', <?php echo $file['image'][0];?>, <?php echo $file['image'][1]; ?>);" title="<?php echo $file['alt']; ?>"><img src="<?php echo $file['image_object']->getThumbnailUrl();//$manager->getThumbnail($file['relative']); ?>" alt="<?php echo $file['alt']; ?>"/></a>  
    58           </td></tr><tr><td class="edit">  
    59               <!--<a href="images.php?dir=<?php //echo $relative; ?>&delf=<?php //echo rawurlencode($file['relative']);?>" title="Trash" onclick="return confirmDeleteFile('<?php //echo $entry; ?>');"><img src="img/edit_trash.gif" height="15" width="15" alt="Trash"/></a><a href="javascript:;" title="Edit" onclick="editImage('<?php //echo rawurlencode($file['relative']);?>');"><img src="img/edit_pencil.gif" height="15" width="15" alt="Edit"/></a>-->  
    60           <?php  
    61           if ($file['image']) {  
    62               echo $file['image'][0].'x'.$file['image'][1];  
    63           }  
    64           else {  
    65               echo "???"; //$entry;  
    66           }  
    67           ?>  
    68           </td></tr></table></td>  
    69         <?php  
    70       }//foreach  
    71   }//function drawFiles  
    72    
    73    
    74   /**  
    75    * Draw the directory.  
    76    */  
    77   function drawDirs($list, &$manager)  
    78   {  
    79       global $relative;  
    80    
    81       foreach($list as $path => $dir)  
    82       { ?>  
    83           <td><table width="100" cellpadding="0" cellspacing="0"><tr><td class="block">  
    84           <a href="images.php?dir=<?php echo rawurlencode($path); ?>" onclick="updateDir('<?php echo $path; ?>')" title="<?php echo $dir['entry']; ?>"><img src="img/folder.gif" height="80" width="80" alt="<?php echo $dir['entry']; ?>" /></a>  
    85           </td></tr><tr>  
    86           <td class="edit">  
    87               <a href="images.php?dir=<?php echo $relative; ?>&deld=<?php echo rawurlencode($path); ?>" title="Trash" onclick="return confirmDeleteDir('<?php echo $dir['entry']; ?>', <?php echo $dir['count']; ?>);"><img src="img/edit_trash.gif" height="15" width="15" alt="Trash"/></a>  
    88               <?php echo $dir['entry']; ?>  
    89           </td>  
    90           </tr></table></td>  
    91         <?php  
    92       } //foreach  
    93   }//function drawDirs  
    94    
    95    
    96   /**  
    97    * No directories and no files.  
    98    */  
    99   function drawNoResults()  
    100   {  
    101   ?>  
    102   <table width="100%">  
    103     <tr>  
    104       <td class="noResult"><script>document.write(i18n("No Images Found"));</script></td>  
    105     </tr>  
    106   </table>  
    107   <?php     
    108   }  
    109    
    110   /**  
    111    * No directories and no files.  
    112    */  
    113   function drawErrorBase(&$manager)  
    114   {  
    115   ?>  
    116   <table width="100%">  
    117     <tr>  
    118       <td class="error">Invalid base directory: <?php echo $manager->config['base_dir']; ?></td>  
    119     </tr>  
    120   </table>  
    121   <?php     
    122   }  
    123    
    124   ?>  
    125   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    126    
    127   <html>  
    128   <head>  
    129       <title>Image List</title>  
    130     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
    131       <link href="assets/imagelist.css" rel="stylesheet" type="text/css" />  
    132   <script type="text/javascript" src="assets/dialog.js"></script>  
    133   <script type="text/javascript">  
    134   /*<![CDATA[*/  
    135    
    136       if(window.top)  
    137           I18N = window.top.I18N;  
    138    
    139       function hideMessage()  
    140       {  
    141           var topDoc = window.top.document;  
    142           var messages = topDoc.getElementById('messages');  
    143           if(messages)  
    144               messages.style.display = "none";  
    145       }  
    146    
    147       init = function()  
    148       {  
    149           hideMessage();  
    150           var topDoc = window.top.document;  
    151    
    152   <?php  
    153       //we need to refesh the drop directory list  
    154       //save the current dir, delete all select options  
    155       //add the new list, re-select the saved dir.  
    156       if($refreshDir)  
    157       {  
    158           $dirs = $manager->getDirs();  
    159   ?>  
    160           var selection = topDoc.getElementById('dirPath');  
    161           var currentDir = selection.options[selection.selectedIndex].text;  
    162    
    163           while(selection.length > 0)  
    164           {   selection.remove(0); }  
    165            
    166           selection.options[selection.length] = new Option("/","<?php echo rawurlencode('/'); ?>");     
    167           <?php foreach($dirs as $relative=>$fullpath) { ?>  
    168           selection.options[selection.length] = new Option("<?php echo $relative; ?>","<?php echo rawurlencode($relative); ?>");       
    169           <?php } ?>  
    170            
    171           for(var i = 0; i < selection.length; i++)  
    172           {  
    173               var thisDir = selection.options[i].text;  
    174               if(thisDir == currentDir)  
    175               {  
    176                   selection.selectedIndex = i;  
    177                   break;  
    178               }  
    179           }         
    180   <?php } ?>  
    181       }     
    182    
    183       function editImage(image)  
    184       {  
    185           var url = "editor.php?img="+image;  
    186           Dialog(url, function(param)  
    187           {  
    188               if (!param) // user must have pressed Cancel  
    189                   return false;  
    190               else  
    191               {  
    192                   return true;  
    193               }  
    194           }, null);         
    195       }  
    196    
    197   /*]]>*/  
    198   </script>  
    199   <script type="text/javascript" src="assets/images.js"></script>  
    200   </head>  
    201    
    202   <body>  
    203   <?php if ($manager->isValidBase() == false) { drawErrorBase($manager); }  
    204       elseif(count($list[0]) > 0 || count($list[1]) > 0) { ?>  
    205   <table>  
    206       <tr>  
    207       <?php drawDirs($list[0], $manager); ?>  
    208       <?php drawFiles($list[1], $manager); ?>  
    209       </tr>  
    210   </table>  
    211   <?php } else { drawNoResults(); } ?>  
    212   </body>  
    213   </html>  
      1 <?php  
      2 /**  
      3  * Show a list of images in a long horizontal table.  
      4  * @author $Author$  
      5  * @version $Id$  
      6  * @package ImageManager  
      7  */  
      8  
      9 require_once('config.inc.php');  
      10 require_once('Classes/ImageManager.php');  
      11  
      12 //default path is /  
      13 $relative = '/';  
      14 $manager =& new ImageManager($IMConfig);  
      15  
      16 $refreshDir = false;  
      17  
      18 // Check for any sub-directory request.  
      19 // Check that the requested sub-directory exists and valid.  
      20 if (isset($_REQUEST['dir'])) {  
      21     $path = rawurldecode($_REQUEST['dir']);  
      22     if ($manager->validRelativePath($path)) {  
      23         $relative = $path;  
      24     }  
      25 }  
      26  
      27 $manager = new ImageManager($IMConfig);  
      28  
      29 // Get the list of files and directories  
      30 $list = $manager->getFiles($relative, $_REQUEST['article_id']);  
      31  
      32  
      33 /* ================= OUTPUT/DRAW FUNCTIONS ======================= */  
      34  
      35 /**  
      36  * Draw the files in an table.  
      37  */  
      38 function drawFiles($list, &$manager)  
      39 {  
      40     global $relative;  
      41  
      42     foreach($list as $entry => $file)  
      43     { ?>  
      44         <td>  
      45             <table width="100" cellpadding="0" cellspacing="0">  
      46             <tr>  
      47                 <td class="block" onclick="selectImage('<?php echo $file['image_object']->getImageUrl(); ?>', '<?php echo $file['alt']; ?>', <?php echo 0+$file['image'][0];?>, <?php echo 0+$file['image'][1]; ?>);">  
      48         <a href="javascript:;" onclick="selectImage('<?php echo $file['image_object']->getImageUrl(); ?>', '<?php echo $file['alt']; ?>', <?php echo 0+$file['image'][0];?>, <?php echo 0+$file['image'][1]; ?>);" title="<?php echo $file['alt']; ?>"><img src="<?php echo $file['image_object']->getThumbnailUrl(); ?>" alt="<?php echo $file['alt']; ?>"/></a>  
      49         </td></tr><tr><td class="edit">  
      50         <?php  
      51         if ($file['image']) {  
      52             echo $file['image'][0].'x'.$file['image'][1];  
      53         }  
      54         else {  
      55             echo " "; //$entry;  
      56         }  
      57         ?>  
      58         </td></tr></table></td>  
      59       <?php  
      60     }//foreach  
      61 }//function drawFiles  
      62  
      63  
      64 /**  
      65  * Draw the directory.  
      66  */  
      67 function drawDirs($list, &$manager)  
      68 {  
      69     global $relative;  
      70  
      71     foreach($list as $path => $dir)  
      72     { ?>  
      73         <td><table width="100" cellpadding="0" cellspacing="0"><tr><td class="block">  
      74         <a href="images.php?dir=<?php echo rawurlencode($path); ?>" onclick="updateDir('<?php echo $path; ?>')" title="<?php echo $dir['entry']; ?>"><img src="img/folder.gif" height="80" width="80" alt="<?php echo $dir['entry']; ?>" /></a>  
      75         </td></tr><tr>  
      76         <td class="edit">  
      77             <a href="images.php?dir=<?php echo $relative; ?>&deld=<?php echo rawurlencode($path); ?>" title="Trash" onclick="return confirmDeleteDir('<?php echo $dir['entry']; ?>', <?php echo $dir['count']; ?>);"><img src="img/edit_trash.gif" height="15" width="15" alt="Trash"/></a>  
      78             <?php echo $dir['entry']; ?>  
      79         </td>  
      80         </tr></table></td>  
      81       <?php  
      82     } //foreach  
      83 }//function drawDirs  
      84  
      85  
      86 /**  
      87  * No directories and no files.  
      88  */  
      89 function drawNoResults()  
      90 {  
      91 ?>  
      92 <table width="100%">  
      93   <tr>  
      94     <td class="noResult"><script>document.write(i18n("No Images Found"));</script></td>  
      95   </tr>  
      96 </table>  
      97 <?php     
      98 }  
      99  
      100 /**  
      101  * No directories and no files.  
      102  */  
      103 function drawErrorBase(&$manager)  
      104 {  
      105 ?>  
      106 <table width="100%">  
      107   <tr>  
      108     <td class="error">Invalid base directory: <?php echo $manager->config['base_dir']; ?></td>  
      109   </tr>  
      110 </table>  
      111 <?php     
      112 }  
      113  
      114 ?>  
      115 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
      116  
      117 <html>  
      118 <head>  
      119     <title>Image List</title>  
      120   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
      121     <link href="assets/imagelist.css" rel="stylesheet" type="text/css" />  
      122 <script type="text/javascript" src="assets/dialog.js"></script>  
      123 <script type="text/javascript">  
      124 /*<![CDATA[*/  
      125  
      126     if(window.top)  
      127         I18N = window.top.I18N;  
      128  
      129     function hideMessage()  
      130     {  
      131         var topDoc = window.top.document;  
      132         var messages = topDoc.getElementById('messages');  
      133         if(messages)  
      134             messages.style.display = "none";  
      135     }  
      136  
      137     init = function()  
      138     {  
      139         hideMessage();  
      140         var topDoc = window.top.document;  
      141  
      142 <?php  
      143     //we need to refesh the drop directory list  
      144     //save the current dir, delete all select options  
      145     //add the new list, re-select the saved dir.  
      146     if($refreshDir)  
      147     {  
      148         $dirs = $manager->getDirs();  
      149 ?>  
      150         var selection = topDoc.getElementById('dirPath');  
      151         var currentDir = selection.options[selection.selectedIndex].text;  
      152  
      153         while(selection.length > 0)  
      154         {   selection.remove(0); }  
      155          
      156         selection.options[selection.length] = new Option("/","<?php echo rawurlencode('/'); ?>");     
      157         <?php foreach($dirs as $relative=>$fullpath) { ?>  
      158         selection.options[selection.length] = new Option("<?php echo $relative; ?>","<?php echo rawurlencode($relative); ?>");       
      159         <?php } ?>  
      160          
      161         for(var i = 0; i < selection.length; i++)  
      162         {  
      163             var thisDir = selection.options[i].text;  
      164             if(thisDir == currentDir)  
      165             {  
      166                 selection.selectedIndex = i;  
      167                 break;  
      168             }  
      169         }         
      170 <?php } ?>  
      171     }     
      172  
      173     function editImage(image)  
      174     {  
      175         var url = "editor.php?img="+image;  
      176         Dialog(url, function(param)  
      177         {  
      178             if (!param) // user must have pressed Cancel  
      179                 return false;  
      180             else  
      181             {  
      182                 return true;  
      183             }  
      184         }, null);         
      185     }  
      186  
      187 /*]]>*/  
      188 </script>  
      189 <script type="text/javascript" src="assets/images.js"></script>  
      190 </head>  
      191  
      192 <body>  
      193 <?php if ($manager->isValidBase() == false) { drawErrorBase($manager); }  
      194     elseif(count($list[0]) > 0 || count($list[1]) > 0) { ?>  
      195 <table>  
      196     <tr>  
      197     <?php drawDirs($list[0], $manager); ?>  
      198     <?php drawFiles($list[1], $manager); ?>  
      199     </tr>  
      200 </table>  
      201 <?php } else { drawNoResults(); } ?>  
      202 </body>  
      203 </html>  
  • trunk/campsite/implementation/management/javascript/xinha/plugins/ImageManager/Classes/ImageManager.php

    r4101 r4132  
    156 156         $fullpath = Files::makePath($base,$path);  
    157 157  
    158    
    159           //$d = @dir($fullpath);  
    160            
    161 158         $articleImages = ArticleImage::GetImagesByArticleNumber($articleId);  
    162 159         foreach ($articleImages as $articleImage) {  
    163 160             $image = $articleImage->getImage();  
    164 161             $img = $this->getImageInfo($image->getImageUrl());  
    165               //$entry = basename($image->getImageStorageLocation());  
    166 162             if (is_array($img) || !$this->config['validate_images']) {  
    167 163                 $file['url'] = $image->getImageUrl();  
    168                   //$file['url'] = Files::makePath($this->config['base_url'],$path).$entry;  
    169                   //$file['relative'] = $path.$entry;  
    170                   //$file['fullpath'] = $fullpath.$entry;  
    171 164                 $file['image'] = $img;  
    172 165                 $file['image_object'] = $image;  
    173 166                 $file['alt'] = htmlspecialchars($image->getDescription(), ENT_QUOTES);  
    174                   //$file['stat'] = stat($fullpath.$entry);  
    175                   //$files[$entry] = $file;  
    176 167                 $files[$articleImage->getTemplateId()] = $file;  
    177 168             }  
    178                
    179 169         }  
    180 170          
    181   //      while (false !== ($entry = $d->read()))  
    182   //      {  
    183   //          //not a dot file or directory  
    184   //          if(substr($entry,0,1) != '.')  
    185   //          {  
    186   //              if(is_dir($fullpath.$entry)  
    187   //                  && $this->isThumbDir($entry) == false)  
    188   //              {  
    189   //                  $relative = Files::fixPath($path.$entry);  
    190   //                  $full = Files::fixPath($fullpath.$entry);  
    191   //                  $count = $this->countFiles($full);  
    192   //                  $dirs[$relative] = array('fullpath'=>$full,'entry'=>$entry,'count'=>$count);  
    193   //              }  
    194   //              else if(is_file($fullpath.$entry) && $this->isThumb($entry)==false && $this->isTmpFile($entry) == false)  
    195   //              {  
    196   //                  $img = $this->getImageInfo($fullpath.$entry);  
    197   //  
    198   //                  if(!(!is_array($img)&&$this->config['validate_images']))  
    199   //                  {  
    200   //                      $file['url'] = Files::makePath($this->config['base_url'],$path).$entry;  
    201   //                      $file['relative'] = $path.$entry;  
    202   //                      $file['fullpath'] = $fullpath.$entry;  
    203   //                      $file['image'] = $img;  
    204   //                      $file['stat'] = stat($fullpath.$entry);  
    205   //                      $files[$entry] = $file;  
    206   //                  }  
    207   //              }  
    208   //          }  
    209   //      }  
    210           //$d->close();  
    211 171         ksort($dirs);  
    212 172         ksort($files);  
    213            
    214           Return array($dirs, $files);  
      173         return array($dirs, $files);  
    215 174     }     
    216 175