Login   Register  
PHP Classes
elePHPant
Icontem

File: plugins/html_checkboxes/plugin.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of P. Krijnberg  >  Expose template engine  >  plugins/html_checkboxes/plugin.php  >  Download  
File: plugins/html_checkboxes/plugin.php
Role: Auxiliary script
Content type: text/plain
Description: Checkboxes plugin
Class: Expose template engine
Template compiler engine extensible with plug-ins
Author: By
Last change: role
Date: 2006-02-11 06:09
Size: 1,001 bytes
 

Contents

Class file image Download
<?php
function expose_plugin_html_checkboxes( & $expose$params )
{
    
$params exposeMergeParameters$params, array(
        
'name'      => '',
        
'options'   => array(),
        
'selected'  => array(),
        
'attr'      => '',
        
'separator' => ''
    
) );
    
    
$params['options'] = exposeReadArray$params['options'] );
    
$params['selected'] = exposeReadArray$params['selected'] );
    
$count count$params['options'] );
    
$i 0;     

    foreach( 
$params['options'] as $key => $value )
    {
        if( 
is_array$value ) ) {
            
$key $value[0];
            
$value $value[1];
        }
        
$checkState in_array$key$params['selected'] ) ? 'checked="checked"' '';
        echo( 
"<label><input name=\"{$params['name']}[$key]\" value=\"$key\" type=\"checkbox\" {$params['attr']} $checkState/>$value</label>" );
        
        if( ++
$i $count ) {
            echo( 
$params['separator'] );
        }
    }
}
?>