Source for file admin.media.html.php

Documentation is available at admin.media.html.php

  1. <?php
  2. /**
  3. @package Mambo
  4. @subpackage Massmail
  5. @copyright  Refer to copyright.php
  6. @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
  7. @author Mambo Foundation Inc see README.php
  8. */
  9.  
  10. /** ensure this file is being included by a parent file */
  11. defined'_VALID_MOS' or die'Direct Access to this location is not allowed.' );
  12.  
  13. /**
  14. @package Mambo
  15. @subpackage Massmail
  16. */
  17. class HTML_Media {
  18.     function showMedia($dirPath,$listdir {
  19.  
  20.     ?>
  21.     <html style="width: 580; height: 440;">
  22.     <style type="text/css">
  23.     <!--
  24.     .buttonHover {
  25.         border: 1px solid;
  26.         border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;
  27.         cursor: hand;
  28.     }
  29.     .buttonOut
  30.     {
  31.         border: 1px solid ButtonFace;
  32.     }
  33.  
  34.     .separator {
  35.       position: relative;
  36.       margin: 3px;
  37.       border-left: 1px solid ButtonShadow;
  38.       border-right: 1px solid ButtonHighlight;
  39.       width: 0px;
  40.       height: 16px;
  41.       padding: 0px;
  42.     }
  43.     .manager
  44.     {
  45.     }
  46.     .statusLayer
  47.     {
  48.         background:#FFFFFF;
  49.         border: 1px solid #CCCCCC;
  50.     }
  51.     .statusText {
  52.         font-family: Verdana, Arial, Helvetica, sans-serif;
  53.         font-size: 15px;
  54.         font-weight: bold;
  55.         color: #6699CC;
  56.         text-decoration: none;
  57.     }
  58.     -->
  59.     </style>
  60.     </head>
  61.  
  62.     <script language="javascript" type="text/javascript">
  63.     function dirup(){
  64.         var urlquery=frames['imgManager'].location.search.substring(1);
  65.         var curdir= urlquery.substring(urlquery.indexOf('listdir=')+8);
  66.         var listdir=curdir.substring(0,curdir.lastIndexOf('/'));
  67.         frames['imgManager'].location.href='index3.php?option=com_media&task=list&listdir=' + listdir;
  68.     }
  69.  
  70.  
  71.     function goUpDir()
  72.     {
  73.         var selection = document.forms[0].dirPath;
  74.         var dir = selection.options[selection.selectedIndex].value;
  75.         frames['imgManager'].location.href='index3.php?option=com_media&task=list&listdir=' + dir;
  76.     }
  77.  
  78.     </script>
  79.     <body>
  80.     <form action="index2.php" name="adminForm" method="post" enctype="multipart/form-data" >
  81.       <table class="adminheading">
  82.         <tr>
  83.         <th class="mediamanager"><?php echo T_('Media Manager')?></th>
  84.         <tr>
  85.           <td align="center">      <fieldset>
  86.             <table width="99%" align="center" border="0" cellspacing="2" cellpadding="2">
  87.               <tr>
  88.                 <td><table border="0" cellspacing="1" cellpadding="3">
  89.                     <tr>
  90.                       <td><?php echo T_('Directory')?></td>
  91.                       <td>
  92.                       <?php echo $dirPath;?>
  93.                       </td>
  94.                       <td class="buttonOut">
  95.                       <a href="javascript:dirup()"><img src="components/com_media/images/btnFolderUp.gif" width="15" height="15" border="0" alt="Up"></a></td>
  96.                     </tr>
  97.                   </table></td>
  98.               </tr>
  99.               <tr>
  100.                 <td align="center" bgcolor="white"><div name="manager" class="manager">
  101.                 <iframe src="index3.php?option=com_media&task=list&listdir=<?php echo $listdir?>" name="imgManager" id="imgManager" width="100%" height="170" marginwidth="0" marginheight="0" align="top" scrolling="auto" frameborder="0" hspace="0" vspace="0" background="white"></iframe>
  102.                 </div>
  103.                 </td>
  104.               </tr>
  105.             </table>
  106.             </fieldset></td>
  107.         </tr>
  108.         <tr>
  109.           <td><table border="0" align="center" cellpadding="2" cellspacing="2" width="100%">
  110.                   <tr>
  111.                 <td align="left"><?php echo T_('Upload')?></td>
  112.                 <td>
  113.                     <input class="inputbox" type="file" name="upload" id="upload" size="79">&nbsp;
  114.                     <?php echo T_('Max size')?> = <?php echo ini_get'post_max_size' );?>
  115.                     </td>
  116.                 </tr>
  117.               <tr>
  118.               <td align="left"><?php echo T_('Code')?></td>
  119.             <td><input class="inputbox" type="text" name="imagecode" size="80" dir="ltr"/></td>
  120.               </tr>
  121.               <tr>
  122.               <td align="left"><?php echo T_('Create Directory')?></td>
  123.                    <td><input class="inputbox" type="text" name="foldername" size="80" dir="ltr"/>
  124.                  </td>
  125.               </tr>
  126.             </table>
  127.  
  128.           </td>
  129.         </tr>
  130.         <tr>
  131.           <td><div style="text-align: right;">
  132.             </div></td>
  133.         </tr>
  134.       </table>
  135.       <input type="hidden" name="option" value="com_media" />
  136.       <input type="hidden" name="task" value="" />
  137.       <input type="hidden" name="cb1" id="cb1" value="0">
  138.     </form>
  139.     </body>
  140.     </html>
  141.  
  142.     <?php
  143.     }
  144.  
  145.  
  146.     //Built in function of dirname is faulty
  147.     //It assumes that the directory nane can not contain a . (period)
  148.     function dir_name($dir){
  149.         $lastSlash intval(strrpos($dir'/'));
  150.         if($lastSlash == strlen($dir)-1){
  151.             return substr($dir0$lastSlash);
  152.         }
  153.         else {
  154.             return dirname($dir);
  155.         }
  156.     }
  157.  
  158.     function draw_no_results(){
  159.     ?>
  160.     <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  161.       <tr>
  162.         <td><div align="center" style="font-size:large;font-weight:bold;color:#CCCCCC;font-family: Helvetica, sans-serif;"><?php echo T_('No Images Found')?></div></td>
  163.       </tr>
  164.     </table>
  165.     <?php
  166.     }
  167.  
  168.     function draw_no_dir({
  169.         global $BASE_DIR$BASE_ROOT;
  170.     ?>
  171.     <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  172.       <tr>
  173.         <td><div align="center" style="font-size:small;font-weight:bold;color:#CC0000;font-family: Helvetica, sans-serif;"><?php printf(T_('Configuration Problem: &quot; %s &quot; does not exist.')$BASE_DIR.$BASE_ROOT?></div></td>
  174.       </tr>
  175.     </table>
  176.     <?php
  177.     }
  178.  
  179.  
  180.     function draw_table_header({
  181.         echo '<table border="0" cellpadding="0" cellspacing="2">';
  182.         echo '<tr>';
  183.     }
  184.  
  185.     function draw_table_footer({
  186.         echo '</tr>';
  187.         echo '</table>';
  188.     }
  189.  
  190.     function show_image($img$file$info$size$listdir{
  191.         global $mosConfig_live_site;
  192.  
  193.         $img_file basename($img);
  194.         $img_url $mosConfig_live_site.'/images/stories'.$listdir.'/'.$img_file;
  195.  
  196.         $filesize HTML_Media::parse_size($size);
  197.     ?>
  198.     <td>
  199.     <table width="102" border="0" cellpadding="0" cellspacing="2">
  200.       <tr>
  201.         <td align="center" class="imgBorder">
  202.         <a href="javascript:;" onClick="javascript:window.top.document.forms[0].imagecode.value = '<img src=&quot;<?php echo $img_url;?>&quot; align=&quot;left&quot; hspace=&quot;6&quot; alt=&quot;<?php echo $img_file;?>&quot; />';"><img src="<?php echo $img_url?><?php echo HTML_Media::imageResize($info[0]$info[1]80)?> alt="<?php echo $file?> - <?php echo $filesize?>" border="0"></a></td>
  203.       </tr>
  204.       <tr>
  205.       <td> <?php echo $file?> </td>
  206.       </tr>
  207.       <tr>
  208.         <td><table width="100%" border="0" cellspacing="0" cellpadding="2">
  209.             <tr>
  210.               <td width="1%" class="buttonOut">
  211.                 <a href="javascript:;" onClick="javascript:window.top.document.forms[0].imagecode.value = '<img src=&quot;<?php echo $img_url;?>&quot; align=&quot;left&quot; hspace=&quot;6&quot; alt=&quot;Code&quot; />';"><img src="components/com_media/images/edit_pencil.gif" width="15" height="15" border="0" alt="<?php echo T_('Code')?>"></a></td>
  212.               <td width="1%" class="buttonOut">
  213.                 <a href="index2.php?option=com_media&task=delete&delFile=<?php echo $file?>&listdir=<?php echo $listdir?>" target="_top" onClick="return deleteImage('<?php echo $file?>');"><img src="components/com_media/images/edit_trash.gif" width="15" height="15" border="0" alt="<?php echo T_('Delete')?>"></a></td>
  214.               <td width="98%" class="imgCaption"><?php echo $info[0].'x'.$info[1]?></td>
  215.             </tr>
  216.           </table></td>
  217.       </tr>
  218.     </table>
  219.     </td>
  220.     <?php
  221.     }
  222.  
  223.     function show_dir($path$dir,$listdir{
  224.         global $mosConfig_absolute_path;
  225.  
  226.         $num_files HTML_Media::num_files($mosConfig_absolute_path.$path);
  227.  
  228.         // Fix for Bug [0000577]
  229.         if ($listdir=='/'{
  230.             $listdir='';
  231.         }
  232.  
  233.     ?>
  234.     <td>
  235.     <table width="102" border="0" cellpadding="0" cellspacing="2">
  236.       <tr>
  237.         <td align="center" class="imgBorder")">
  238.           <a href="index3.php?option=com_media&task=list&listdir=<?php echo $listdir.$path?>" target="imgManager" onClick="javascript:updateDir();">
  239.             <img src="components/com_media/images/folder.gif" width="80" height="80" border="0" alt="<?php echo $dir?>">
  240.           </a>
  241.         </td>
  242.       </tr>
  243.       <tr>
  244.       <td> <?php echo $dir?> </td>
  245.       </tr>
  246.       <tr>
  247.         <td><table width="100%" border="0" cellspacing="1" cellpadding="2">
  248.             <tr>
  249.               <td width="1%" class="buttonOut">
  250.                 <a href="index2.php?option=com_media&task=deletefolder&delFolder=<?php echo $path?>&listdir=<?php echo $listdir?>" target="_top" onClick="return deleteFolder('<?php echo $dir?>', <?php echo $num_files?>);"><img src="components/com_media/images/edit_trash.gif" width="15" height="15" border="0" alt="<?php echo T_('Delete')?>"></a></td>
  251.               <td width="99%" class="imgCaption"></td>
  252.             </tr>
  253.           </table></td>
  254.       </tr>
  255.     </table>
  256.     </td>
  257.     <?php
  258.     }
  259.  
  260.     function show_doc($doc$listdir$icon{
  261.         global $mosConfig_absolute_path,$mosConfig_live_site;
  262.  
  263.     ?>
  264.  
  265.     <td>
  266.     <table width="102" border="0" cellpadding="0" cellspacing="2">
  267.       <tr>
  268.         <td align="center" class="imgBorder">
  269.           <a href="index3.php?option=com_media&task=list&listdir=<?php echo $listdir?>" onClick="javascript:window.top.document.forms[0].imagecode.value = '<a href=&quot;<?php echo $mosConfig_live_site.'/images/stories'.$listdir.'/'.$doc;?>&quot;><?php echo T_('Insert your text here')?></a>';">
  270.           <img border="0" src="<?php echo $icon ?>" alt="<?php echo $doc?>"></a>
  271.         </td>
  272.       </tr>
  273.       <tr>
  274.       <td> <?php echo $doc?> </td>
  275.       </tr>
  276.       <tr>
  277.           <td><table width="100%" border="0" cellspacing="0" cellpadding="2">
  278.             <tr>
  279.               <td width="1%" class="buttonOut">
  280.                 <a href="javascript:;" onClick="javascript:window.top.document.forms[0].imagecode.value = '<a href=&quot;<?php echo $mosConfig_live_site.'/images/stories'.$listdir.'/'.$doc;?>&quot;>Insert your text here</a>';"><img src="components/com_media/images/edit_pencil.gif" width="15" height="15" border="0" alt="<?php echo T_('Code')?>"></a></td>
  281.               <td width="1%" class="buttonOut">
  282.                 <a href="index2.php?option=com_media&task=delete&delFile=<?php echo $doc?>&listdir=<?php echo $listdir?>" target="_top" onClick="return deleteImage('<?php echo $doc?>');"><img src="components/com_media/images/edit_trash.gif" width="15" height="15" border="0" alt="<?php echo T_('Delete')?>"></a></td>
  283.               <td width="98%" class="imgCaption"></td>
  284.             </tr>
  285.           </table></td>
  286.       </tr>
  287.     </table>
  288.     </td>
  289.     <?php
  290.     }
  291.  
  292.     function parse_size($size){
  293.         if($size 1024{
  294.             return $size.' bytes';
  295.         }
  296.         else if($size >= 1024 && $size 1024*1024)
  297.         {
  298.             return sprintf('%01.2f',$size/1024.0).' Kb';
  299.         }
  300.         else
  301.         {
  302.             return sprintf('%01.2f',$size/(1024.0*1024)).' Mb';
  303.         }
  304.     }
  305.  
  306.     function imageResize($width$height$target{
  307.  
  308.         //takes the larger size of the width and height and applies the
  309.         //formula accordingly...this is so this script will work
  310.         //dynamically with any size image
  311.  
  312.         if ($width $height{
  313.             $percentage ($target $width);
  314.         else {
  315.             $percentage ($target $height);
  316.         }
  317.  
  318.         //gets the new value and applies the percentage, then rounds the value
  319.         $width round($width $percentage);
  320.         $height round($height $percentage);
  321.  
  322.         //returns the new sizes in html image tag format...this is so you
  323.         //can plug this function inside an image tag and just get the
  324.  
  325.         return "width=\"$width\" height=\"$height\"";
  326.  
  327.     }
  328.  
  329.     function num_files($dir)
  330.     {
  331.         $total 0;
  332.  
  333.         if(is_dir($dir))
  334.         {
  335.             $d @dir($dir);
  336.  
  337.             while (false !== ($entry $d->read()))
  338.             {
  339.                 //echo $entry."<br>";
  340.                 if(substr($entry,0,1!= '.'{
  341.                     $total++;
  342.                 }
  343.             }
  344.             $d->close();
  345.         }
  346.         return $total;
  347.     }
  348.  
  349.  
  350.     function imageStyle($listdir){
  351.  
  352.     ?>
  353.     <script language="javascript" type="text/javascript">
  354.     function updateDir(){
  355.         var allPaths = window.top.document.forms[0].dirPath.options;
  356.         for(i=0; i<allPaths.length; i++)
  357.         {
  358.             allPaths.item(i).selected = false;
  359.             if((allPaths.item(i).value)== '<?php if (strlen($listdir)>0echo $listdir ;else echo '/';}  ?>')
  360.             {
  361.                 allPaths.item(i).selected = true;
  362.             }
  363.         }
  364.     }
  365.  
  366.     function deleteImage(file)
  367.     {
  368.         if(confirm(<?php echo T_('"Delete file \""+file+"\"?"')?>))
  369.         return true;
  370.  
  371.         return false;
  372.     }
  373.     function deleteFolder(folder, numFiles)
  374.     {
  375.         if(numFiles > 0) {
  376.             alert(<?php echo T_('"There are "+numFiles+" files/folders in \""+folder+"\".\n\nPlease delete all files/folder in \""+folder+"\" first."')?>);
  377.             return false;
  378.         }
  379.  
  380.         if(confirm(<?php echo T_('"Delete folder \""+folder+"\"?"')?>))
  381.         return true;
  382.  
  383.         return false;
  384.     }
  385.     </script>
  386.     </head>
  387.     <body onLoad="updateDir()">
  388.     <style type="text/css">
  389.     <!--
  390.     .imgBorder {
  391.         height: 96px;
  392.         border: 1px solid threedface;
  393.         vertical-align: middle;
  394.     }
  395.     .imgBorderHover {
  396.         height: 96px;
  397.         border: 1px solid threedface;
  398.         vertical-align: middle;
  399.         background: #FFFFCC;
  400.         cursor: hand;
  401.     }
  402.  
  403.     .buttonHover {
  404.         border: 1px solid;
  405.         border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;
  406.         cursor: hand;
  407.         background: #FFFFCC;
  408.     }
  409.  
  410.     .buttonOut
  411.     {
  412.      border: 0px;
  413.     }
  414.  
  415.     .imgCaption {
  416.         font-size: 9pt;
  417.         font-family: "MS Shell Dlg", Helvetica, sans-serif;
  418.         text-align: center;
  419.     }
  420.     .dirField {
  421.         font-size: 9pt;
  422.         font-family: "MS Shell Dlg", Helvetica, sans-serif;
  423.         width:110px;
  424.     }
  425.     -->
  426.     </style>
  427.  
  428.     <?php
  429.     }
  430.  
  431. }
  432. ?>

Documentation generated on Mon, 05 May 2008 16:15:28 +0400 by phpDocumentor 1.4.0