Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2009-07-17 15:32:12

ateslik
Xinha Community Member
Registered: 2009-07-16
Posts: 33

PATCH: InsertImage selection dropdown for inline attachments

Hello,

   Some software allows users to upload images as attachments to their posts. The uploaded attachments are usually accessible for viewing via a URL internally generated by the software, but unknown to the user. These attachments should be accessible from the InsertImage dialog so that users can place what they've uploaded inline.

   This patch creates the configuration option 'selectableImages'. This option allows xinha to be passed a list of attached image names and their internal attachment URLs so that they may be used inline during message posting. The creation of the selectableImages array is a task for the coder on the server side via Perl, Php, Python, etc.

   The default selectableImages array is empty. A sample array may look like:

xinha_config.selectableImages = [
  ['image_name01', 'image_url01'],
  ['image_name02', 'image_url02'],
];

I've been integrating Xinha into OpenWebMail and ran into this need.

Thanks,
Alex

P.S.- The file modules/InsertImage/insert_image.html is no longer used and is confusing to have laying around. It would be great if it could be removed.

Index: XinhaCore.js
===================================================================
--- XinhaCore.js    (revision 1190)
+++ XinhaCore.js    (working copy)
@@ -934,6 +934,18 @@
     ["separator","htmlmode","showhelp","about"]
   ];
 
