<?php

function ewz_show_webform_help($webforms ){
    ?>

    <div id="help-text" style="display:none">
        <!-- HELP POPUP Webforms -->
        <div id="shortcode_help" class="wp-dialog" >
            EntryWizard defines two shortcodes that you may include in a page.<br>
            These shortcodes may be inserted by typing them directly into the page, or by using the EWZ Shortcodes menu in the text editor.
                <hr>
            <p><b><i>1. The ewz_show_webform shortcode</i></b><br><br>
            The shortcode <b>&nbsp; &#91;ewz_show_webform&nbsp;identifier="xxx"&#93;</b> &nbsp; inserts the
               webform with identifier "xxx" into your page.
              You use this page to create the webforms and set their identifiers.</p>
            <p>This is the main shortcode defined by the plugin, and the one normally used.</p>
                <hr>
                <br>
            <b><i>2. The ewz_followup shortcode</i></b>
            <p>It is also possible to display a read-only summary of all the  data uploaded
               by the user, via specified webforms, using the shortcode<br>
               <b>&#91;ewz_followup &nbsp; idents="ident1,ident2,ident3" &nbsp; show="item_data,content"&#93;</b> </p>
            <ul>
              <li>The parameter "idents" lists the identifiers of all webforms to be displayed, separated by commas.</li>
               <li>The parameter "show" lists extra information to be displayed, beyond the fields defined by the layout. <br />
                  The "show" parameter may include any ( or none ) of the following data:
                  <ul><li> "title","caption","description","tag" uploaded using the "extra image data" section of the webform below</li>
                      <li> "item_data" uploaded using the  "extra item data"  section of the webform below</li>
                  </ul>
               </li>
            </ul>
            <p><i>( The motivation for this was the use by some camera clubs of a yearly "Second Chance" competition
                 in which previously uploaded images could be re-submitted for a second chance. )</i></p>

            <p>NB: If all the webforms requiring "followup" use the same layout, you may find that the interface offered by
               the new Ewz-Rating plugin is a little nicer and more flexible.</p>
            <hr>

            <b><i>Special Field Identifiers</i></b>
            <ul>
              <li> If the identifier has the special value 'followupQ', the field is treated as a
              "followup" field, which is not displayed by the 'ewz_show_webform' shortcode.
              It is the <u>only input</u> field shown by the 'ewz_followup' shortcode.
              Data entered in it will be stored and may be downloaded as usual.
              </li>
              <li> If the field contains 'XFQ' as part of it's identifier, the field will <b>not</b> be displayed by
              the followup shortcode.</li>
              <li>A "followupQ" field may not be of "Image File" type.</li>
              <li>Restrictions will not be enforced on "followupQ" fields.</li>
            </ul>
            <hr>

            <b><i>'Hiding' Webforms</i></b>
            <p>If you wish to keep a large number of webforms active, but do not need to be able to edit all of them, you may hide some of them from this page.
               Select the ones you wish to hide, then choose "Hide Selected Webforms" from the "Bulk Actions" list and click "Apply".
            </p>
            <p>You may "unhide" them by selecting them from the drop-down list at the top of this page. (To delete them, you must first unhide them ).</p>
            <p>Hiding and un
        </div>

      <!-- HELP POPUP Web Forms ~ Compressed View -->
       <div id="wfcompressed_help" class="wp-dialog ewz-help" >
           <p>If you have a large number of web forms, you may prefer a more
            condensed view when rearranging them, so you can see more at once.</p>
            Selecting this will remove some of the vertical spacing.
           <p> Note: this option is not
            saved, so you will need to re-select every time you open the page.
          </p>
       </div>

        <!-- HELP POPUP Webforms ~ Auto-Open/Close -->
      <div id="wfauto_help" class="wp-dialog ewz-help" >
           <p>If any webform has the "Open Automatically" or "Close Automatically" date/times set for future dates, they will be listed here.</p>
       </div>

       <!-- HELP POPUP Web Forms ~ Hidden Forms List -->
       <div id="wfhidden_help" class="wp-dialog ewz-help" >
           <p>The listed forms have been hidden from this page using the "Hide Selected Webforms" option in the Bulk Actions dropdown.<br>
            You may unhide forms by selecting them and then clicking "Un-Hide Selected".  The newly visible forms will show close to the top of the list.
          </p>
       </div>

        <!-- HELP POPUP Webforms ~ Batch Actions -->
        <div id="cleanup_help" class="wp-dialog" >
            <p>If you wish to keep a large number of webforms active, but do not need to be able to edit all of them, you may hide some of them from this page.
               Select the ones you wish to hide, then choose "Hide Selected Webforms"  and click "Apply".
            </p>
            <p>You may "unhide" them by selecting them from the drop-down list at the top of this page. (To delete them, you must first unhide them ).</p>
            <p>When you download spreadsheets or images, .csv or .zip files may be generated in the webform folder
               (inside wp-content/uploads/ewz_img_uploads). They are not needed after your download is complete, and the
               "Cleanup Selected Webform Folders" action deletes any that are more than a minute old.
            </p>
        </div>

        <!-- HELP POPUP Webforms ~ Add, Save Order -->
        <div id="wfnew_help" class="wp-dialog" >
            <p>Add a New Webform creates a new, blank webform, and adds it to the top of the list.
               You then need to give it a title, an identifier and a layout before saving it.</p>
            <p>Webforms may be dragged to rearrange them.
               Clicking "Save Order of Webforms" will save the order, and
               the new order will subsequently be used for this page</p>
        </div>

        <!-- HELP POPUP  Webforms ~ Setup ~ Title -->
        <div id="title_help" class="wp-dialog" >
            <p>The title is displayed at the top of the webform. No two webforms
                may have the same title.</p>
        </div>

        <!-- HELP POPUP Webforms ~ Setup ~ Identifier -->
        <div id="ident_help" class="wp-dialog" >
            <p>The  main uses of this identifier are
                <ol>
                   <li> To specify which webform to use in the "ewz_show_webform" shortcode.  If your identifier is
                        "main", then in the page where you wish the webform to appear,
                         type <pre>[ewz_show_webform identifier="main"]</pre>
                   </li>
                   <li> As the name for the folder in which the image files are stored on the server ( within the uploads/ewz_img_uploads folder ).</li>
                   <li> The identifier is also included as part of the filename when  downloading images.</li>
                </ol>
            </p>
            <p>To make it acceptable as part of a filename on most systems, it
                must consist of <b>letters, digits or underscores</b> only,
                and start with a letter.</p>
            <p>It should be kept as short as possible, but no two webforms may
                have the same identifier.</p>
        </div>

        <!-- HELP POPUP Webforms ~ Setup ~ Layout -->
        <div id="wlayout_help" class="wp-dialog" >
            <p>The layouts are created in the Layouts admin page.
                You select one here. It determines what information is required,
                and in what order the items appear in the form.</p>
            <p>If the selected layout allows the webform to override the number of items allowed,
               you will need to save the webform before the "number of items" selection box appears.</p>
        </div>

        <!-- HELP POPUP Webforms ~ Setup ~ Number of Items -->
        <div id="numitems_help" class="wp-dialog" >
           <p>If the layout allows it, this option overrides the "Maximum number of items" set in the layout.</p>
           <p>It has no effect on any maximum numbers set in the layout for drop-down selection fields.</p>
        </div>

        <!-- HELP POPUP Webforms ~ Setup ~ Prefix -->
        <div id="prefix_help" class="wp-dialog" >
           <?php /****** NB: this is repeated for each webform below, and needs to be changed there, too ***/ ?>
           <h2>Optional Filename Change</h2>
           <p>Normally, an uploaded image file is stored on the server with a name as close as possible
              ( with just spaces and special characters changed ) to the one given it by the person uploading.
               And the file is normally downloaded by the administrator with the same name as it has on the server.
               If you are happy with that, you do not need to read any further.</p>

           <h2>Adding a Prefix to the Filename</h2>
            <p class="ewz_wnotes">(Applies to all webforms)</p>
           <p>If you wish, <u>you may choose to add a prefix</u> to each of the image file names, or even replace the filename
              with a generated one.</p>
           <ul>
              <li>
              The prefix is normally applied to each file as it is uploaded to the server ( and the new filename
              is displayed to the person uploading ). <br>
              If using the Download buttons on this page takes too long and times out ( which may happen if your webhost limits
              certain resources and you attempt to download too many images ), you may then use ftp to obtain the renamed
              files from the <?php print EWZ_IMG_UPLOAD_DIR ?> folder.
              </li>
              <li>
              If you deselect this option, the prefix is applied only to the files downloaded using the Download Images buttons below.
              Then you do not have the option of downloading the renamed images via FTP.<br>
              Also note that you need to be very careful downloading anything before the webform has been closed for uploads, because
              the user may later change a field that is used in the filename.
              </li>
            </ul>

            <p>
               The prefix may contain only letters, digits, dashes or underscores,  <u>spaces only if it is NOT applied on upload</u>,
               plus the  following expressions, which will be replaced as indicated here:</p>
           <table class="ewz_border">
               <thead><tr><th class="ewz_b">Expression</th><th class="ewz_b">Replacement</th></tr></thead>
               <tbody>
                   <tr><td class="ewz_b">[~RAND] </td>
                       <td class="ewz_b"> A random 3-digit number between 0 and 999 **</td></tr>
                   <tr><td class="ewz_b">[~WFM] </td>
                       <td class="ewz_b"> Identifier for this webform</td></tr>
                   <tr><td class="ewz_b">[~UID] </td>
                       <td class="ewz_b"> Submitter's Wordpress ID Number</td></tr>
                   <tr><td class="ewz_b">[~FLD] </td>
                       <td class="ewz_b"> Wordpress ID of the field the image was uploaded under<br>
                           (only useful if an item may contain more than one image)  </td></tr>
                   <tr><td class="ewz_b">[~1] </td>
                       <td class="ewz_b"> <i>For generated filenames only</i>, a number 1,2,3,... to ensure no two images have the same filename</td></tr>
     <?php
        foreach( Ewz_Custom_Data::$data as $key => $value ) {
            $esc_code = str_replace( 'custom', '~CD', esc_html( $key ) );
     ?>
            <tr><td class='ewz_b'> [<?php print $esc_code; ?>] </td>
                <td class='ewz_b'> <?php print esc_html( $value); ?>  ( Custom data )</td>
            </tr>
     <?php } ?>
              </tbody>
           </table>
           <p><i><b>**</b> If random numbers are used and the prefix is NOT applied on upload, <b>spreadsheet and images must be downloaded together</b> if these numbers are to match in filename and spreadsheet.</p>
           <p><b>More information will be available once this new webform has been saved</b></p>
       </div>

       <?php foreach ( $webforms as $webform  ) { ?>
           <div id="prefix<?php print esc_attr("$webform->webform_id"); ?>_help" class="wp-dialog" >
           <?php /****** NB: this text is also above for new webforms, and needs to be changed there, too ***/ ?>
               <h2>Optional Filename Change</h2>
               <p>Normally, an uploaded image file is stored on the server with a name as close as possible
                  ( with just spaces and special characters changed ) to the one given it by the person uploading.
                   And the file is normally downloaded by the administrator with the same name as it has on the server.
                   If you are happy with that, you do not need to read any further.</p>

               <h2>Adding a Prefix to the Filename</h2>
               <p>If you wish, <u>you may choose to add a prefix</u> to each of the image file names, or even replace the filename
                  with a generated one.</p>
               <ul>
                  <li>
                  The prefix is normally applied to each file as it is uploaded to the server ( and the new filename
                  is displayed to the person uploading ). <br>
                  If using the Download buttons on this page takes too long and times out ( which may happen if your webhost limits
                  certain resources and you attempt to download too many images ), you may then use ftp to obtain the renamed
                  files from the <?php print EWZ_IMG_UPLOAD_DIR ?> folder.
                  </li>
                  <li>
              If you deselect this option, the prefix is applied only to the files downloaded using the Download Images buttons below.
              Then you do not have the option of downloading the renamed images via FTP.<br>
              Also note that you need to be very careful downloading anything before the webform has been closed for uploads, because
              the user may later change a field that is used in the filename.
                  </li>
                </ul>

                <p>
                   The prefix may contain only letters, digits, dashes or underscores,  <u>spaces only if it is NOT applied on upload</u>,
                   plus the  following expressions, which will be replaced as indicated here:</p>
               <table class="ewz_border">
                   <thead><tr><th class="ewz_b">Expression</th><th class="ewz_b">Replacement</th></tr></thead>
                   <tbody>
                   <tr><td class="ewz_b">[~RAND] </td>
                       <td class="ewz_b"> A random 3-digit number between 0 and 999 **</td></tr>
                   <tr><td class="ewz_b">[~WFM] </td>
                       <td class="ewz_b"> Identifier for this webform</td></tr>
                   <tr><td class="ewz_b">[~UID] </td>
                       <td class="ewz_b"> Submitter's Wordpress ID Number</td></tr>
                   <tr><td class="ewz_b">[~FLD] </td>
                       <td class="ewz_b"> Wordpress ID of the field the image was uploaded under<br>
                           (only useful if an item may contain more than one image)  </td></tr>
                   <tr><td class="ewz_b">[~1] </td>
                       <td class="ewz_b"> <i>For generated filenames only</i>, a number 1,2,3,... to ensure no two images have the same filename</td></tr>
     <?php
        foreach( Ewz_Custom_Data::$data as $key => $value ) {
            $esc_code = str_replace( 'custom', '~CD', esc_html( $key ) );
     ?>
            <tr><td class='ewz_b'> [<?php print $esc_code; ?>] </td>
                <td class='ewz_b'> <?php print esc_html($value)?>  ( Custom data )</td>
            </tr>
     <?php } ?>

            <tr><td colspan="2" style="text-align:center; background: #eeeeee; font-style:italic;">Anything below here depends on the layout</td></tr>
               <?php
                    foreach( $webform->field_types as $field_id => $field_type ) {
                       if( $webform->field_idents[ $field_id ] != 'followupQ' ) {
                           $esc_code =  '~'. esc_attr( $webform->field_idents[ $field_id ] ) ;
               ?>
                                   <tr><td class="ewz_b">[<?php print $esc_code; ?>] </td>
                                       <td class="ewz_b"> <?php print esc_html( $webform->field_names[ $field_id ] ) ?>
                                       <b><?php print ( esc_html($field_type) != 'opt' ? '***' : '') ?></b></td>
                                   </tr>
               <?php
                      }
                   }
               ?>
           </tbody></table>
               <p><i><b>**</b> If the prefix is NOT applied on upload, spreadsheet and images <b>must be downloaded together</b> if these random numbers are to match in filename and spreadsheet.<br>
              <p><i><b>*** Only if the prefix is NOT applied on upload</b><br>
                 If the prefix is applied on upload, <b>only option-list fields</b> may be used in this way. This ensures that
                 the resulting filename is legitimate on the server, and not unreasonably long.
                ( What is put into the prefix is the "Value for Spreadsheet", not the "Label for Web Page" ). <br>
                If the prefix is *not* applied on upload, any field may be used. The resulting filename is processed to remove
                or replace any characters ( including spaces ) that are not safe in filenames for most systems.
                <br><br><b>Warning:</b> If you use user-editable data as part of the prefix, and apply the prefix
                    immediately on upload, that data <u>can no longer be changed by the user</u> after the upload.
                </i>

               </p>
               For instance, suppose
                   <ol><li> You set the identifier for this webform
                       as "group1" and enter &nbsp; <b>"2012Jan-[~WFM]-[~UID]-[~Cat]"</b>
                       in the Optional Prefix box above</li>
                   <li> A member with wordpress id number <b>257</b> uploads images</li>
                   <li> One of these images is uploaded with the filename <b>myimage.jpg</b> and with value "P" selected from a drop-down menu with identifier "Cat"</li>
               </ol>
               <p>Then the image will be downloaded with the filename
               &nbsp; <b>"2012Jan-group1-257-P-my_image.jpg".</b>  This may be useful
               if you wish the images to sort or group in a particular way.
               </p>
               <h2>Generating an Entire New Filename</h2>
               <p><u>You may also generate an entire image filename</u>.
                  This will be simply the "prefix" alone, with its special expressions replaced as above.<br>
                  This facility should be used cautiously, because if anything goes wrong it may be more difficult to associate
                  the renamed image with the original. But it may be necessary if a particular filename format is needed.<br><br>
                  If more than one image in the webform has the same value for the prefix, numbers 1,2,3... will be appended to the <u>second and
                  subsequent filenames</u> as required ( this is a Wordpress function, not part of EntryWizard ), but not to the first.
                  You may choose instead to insert '[~1]' into the prefix, and EntryWizard will replace this with a number in <u>every</u>
                  file that makes the filenames unique. </p>

                For instance, suppose
                   <ol><li>You have an option list with identifier "Cat" which may return "value for spreadsheet" of "PD", "ND", "NP" </li>
                       <li>and a custom field "Custom1" containing a membership number</li>
                       <li>You set the options to apply prefix on upload, and generate a filename</li>
                       <li>You set the prefix to "Img[~CD1][~Cat][~1]"</li>
                       <li>A user with membership number 52 uploads two image files both with a "Cat" value of "ND"</li>
                   </ol>
                 <p>  Then the images will be saved on the server as "Img52ND1.jpg" and "Img52ND2.jpg".
                   After uploading, the user will no longer be able to change the "Cat" option, although they may still change any other fields.</p>

                <p><b>Warning:</b> Wordpress does strange things with files whose name consists entirely of digits.  <br>
                  Wordpress also appends a number to the end of duplicate filenames in the upload folder, to distinguish them.
                  Normally, EntryWizard tries to make that more visible by adding an underscore to the end of filenames that end in a digit,
                  but it does  not do this when you elect to generate the entire filename. So it is then your responsibility to make
                  sure that no completely numeric filenames are generated, and that if you generate duplicate filenames, you understand
                  how they are handled.</p>
                 <p><b>Warning:</b> When downloading files with generated names that were not applied on upload, spreadsheet and images
                 should be downloaded together using the  "Download Images and Spreadsheet" button to make sure the generated filenames match.</p>
           </div>
        <?php // end foreach ( $webforms as $webform  )
           }
        ?>

        <!-- HELP POPUP Webforms ~ Setup ~ Open for Uploads -->
        <div id="open_help" class="wp-dialog" >
            <p>When this box is checked, users may upload images using the webform.
                When is it not checked, they see only a "Sorry, not open for upload"
                message (or whatever you assigned in the Settings).</p>
            <p>When the webform is closed, you have the option of opening it
                temporarily for selected members only.
                This may be useful if someone needs to change a submission, or
                is late for an acceptable reason,
                but you do not wish anyone else to be able to upload
            </p>
        </div>


        <!-- HELP POPUP Webforms ~ Setup ~ Show User Selection -->
        <div id="openfor_help" class="wp-dialog" >
            <p>When the webform is closed, an <b>Administrator</b> has the option of opening it
                temporarily for selected members only.
                This may be useful if someone needs to change a submission, or
                is late for an acceptable reason,
                but you do not wish anyone else to be able to upload.</p>
            <p>Checking this box will open a list of users for you to select. Because the list may be long, and is not always used,
               it is obtained from the server when you click. This means it may be a little slow to load.</p>
            <p>
                Clicking an item in the left-hand box will "select" it -- ie move it to the right-hand box.
                Clicking an item in the right-hand box will "de-select" it -- ie move it back to the left-hand box.
                (If you have a long list of users, try using Ctrl-F to search the list.)</p>
             <p>When you "Save Changes", your selected users will be able to
                upload but others will not.</p>
            <p>Note that to see the user list, you need either wordpress <b>"list_users"</b> capability,
               or 'See User Data' permission via the EntryWizard Permissions page.
            </p>
            <p><i>Opening the webform automatically cancels any existing selection.</i></p>
        </div>



        <!-- HELP POPUP Webforms ~ Setup ~ Close Automatically -->
        <div id="autoopenclose_help" class="wp-dialog" >
           <p>As of version 1.3.16, a webform may be set to open and/or close automatically at specified date/times.
              ( in the timezone specified by your site settings ).
           </p>
           <p><b>Notes: </b><br>
              <b>1. Date Format and Time Format must be set</b> in your  wordpress Settings.<br>
              <b>2. This feature relies on wp-cron</b>, which is the built-in timing facility for wordpress.<br>
              Some sites modify the way in which wp-cron is run. If your site has done this,
              please note that the webform will be opened <i>the first time wp-cron is run after your set opening time</i>
              and closed <i>the first time wp-cron is run after your set closing time</i>.<br>
              Opening and closing times are stored by wp-cron, not by entrywizard. <br>

              A new button at the top right of this page will pop up a list of all your scheduled open/close events.
              If you make heavy use of the auto-open/close feature, you may wish to install one of the many plugins availble to view or control wp-cron.</p>
           <p>If error logging is turned on (in wp-config.php), the open or close action will be logged when it actually takes place.
           </p>
        </div>

        <!-- HELP POPUP Webforms ~ Data ~ Per-Image Upload -->
        <div id="imgcsv_help" class="wp-dialog" >
             <p>You may optionally upload a .csv file containing three or four extra items
                 of data to be stored for each <b>image</b>.<br>
             For images you subsequently attach to a page (using the Manage Items link below),
                 the first three items are used for the Title, Caption and Description of
                 the image in a standard Wordpress gallery, and the optional fourth is a tag intended to help
                 in sorting the images within the gallery.
                 They may also be: </p>
                 <ul>
                 <li>included in a downloaded spreadsheet (see Extra Data in the Layout)</li>
                 <li>displayed in a "followup" page (see the Help item at the top of this page )</li>
                 <li>displayed to judges if you are using the EWZ-Rating plugin.</li>
               </ul>
             The following rules apply:
             <ul>

            <li>The file must be in plain text, "comma-delimited" format.<br>
                The easiest way to generate the .csv file is to save a spreadsheet
                in .csv format.  There should be no header line.</li>
            <li>The first column <b>must contain the wordpress item sequence number</b>.
                You may obtain this by including the WP Item ID under Extra Data in the layout and then
                viewing it by clicking "Manage Items" on the webforms page or by downloading the spreadsheet.</li>
            <li>The second column must contain the identifier you assigned to the layout field that contained the image file. It will usually
                have the same value for every line in the file.</li>
            <li>The 3rd, 4th, 5th columns contain, in this order:
                  <br> &nbsp; The title
                  <br> &nbsp; The caption
                  <br> &nbsp; The description
                  <br> &nbsp; The optional 6th column contains the tag.
                <br>for each image you wish to annotate in this way.</li>
            <li>You may use some basic html markup in your text:<br>
            <?php print allowed_tags(); print "&lt;br&gt;"; ?></li>
           </ul>
            <p><b>Note:</b> If you upload a second file containing the same item number, the title, caption and description
               for that item wil be overwritten by the new values.
            </p>
            <p><b>Note:</b> By default, accented characters (and others requiring more than 8 bits) are removed from uploaded .csv files because they have caused problems in the past. If you are confident your software can generate correct .csv files, you may try unchecking the "convert the data to ASCII format" option in the Settings page.
            </p>
            The following examples show lines as they would appear if you opened the csv file in a text editor like wordpad (<u>not</u> excel):
           <p><b>Example 1</b>:  if your layout allows for one image per item, in column 3, and you have assigned
           the identifier "imgfile"  to the image field,<br> the line:
           <br><br><i>700,"imgfile",Antelope,"John Doe: Antelope","Intermediate Runner Up","NatNov"</i><br><br>
               would assign a Title of "Antelope", a Caption of "John Doe: Antelope", a Description of "Intermediate Runner Up"
               and a Tag "NatNov" ( to be used in sorting the items before attaching to a page ).
               for the image of item 700. ( Note that the field identifier "imgfile" would be the same for every item using that layout ).</p>

           <p><b>Example 2</b>:  if your layout allows for two images per item, in columns 1 and 5, and you have assigned
           identifiers 'original' and 'final' to columns 1 and 5,<br> the line:
           <br><br><i>700,original,"Title for image 1","Caption for image 1","Image 1 Description","final","title
               for column 5", "&lt;b&gt;Caption #5&lt;/b&gt;","Description for image in column 5"</i><br><br>
               would create Title, Caption and Description values for the images in columns 1 and 5
               of item 700, with the caption for item 5 in bold.</p>
            ( Since commas are used to separate the columns, any value that actually contains a comma should be surrounded by quotes. If a column contains no comma, quotes may be generated or not, depending on the software you use.)
        </div>

        <!-- HELP POPUP Webforms ~ Data ~ Per-Item Upload -->
        <div id="itmcsv_help" class="wp-dialog" >
             <p>You may also optionally upload a .csv file containing a single extra piece
                of text to be stored for each <b>item</b>. This is referred to as the Added Item Data.
                It may be: </p>
                 <ul>
                 <li>included in a downloaded spreadsheet (see Extra Data in the Layout)</li>
                 <li>displayed in a "followup" page (see the Help item at the top of this page )</li>
                 <li>displayed to judges if you are using the EWZ-Rating plugin.</li>
               </ul>
               The following rules apply:
             <ul>
            <li>The file must be in plain text, "comma-delimited" format.<br>
                The easiest way to generate the .csv file is to save a spreadsheet
                in .csv format. There should be no header line.</li>
            <li>The first column <b>must contain the wordpress item sequence number</b>.
                You may obtain this by including the WP Item ID under Extra Data in
                the layout and then viewing it by clicking "Manage Items" on the webforms page.</li>
            <li>The second column should contain the text you wish to store for the item</li>
            <li>You may use some basic html markup in your text:<br>
            <?php print allowed_tags(); print "&lt;br&gt;"; ?></li>
           </ul>
            <p><b>Note:</b> If you upload a second file containing the same item number, the title, caption and description
               for that item wil be overwritten by the new values.
            </p>
            <p><b>Note:</b> By default, accented characters (and others requiring more than 8 bits) are removed from uploaded .csv files because they have caused problems in the past. If you are confident your software can generate correct .csv files, you may try unchecking the "convert the data to ASCII format" option in the Settings page.
            </p>

        </div>

        <!-- HELP POPUP Webforms ~ Data  ~ Batch Entry Upload -->
        <div id="entry_help" class="wp-dialog" >
           <p>The normal way to get items into the entrywizard database is by uploading them using the ewz_show_webform shortcode.
           </p>
           <p>This section provides a way to add any number of items to the entrywizard database if you already have the images, and have the
                required information in a spreadsheet.<br>
                It may be useful if you want to use Ewz-Rating for online judging, without having each user upload individually.</p>
            <p>The disadvantage of doing this is that you do not get all of entrywizard's usual checking of image dimensions and allowed values.
                   You are responsible for providing valid data yourself in the correct columns, although some minimal checking is performed.</p>
           <p><b>Please read the following instructions carefully:</b></p>
           <p><b><u>Images</u></b><br>
              The .jpg images <u>and their thumbnails</u> must be placed in the uploads/ewz_img_uploads/XXX folder, where XXX is the
              identifier of this webform. </p>
              <p>If the image filenames contain any characters other than letters, digits, dashes or underscores, the batch loading process will
              rename them. If any image is renamed, a .csv file containing the original and new names is placed in the webform's uploads folder.</p>
            <p><b><u>Format of Uploaded File</u></b></p>
           <ul>
            <li>The file must be in plain text, "comma-delimited" format.
              ( The easiest way to generate the .csv file is to save a spreadsheet in .csv format ).</li>
              <li>The first (header) row consists of the field identifiers of the fields you wish to populate.</li>
            <li>Subsequent rows are values for those fields, in the same order as they appear in the first row.
               <ul><li>For a checkbox or radio-button field, the value should be "1" if the field is to be checked, and "0" otherwise.</li>
                   <li>For an image field, the value should be the filename of the image ( without any path component ), optionally followed by
                       a colon and the thumbnail filename.  If the thumbnail filename is not specified, it is assumed to be the image filename with
                       '.jpg' replaced by '-thumb.jpg'.</li>
                   <li>An extra column "LoginName" (note the capitalization), may be added, containing a valid wordpress user login.
                       If there is no such column, the item owner is assumed to be the administrator doing the upload.</li>
               </ul>
             </li>
           </ul>

                       <p>Here is an example file as you would see it if you opened it in a text editor like wordpad (<u>not</u> excel):<br><pre>
<b>LoginName,type,category,Title,Filename,ForComment</b>
user150,Print,Assigned,"Batch-Uploaded Image",test123.jpg,1
myname,Digial,Pictorial,"Image Number Two",test345.jpg:test345-120x120.jpg,0
myname,Digital,Assigned,"Image Number Three",test789.jpg:thumb_for_test789.jpg,1
</pre></p>
 <p>The image files test123.jpg, test345.jpg, test789.jpg, together with their thumbnails
     test123-thumb.jpg, test345-120x120.jpg and thumb_for_test789.jpg,
                should be in the correct subdirectory  of uploads/ewz-img-uploads. <br>
                ( ie in uploads/ewz-img-uploads/your-webform-identifier )</br>
 ( Since commas are used to separate the columns, any value that actually contains a comma should be surrounded by quotes. If a column contains no comma, quotes may be generated or not, depending on the software you use.)

            <p><b>Note:</b> By default, accented characters (and others requiring more than 8 bits) are removed from uploaded .csv files because they have caused problems in the past. If you are confident your software can generate correct .csv files, you may try unchecking the "convert the data to ASCII format" option in the Settings page.
            </p>

            <p><b><u>Usage</u></b></p>
               <ul>
                 <li>The batch entry upload does NOT work in the same way as the data uploads above.<br>
                     <b>*Repeating a successful upload will <u>duplicate the items</u> in the EntryWizard database.*</b><br>
                     If something goes wrong, you need to delete the item via the "Manage Items" link below, and make sure the file has
                     been deleted from the server. Then upload a corrected file contain <u>only that item</u>.</li>
                 <li>If you include a "LoginName" column, you may click the "Check Data" radiobutton to request EntryWizard to run some checks
                       on your data before you actually save it. <br>
                       If there are any errors  found ( such as unsatisfied restrictions ), this will be reported. <br>
                       NOTE 1: the checks assume that there are no items for the webform currently on the database for any user in the file
                        -- if there are, an item may fail to save, or save data that does not satisfy count limits, even if it passes the check.<br>
                       NOTE 2: some checks stop at the first error found, so you need to repeat the check process until there are no errors.<br>
                       NOTE 3: most data checks normally performed by EntryWizard on uploaded items will be done, but there is no checking of
                               image size or dimensions.
                      </li>
                <li>If you do not include a "LoginName" column, checking the data is not possible.</li>
                <li>In either case, once you check the "Do Upload" radiobutton, <u>you are responsible for making sure the data is correct</u>.
                    If you run a check first, you will have to re-select the file for upload - make sure to pick the correct file.</li>
                <li>You may need to widen the message window to see the error report properly.</li>
               <li>To make changes after the saving has taken place, you would need to either log in as the relevant user,
                       or delete the item using the admin interface and re-upload it.</li>
               </ul>
           <p>Note that there will be no image size or dimension information available in the spreadsheet or item list display</p>
        </div>

        <!-- HELP POPUP Webforms ~ Data ~ Discrepancy Report -->
        <div id="filereport_help" class="wp-dialog" >
            <p>Report on any discrepancies between image filenames stored on the database and files actually on the server.</p>
            <p>The image files themselves ( and their thumbnail files ) are stored in the matching webform folder in the
               ewz_img_uploads uploads folder. All other information about an item is
               stored in the wordpress database, together with the image filenames.  Normally, the uploads folder should contain an
               image and a thumbnail for every image uploaded to the webform.
               Discrepancies may occur:  </p>
                  <ol><li>In rare cases where something fails while a user is uploading, or when an administrator deletes an item.</li>
                      <li>If you used the batch entry uploader, and did not put all the right images in the folder.</li>
                      <li>If you have copied the database, perhaps to a test site, and have not copied all the images.</li>
                      <li>There may sometimes be a small number of .zip or .csv files generated by EntryWizard for downloading.
                          If you like, you can deleted them once they are no longer required.
                          EntryWizard normally deletes old ones when new ones are created.</li>
                  </ol>
               <p>( Extra files in the folder should not do any harm other than using storage space. )</p>
        </div>

        <!-- HELP POPUP Webforms ~ Data ~ Select Items -->
        <div id="datasel_help" class="wp-dialog" >
            <p>The data management area for the webform lets you select all its
                items or just some of them.
               A selection list is generated here for each field in the webform's
               layout, except for text and image fields.
             </p>
             <p><i>New in version 1.2.5 for those who created an ewz_extra plugin to allow entrywizard to
                access custom fields: </i> If you have a custom field that <u>may take on only a limited number
                of values</u>,  you may add a new "selection_list" function  to your ewz_extra.php file that
                enables you to select by this field, too.  See ewz_extra.txt file.
             </p>
             <p>
               With the selected images you may do one of several things:</p>
            <ul>
             <li> Download a spreadsheet containing all the uploaded information
                connected to the items
                <br>( <i>The spreadsheet is in .csv (comma-delimited) form, which
                    should open easily in most spreadsheet software.
                 The separator/delimiter is a comma (,), and the text delimiter is a
                    double quote (").</i></li>
            <li>Download the same spreadsheet together with the uploaded image
                files</li>
            <li>Download just the uploaded image files</li>
           <?php if( Ewz_Permission::can_manage_some_webform() ) { ?>
                <li>View the images and the fields that would show in the spreadsheet ( Requires permission to manage the webform ).
                With the image thumbnails visible, you may then inspect data, remove individual items,
                 or attach images to a page or post.</li>
             </ul>
             <p>Note that downloading a large number of images by this method may take more time than some
                webhosting companies allow. In that case, the alternative is to download the images via
                ftp. The images are in a folder whose name is the webform identifier, inside:<br>
                <?php print EWZ_IMG_UPLOAD_DIR ?>.  <br>Unfortunately, if you are using a prefix, you will then have to apply it on upload.</p>
             <p>The alternative would be to select a smaller number of images at a time for download, if necessary adding more
                fields to the layout.</p>
            <?php } ?>
        </div>
      </div>
<?php
    }