Just a little function humor.

5 posts by 2 authors in: Forums > CMS Builder
Last Post: August 14, 2015   (RSS)

By rconring - August 7, 2015

I hope I am not breaking forum decorum but I just had to share this nugget with the CMSB community.

The other day, I found myself in need of a function to replace an array of placeholders with an array of variables.  I knew I had written that very function for use on another site some time ago but could not remember which site.  I did remember that I had named the function something like "replace_token" or "swap_token" ... I knew it had "token" in the name so I did a search of my web projects directory for *token*.  

Holy Smoke! (pun intended)  Ironically, there is was in a little quickie site I did for a client last year .... cannabiscrusades.com! 

If you don't get it, it's probably a good thing!  LOL

Ron Conring
Conring Automation Services
----------------------------------------
Software for Business and Industry Since 1987

By Dave - August 12, 2015

Hey Ron, 

We use a lot of metaphors to describe data and ideas and we often deal with hierarchical/tree structured data.   So we use a very common child/parent metaphor in the code to describe how uploads work, and when creating a new record in the CMS, you can upload files before the record is created.  So on save "child" upload records are "adopted" by the "parent" record.  Except sometime a user might upload some files and then not click save.  In which case we need to clean up the uploads and remove them after a period of time.

Anyways, I remember having a conversation about some  unintentionally morbid code that killed off or abandoning children that weren't adopted.   I think we ended up changing some of the wording, but just know that if you ever see some code that reads like that, we didn't mean it that way! :-)

Dave Edis - Senior Developer
interactivetools.com

By Dave - August 14, 2015

Hi Ron, 

Here's a couple things that might be of interest:

Customize WYSIWYG - You can edit/limit the buttons shown on the wysiwyg by editting /lib/wysiwyg.php.  You can save it as wysiwyg_custom.php.  The button list looks like this: formatselect,fontsizeselect,bold,italic,underline,|,justifyleft,justifycenter,justifyright,|,bullist,numlist,|,outdent,indent,|,sub,sup,charmap,|,removeformat,fullscreen

htmlPurify() - For plugin authors there's also a function in /lib/common.php called htmlPurify() that filters out unwanted HTML.  It's a bit more work to implement but works well.  We use it for this forum.  It uses an underlying library from: http://htmlpurifier.org/

Related Records Drag Sorting - Try setting this to '1' in your /data/settings file(s):  'allowRelatedRecordsDragSorting' => '0',  Note that sorting a subset of the records might produce unexpected results, so make sure you test it before relying on it.

Hope one of those help!

Dave Edis - Senior Developer
interactivetools.com

By Dave - August 14, 2015

Hi Ron, 

Here's a couple things that might be of interest:

Customize WYSIWYG - You can edit/limit the buttons shown on the wysiwyg by editting /lib/wysiwyg.php.  You can save it as wysiwyg_custom.php.  The button list looks like this: formatselect,fontsizeselect,bold,italic,underline,|,justifyleft,justifycenter,justifyright,|,bullist,numlist,|,outdent,indent,|,sub,sup,charmap,|,removeformat,fullscreen

htmlPurify() - For plugin authors there's also a function in /lib/common.php called htmlPurify() that filters out unwanted HTML.  It's a bit more work to implement but works well.  We use it for this forum.  It uses an underlying library from: http://htmlpurifier.org/

Related Records Drag Sorting - Try setting this to '1' in your /data/settings file(s):  'allowRelatedRecordsDragSorting' => '0',  Note that sorting a subset of the records might produce unexpected results, so make sure you test it before relying on it.

Hope one of those help!

Dave Edis - Senior Developer
interactivetools.com