Configuring file registration

From ARK
Revision as of 12:02, 2 July 2008 by 81.152.200.70 (talk)

Jump to: navigation, search

If you are looking for a how-to for using the file registration system then this page will be more help: How-to: Register and Upload Files

In order to utilise the new dataclass of 'file' there are a few changes that need to be made to your currently existing database and also the config files.

Run the following SQL in phpMyAdmin to create the tables:

 CREATE TABLE `cor_lut_file` (
 `id` int( 11 ) NOT NULL AUTO_INCREMENT ,
 `filename` varchar( 255 ) COLLATE utf8_unicode_ci NOT NULL ,
 `module` varchar( 255 ) COLLATE utf8_unicode_ci NOT NULL ,
 `batch` varchar( 255 ) COLLATE utf8_unicode_ci NOT NULL default '0',
 `cre_by` int( 11 ) NOT NULL default '0',
 `cre_on` datetime NOT NULL default '0000-00-00 00:00:00',
 PRIMARY KEY ( `id` )
 ) ENGINE = MYISAM DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci;
CREATE TABLE `ARK_DB_NAME`.`cor_tbl_file` (
`id` int( 11 ) NOT NULL AUTO_INCREMENT ,
`itemkey` varchar( 50 ) COLLATE utf8_unicode_ci NOT NULL default '',
`itemvalue` varchar( 30 ) COLLATE utf8_unicode_ci NOT NULL default '',
`file` varchar( 255 ) COLLATE utf8_unicode_ci NOT NULL default '',
`cre_by` int( 11 ) NOT NULL default '0',
`cre_on` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY ( `id` ) ,
FULLTEXT KEY `txt` ( `file` )
) ENGINE = MYISAM DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci COMMENT = 'Allows frags of class file to be linked';

First set the registered files directory in the settings.php. This directory needs to exist and be writeable by the www user.

 // FILES
 $registered_files_dir = $ark_server_path . '/data/files/';

You will then have to make sure you have 2 files in that directory (the folder and files should already exist if you have got a fresh copy of the codebase)

  • blank.jpg
  • tahomabd.ttf


Now add a field to handle the files in field_settings.php

 //FILE FIELDS
 $conf_field_file =
   array(
       'dataclass' => 'file',
       'classtype' => 'file',
       'alias_tbl' => 'cor_lut_file',
       'alias_col' => 'id',
       'alias_src_key' => '1',
       'alias_type' => '1',
       'editable' => TRUE,
       'hidden' => FALSE,
       'add_validation' => $file_add_validation,
       'edt_validation' => $file_edt_validation
 );

As you have stated in the above field settings that you will be usinf the file_add and edt validation - you need to set those up in your vd_settings.php

 // file - request and chkSet
 $file_vd_file =
   array(
       'rq_func' => 'reqMulti',
       'vd_func' => 'chkSkipBlank',
       'var_name' => 'file',
       'lv_name' => 'dyn_field',
       'var_locn' => 'request'
 );
 // file - request and chkSet
 $file_vd_requiredfile =
   array(
       'rq_func' => 'reqMulti',
       'vd_func' => 'chkSet',
       'var_name' => 'file',
       'lv_name' => 'dyn_field',
       'var_locn' => 'request'
 );
 // 4 - Compound items
 // itemkey - request and chkSet
 $file_vd_key =
   array(
       'rq_func' => 'reqMulti',
       'vd_func' => 'chkSet',
       'var_name' => 'itemkey',
       'lv_name' => 'item_key',
       'var_locn' => 'live'
 );
 // file - request and chkSet
 $file_vd_val =
   array(
       'rq_func' => 'reqItemVal',
       'vd_func' => 'chkSet',
       'var_name' => 'itemval',
       'lv_name' => 'itemval',
       'var_locn' => 'request',
       'req_keytype' => 'auto',
       'ret_keytype' => 'cd'
 );
 // add file default validation group
 $file_add_validation =
   array(
       $vd_cre_on,
       $vd_log,
       $vd_ste_cd,
       $vd_cre_by,
       $file_vd_file,
       $file_vd_key,
       $file_vd_val,
       $vd_lang
 );
 // edt file default validation group
 $file_edt_validation =
   array(
       $vd_cre_on,
       $vd_log,
       $vd_ste_cd,
       $vd_cre_by,
       $file_vd_file,
       $file_vd_key,
       $file_vd_val,
       $vd_frag_id,
       $vd_lang
 );


Finally add the field to the conf_register array in the mod_settings file, for example:

 $conf_register =
   array(
       'view_state' => 'max',
       'edit_state' => 'edit',
       'sf_title' => 'register', //appears in the titlebar of the subform (mk nname)
       'sf_html_id' => 'sph_cd_register', //the form id tag (must be unique)
       'script' => 'php/data_entry/register.php',
       'op_label' => 'save',
       'op_input' => 'save',
       'op_reg_mode' => 'sgl',
       'op_no_rows' => 15,
       'fields' => 
           array(
               $conf_field_itemkey,
               $conf_field_short_desc,
               $conf_field_cxtxmi,
               $conf_field_takenby,
               $conf_field_takenon,
               $conf_field_file,
               $conf_reg_op
       )
 );

In order to allow you to choose the sizes of thumbnails an array called thumbnail_sizes can be set in settings.php.

It should be in the form:

$thumbnail_sizes =
    array(
        'arkthumb_width' => 350,
        'arkthumb_height' => 400,
        'webthumb_width' => 500,
        'webthumb_height' => 500
);

In order to make it easier for your users to get to the upload page - you may want to add a link onto the data_entry page (add this in settings.php)

 $data_entry_left_panel[] = array('href' => "{$_SERVER['PHP_SELF']}?view=files", 'text' => 'Upload Files');

If you then want to add the subform to make the files display in your micro_view you need to set up your subform conf (in the mod_settings.php file). This is an example that should work (obviously you need to rename as appropriate):

 $conf_mcd_fph =
  array(
      'op_moddif' => FALSE,
      'view_state' => 'max',
      'edit_state' => 'view',
      'sf_title' => 'photo', //appears in the titlebar of the subform (mk nname)
      'sf_html_id' => 'spf_img_display', //the form id tag (must be unique)
      'script' => 'php/subforms/sf_file_imageflow.php',
      'sf_nav_type' => 'name',
      'op_lightbox' => TRUE,
      'op_default_dir' => 'data/files',
      'fields' => array(
          $conf_field_file
      ),
 );