Full Example

Full Example

The configuration file

<?php
/*
* typesmgm_yap.cfg
* Configuration file
* $Header: d:/cvs/classistd/yap/test5.php,v 1.2 2004/04/29 20:56:42 Administrator Exp $
*/

/**
* How to access the database and get the data
*/
$DbInfoCfg=array('selectquery'    => 'select * from items where ',    
                 
/* field to use to order the rows
                  * it must 'selected' from $SelectQuery
                  */         
                 
'orderfield'     => 'Description',
                 
/* order A=upward, D=descending*/
                 
'orderdirection' => 'A',                 
                 
'NeedOpenDb'     => false
                
);
// Field to use to perform searchs
$SearchFieldCfg=array(  
                    array(
'description' => 'Network Name',
                           
'fieldname'        => 'NetworkName',
                           
'type'         => 'A',
                           
'useregex'     => 1
                           
),
                    array(
'description' => 'Serial Number',
                           
'fieldname'        => 'SerialNo',
                           
'type'         => 'A',
                           
'useregex'     => 1
                           
),
                    array(
'description' => 'Ip Address',
                           
'fieldname'        => 'IpAddress',
                           
'type'         => 'A',
                           
'useregex'     => 1
                           
),                           
                    );
// Fields to show for each row
$ShowFieldCfg=array(
                  
// I'll set 4 field. First one
                  // Database field
                  
array('fieldname' => 'Description',
                        
'header'    => 'Description'),                  
                  array(
'fieldname' => 'serialNo',
                        
'header'    => 'Serial'),                  
                  array(
'fieldname' => 'NetworkName',
                        
'header'    => 'Network Name'),                  
                  array(
'fieldname' => 'IpAddress',
                        
'header'    => 'Ip'),                                          
                  );
                  
// set to show the detail mode link
$ShowInfoCfg=array(

'prefix' => 'pciobj1',                   // Prefix to apply to the session variable. This allows you
                                         // to have many CYap pages those do not interfere to each other
                 
'showdethref' => true,                   // set to show the detail mode link
// the following parameter tells to yap to call my custom
// page (showitem.php) instead to switch in detail mode if the user
// clicks on the details link
'customdetpage' => 'showitem.php',                     
            
// 'rowcallback' => '',                  // Callback function called on each row.  It is useful
                                         // to add custom link to each row. Optional, default no callback
                 
'exit' => 'index.php',                   // page to load on exit
                 
// 'OnOkHref' => '',                     // page to call if the add/modify action successed
                                         // (only add o modify mode).
                 
// 'OnAbortHref' => '',                  // page to call if the add/modify action is aborted
                                         // (only add o modify mode).
                 
'showfirstcallrow' => false,             // In the first call to this page shuold I shows the first
                                         // 15 records from the input (TRUE/FALSE, default: FALSE)
                 
'mode' => 'DisplayTable',                // DisplayTable (default), DisplayDetail (as detailmode=true),
                                         // Add, Modify                
                 
// 'KeyId' => '',                        // Index value of the row to be modfied (only modify mode)
                                
// 'boxclass' => 'CPciBox',              // Class used to draw an message box (default: CYapBox)
                 
// Not used, I said to use my page to show the row full detail.
// See below
// 'detailviewclass' => 'CYap_DetailView',  // Class used to render the row's detail
                                          // (default: CYap_DetailView)
// I need the picture link to detail/add/delete/modify function.
// I wrote the expension to perform that job, now I tell it
// to Yap.                 
'tableviewclass' => 'Pci_CYap_TableView', // As the previous one, butr use to
                                          // render the table (default: CYap_TableView)
/*
* As the previous parameter, set to use my class
*/                 
'skippageclass' => 'Pci_CYap_MoveToPage', // Display first, previous, next,
                                          // last page (default: CYap_MoveToPage)
                                
'pagenumberclass' => 'Pci_CYap_PageNumber',  // Display the number of the pages before and
                                          // after the current one (default: CYap_PageNumber)
                                         
'formclass' => 'Pci_CYap_Form',           // Draw the form to perform the add/modify functions
                                          // (default: CYap_Form)       
                 
);

// Enable the add/modify/delete row function.
// I don't set any callback function, so the link
// is enable on all roows
$ModifyInfoCfg=array(
                 
'table' => 'items',             // Table name
                 
'keyfield' => 'id',             // Unique identifier field.
                 
'showdelete' => true,          // Should I show the delete link on each row?
                 
'showmodify' => true,          // Should I show the modify link on each row?

'showadd' => true,             // Should I show the new row link?

/*
* This is a special case where the modify functions provided by yap don't
* match my requirements, so I set to call my custom page.
*/
'customaddpage' => 'NewObject.php',
'custommodifypage' => 'showitem.php',
'customdeletepage' => 'removeitem.php',
/*
* I don't want enable the delete function to everyone. So i wrote
* the function MayIRemove to check (on each row) if enable or not
* the link
*/
'deleteallow' => 'MayIRemove',

);

?>