plainblack.com
Username Password
search
Bookmark and Share

MLthingy Operation

=head1 NAME

Package WebGUI::Operation::MLthingy

=head1 BENEFITS

    Ultimate solution for easy getting usable table and field names in your Thingy!

    1. Change your thing structures with readable field names only by expanding your data form with new fields
    2. Use thing table names like Thingy_mytable and thing field names like field_myfield
       instead of some very ugly names including assetId's
    3. Easy SQLReports for Things
    4. A lot of karma or other gifts to the author for his brilliant idea

=head1 DESCRIPTION

Operation for expanding an __existing__ Thing by using all the fields from a form like

    - a WebGUI DataForm object
    - a HTML-form, where fields are named by field_xxx, field_yyy etc.

Using a DataForm, your existing Thing will be expanded by the same fields as you expand your DataForm with.

=head2 www_mlthingfields( < $thingId | $label > )

     calls renameThing if $session->form->process('rename')
 or  saveFormfieldsToThing

=head3 thingId

The thingId of the Thing to expand (Table = "Thing_thingId")
To use this, your thingId should be unique

=head3 label

The label of the Thing to expand
To use this, your label should be unique

=head2 saveFormfieldsToThing

    If $params->{allfields}, fieldnames from the form will be added to the thing.

=head3 saveFormfieldsToThing from DataForm

    all fields but:
    $params->{allfields} == 1 && $fld =~ /^allfields$|thingId$|^op$|CsrfToken|func|entryId|rename/i
    will be added as field_<name of the formfield> to the table Thingy_<thingId>

=head3 saveFormfieldsToThing from HTML-form

    all fields but:
     !$params->{allfields} && $fld !~ /field_/
    will be added als <name of the formfield> to the table Thingy_<thingId>

=head2 Rename Thing

    Implemented but not yet tested extensively.
    It seems to work, but beware to use it, if you're using thing relations !!!

    if $session->form->process('rename'),
    Thingy_<thingId> will be renamed to Thingy_<$session->form->process('rename')>

=head2 Examples

=head3 HTML-Form

    1. Init a Thingy
    2. Init a Thing with name "myThing" with at least 1 field, e.g. "dummy"     
    3. Init an article or snippet form
       (to test, put it in the desription of your thingy):

    <form>
        <input type="hidden" name="op" value="mlthingfields">    
        The thing (thingId) to work with: <input type="text" name="thingId" value="" ><br>
        If you just initialized the thing, your thing will have a terrable thingId.
        You also may use the label, as long as it is unique<br>
        The thing (label) to work with: <input type="text" name="label" value="myThing" ><br>
    
        <hr>
        Take all the fields of this form into myThing:<br>
        <input type="radio" name="allfields" value="0" checked >No, take only the fields with names like "field_XXX"<br>
        <input type="radio" name="allfields" value="1">Yes and expand the used fieldname YYY to field_YYY<br>

        <hr>
    
        Expand table with fields:<br>
        <input type="text" name="field_field01"><br>
        <input type="text" name="field_field02"><br>
        (Please understand, this form doesn't use an action. <br>
         You don't have to fill in values. The MLthingy-op just takes the fields
         to expand your thing with.)
    
        <hr>
        If you fill-in the next field, the thingId and the Thing tablename, but no field names will be changed.<br>
        If you're not using the label to select, remember to use that name with your next change.<br>
        Please be very carefull, especially if you have thing relations, since this is tested only for some cases.
        New Thingname: <input type="text" name="rename"><br>
    
        <hr>
        <input type="submit">       
    </form>

    4. Try out and see, what your thing is doing (Normal thing views or manage things)
    5. change the form, again and again if you like
    6. Test the same procedure with a DataForm as starting object.

=head3 DataForm usage

    If you initialize a DataForm, give it the fields as shown in the above example.
    Fieldnames will be expanded by 'field_' before taken over by your thing table.

=head2 Installation

    1. Copy to your (Custom-) Macros or subdirectory
    2. Expand Operation.pm getOperations with:
       'mlthingfields' => 'MLthingy',

=head3 TODO's

    Should be implemented as a Content Module to prevent using the fieldname "op"    

=head2 DISCLAIMER / GOTCHAS

    No tests for acceptable table or field names, so think before you do
    and/or watch your database to see what's happening!

    This program works or works not and even doesn't tell you why.
    So use this operation on your own risk!!!
    It only works for the author's purposes

=head1 AUTOR/COPYRIGHT

    Martien A. M. Lammers, webguide@innovate.de
    @(#) Version:   $Revision: #6 $
    @(#)            $Change: 3807 $
    @(#) Datum:     $Date: 2011/11/25 $
 

=cut

Comments
DownloadMLthingy_pm.txt MLthingy_pm.txt
LinksMartien Lammers
No Support Offered
Statistics Downloads: 1422
Views: 6417
Rating: 0
Updated: 11/25/2011
Keywords Operation Thingy
NavigationMore from Martien Lammers
Back to the Bazaar
© 2023 Plain Black Corporation | All Rights Reserved