GetSimple Support Forum

Full Version: Edit page - Insert Image - Combo box with images
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Good day
------------

GS Version : 2.01 (stable downloaded)
Code changed : admin/edit.php
From Line : 304

I dont really know where to put this, but wanted to share as I hope it can help someone. is not really a plugin but enhancement of GS. I made a plugin for CKEditor to allow a combo box with all the image names in the uploads folder to be selectable and when you select them the correct url is added automatically for you to the URL at the top and image become viewable. I also added my edit.php file to the post for those that want to take a look.

Code:
<script type="text/javascript">
    //<![CDATA[

// Added GS image files to be selectable via the image insert system.
// Author : Dominion IT
// url : www.dominion-it.co.za
CKEDITOR.on( 'dialogDefinition', function( ev )
    {
        var dialogName = ev.data.name;
        var dialogDefinition = ev.data.definition;
        
        if ( dialogName == 'image' ) {
            var infoTab = dialogDefinition.getContents( 'info' );
            var dlg = dialogDefinition.dialog;

            //Add the combo box
            infoTab.add( {
                    id : 'cmbGSImages',
                    type : 'select',
                    labelLayout : 'horizontal',
                    widths : [ '35%','85%' ],
                    style : 'width:90px',
                    label : 'Uploaded Images ',
                    'default' : '',
                    items :
                    [  
                        [ 'Custom' , 'CUSTOM']
    
                       <?php
                            $path = GSDATAUPLOADPATH;
                            $filenames = getFiles($path);
                            if (count($filenames) != 0) {
                                foreach ($filenames as $file) {
                                    if ($file == "." || $file == ".." || is_dir($path . $file) || $file == ".htaccess") {
                                        // not a upload file
                                    } else {
                                        $ext = substr($file, strrpos($file, '.') + 1);
                                        $extention = get_FileType($ext);
                                        if (strtolower($ext) == 'gif' || strtolower($ext) == 'jpg' || strtolower($ext) == 'jpeg' || strtolower($ext) == 'png') {
                                            $URLtothefile = $SITEURL."/data/uploads/$file";
                                            echo ",[ '$file' , '$URLtothefile']";
                                        }
                                    }
                                }
                            }
                       ?>
                        
                    ],
                    onChange : function() {
                      var cmbValue = this.getValue();
                      if (cmbValue != 'CUSTOM') {
                        dlg.setValueOf( 'info', 'txtUrl', cmbValue );
                      }  
                    }

                });

        }        
    });

    //]]>
    </script>

Hope it can help somebody

Dominion IT

www.dominion-it.co.za
Hi there.. Sorry, I noted I still had part of testing code there.. cleaned it up must look as follows now
(my edit.php file is included also)

Code:
<script type="text/javascript">
    //<![CDATA[

// Added GS image files to be selectable via the image insert system.
// Author : Dominion IT
// url : www.dominion-it.co.za
CKEDITOR.on( 'dialogDefinition', function( ev )
    {
        var dialogName = ev.data.name;
        var dialogDefinition = ev.data.definition;
        
        if ( dialogName == 'image' ) {
            var infoTab = dialogDefinition.getContents( 'info' );
            var dlg = dialogDefinition.dialog;

            //Add the combo box
            infoTab.add( {
                    id : 'cmbGSImages',
                    type : 'select',
                    labelLayout : 'horizontal',
                    widths : [ '35%','85%' ],
                    style : 'width:90px',
                    label : 'Uploaded Images ',
                    'default' : '',
                    items :
                    [  
                        [ 'Custom' , 'CUSTOM']
    
                       <?php
                            $path = GSDATAUPLOADPATH;
                            $filenames = getFiles($path);
                            if (count($filenames) != 0) {
                                foreach ($filenames as $file) {
                                    if ($file == "." || $file == ".." || is_dir($path . $file) || $file == ".htaccess") {
                                        // not a upload file
                                    } else {
                                        $ext = substr($file, strrpos($file, '.') + 1);
                                        if (strtolower($ext) == 'gif' || strtolower($ext) == 'jpg' || strtolower($ext) == 'jpeg' || strtolower($ext) == 'png') {
                                            $URLtothefile = $SITEURL."/data/uploads/$file";
                                            echo ",[ '$file' , '$URLtothefile']";
                                        }
                                    }
                                }
                            }
                       ?>
                        
                    ],
                    onChange : function() {
                      var cmbValue = this.getValue();
                      if (cmbValue != 'CUSTOM') {
                        dlg.setValueOf( 'info', 'txtUrl', cmbValue );
                      }  
                    }

                });

        }        
    });

    //]]>
    </script>
Hi there.

Added small bug fix with the url had double // in them.

Also added custom links to the links dialog box as in this post

http://get-simple.info/forum/viewtopic.php?id=1049

Hope it can help somebody..
(File is attached to this post)
Hi there
-0=0-=0-=

Hopefully last updated.

I added a selection box for Thumbnails and the smaller version of the images also. Thus you can select all 3 versions of the image that is automatically available from one place now.

Attached my admin/edit.php file to post

Hope it can help
Hi there.

Here is image of what the new insert image dialog looks like

[Image: beeld_in_page_4.jpg]
dominionit Wrote:Hi there.

Here is image of what the new insert image dialog looks like

[Image: beeld_in_page_4.jpg]

Very nice! One of the most customer-friendly enhancements I´ve seen. Only one thing: You have to save the page between each inserted image, or the image-button won´t work.

Great one! Erix1
Thanks, will look into it.., just game back from week away.. just have to catchup on stuff first..tx
erix1 Wrote:
dominionit Wrote:Hi there.

Here is image of what the new insert image dialog looks like

Very nice! One of the most customer-friendly enhancements I´ve seen. Only one thing: You have to save the page between each inserted image, or the image-button won´t work.

Great one! Erix1

Hi there.

K I fixed the problem. Could not believe what it was Big Grin but at least it is fixed. had to force all combo boxes back to Custom after all selects else it had error creating new box. But all are working and fixed now.

thanks, hope it helps. let me know if there is any other issues.
Hi there.

Made a version for GS v2.03.

works without issue that I could see. say if you find anything

thanks