Avatar of theclay
theclay

asked on 

PHP to create Java array (tinymce image list)

I'm using tinymce do do some wysiwyg editing on my site.  To insert images it displays a drop down list of images which I need to propagate with all the images in a given image directory.

Here's the code in the main script:
"external_image_list_url : tinymce/lists/link_list.js"

And here's link_list.js:

var tinyMCEImageList = new Array(
      // Name, URL
      ["Logo 1", "media/logo.jpg"],
      ["Logo 2 Over", "media/logo_over.jpg"]
);

Now I need that array to show all the files in the images/dogs directory.  Here's the PHP code I'd want to run there:

function getfiles($dirname=".") {
$pattern="(\.jpg$)|(\.png$)|(\.jpeg$)|(\.gif$)"; //valid image extensions
$files = array();
if($handle = opendir($dirname)) {
   while(false !== ($file = readdir($handle))){
      if(eregi($pattern, $file)) //if this file is a valid image
         echo "$file <br />";
   }
 closedir($handle);
}
return($files);
}

How do I get the two to work together?

Hope the question makes sense
PHPJSP

Avatar of undefined
Last Comment
theclay
ASKER CERTIFIED SOLUTION
Avatar of moty66
moty66

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of theclay
theclay

ASKER

Thanks.  Took a wee bit of tweeking but it works well now.  I'm not 100% sure, but it seems JScript likes the values to be enclosed in double quotes, so I used something like $buffer .= '["'.$value.'", "'.$mydir.'/'.$value.'"],'."\n"
PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo