MCImageManager

Questions about Jaws plugins for text parsing

MCImageManager

Postby simen on Tue Sep 22, 2009 1:01 pm

Hello, will MCImageManager be implemented soon? Would be great and make uploading images much easier.
simen
 
Posts: 5
Joined: Wed Apr 29, 2009 12:16 am

Re: MCImageManager

Postby simen on Thu Oct 15, 2009 1:24 am

I might be a stupid noob, I didn't notice that MCImageManager costed money. But I'm not lazy, so I made a "image upload" functionality kinda. I integrated Phoo into TinyMCE. And a very dirty integration to.

Here is the way I did it, use at your own risk.

First, the three steps needed:

  • Upload image_list.php to jaws_root/libraries/tinymce/
  • Change the variable $album (image_list.php) to the album you want to use in Phoo
  • In jaws_root/include/Jaws/Widgets/TinyMCE.php change:

    $this->_XHTML.= "plugins : '{$plugins}',\n";

    To:

    $this->_XHTML.= "plugins : '{$plugins}',\n";
    $this->_XHTML.= "external_image_list_url : './libraries/tinymce/image_list.php',\n";

And here is image_list.php
Code: Select all
<?php
$album="tinymce"; // Album name

//// QUERYING START
include("../../config/JawsConfig.php");
$prefix=$db['prefix'];

$link=connect($db['host'], $db['name'], $db['user'], $db['password']);
mysql_set_charset($db['charset'],$link);

$select[]="SELECT i.filename, i.title FROM ".$prefix."phoo_image i, (".
"SELECT ia.phoo_image_id ".
"FROM ".$prefix."phoo_album a, ".$prefix."phoo_image_album ia ".
"WHERE a.name = '".$album."' AND a.id=ia.phoo_album_id) ia ".
"WHERE i.id=ia.phoo_image_id";

$array=fetch(query($select));
$arrayL=count($array['filename']);
$filelist="var tinyMCEImageList = new Array(\n\t// Name, URL";

for($i=0; $i < $arrayL; $i++) {
   $filelist.="\n\t[\"".$array['title'][$i]."\",\"".$array['filename'][$i]."\"]";
   
   if($i < $arrayL-1) {$filelist.=",";}
}
$filelist.="\n);";

close();
//// QUERYING END

header('Content-type: text/javascript');
echo $filelist;

//// FUNCTIONS START
function connect($host, $db, $user, $password) {
   $link = mysql_connect($host, $user, $password);
   if (!$link) {
      die('Could not connect: '.mysql_error());
   }
   
   $db_selected = mysql_select_db($db, $link);
   if (!$db_selected) {
      die ('Can\'t use dota : '.mysql_error());
   }
   return $link;
}

function query($query, $output=false) {
   foreach($query as $q) {
      $result = mysql_query($q);
      if (!$result) {
         die('Invalid query: '.mysql_error()."\n$q\n");
      }
      else {
         if ($output==true) { echo $q, "\nsuccessful\n"; }
      }
   }
   return $result;
}

function fetch($result) {
   while ($rows = mysql_fetch_assoc($result)) {
      foreach($rows as $key=>$row) {
         $return[$key][]=$row;
      }
   }
   if (isset($return)) { return $return;}
   else { $return=array(); return $return; }
}

function close($link) {
   mysql_close($link);
}
//// FUNCTIONS END
?>
simen
 
Posts: 5
Joined: Wed Apr 29, 2009 12:16 am


Return to Plugins

Who is online

Users browsing this forum: No registered users and 1 guest

cron