Changeset 686 for trunk/plugins


Ignore:
Timestamp:
01/22/07 15:06:18 (13 years ago)
Author:
gocher
Message:

Update InsertPicture? plugin

Location:
trunk/plugins/InsertPicture
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugins/InsertPicture/InsertPicture.php

    r677 r686  
    11<?PHP 
    22  //this plugin only use the relativ webpath to the picturefolder 
    3   //default ~  /htmlarea/plugins/InsertPicture/demo_pictures/ 
     3  //default ~  /Xinha/plugins/InsertPicture/demo_pictures/ 
    44  strstr( PHP_OS, "WIN") ? $strPathSeparator = "\\" : $strPathSeparator = "/"; 
    55  if (isset($_REQUEST['picturepath'])) { 
    6     $getRequest = true; 
    7     $PicturePath = 'http://'.$_SERVER['HTTP_HOST'].$_REQUEST['picturepath']; 
    8     //$LocalPicturePath = $_REQUEST['localpicturepath']; 
    9  
    10     $AInsertPicturePath = explode ('/', 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/demo_pictures/'); 
    11     $ALocalInsertPicturePath = explode($strPathSeparator, dirname(__FILE__).$strPathSeparator.'demo_pictures'); 
    12     $APicturePath = explode('/', 'http://'.$_SERVER['HTTP_HOST'].$_REQUEST['picturepath']); 
    13  
    14     $AtheFilePath = array_values (array_diff ($APicturePath, $AInsertPicturePath)); 
    15     $theFilePath = implode($strPathSeparator, $AtheFilePath).$strPathSeparator; 
    16  
     6    $PicturePath = $_REQUEST['picturepath']; 
     7 
     8    $AInsertPicturePath = explode ('/', dirname($_SERVER['PHP_SELF'])); 
     9    $ALocalInsertPicturePath = explode($strPathSeparator, dirname(__FILE__)); 
    1710    $AtheRootPath = array_values (array_diff ($ALocalInsertPicturePath, $AInsertPicturePath)); 
    18     $theRootPath = implode($strPathSeparator, $AtheRootPath); 
    19  
    20     $LocalPicturePath = $theRootPath.$strPathSeparator.$theFilePath.$strPathSeparator; 
    21   } else { 
    22     $getRequest = false; 
    23     $PicturePath =  'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/demo_pictures/'; 
    24     $LocalPicturePath = dirname(__FILE__).$strPathSeparator.'demo_pictures'; 
     11    $RootPath = implode($strPathSeparator, $AtheRootPath); 
     12 
     13    $LocalPicturePath = str_replace('http://'.$_SERVER['HTTP_HOST'], "", $PicturePath); 
     14    $LocalPicturePath = str_replace('/', $strPathSeparator, $LocalPicturePath); 
     15    $LocalPicturePath = $RootPath.$LocalPicturePath; 
     16 
     17    $LocalPicturePath = dirname(__FILE__).$strPathSeparator.'demo_pictures'.$strPathSeparator; 
     18    //$LocalPicturePath = realpath('../../../../images/content/').$strPathSeparator; 
    2519  } 
    2620  $limitedext = array(".gif",".jpg",".png",".jpeg"); //Extensions you want files uploaded limited to. 
    2721  $limitedsize = "1000000"; //size limit in bytes 
    2822  $message = ""; 
    29   function formatSize($size)  
     23 
     24  function formatSize($size) 
    3025  { 
    31     if($size < 1024)  
    32       return $size.' bytes';     
    33     else if($size >= 1024 && $size < 1024*1024)  
    34       return sprintf('%01.2f',$size/1024.0).' Kb';       
     26    if($size < 1024) 
     27      return $size.' bytes'; 
     28    else if($size >= 1024 && $size < 1024*1024) 
     29      return sprintf('%01.2f',$size/1024.0).' Kb'; 
    3530    else 
    36       return sprintf('%01.2f',$size/(1024.0*1024)).' Mb';        
    37   } 
    38  
     31      return sprintf('%01.2f',$size/(1024.0*1024)).' Mb'; 
     32  } 
     33  $DestFileName = ""; 
    3934  if (isset($_FILES['file'])) { 
    4035    $file = $_FILES['file']; 
    4136    $ext = strrchr($file['name'],'.'); 
    42     if (!in_array($ext,$limitedext)) { 
     37    if (!in_array($ext,$limitedext)) 
    4338      $message = "The file you are uploading doesn't have the correct extension."; 
    44     } else if (file_exists($LocalPicturePath.'\\'.$file['name'])) { 
     39    else if (file_exists($LocalPicturePath.$file['name'])) 
    4540      $message = "The file you are uploading already exists."; 
    46     } else if ($file['size'] > $limitedsize) { 
     41    else if ($file['size'] > $limitedsize) 
    4742      $message = "The file you are uploading is to big. The max Filesize is</span><span> ".formatSize($limitedsize)."."; 
    48     } else { 
    49       copy($file['tmp_name'], $LocalPicturePath.$strPathSeparator.$file['name']); 
    50     } 
    51   } 
    52  
     43    else 
     44      copy($file['tmp_name'], $LocalPicturePath.$file['name']); 
     45    $DestFileName = $file['name']; 
     46  } 
    5347?> 
    5448<html> 
    55  
    5649<head> 
    5750  <title>Insert Image</title> 
    58          
    5951<link rel="stylesheet" type="text/css" href="../../popups/popup.css" /> 
    6052<script type="text/javascript" src="../../popups/popup.js"></script> 
     
    6254<script type="text/javascript"> 
    6355 
    64 var HTMLArea = window.opener.HTMLArea; 
     56var Xinha = window.opener.Xinha; 
    6557function i18n(str) { 
    66   return (HTMLArea._lc(str, 'HTMLArea')); 
     58  return (Xinha._lc(str, 'Xinha')); 
    6759} 
    6860 
     
    7264  window.resizeTo(500, 490); 
    7365  // Make sure the translated string appears in the drop down. (for gecko) 
    74   document.getElementById("f_align").selectedIndex = 1; 
    75   document.getElementById("f_align").selectedIndex = 5; 
     66  document.getElementById("f_align").selectedIndex = 0; 
     67  document.getElementById("f_align").selectedIndex = document.getElementById("f_align").selectedIndex; 
    7668  var param = window.dialogArguments; 
    7769  if (param) { 
     
    8072      document.getElementById("f_border").value = param["f_border"]; 
    8173      document.getElementById("f_align").value = param["f_align"]; 
    82       document.getElementById("f_vert").value = param["f_vert"]; 
    83       document.getElementById("f_horiz").value = param["f_horiz"]; 
     74      document.getElementById("f_vert").value = (param["f_vert"]!="-1") ? param["f_vert"] : ""; 
     75      document.getElementById("f_horiz").value = (param["f_horiz"]!="-1") ? param["f_horiz"] : ""; 
    8476      document.getElementById("f_height").value = param["f_height"]; 
    85       document.getElementById("f_width").value = param["f_width"];                       
     77      document.getElementById("f_width").value = param["f_width"]; 
    8678      window.ipreview.location.replace(param.f_url); 
    8779  } 
    8880  document.getElementById("f_url").focus(); 
     81  document.getElementById("filelist").selectedIndex = document.getElementById("filelist").selectedIndex; 
     82<?php If ($DestFileName<>"") 
     83  echo "CopyToURL(\"".$PicturePath.$DestFileName."\");" 
     84?> 
    8985} 
    9086 
     
    10298  } 
    10399  // pass data back to the calling window 
    104   var fields = ["f_url", "f_alt", "f_align", "f_border", 
    105                 "f_horiz", "f_vert"]; 
     100  var fields = ["f_url", "f_alt", "f_align", "f_border", "f_horiz", "f_vert", "f_width", "f_height"]; 
    106101  var param = new Object(); 
    107102  for (var i in fields) { 
     
    126121    } 
    127122  } 
    128   submit(); 
    129   return false; 
     123  return true; 
    130124} 
    131125 
     
    174168} 
    175169</script> 
    176  
    177170</head> 
    178  
    179171<body class="dialog" onload="Init()"> 
    180  
    181172<div class="title">Insert Image</div> 
    182173<table border="0" width="100%" style="padding: 0px; margin: 0px"> 
    183174  <tbody> 
    184175  <tr> 
    185     <td>Images on the Server:<br> 
    186     <select value="" style="width:200" size="10" onClick="CopyToURL(this[this.selectedIndex].value);"> 
     176    <td>Images on the Server:<?php /*echo $LocalPicturePath*/ ?><br> 
     177    <select id="filelist" name="filelist" style="width:200" size="10" onClick="CopyToURL(this[this.selectedIndex].value);"> 
    187178<?php 
    188179  $d = @dir($LocalPicturePath); 
    189   while (false !== ($entry = $d->read())) { //not a dot file or directory 
    190     if(substr($entry,0,1) != '.') {  
    191       echo '<OPTION value="' . $PicturePath.$entry. '">' . $entry . '(' . formatSize(filesize($LocalPicturePath.'\\'.$entry)) .')</OPTION>'; 
     180  while (false !== ($entry = $d->read())) { 
     181    if(substr($entry,0,1) != '.') {  //not a dot file or directory 
     182      if ($entry == $DestFileName) 
     183        echo '<OPTION value="' . $PicturePath.$entry. '" selected="selected">' . $entry . '(' . formatSize(filesize($LocalPicturePath.'\\'.$entry)) .')</OPTION>'; 
     184      else 
     185        echo '<OPTION value="' . $PicturePath.$entry. '">' . $entry . '(' . formatSize(filesize($LocalPicturePath.'\\'.$entry)) .')</OPTION>'; 
    192186    } 
    193187  } 
     
    195189?> 
    196190    </select> 
    197 <?php 
    198   if ($getRequest == true) { 
    199     echo '<form method="post" action="'.$_SERVER['PHP_SELF'].'?picturepath='.$_REQUEST['picturepath'].'" enctype="multipart/form-data">'; 
    200   } else { 
    201     echo '<form method="post" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data">'; 
    202   } 
    203 ?> 
     191 
     192      <form method="post" action="" enctype="multipart/form-data"> 
     193        <input type="hidden" name="localpicturepath" value="<?php echo $LocalPicturePath ?>"> 
     194        <input type="hidden" name="picturepath" value="<?php echo $PicturePath ?>"> 
    204195        <input type="file" name="file" id="file" size="30"><br> 
    205         <button type="submit" name="ok" onclick="return onUpload();">Upload file</button><br> 
     196        <button type="submit" name="ok" onclick="onUpload();">Upload file</button><br> 
    206197        <span><?php echo $message ?></span> 
    207198      </form> 
     
    218209 
    219210<form action="" method="get"> 
     211  <input type="hidden" name="localpicturepath" value="<?php echo $LocalPicturePath ?>"> 
     212  <input type="hidden" name="picturepath" value="<?php echo $PicturePath ?>"> 
    220213<table border="0" width="100%" style="padding: 0px; margin: 0px"> 
    221214  <tbody> 
     
    224217    <td style="width: 7em; text-align: right">Image URL:</td> 
    225218    <td><input type="text" name="url" id="f_url" style="width:75%" 
    226       title="Enter the image URL here" /> 
     219      title="Enter the image URL here"  value="<?php echo $PicturePath.$DestFileName ?>"/> 
    227220      <button name="preview" onclick="return onPreview();" 
    228221      title="Preview the image in a new window">Preview</button> 
     
    253246  <option value="texttop"                      >Texttop</option> 
    254247  <option value="absmiddle"                    >Absmiddle</option> 
    255   <option value="baseline" selected="1"        >Baseline</option> 
     248  <option value="baseline"                     >Baseline</option> 
    256249  <option value="absbottom"                    >Absbottom</option> 
    257250  <option value="bottom"                       >Bottom</option> 
     
    263256 
    264257<div class="fl" style="width: 6em;">Border thickness:</div> 
    265 <input type="text" name="border" id="f_border" size="5" 
    266 title="Leave empty for no border" /> 
    267  
     258<input type="text" name="border" id="f_border" size="5" title="Leave empty for no border" /> 
    268259<div class="space"></div> 
    269260 
     
    291282 
    292283<div class="fr" style="width: 5em;">Horizontal:</div> 
    293 <input type="text" name="horiz" id="f_horiz" size="5" 
    294 title="Horizontal padding" /> 
    295  
     284<input type="text" name="horiz" id="f_horiz" size="5" title="Horizontal padding" /> 
    296285<p /> 
    297286 
    298287<div class="fr" style="width: 5em;">Vertical:</div> 
    299 <input type="text" name="vert" id="f_vert" size="5" 
    300 title="Vertical padding" /> 
     288<input type="text" name="vert" id="f_vert" size="5" title="Vertical padding" /> 
    301289 
    302290<div class="space"></div> 
  • trunk/plugins/InsertPicture/insert-picture.js

    r677 r686  
    1 // Insert Image plugin for HTMLArea 
     1// Insert Image plugin for Xinha 
    22// Original Author - Udo Schmal 
    33// 
     
    66// This notice MUST stay intact for use (see license.txt). 
    77 
    8 //Usage: 
    9 //  if(typeof InsertPicture != 'undefined') 
    10 //  {  InsertPicture.PicturePath = [webpath to imagefolder]; 
    11 //     InsertPicture.LocalPicturePath = [local server path to imagefolder]; 
    12 //  } 
    13 //  for Example: 
    14 //  if(typeof InsertPicture != 'undefined') 
    15 //  {  InsertPicture.PicturePath = _editor_url + "plugins/insertPicture/demo_pictures/"; 
    16 //     InsertPicture.LocalPicturePath = "d:\\inetpub\\wwwroot\\xinha\\trunk\\plugins\\insertPicture\\demo_pictures"; 
    17 //  } 
    18  
    19  
    208function InsertPicture(editor) { 
    21 // nothing to do 
     9  if ( typeof _editor_picturePath !== "string" ) 
     10    _editor_picturePath = _editor_url + "plugins/InsertPicture/demo_pictures/"; 
     11  InsertPicture.Scripting = "php"; //else "asp" 
     12  editor.config.URIs.insert_image =  '../plugins/InsertPicture/InsertPicture.' + InsertPicture.Scripting + '?picturepath=' + _editor_picturePath; 
    2213} 
    2314 
    2415InsertPicture._pluginInfo = { 
    25         name          : "InsertPicture", 
    26         version       : "1.0.1", 
    27         developer     : "Udo Schmal", 
    28         developer_url : "http://www.Schaffrath-NeueMedien.de/", 
    29         sponsor       : "L.N.Schaffrath NeueMedien", 
    30         sponsor_url   : "http://www.schaffrath-neuemedien.de/",  
    31         c_owner       : "Udo Schmal", 
    32         license       : "htmlArea" 
     16  name          : "InsertPicture", 
     17  version       : "1.0.2", 
     18  developer     : "Udo Schmal", 
     19  developer_url : "http://www.Schaffrath-NeueMedien.de/", 
     20  sponsor       : "L.N.Schaffrath NeueMedien", 
     21  sponsor_url   : "http://www.schaffrath-neuemedien.de/", 
     22  c_owner       : "Udo Schmal", 
     23  license       : "htmlArea" 
    3324}; 
    3425 
    35 HTMLArea.prototype._insertImage = function(image) { 
    36         var editor = this; 
    37         var outparam = null; 
    38         if (typeof image == "undefined") { 
    39                 image = this.getParentElement(); 
    40                 if (image && !/^img$/i.test(image.tagName)) 
    41                         image = null; 
    42         } 
    43         if (image) outparam = { 
    44                 f_url    : image.getAttribute("src"), 
    45                 f_alt    : image.alt, 
    46                 f_border : image.border, 
    47                 f_align  : image.align, 
    48                 f_vert   : image.vspace, 
    49                 f_horiz  : image.hspace, 
    50                 f_width  : image.width, 
    51                 f_height : image.height 
    52         }; 
    53  
    54         var manager = _editor_url + 'plugins/InsertPicture/InsertPicture.php' 
    55                       + '?picturepath=' + InsertPicture.PicturePath; 
    56  
    57         Dialog(manager, function(param) { 
    58                 if (!param) {   // user must have pressed Cancel 
    59                         return false; 
    60                 } 
    61                 if (!image) { 
    62                         var sel = editor._getSelection(); 
    63                         var range = editor._createRange(sel); 
    64                         editor._doc.execCommand("insertimage", false, param.f_url); 
    65                         if (HTMLArea.is_ie) { 
    66                                 image = range.parentElement(); 
    67                                 // wonder if this works... 
    68                                 if (image.tagName.toLowerCase() != "img") { 
    69                                         image = image.previousSibling; 
    70                                 } 
    71                         } else { 
    72                                 image = range.startContainer.previousSibling; 
    73                         } 
    74                 } else { 
    75                         image.src = param.f_url; 
    76                 } 
    77  
    78                 for (field in param) { 
    79                         var value = param[field]; 
    80                         switch (field) { 
    81                             case "f_alt"    : image.alt  = value; break; 
    82                             case "f_border" : image.border = parseInt(value || "0"); break; 
    83                             case "f_align"  : image.align        = value; break; 
    84                             case "f_vert"   : image.vspace = parseInt(value || "0"); break; 
    85                                 case "f_horiz"  : image.hspace = parseInt(value || "0"); break; 
    86                                 case "f_width"  : image.width = parseInt(value || "0"); break; 
    87                                 case "f_height"  : image.height = parseInt(value || "0"); break; 
    88                         } 
    89                 } 
    90  
    91  
    92         }, outparam); 
    93 }; 
  • trunk/plugins/InsertPicture/lang/de.js

    r677 r686  
    99  "Please select a file to upload.": "WÀhlen Sie eine Datei zum hochladen aus.", 
    1010  "Upload file": "Datei hochladen", 
    11   "Open file in new window": "Datei in neuen Fenster anzeigen" 
     11  "Open file in new window": "Datei in neuen Fenster anzeigen", 
     12  "Size": "Größe", 
     13  "Width:": "Breite", 
     14  "Height:": "Höhe" 
    1215}; 
Note: See TracChangeset for help on using the changeset viewer.