<?php
    
class Formo extends Formo_Core
    
{
        protected 
$_remove_filter = array( );
        
        
/**
         * Automatyczne ustawienie akcji formularza oraz dodanie filtrów
         */
        
public function __construct$name 'formo'$type '')
        {           
            
parent :: __construct$name$type );
            
$this   -> set'action'url :: current( ) );
        }

        
/**
         * Dodanie komunikatu błedu na podstawie reguły walidacji
        */
        
public function add_rule$element$rule$message '' )
        {
            if( !
$message )
            {
                
$rule_name $this -> get_rule_name$rule );
                
$message Kohana :: lang'validation.' $rule_name], $rule_name] );
            }

            return 
parent :: add_rule$element$rule$message );
        }
 
        
/**
         * Pobranie nazwy funkcji reguły na podstawie jej nazwy
         *
         * @param string $rule Nazwa reguły
         * @return string Nazwa funkcji reguły
         */
        
private function get_rule_name$rule )
        {
            
$rule_name $rule;

            if( 
$pos strpos$rule_name'::' ) )
            {
                
$rule_name substr$rule_name$pos +);
            }

            if (
preg_match('/^([^\[]++)\[(.+)\]$/'$rule_name$matches))
            {
                
$rule_name $matches[1];
                
$args preg_split('/(?<!\\\\),\s*/'$matches[2]);

                
$args str_replace('\,'','$args);
            }

            
$rule_name str_replace'[]'''$rule_name );

            return array( 
$rule_name$args );
        }

        
/**
         * Usunięcie filtra z elementu
         *
         * @param string $element Nazwa elementu
         * @param string $filter Nazwa filtra
         * @return object
         */
        
public function remove_pre_filter$element$filter )
        {
            
$this -> _remove_filter$element ][ $filter ] = true;
            return 
$this;
        }
    }
?>