hi,
i have done a whole lot of changes to your cool little module, atm i am veeery tired so reaaally sorry i am not splitting this up into several patches but just attach my current version.. a good visual diff comparision tool very helpful for patch reviewing is kdiff3 by the way ;)
cheers!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

eMPee584’s picture

doh i forgot to run this through the coder module... a million little fibers *g
yeah well i'll upload a version with those fixes applied aswell after dinner..

Agileware’s picture

Title: implement hooks to replace page/block titles, fix php errors, misc cleanup, font/style preview » Looks good

Thanks for the code, it looks good.

We'll roll it into the 6 version shortly.

eMPee584’s picture

Title: Looks good » further changes...
FileSize
10.54 KB

All coder warnings fixed. There have been evasive changes to the module! Further comments later gotta run. It worx properly on hfopi.org.

eMPee584’s picture

Ok here's a summary of the changes to the current signwriter version:

coder warnings fixed:
- added @file description to signwriter.install.
- Implementation of hook_foo(). function header standardization.
- all true/false/null constants CAPITALIZED.
- security warnings: remove variables from SQL statements.
- string functions replaced by drupal's own.
- some indention style fixes for consistency.

real code changes:
- removal of wrapper function signwriter_profile_page(), receive form directly via drupal_get_form().
- rename _signwriter_profile_submit() to signwriter_profile_form_submit() and _signwriter_profile_validate() to signwriter_profile_form_validate() so they get automatically called for validation and submittal.
- same for signwriter_confirm_delete_profile_page().
- make internally called functions signwriter_delete_profile() accept profile object only.
- consequently remove _signwriter_profile_whereclause() and put this detection into signwriter_load_profile().
- move jpeg/jpg synonym to signwriter_available_image_types().
- add subdirectory '/fonts' to theme and files path searched.
- move default cache directory to files dir.
- rename theme_signwriter_text_convert() to theme_signwriter_text().
- text is now a destinct parameter, not part of the signwriter profile.
- make theme_signwriter_text() use image_theme, and take attributes, set proper alt/tooltip text on image
- fix php warning in signwriter_title_convert() (case of no end tag lead to matches[3] not being set, now always is because end of line is put in matches[4]).
- rename variable $signwriter to $profile in theme_signwriter_text().
- rename global variables to include module name.
- add preprocess_page and preprocess_block hooks and correspondent settings to directly replace block/page titles via theme flow.
- add cron hook to clear all generated image files once a week.
- filename generation: name starts with trimmed version of text, then md5 of text + serialized profile, then string 'signwriter' to unambigiously identify them (needed for safe clean up).
- existing profiles are shown as previews in table and in selection for block/page hook.
- found fonts are shown as previews in a radio group (with current style)
- add update function to delete old variables, clear caches and rebuild menus

i think that's all ;)
patch is attached.

Agileware’s picture

add cron hook to clear all generated image files once a week.

Might want to have an option to enable/disable this feature as it could cause a lot of overhead for large websites (10,000+ nodes). Or make it a little bit smarter...

Agileware’s picture

Title: further changes... » implement hooks to replace page/block titles, font/style preview, coder style
eMPee584’s picture

Yeah well smartness, that's a slight problem: the code would need to keep track of which images are still valid.. I'd say even for large sites this is quite sufficient as generating that image probably takes as much cpu cycles as building the surrounding page, and both being cached after the first access. That's why i left it that simple. You can check out how fast GD generates the images easily: drop a couple 'hundred fonts into one of the looked paths - and go to the add profile page! heck i'm doing that right now ;)

eMPee584’s picture

ha well check this out:

Generated 330 previews in 3.24603509903 seconds.

Just measured with some random fonts, doesn't look like too bad of a bottleneck.. :)

eMPee584’s picture

ok well i found several errors testing this, updated patch will follow soon.

eMPee584’s picture

wow there still was much to be done :O

