Re: fckeditor and PDF and pesky users

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Richard Lynch said the following on Monday, October 17, 2005 3:30 PM:
On Fri, October 14, 2005 6:03 pm, Jason Kovacs wrote:
Richard Lynch said the following on Friday, October 14, 2005 3:39 PM:

I added a custom drop-down menu to FCKEditor's Link window that fills
in the URL upon selecting the menu item, but this url consisted of
just a
path to a redirect.php script where I set a GET variable to the ID of
the
document, then passing through the PDF or DOC data.  Though you could
link the full path to the PDF in the URL, I just had my documents
stored
behind the web-accessible address.  Every time a new document was
uploaded, I decided to write the URL's statically to a file that the
FCKEditor script (changed fck_link.html to fck_link.php) will read
into
Javascript arrays, as opposed to accessing the DB every time this Link
window was viewed.  I added about 50 lines of Javascript code to
fck_link.php to do what I wanted in setting the URL from the Select
list.

Sweet!

I must warn you though, every time that I upgrade FCKEditor, I have to
reapply the changes I've done and there is the possibility that the
FCKEditor scripts may change to cause compatibility problems.  Let me
know if you are interested in this route and I can post my alterations
to
FCKEditor,

Please do!

but the PDF file management is up to you.

Oh yeah.  That's for sure.

I've had many
non-technical users working with this utility just fine for about 6
months,
so it works and though its not the most graceful implementation from a
developer's standpoint, it makes the user interface easiest to work
with.

It certainly sounds like a very good solution.

Be really nifty if fckEditor folks took a look at it and considered
adding it as a feature.

We can't be the only ones needing this kind of thing.

Here's my changes to FCKEditor, and it works on version 2.0 RC3, but should
work for other later versions too unless drastic changes have been made by
it's developers to the affected scripts.   I tried to clean it up for you as
much as possible and took out my customizations using doc ID's and broadened
it to use string URL's, which you'll need to write along with the doc
entry's Title to a static JS file that gets read by FCKEditor (using php).
The code also handles grouping uploaded documents into 1-level-deep groups,
so this is something you'll have to keep track of in your upload utility.
If that's not something you need or can easily figure out, just take out the
JS code that deals with Option Groups and flatten the document data array.

FCKEditor Customization Notes for linking Documents
---------------------------------------------------
By Jason Kovacs - 2005-05-04

1. Install the FCKeditor utility to /path/to/public_html/js/FCKeditor/.

2. The directory /path/to/public_html/js/data/ must be created and have
permissions of 777.

3. Set up the Document Upload utility to write static data to the file
/path/to/public_html/js/data/fck_link_docdata.js
  with the following structure:
---
var documentGroups = ["Group 1","Group 2"];
var documentData =
[
[
 ["Doc Title 1","URL"],
 ["Doc Title 2","URL"]
],
[
 ["Doc Title 1","URL"],
 ["Doc Title 2","URL"]
]
];
---

4. Rename ./js/FCKeditor/editor/dialog/fck_link.html to fck_link.php and
Edit it to have these changes:

4a. Below <meta name="robots" content="noindex, nofollow" />, insert:
<SCRIPT Language="JavaScript"><!-- <?
@readfile("/path/to/public_html/js/data/fck_link_docdata.js");
?>
//--></SCRIPT>

4b. Insert the following two Table rows above the <tr> for "Protocol":
    <tr>
     <td nowrap="nowrap" colspan=3>
      <span fckLang="DlgLnkDocument">Documents</span><br />
      <select style="WIDTH: 100%" id="cmbLinkDocument"
onchange="SetDocumentUrl(this.value);">
                                                        <option
value=0>Select a Document File</option>
      </select>
     </td>
    </tr>

5. Edit ./js/FCKeditor/editor/dialog/fck_link/fck_link.html to have these
changes:

5a. Add these lines after "LoadSelection() ;" in the window.onload
function() call:
// Load the Documents select menu with optgroups/options from the included
data arrays.
LoadDocumentData() ;

5b. Before the SetLinkType function, add the following:

function LoadDocumentData()
{
var sUrl = GetE('txtUrl').value;
var docSelectObj = GetE('cmbLinkDocument');
for(var i=0; i < documentGroups.length; i++)
{
 optGroup = document.createElement('optgroup');
 optGroup.label = documentGroups[i];
 docSelectObj.appendChild(optGroup);
 for(var j=0; j < documentData[i].length; j++)
 {
  var objOption = document.createElement("option");
  objOption.innerHTML = documentData[i][j][0];
  objOption.value = documentData[i][j][1];
  if(objOption.value == sUrl) objOption.selected = true;
                       optGroup.appendChild(objOption);
 }
}
}

5c. Change the line in the function SetLinkType from:
window.parent.SetTabVisibility( 'Advanced' , (linkType != 'anchor' ||
bHasAnchors) ) ;
   To the line:
window.parent.SetTabVisibility( 'Advanced' , false ) ;

5d. Change the line in the function OnUrlChange from:
var sProtocol = oRegex.UrlOnChangeProtocol.exec( sUrl ) ;
   To the lines:
var sProtocol = oRegex.UrlOnChangeProtocol.exec( "" ) ; // force change
protocol
sProtocol = oRegex.UrlOnChangeProtocol.exec( sUrl ) ;

5e. Add the following function after SetUrl at the end of the file:

function SetDocumentUrl( url )
{
if(url=="")
{
 SetUrl("");
 SetTarget(""); OnTargetNameChange();
}
else
{
 SetUrl( url );
 SetTarget("_blank"); OnTargetNameChange();
 var pageSelectObj = GetE('cmbLinkContentPage');
 pageSelectObj.selectedIndex = 0;
}
}

6. Alter ./js/FCKeditor/editor/js/fckeditorcode_ie_2.js where fck_link.html
is used and change it to fck_link.php .

This should be a good base for you to work with, but make customizations to
get to work for your needs, and obviously change the paths where necessary.
Hope it helps you and others.

-Jason Kovacs

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux