[geeklog-devel] Static Pages Plugin and advanced editor
Samuel Leathers
sam at theleathers.net
Fri Apr 30 11:45:46 EDT 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Thanks Mark for your reply. Just what I was looking for. Figure now was
a good time to test my wings and fly, so here's a more elegant patch
I've attached. Please look it over when you get the chance and give me
any feedback regarding coding style or functionality.
Sam
On 4/30/10 11:14 AM, Mark Howard wrote:
> Hi Sam -
>
> Sure. The file you're looking for is
> public_html/admin/plugins/staticpages/index.php.
>
> The function names have changed in 1.2.0, but in 1.1.8, the function
> we're interested was called form(), i can be found on line 63. This
> function is called from staticpageeditor() which is on line 451.
> staticpageeditor() is what figures out whether you're creating a new
> form or not, and if it's a new form, it sets a bunch of the array values
> to initial/default values.
>
> When you're creating a new staticpage, the $A array is passed containing
> an 'default' set of values. The field in the gl_staticpages table that
> we want to control is called 'postmode'. staticpageeditor() looks like
> it takes an optional 3rd parameter which allows you to specify that
> ($editor = ''), and it also looks like there is an associative array
> variable called $A['editor'] that is set to that value, however it
> doesn't look like form() is doing anything with it.
>
> Therefore - what you have here is I believe a bug. Here's a patch you
> can try until we fix this elegantly:
>
> In staticpageeditor(), in the second part of the 'if' statement, try
> hard-forcing the value of $A['postmode'] like this:
>
> function staticpageeditor ($sp_id, $mode = '', $editor = '')
> {
> global $_CONF, $_TABLES, $_USER;
>
> if (!empty ($sp_id) && $mode == 'edit') {
> $result = DB_query ("SELECT *,UNIX_TIMESTAMP(sp_date) AS
> unixdate FROM {$_TABLES['staticpage']} WHERE sp_id = '$sp_id'" .
> COM_getPermSQL ('AND', 0, 3));
> $A = DB_fetchArray ($result);
> $A['sp_old_id'] = $A['sp_id'];
> } elseif ($mode == 'edit') {
> $A['sp_id'] = COM_makesid ();
> $A['sp_uid'] = $_USER['uid'];
> $A['unixdate'] = time ();
> $A['sp_help'] = '';
> $A['sp_old_id'] = '';
> $A['commentcode'] = $_CONF['comment_code'];
> $A['sp_where'] = 1; // default new pages to "top of page"
> $A['sp_search'] = 1;
> $A['postmode'] = 'adveditor'; // <===========================
> this is the line to add
> } elseif (!empty ($sp_id) && $mode == 'clone') {
> $result = DB_query ("SELECT *,UNIX_TIMESTAMP(sp_date) AS
> unixdate FROM {$_TABLES['staticpage']} WHERE sp_id = '$sp_id'" .
> COM_getPermSQL ('AND', 0, 3));
> $A = DB_fetchArray ($result);
> $A['sp_id'] = COM_makesid ();
> $sp_id = $A['sp_id'];
> $A['sp_uid'] = $_USER['uid'];
> $A['unixdate'] = time ();
> $A['sp_hits'] = 0;
> $A['sp_old_id'] = '';
> } else {
> $A = $_POST;
> if (empty ($A['unixdate'])) {
> $A['unixdate'] = time ();
> }
> $A['sp_content'] = COM_checkHTML (COM_checkWords
> ($A['sp_content']));
> }
> if (isset ($A['sp_title'])) {
> $A['sp_title'] = strip_tags ($A['sp_title']);
> }
> $A['editor'] = $editor;
>
> return form ($A);
>
> Samuel Leathers wrote:
> I'm not sure if this is a bug, by design or something missing in my
> configuration. When I create a new static page, it defaults to a Post
> Mode of HTML formatted, rather than looking at the value of
> advanced_editor in the gl_userprefs SQL table. A story on the other
> hand, correctly looks at the gl_userprefs, and displays the FCK editor
> by default for users that have it checked in their preferences.
>
> I've been poking around in plugins/staticpages as well as
> public_html/staticpages/index.php, trying to find where it's deciding
> the selected value for Post Mode. When you edit a page that's already
> been set to advanced editor, it pulls up the FCK editor by default, so
> somewhere in the page it must be doing a query of the content of that
> page in the database to determine what Post Mode to set. If I could find
> that part of the code, it would be fairly easy to modify the query, if
> it's a new page to look ato the gl_userprefs to get a default value.
>
> Can someone give me some guidance that's worked with the staticpages
> plugin before? I'm at a loss at this point.
>
> Sam
_______________________________________________
geeklog-devel mailing list
geeklog-devel at lists.geeklog.net
http://eight.pairlist.net/mailman/listinfo/geeklog-devel
> --
> -m
> "Ideas are like rabbits. You get a couple and learn how to handle them,
> and pretty soon you have a dozen." --John Steinbeck (1902-1968)
> _______________________________________________
> geeklog-devel mailing list
> geeklog-devel at lists.geeklog.net
> http://eight.pairlist.net/mailman/listinfo/geeklog-devel
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.13 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQEcBAEBAgAGBQJL2vsqAAoJEF7J+Z7XDXx/UukIAJ2nMJpAsBQ/4UEN8dbVwNhB
9SpoeK1wL94/HfQCUjODKLEk2PWaoBH+FF4XzgiDg1OiZAh7GaYaaQTayAx8BgZm
D6iTfPovkpfTvkAFumpzfDoX1WI4skOK5hPvlgOaROZsyR3Y1XlIQq+k0p70ecrT
FBK6LnJjresIpRJdcWgoJMo3oQdc/LV1LRSyObMO7djkTjXmimD5MeV+7cLUShbt
kPKgOSscdoS7opL/deG+C81hTmTkeBvE12ZYuxlt5GgE6DjpjmQATek3/qJNuOKs
vky5/zxB55qaS7kkRroReudR2qE4wm1/Lb2luwGP9TVRF5LRBr6dXblyoicFH2w=
=qaR8
-----END PGP SIGNATURE-----
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: adv_edit.patch
URL: <https://pairlist8.pair.net/pipermail/geeklog-devel/attachments/20100430/b6565c82/attachment.ksh>
More information about the geeklog-devel
mailing list