+  /** This array provides a list of filenames and their corresponding URLs, so that those images may be chosen
+   *  via a selection dropdown menu in the InsertImage dialog module. This enables integration with email or blog
+   *  software where users have uploaded images accessable via special URLs provided by those softwares, but not
+   *  immediately apparent to the user. A sample array should look like [['image1','url1'],['image2','url2']].
+   * Default value:
+   *<pre>
+   *xinha_config.selectableImages = [];
+   *</pre>
+   * @type Array
+   */
+  this.selectableImages = [];
+
   /** The fontnames listed in the fontname dropdown
    * Default value:
    *<pre>
Index: modules/InsertImage/insert_image.js
===================================================================
--- modules/InsertImage/insert_image.js    (revision 1190)
+++ modules/InsertImage/insert_image.js    (working copy)
@@ -71,20 +71,47 @@
     // Connect the OK and Cancel buttons
     dialog.getElementById('ok').onclick = function() {self.apply();}
 
-    dialog.getElementById('cancel').onclick = function() { self.dialog.hide()};
+    dialog.getElementById('cancel').onclick = function() {
+          dialog.getElementById('f_selectable').options.selectedIndex = 0;
+          dialog.getElementById('f_url').value = '';
+          dialog.getElementById('ipreview').src = '';
+          self.dialog.hide();
+        }
 
-    dialog.getElementById('preview').onclick = function() { 
-      var f_url = dialog.getElementById("f_url");
+    dialog.getElementById('f_selectable').onchange = function() {
+          var f_url = dialog.getElementById('f_url');
+
+          if (dialog.getElementById('f_selectable').options.selectedIndex > 0) {
+             var f_selectable = dialog.getElementById('f_selectable').options[dialog.getElementById('f_selectable').options.selectedIndex];
+             f_url.value = f_selectable.value;
+          } else {
+             f_url.value = '';
+             dialog.getElementById('ipreview').src = '';
+          }
+        }
+
+        // Populate the f_selectable selection list
+        for (var i=0; i<editor.config.selectableImages.length; i++) {
+          var text = editor.config.selectableImages[i][0];
+          var value = editor.config.selectableImages[i][1];
+          // preserve option 0 of the select list (the nothing selected option)
+          dialog.getElementById('f_selectable').options[i+1] = new Option(text, value);
+        }
+
+    dialog.getElementById('preview').onclick = function() {
+      var f_url = dialog.getElementById('f_url');
       var url = f_url.value;
 
       if (!url) {
         alert(dialog._lc("You must enter the URL"));
         f_url.focus();
-        return false;
-      }
-      dialog.getElementById('ipreview').src = url;
+            return false;
+          }
+
+          dialog.getElementById('ipreview').src = url;
       return false;
     }
+
     this.dialog.onresize = function ()
   {
         var newHeightForPreview = 
Index: modules/InsertImage/dialog.html
===================================================================
--- modules/InsertImage/dialog.html    (revision 1190)
+++ modules/InsertImage/dialog.html    (working copy)
@@ -5,6 +5,14 @@
   <tbody>
 
   <tr>
+    <td style="width: 7em; text-align: right"><l10n>Attachments:</l10n></td>
+    <td>
+      <select size="1" name="[f_selectable]" id="[f_selectable]" style="width:75%" title="_(Select an attached image here)" />
+        <option value="0"><l10n>-- no attachments are selected --</l10n></option>
+      </select>
+    </td>
+  </tr>
+  <tr>
     <td style="width: 7em; text-align: right"><l10n>Image URL:</l10n></td>
     <td><input type="text" name="[f_url]" id="[f_url]" style="width:75%"
       title="_(Enter the image URL here)" />
@@ -80,4 +88,4 @@
 <div class="buttons" id="[buttons]">
   <input type="button" id="[ok]"     value="_(OK)"     />
   <input type="button" id="[cancel]" value="_(Cancel)" />
-</div>
\ No newline at end of file
+</div>

Offline


Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/xinha/public_html/r.f/include/parser.php on line 774

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/xinha/public_html/r.f/include/parser.php on line 774

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/xinha/public_html/r.f/include/parser.php on line 774

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/xinha/public_html/r.f/include/parser.php on line 774

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/xinha/public_html/r.f/include/parser.php on line 774

#2 2009-07-20 04:28:16

ray
Xinha Administrator
From: Germany
Registered: 2005-03-23
Posts: 521
Website

Re: PATCH: InsertImage selection dropdown for inline attachments

Hi Alex,
thanks for your contribution. I have openend a ticket for this here http://xinha.webfactional.com/ticket/1453

Offline


Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/xinha/public_html/r.f/include/parser.php on line 774

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/xinha/public_html/r.f/include/parser.php on line 774

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/xinha/public_html/r.f/include/parser.php on line 774

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/xinha/public_html/r.f/include/parser.php on line 774

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/xinha/public_html/r.f/include/parser.php on line 774

#3 2009-07-20 10:40:44

ateslik
Xinha Community Member
Registered: 2009-07-16
Posts: 33

Re: PATCH: InsertImage selection dropdown for inline attachments

Thanks ray,

    inclusion would be ideal and would allow me to merge xinha into the OpenWebMail trunk via an svn:external. You can read about our project at our homepage: http://openwebmail.acatysmoof.com.

Thanks,
Alex

Offline

#4 2009-07-27 13:42:05

ateslik
Xinha Community Member
Registered: 2009-07-16
Posts: 33

Re: PATCH: InsertImage selection dropdown for inline attachments

Hi ray,

   What is the normal waiting period for a patch to be applied? Are there criteria for a patch to get applied? Please let me know if you need anything else from me.

Thanks,
Alex

Offline

#5 2010-01-12 22:22:59

ateslik
Xinha Community Member
Registered: 2009-07-16
Posts: 33

Re: PATCH: InsertImage selection dropdown for inline attachments

whoops - didn't see the update to the ticket. Thanks gogo. I'll see about modifying the patch per the suggestions.

Offline


Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/xinha/public_html/r.f/include/parser.php on line 774

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/xinha/public_html/r.f/include/parser.php on line 774

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/xinha/public_html/r.f/include/parser.php on line 774

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/xinha/public_html/r.f/include/parser.php on line 774

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/xinha/public_html/r.f/include/parser.php on line 774

#6 2010-08-17 20:53:44

winechristmas
New member
From: Canada
Registered: 2010-08-17
Posts: 1

Re: PATCH: InsertImage selection dropdown for inline attachments

Thanks ray for the patch file. What can i do if the normal time period is passed to apply a patch?

Melbourne electricians

Last edited by winechristmas (2011-09-28 23:02:47)

Offline

#7 2010-08-21 05:32:36

expressskiphire
New member
From: Canada
Registered: 2010-08-21
Posts: 1
Website

Re: PATCH: InsertImage selection dropdown for inline attachments

Using the basic 'Insert/Edit Image' button creates an HTML <img src=....> item into the TinyMCE window. You have to specify the full URL to the image file. Is it possible to default part of the URL so that you only have to specify the image file name? IE:
Instead of entering the URL "page_images/uploads/image.jpg", could the "page_images/uploads/" part be defaulted or preset somewhere so that the user just enters the filename.jpg part?
All of my images are in the same dir - but I want to save keying the full path each time if possible.

Any suggestions welcome. Thank you.

Offline

#8 2010-08-21 07:37:15

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: PATCH: InsertImage selection dropdown for inline attachments

This is not a forum about TinyMCE, go ask them if you are using TinyMCE

IUf you are using Xinha, the answer is no, not in Xinha, you would have to write a Xinha plugin or do it server-side.


James Sleeman

Offline


Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/xinha/public_html/r.f/include/parser.php on line 774

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/xinha/public_html/r.f/include/parser.php on line 774

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/xinha/public_html/r.f/include/parser.php on line 774

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/xinha/public_html/r.f/include/parser.php on line 774

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/xinha/public_html/r.f/include/parser.php on line 774

#9 2010-12-25 04:16:13

ChrisBrad51
New member
Registered: 2010-07-22
Posts: 2

Re: PATCH: InsertImage selection dropdown for inline attachments

@ray...you did a good job and also thanks for the link of inline attachments file.



                word problems
               
                thesis writing

Last edited by ChrisBrad51 (2010-12-26 16:48:52)

Offline

Board footer

Powered by FluxBB