- _signwriter_db_fields() now returns integer, string or all fields
- fixed profile saving, f.e. to correctly handle cleared form fields (required schema changes: disable NOT NULL on some fields)
- make update function change table according to updated schema
- fixed profile deletion
- added profile name to edit page titles
- fixed _signwriter_get_val to not throw php error on every undefined variable and use it instead of the left empty/is_null checks
- various small clean ups, string changes and indention fixes
- removed paragraph tags around table and form
- remove unnecessary theme call from settings_page function
- change fontsize property in a clone of the profile object before recursion (for set max width without multiline) to prevent strange float values appear in form field
- remove xpm/bmp support, doesn't work properly and will never be needed on websites
- revert moving the jpeg synonym line
- remove unneeded GDFONTPATH setting - detect safe_mode in font_paths function and react by converting all paths to absolute
- put _ in front of internal functions
- add minimal function descriptions
- reorder functions

that's about all i can think of right now... only done quick test with safe_mode on, didn't mess with the filter logics at all so that needs testing too. other than that, i think my work's done ;)

eMPee584’s picture

Title: implement hooks to replace page/block titles, font/style preview, coder style » PLEASE TEST: implement hooks to replace page/block titles, font/style preview, coder style, unicode handling
FileSize
72.78 KB

hi again,
changes from last revision:
- add colons after last array entry in install file
- schema/update function change: add field 'allowed_nonasciichars' to profile table
- handling of special characters: filter strings containing them, put out a notice listing (only admins & can be turned off via settings) the colliding characters and put a field 'Allowed non-ASCII characters' on each profile's setting page
- add 'Clean signwriter cache now' button to the settings page
- fix case where width is always maxwidth
- add strong tag to _signwriter_strip_tags
- done some intensive testing, no remaining problems i think
- but others need to test if it works for them, too!

Agileware’s picture

Status: Needs review » Fixed

Thanks for your work on this patch.

I have done some testing of my own and it seems to be working correctly.

It has been rolled into the 6.x-1.0 release.

A bug fix for multiline text repeating when there is no drop shadow is also in that release.

eMPee584’s picture

Title: PLEASE TEST: implement hooks to replace page/block titles, font/style preview, coder style, unicode handling » implement hooks to replace page/block titles, font/style preview, coder style, unicode handling

wow you did a careful in-depth review indeed, cool! :)
one note regarding

    $preview_profile->fontsize = 12;
    $preview_profile->maxwidth = 400;

i thought it is good if you see the font previews at the set size you've set in the profile and because that may create very wide images in this case i unset maxwidth.. i still think that's more wysiwyg...
and the new form error, well actually if the field is blank, 20 is used as said in the description.. now you can't blank save that field anymore :((((11(1(

eMPee584’s picture

Status: Fixed » Postponed (maintainer needs more info)

see above note regarding fontsize/maxwidth..

Agileware’s picture

Status: Postponed (maintainer needs more info) » Fixed

I can see your point with the size & width. It does get a little crazy on the screen though if you have a lot of fonts and large font sizes.

In 6.x-1.1 I have removed the fontsize & maxwidth lines.

I also changed the validate on fontsize so it only checks for non-numeric entries and fixed the "Profile '@name' saved." part in cases where fontsize has been left empty.

eMPee584’s picture

Status: Fixed » Active

ok the non-numeric check is good but lines ~640 and 804, one of 'em could go away...

Agileware’s picture

eMPee584 can you please apply for a CVS account so I can give you CVS access for Signwriter. Try this page, http://drupal.org/cvs-application/requirements

eMPee584’s picture

so you're tired committing patches for me eh *g
alright i don't see much more problems with the current code and am pretty busy atm but going to file a request for it..

Agileware’s picture

Happy to apply patches but thought you might want it as you've been contributing a lot.

eMPee584’s picture

as long as improvements do get committed, who cares ;)
anyways got the account and forgot about it, swamped with stuff to do right now so hope i can try and figure this CVS stuff out soon..

Agileware’s picture

Status: Active » Closed (fixed)
Agileware’s picture

Sorry forgot to mention that you now have CVS access to this module. Rock'n roll buddy!