You are not logged in.
Pages: 1
I wanted a full and compact version of xinha that would work in various levels of directories and keep my style sheets but did not want to have seperate js files for each one. (I have one editor page that gets included in various places)
The solution:
rename htmlarea.js to htmlarea.php
in the very first line (no whitespace or line feeds) put this in htmlarea.php.
<?php
header('Content-Type: text/javascript');
?>
then search for root.target
replace
<?' + root.target + ' ' + root.data + '?>
with
<?echo '<?' + root.target + ' ' + root.data + '?>'; ?>
this will serve it as a .js file and now we have a smarter javascript.
Now in the "included" php page that calls the javascript you can use this.
To get $filepath I use this which looks for a specific file (keyfile.htm) that is only found in www dir.
if (file_exists("keyfile.htm")) {
$filepath = "."; }
elseif (file_exists("../keyfile.htm")){
$filepath = ".."; }
elseif (file_exists("../../keyfile.htm")){
$filepath = "../.."; }
// etc...
<!-- Load up the actual editor core -->
// ========= I changed this line as it was what I used in htmlarea =====
// this uses $filepath to find the javascript file and passes the $filepath to the javascript php file
<script language="Javascript1.2" type="text/javascript" src="<? echo $filepath ?>/editor/htmlarea.php?filepath=<? echo $filepath?>&editor=compact "></script>
here is the cool part - you can use the $filepath to insure you always get your htmlarea.php file and stylesheet from htmlarea.php.
this.pageStyle = "<?echo $filepath?>/style/elements.php?editor";
this.pageStyleSheets = [<?echo $filepath?>/style/elements.php?editor];
Note : I also use php for my style sheets since browsers cach by mimetype - I wanted the same css features for the editor as my web pages use but just needed a few things changed. this way I can use the ?editor and then from the stylesheet I can see what $_querystring contains and make those css changes via php.
Use this for the first line in the stylesheet.
<?php
header("Content-type: text/css");
?>
Now you have "smart" stylesheets.
Likewise you can look to see what $editor equals in htmlarea.php, full or compact, and just serve the features you want for those pages.
Having a php stylesheet has advantages. you can now have a config section at the top where you can set link colors, layout properties etc.
$rightwidth = '150px';
$rightbkg = 'blue';
Also you can disable certain plugins with a link on the editor.php page.
<a href="editor.php?disableInsertMarquee">Disable Marquee</a>
then
xinha_plugins = xinha_plugins ? xinha_plugins :
[
'CharacterMap',
'FullScreen',
'ImageManager',
'<? if($_QUERYSTRING == "disableInsertMarquee"){}
else {echo'InsertMarquee';}?>',
'HorizontalRule',
'InsertAnchor',
'Linker',
'ListType',
'SaveSubmit',
'SpellChecker',
'TableOperations'
];
When the editor loads the marquee will not be available and you can also add features the same way . . . . even use a form with multple check boxes for features.
Now you have a one size that fits all "smart" editor.
Hope this helps someone . . . .
Regards
Loren
Offline
What about caching mechanisms ? With this *trick*, users are forced to reload over and over the same (heavy) piece of javascript without any caching mechanisms available. Not very bandwitdh friendly.
Offline
They only load 2 versions of the javascript, full and compact . . . It should get cached . . . . Browsers should cach by mime type so in essence there are only two versions. I use this all the time and the first go round it is a bit slow but after that its rather quick. So I assume that it is being cached.
Also you can add this to the .htaccess file which seems to further speed things up.
php_flag zlib.output_compression on
php_value zlib.output_compression_level 9
regards
Loren
Offline
Pages: 1