Page 1 of 1

$_SESSION["tiny_live_textareas"] holding duplicates?

Posted: Thu Feb 28, 2008 5:09 pm
by roadfever
Apologies for the length/complication here!

I have a user-defined tag that creates tinyMCE text areas in some forms that also contain some regular textareas.  In 1.2.3, after the first time you load the page, you get one more instance of each WYSIWYG text area with each load.  This persists until you clear browser cookies or jump between major areas of the admin interface (re-loading pages in Content doesn't clear it up, but browsing the Extensions pages might.)

The page source HTML only contains one textarea tag, but the  tinyMCE.init call provided by tinyconfig.php contains duplicate names in the 'elements:' list, causing some Ajax code to create multiple textareas.

The code in tinyconfig.php that I thought should re-initialize $_SESSION["tiny_live_textareas"] has been commented out (on or about line 56) as has the code in TinyMCE.module.php around line 128.  The code in WYSIWYGTextarea() that builds the list does not chek for duplicates (line 87).

HOWEVER, the rest of the system doesn't have duplicate textareas popping up, so there must be some way that $_SESSION["tiny_live_textareas"] is re-initialized.  Could someone please clue me in on how $_SESSION["tiny_live_textareas"] should be initialzed/cleared?

Code of my tag with a hack to uniquify the variable is below for reference.  Thanks!

global $gCms;
$obj = new stdClass();
$name = $params['name'];
$columns = 80;
$rows = 15;
//echo "\n";
foreach($gCms->modules as $key=> $value)
{
  if ($gCms->modules[$key]['object']->GetName() == "TinyMCE")
  {
      $obj = $gCms->modules[$key]['object'];
      $obj->wysiwygactive=true;
  //    echo "\n";
      echo $obj->WYSIWYGTextarea($name,$columns,$rows,'',$params ['content']);
      break;
    }
}
//echo "\n";
if (isset($_SESSION["tiny_live_textareas"]) && !($_SESSION["tiny_live_textareas"]==''))
{
  $areas = Array();
  $areas = explode(',', $_SESSION["tiny_live_textareas"]);
  $areas =array_unique($areas);
  $_SESSION["tiny_live_textareas"] = implode(',',$areas);
}
//echo "\n";