text:
<container xmlns="http://symfony.com/schema/dic/services"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://symfony.com/schema/dic/services/services-1.0.xsd">
    <services>
        <service id="sonata.admin.pages" class="BardisCMS\PageBundle\Admin\PageAdmin">
            <tag name="sonata.admin" manager_type="orm" group="Pages" label="Website Pages" />
            <argument />
            <argument>BardisCMS\PageBundle\Entity\Page</argument>
            <argument>PageBundle:PageAdmin</argument>
            <call method="setTranslationDomain">
                <argument>PageBundle</argument>
            </call>
        </service>
        <service id="sonata.admin.categories" class="BardisCMS\CategoryBundle\Admin\CategoryAdmin">
            <tag name="sonata.admin" manager_type="orm" group="Category" label="Categories" />
            <argument />
            <argument>BardisCMS\CategoryBundle\Entity\Category</argument>
            <argument>CategoryBundle:CategoryAdmin</argument>
            <call method="setTranslationDomain">
                <argument>CategoryBundle</argument>
            </call>
        </service>
        <service id="sonata.admin.tags" class="BardisCMS\TagBundle\Admin\TagAdmin">
            <tag name="sonata.admin" manager_type="orm" group="Tag" label="Tags" />
            <argument />
            <argument>BardisCMS\TagBundle\Entity\Tag</argument>
            <argument>TagBundle:TagAdmin</argument>
            <call method="setTranslationDomain">
                <argument>TagBundle</argument>
            </call>
        </service>
        <service id="sonata.admin.blogs" class="BardisCMS\BlogBundle\Admin\BlogAdmin">
            <tag name="sonata.admin" manager_type="orm" group="Blog" label="Blog Pages" />
            <argument />
            <argument>BardisCMS\BlogBundle\Entity\Blog</argument>
            <argument>BlogBundle:BlogAdmin</argument>
            <call method="setTranslationDomain">
                <argument>BlogBundle</argument>
            </call>
        </service>
        <service id="sonata.admin.menus" class="BardisCMS\MenuBundle\Admin\MenuAdmin">
            <tag name="sonata.admin" manager_type="orm" group="Menus" label="Menus" />
            <argument />
            <argument>BardisCMS\MenuBundle\Entity\Menu</argument>
            <argument>MenuBundle:MenuAdmin</argument>
            <call method="setTranslationDomain">
                <argument>MenuBundle</argument>
            </call>
        </service>
        <service id="sonata.admin.contentblocks" class="BardisCMS\ContentBlockBundle\Admin\ContentBlockAdmin">
            <tag name="sonata.admin" manager_type="orm" group="Content Blocks" label="Content Blocks" />
            <argument />
            <argument>BardisCMS\ContentBlockBundle\Entity\ContentBlock</argument>
            <argument>SonataAdminBundle:CRUD</argument>
            <call method="setTranslationDomain">
                <argument>ContentBlockBundle</argument>
            </call>
        </service>
        <service id="sonata.admin.settings" class="BardisCMS\SettingsBundle\Admin\SettingsAdmin">
            <tag name="sonata.admin" manager_type="orm" group="Settings" label="Website Settings" />
            <argument />
            <argument>BardisCMS\SettingsBundle\Entity\Settings</argument>
            <argument>SettingsBundle:SettingsAdmin</argument>
            <call method="setTranslationDomain">
                <argument>SettingsBundle</argument>
            </call>
        </service>
        <service id="sonata.media.resizer.bardiscms" class="BardisCMS\ContentBlockBundle\Media\Resizer\BardisCMSResizer">
            <tag name="sonata.media.resizer" />
            <argument type="service" id="sonata.media.adapter.image.gd" />
        </service>
        <service id="sonata.admin.comments" class="BardisCMS\CommentBundle\Admin\CommentAdmin">
            <tag name="sonata.admin" manager_type="orm" group="Comments" label="Comments" />
            <argument />
            <argument>BardisCMS\CommentBundle\Entity\Comment</argument>
            <argument>CommentBundle:CommentAdmin</argument>
            <call method="setTranslationDomain">
                <argument>CommentBundle</argument>
            </call>
        </service>
        <service id="sonata.block.service.clearcache" class="BardisCMS\PageBundle\Block\Service\ClearCacheService">
            <tag name="sonata.block" />
            <argument>sonata.block.clearcache</argument>
            <argument type="service" id="templating" />
        </service>
        <service id="guzzle.client.adapter" class="Csa\Bundle\GuzzleBundle\GuzzleHttp\Cache\DoctrineAdapter">
            <argument type="service" id="guzzle.client.cache.service" />
        </service>
        <service id="guzzle.client.cache.service" class="Doctrine\Common\Cache\FilesystemCache">
            <argument>"%kernel.cache_dir%/data/guzzle_cache"</argument>
            <argument>7200</argument>
        </service>
    </services>
</container>

redpajama_set_name: RedPajamaGithub


text:
<!DOCTYPE html>

    <meta http-equiv="refresh" content="0;URL=../../openssl_sys/fn.SSL_get_selected_srtp_profile.html">

Redirecting to ../../openssl_sys/fn.SSL_get_selected_srtp_profile.html...


text:
<?php

/**
 * Form module for O3 Engine
 *
 * @package o3
 * @link    todo: add url
 * @author  Zotlan Fischer <zoli_fischer@yahoo.com>
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 */

/**
* Base class for o3 form module classes
*/
class o3_form_base_class {

	//form is in scope, all fields will be added to this form
	static $o3_form_base_current_form = '';

	//if in form is in scope create knockout bindings
	static $o3_form_base_current_knockout = true;

	//type of field - form, text, percent, number, checkbox, radio
	public $type = 'text';

	//label
	public $label = '';

	//mandatory to be filled
	public $mandatory_ = false;

	//checked only for radio and checkbox
	public $checked_ = false;

	//error msg to show on not valid
	public $error_ = '';

	//parent form of input
	public $form_ = '';

	//attributes for field (input/select)
	public $field_attr_ = '';

	//data-bind attribute for field (input/select)
	public $field_bind_ = array();

	//attributes for the container
	public $attr_ = '';

	//data-bind attribute for the container
	public $bind_ = array();

	//node slist for nested fields like checkbox list, radio
	public $nodes = array();

	/*
	* Constructor
	*/
	function __construct( $type = 'text', $label = '', $id = '', $value = null ) {
		//set scope from
		$this->form( o3_form_base_class::$o3_form_base_current_form );

		//initialize
		$this->type = $type;
		$this->label = $label;
		$this->field_attr( 'value', $value === null ? '' : $value );
		$this->field_attr( 'id', $id );

		//set container id
		$this->attr( 'id', 'o3-form-field-'.( $this->form() != '' ? $this->form().'-' : '' ).$this->field_attr('id') );
		$this->attr( 'class', 'o3-form-field-holder o3-form-field-holder-'.$this->type );

		$name = $id;
		if ( $type != 'form' )
			$name = ( $this->form() != '' ? $this->form().'[' : '' ).$id.( $this->form() != '' ? ']' : '' );
		$this->field_attr( 'name', $name );

		//set o3 form type attr for javascript
		$this->field_attr('o3-form-type',$this->type);
	}

	/*
	* Buffer
	* @return string
	*/
	public function buffer() {
		$buffer = '';
		return $buffer;
	}

	/*
	* Print the buffer
	* @return self / string
	*/
	public function flush( $output = true ) {
		$buffer = $this->buffer();
		if ( $output ) {
			echo $buffer;
			return $this;
		}
		return $buffer;
	}

	/*
	* Set or get field attributes
	*
	* @param $attr_name Name of the attribute to get or set
	* @param $attr_value (optional) The value to set to the attribute
	* @param $append (optional) If true the attribute is replaced with the value, else is appended
	*
	* @return mixed If 2nd parameter omited the value of attribute else the object itself
	*/
	public function field_attr() {
		$args = func_get_args();
		if ( func_num_args() > 1 ) {
			if ( isset($args[2]) && $args[2] === true ) {
				//replace
				$this->field_attr_[$args[0]] = $args[1];
			} else {
				//append
				$this->field_attr_[$args[0]] = trim( ( isset($this->field_attr_[$args[0]]) ? $this->field_attr_[$args[0]].' ' : '' ).$args[1] );
			}
		} else if ( func_num_args() > 0 ) {
			return isset($this->field_attr_[$args[0]]) ? $this->field_attr_[$args[0]] : '';
		}
		return $this;
	}

	/*
	* Set or get attributes for container
	*
	* @param $attr_name Name of the attribute to get or set
	* @param $attr_value (optional) The value to set to the attribute
	* @param $append (optional) If true the attribute is replaced with the value, else is appended
	*
	* @return mixed If 2nd parameter omited the value of attribute else the object itself
	*/
	public function attr() {
		$args = func_get_args();
		if ( func_num_args() > 1 ) {
			if ( isset($args[2]) && $args[2] === true ) {
				//replace
				$this->attr_[$args[0]] = $args[1];
			} else {
				//append
				if ( isset($args[0]) )
				$this->attr_[$args[0]] = trim( ( isset($this->attr_[$args[0]]) ? $this->attr_[$args[0]].' ' : '' ).$args[1] );
			}
		} else if ( func_num_args() > 0 ) {
			return $this->attr_[$args[0]];
		}
		return $this;
	}

	/*
	* Set form true / false or get value
	*/
	public function form() {
		$args = func_get_args();
		if ( func_num_args() > 0 ) {
			$this->form_ = $args[0];
		} else {
			return $this->form_;
		}
		return $this;
	}

	/*
	* Set mandatory true / false or get value
	*/
	public function mandatory() {
		$args = func_get_args();
		if ( func_num_args() > 0 ) {
			$this->mandatory_ = $args[0];
		} else {
			return $this->mandatory_;
		}
		return $this;
	}

	/*
	* Set checked true / false or get value
	*/
	public function checked() {
		$args = func_get_args();
		if ( func_num_args() > 0 ) {
			$this->checked_ = $args[0];
		} else {
			return $this->checked_;
		}
		return $this;
	}

	/*
	* Set error message or get value
	*/
	public function error() {
		$args = func_get_args();
		if ( func_num_args() > 0 ) {
			$this->error_ = $args[0];
		} else {
			return $this->error_;
		}
		return $this;
	}

	/*
	* Set or get data-bind attribute values
	*
	* @param $bind_name Name of the attribute to get or set
	* @param $bind_value (optional) The value to set to the attribute
	* @param $append (optional) If true the attribute is replaced with the value, else is appended
	*
	* @return mixed If 2nd parameter omited the value of attribute else the object itself
	*/
	public function field_bind() {
		$args = func_get_args();
		if ( func_num_args() > 1 ) {
			if ( isset($args[2]) && $args[2] === true ) {
				//replace
				$this->field_bind_[$args[0]] = $args[1];
			} else {
				//append and trim the sep. comma
				$this->field_bind_[$args[0]] = o3_trim( ( isset($this->field_bind_[$args[0]]) ? $this->field_bind_[$args[0]].', ' : '' ).o3_trim( $args[1], ',' ), ',' );
			}
		} else if ( func_num_args() > 0 ) {
			return $this->field_bind_[$args[0]];
		}
		return $this;
	}

	/*
	* Set or get data-bind attribute values for container
	*
	* @param $bind_name Name of the attribute to get or set
	* @param $bind_value (optional) The value to set to the attribute
	* @param $append (optional) If true the attribute is replaced with the value, else is appended
	*
	* @return mixed If 2nd parameter omited the value of attribute else the object itself
	*/
	public function bind() {
		$args = func_get_args();
		if ( func_num_args() > 1 ) {
			if ( isset($args[2]) && $args[2] === true ) {
				//replace
				$this->bind_[$args[0]] = $args[1];
			} else {
				//append and trim the sep. comma
				$this->bind_[$args[0]] = o3_trim( ( isset($this->bind_[$args[0]]) ? $this->bind_[$args[0]].', ' : '' ).o3_trim( $args[1], ',' ), ',' );
			}
		} else if ( func_num_args() > 0 ) {
			return $this->bind_[$args[0]];
		}
		return $this;
	}

	/*
	* Returns data-bind attribute value
	*/
	public function get_field_bind() {
		$binds = array();
		foreach ( $this->field_bind_ as $key => $value ) {
			if ( $key == 'css' || $key == 'event' || $key == 'attr' )
				$value = '{ '.$value.' }';
			$binds[] = ' '.$key.': '.$value.' ';
		}
		return implode(', ', $binds);
	}

	/*
	* Returns data-bind attribute container
	*/
	public function get_bind() {
		$binds = array();
		foreach ( $this->bind_ as $key => $value ) {
			if ( $key == 'css' || $key == 'event' || $key == 'attr' )
				$value = '{ '.$value.' }';
			$binds[] = ' '.$key.': '.$value.' ';
		}
		return implode(', ', $binds);
	}

	/*
	* Returns attributes string for input
	*/
	public function get_field_attr() {

		$bind = $this->get_field_bind();
		if ( $bind != '' )
			$this->field_attr( 'data-bind', $bind );

		$attrs = array();
		foreach ( $this->field_attr_ as $key => $value )
			$attrs[] = ' '.$key.'="'.o3_html($value,ENT_COMPAT).'" ';

		return implode( ' ', $attrs);
	}

	/*
	* Returns attributes string for container
	*/
	public function get_attr() {

		$bind = $this->get_bind();
		if ( $bind != '' )
			$this->attr( 'data-bind', $bind );

		$attrs = array();
		foreach ( $this->attr_ as $key => $value )
			$attrs[] = ' '.$key.'="'.o3_html($value,ENT_COMPAT).'" ';

		return implode( ' ', $attrs);
	}

	/*
	* Add node
	* @param - $label
	* @param - $value
	*/
	function node( $label, $value, $id = "" ) {
		$this->nodes[] = new o3_form_radio_node( $label, $id, $value );
		return $this;
	}

	/*
	* Set / get validator function name
	*/
	function validator() {
		$args = func_get_args();
		if ( func_num_args() > 0 ) {
			$this->field_attr('o3-form-validator',$args[0],true);
			return $this;
		}
		return $this->field_attr('o3-form-validator');
	}

}

/**
* Base class for HTML input/select field
*/
class o3_form_field_base_class extends o3_form_base_class {

	//attributes for error
	var $error_attr_ = array();

	/*
	* Set or get error attributes
	* If 1 parameter passed gets the attribute, if 2 parameter passed sets the attribute with the 2nd parameter value
	*/
	function error_attr() {
		$args = func_get_args();
		if ( func_num_args() > 1 ) {
			$this->error_attr_[$args[0]] = $args[1];
		} else if ( func_num_args() > 0 ) {
			return $this->error_attr_[$args[0]];
		}
		return $this;
	}

	/*
	* Returns error attributes string for input
	*/
	public function get_error_attr() {
		$error_attrs = array();
		foreach ( $this->error_attr_ as $key => $value ) {
			$error_attrs[] = ' '.$key.'="'.$value.'" ';
		}

		return implode( ' ', $error_attrs);
	}

}

/**
* HTML text input email value
*/
class o3_form_email extends o3_form_field_base_class {

	/*
	* Constructor
	*/
	function __construct( $label, $id, $value = null ) {
		global $o3;
		parent::__construct( 'email', $label, $id, $value );

		if ( o3_form_base_class::$o3_form_base_current_knockout ) {
			//Add knockout update by keypress
			$this->field_bind( 'valueUpdate', "'keyup'" );

			//Add knockout value
			$this->field_bind( 'value', ( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id') );

			//Event to readonly on loading
			//$this->field_bind( "attr", "readonly: ".( $this->form() != '' ? $this->form().'.' : '' )."loading" );
		}

		//validator function
		$this->validator('email');

		//add mandatory class
		/*if ( $this->mandatory() )
			$this->attr( 'class', $this->attr( 'class' ).' o3-form-field-mandatory ' );
		*/

		//Set valid decimal error message
		$this->error( isset($o3) && isset($o3->lang) ? $o3->lang->_(O3_FORM_ERR_VALID_EMAIL) : O3_FORM_ERR_VALID_EMAIL );

		//Add class to error msg
		$this->error_attr( 'class', 'o3-form-field-error' );
	}

	/*
	* Buffer
	* @return string
	*/
	public function buffer() {

		$buffer = '
get_attr().'>

						field_attr('id').'">'.$this->label.'';

		$buffer .= '<input type="email" novalidate="novalidate" oninvalid="return false" '.$this->get_field_attr().' />';

		$buffer .= '

get_error_attr().'>'.nl2br(o3_html( isset($this->error_attr_['text']) ? $this->error_attr_['text'] : '' )).'

';

		return $buffer;
	}

	/*
	* Print the buffer
	* @return self / string
	*/
	public function flush( $output = true ) {
		global $o3;

		//if mandatory
		if ( $this->mandatory() ) {

			//update the error text
			$this->error( trim($this->error()."\n".( isset($o3) && isset($o3->lang) ? $o3->lang->_(O3_FORM_ERR_MANDATORY) : O3_FORM_ERR_MANDATORY ) ) );

			//javascript reference
			$this->field_attr('o3-form-mandatory','true');
		}

		//if validator or mandatory add error
		if ( $this->validator() != '' || $this->mandatory() )
			if ( o3_form_base_class::$o3_form_base_current_knockout ) {
				$this->field_bind( "o3_validate", ( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id') );
				$this->field_bind( "css", "'o3-field-error': ".( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').".o3_showError()" );

				//show field error
				$this->error_attr( 'data-bind', 'o3_slideVisible: '.( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').'.o3_showError ? '.( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').'.o3_showError() : false' );
			}

		if ( !isset($this->error_attr_['text']) )
			$this->error_attr( 'text', $this->error() );

		$buffer = $this->buffer();
		if ( $output ) {
			echo $buffer;
			return $this;
		}
		return $buffer;
	}

}

/**
* HTML text input float value
*/
class o3_form_number extends o3_form_field_base_class {

	/*
	* Constructor
	*/
	function __construct( $label, $id, $value = null ) {
		global $o3;
		parent::__construct( 'number', $label, $id, $value );

		if ( o3_form_base_class::$o3_form_base_current_knockout ) {
			//Add knockout update by keypress
			$this->field_bind( 'valueUpdate', "'keyup'" );

			//Add knockout value
			$this->field_bind( 'value', ( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id') );

			//Event to readonly on loading
			//$this->field_bind( "attr", "readonly: ".( $this->form() != '' ? $this->form().'.' : '' )."loading" );
		}

		//validator function
		$this->validator('number');

		//add mandatory class
		if ( $this->mandatory() )
			$this->attr( 'class', $this->attr( 'class' ).' o3-form-field-mandatory ' );

		//Set valid decimal error message
		$this->error( isset($o3) && isset($o3->lang) ? $o3->lang->_(O3_FORM_ERR_VALID_NUMBER) : O3_FORM_ERR_VALID_NUMBER );

		//Add class to error msg
		$this->error_attr( 'class', 'o3-form-field-error' );
	}

	/*
	* Buffer
	* @return string
	*/
	public function buffer() {

		$buffer = '
get_attr().'>

						field_attr('id').'">'.$this->label.'';

		$buffer .= '<input type="text" '.$this->get_field_attr().' />';

		$buffer .= '

get_error_attr().'>'.nl2br(o3_html( isset($this->error_attr_['text']) ? $this->error_attr_['text'] : '' )).'

';

		return $buffer;
	}

	/*
	* Print the buffer
	* @return self / string
	*/
	public function flush( $output = true ) {
		global $o3;

		//if mandatory
		if ( $this->mandatory() ) {

			//update the error text
			$this->error( trim($this->error()."\n".( isset($o3) && isset($o3->lang) ? $o3->lang->_(O3_FORM_ERR_MANDATORY) : O3_FORM_ERR_MANDATORY ) ) );

			//javascript reference
			$this->field_attr('o3-form-mandatory','true');
		}

		//if validator or mandatory add error
		if ( $this->validator() != '' || $this->mandatory() )
			if ( o3_form_base_class::$o3_form_base_current_knockout ) {
				$this->field_bind( "o3_validate", ( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id') );
				$this->field_bind( "css", "'o3-field-error': ".( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').".o3_showError()" );

				//show field error
				$this->error_attr( 'data-bind', 'o3_slideVisible: '.( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').'.o3_showError ? '.( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').'.o3_showError() : false' );
			}

		if ( !isset($this->error_attr_['text']) )
			$this->error_attr( 'text', $this->error() );

		$buffer = $this->buffer();
		if ( $output ) {
			echo $buffer;
			return $this;
		}
		return $buffer;
	}

}

/**
* HTML text input float value
*/
class o3_form_float extends o3_form_field_base_class {

	/*
	* Constructor
	*/
	function __construct( $label, $id, $value = null ) {
		global $o3;
		parent::__construct( 'float', $label, $id, $value );

		if ( o3_form_base_class::$o3_form_base_current_knockout ) {
			//Add knockout update by keypress
			$this->field_bind( 'valueUpdate', "'keyup'" );

			//Add knockout value
			$this->field_bind( 'value', ( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id') );

			//Event to readonly on loading
			//$this->field_bind( "attr", "readonly: ".( $this->form() != '' ? $this->form().'.' : '' )."loading" );
		}

		//validator function
		$this->validator('float');

		//Set valid decimal error message
		$this->error( isset($o3) && isset($o3->lang) ? $o3->lang->_(O3_FORM_ERR_VALID_FLOAT) : O3_FORM_ERR_VALID_FLOAT );

		//Add class to error msg
		$this->error_attr( 'class', 'o3-form-field-error' );
	}

	/*
	* Buffer
	* @return string
	*/
	public function buffer() {

		//add mandatory class
		if ( $this->mandatory() )
			$this->attr( 'class', $this->attr( 'class' ).' o3-form-field-mandatory ' );

		$buffer = '
get_attr().'>

						field_attr('id').'">'.$this->label.'';

		$buffer .= '<input type="text" '.$this->get_field_attr().' />';

		$buffer .= '

get_error_attr().'>'.nl2br(o3_html( isset($this->error_attr_['text']) ? $this->error_attr_['text'] : '' )).'

';

		return $buffer;
	}

	/*
	* Print the buffer
	* @return self / string
	*/
	public function flush( $output = true ) {
		global $o3;

		//if mandatory
		if ( $this->mandatory() ) {

			//update the error text
			$this->error( trim($this->error()."\n".( isset($o3) && isset($o3->lang) ? $o3->lang->_(O3_FORM_ERR_MANDATORY) : O3_FORM_ERR_MANDATORY ) ) );

			//javascript reference
			$this->field_attr('o3-form-mandatory','true');
		}

		//if validator or mandatory add error
		if ( $this->validator() != '' || $this->mandatory() )
			if ( o3_form_base_class::$o3_form_base_current_knockout ) {
				$this->field_bind( "o3_validate", ( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id') );
				$this->field_bind( "css", "'o3-field-error': ".( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').".o3_showError() " );

				//show field error
				$this->error_attr( 'data-bind', 'o3_slideVisible: '.( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').'.o3_showError ? '.( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').'.o3_showError() : false' );
			}

		if ( !isset($this->error_attr_['text']) )
			$this->error_attr( 'text', $this->error() );

		$buffer = $this->buffer();
		if ( $output ) {
			echo $buffer;
			return $this;
		}
		return $buffer;
	}

}

/**
* HTML text input
*/
class o3_form_select extends o3_form_field_base_class {

	/*
	* Constructor
	*/
	function __construct( $label, $id, $value = null ) {
		parent::__construct( 'select', $label, $id, $value );

		if ( o3_form_base_class::$o3_form_base_current_knockout ) {
			//Add knockout update by keypress
			$this->field_bind( 'valueUpdate', "'keyup'" );

			//Add knockout value
			$this->field_bind( 'value', ( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id') );

			//Event to readonly on loading
			//$this->field_bind( "attr", "readonly: ".( $this->form() != '' ? $this->form().'.' : '' )."loading" );
		}

		//Add class to error msg
		$this->error_attr( 'class', 'o3-form-field-error' );
	}

	/*
	* Buffer
	* @return string
	*/
	public function buffer() {

		//add mandatory class
		if ( $this->mandatory() )
			$this->attr( 'class', $this->attr( 'class' ).' o3-form-field-mandatory ' );

		$buffer = '
get_attr().'>

						field_attr('id').'">'.$this->label.'
						<select '.$this->get_field_attr().'>';

		foreach ( $this->nodes as $node )
			$buffer .= '<option value="'.o3_html($node->field_attr('value')).'">'.$node->label.'</option>';

		$buffer .= '</select>

get_error_attr().'>'.nl2br(o3_html( isset($this->error_attr_['text']) ? $this->error_attr_['text'] : '' )).'

';

		return $buffer;
	}

	/*
	* Print the buffer
	* @return self / string
	*/
	public function flush( $output = true ) {
		global $o3;

		//if mandatory
		if ( $this->mandatory() ) {

			//update the error text
			$this->error( isset($o3) && isset($o3->lang) ? $o3->lang->_(O3_FORM_ERR_MANDATORY) : O3_FORM_ERR_MANDATORY );

			//javascript reference
			$this->field_attr('o3-form-mandatory','true');

		}

		//if validator or mandatory add error
		if ( $this->validator() != '' || $this->mandatory() )
			if ( o3_form_base_class::$o3_form_base_current_knockout ) {
				$this->field_bind( "o3_validate", ( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id') );
				$this->field_bind( "css", "'o3-field-error': ".( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').".o3_showError()" );

				//show field error
				$this->error_attr( 'data-bind', 'o3_slideVisible: '.( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').'.o3_showError ? '.( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').'.o3_showError() : false' );
			}

		if ( !isset($this->error_attr_['text']) )
			$this->error_attr( 'text', $this->error() );

		$buffer = $this->buffer();
		if ( $output ) {
			echo $buffer;
			return $this;
		}
		return $buffer;
	}

}

/**
* HTML text input
*/
class o3_form_text extends o3_form_field_base_class {

	/*
	* Constructor
	*/
	function __construct( $label, $id, $value = null ) {
		parent::__construct( 'text', $label, $id, $value );

		if ( o3_form_base_class::$o3_form_base_current_knockout ) {
			//Add knockout update by keypress
			$this->field_bind( 'valueUpdate', "'keyup'" );

				//Add knockout value
			$this->field_bind( 'value', ( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id') );

			//Event to readonly on loading
			//$this->field_bind( "attr", "readonly: ".( $this->form() != '' ? $this->form().'.' : '' )."loading" );
		}

		//Add class to error msg
		$this->error_attr( 'class', 'o3-form-field-error' );
	}

	/*
	* Buffer
	* @return string
	*/
	public function buffer() {

		//add mandatory class
		if ( $this->mandatory() )
			$this->attr( 'class', $this->attr( 'class' ).' o3-form-field-mandatory ' );

		$buffer = '
get_attr().'>

						field_attr('id').'">'.$this->label.'';

		$buffer .= '<input type="'.$this->type.'" '.$this->get_field_attr().' />';

		$buffer .= '

get_error_attr().'>'.nl2br(o3_html( isset($this->error_attr_['text']) ? $this->error_attr_['text'] : '' )).'

';

		return $buffer;
	}

	/*
	* Print the buffer
	* @return self / string
	*/
	public function flush( $output = true ) {
		global $o3;

		//if mandatory
		if ( $this->mandatory() ) {

			//update the error text
			$this->error( trim($this->error()."\n".( isset($o3) && isset($o3->lang) ? $o3->lang->_(O3_FORM_ERR_MANDATORY) : O3_FORM_ERR_MANDATORY ) ) );

			//javascript reference
			$this->field_attr('o3-form-mandatory','true');
		}

		//if validator or mandatory add error
		if ( $this->validator() != '' || $this->mandatory() )
			if ( o3_form_base_class::$o3_form_base_current_knockout ) {
				$this->field_bind( "o3_validate", ( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id') );
				$this->field_bind( "css", "'o3-field-error': ".( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').".o3_showError()" );

				//show field error
				$this->error_attr( 'data-bind', 'o3_slideVisible: '.( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').'.o3_showError ? '.( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').'.o3_showError() : false' );
			}

		if ( !isset($this->error_attr_['text']) )
			$this->error_attr( 'text', $this->error() );

		$buffer = $this->buffer();
		if ( $output ) {
			echo $buffer;
			return $this;
		}
		return $buffer;
	}

}

/**
* HTML text input
*/
class o3_form_textarea extends o3_form_field_base_class {

	/*
	* Constructor
	*/
	function __construct( $label, $id, $value = null ) {
		parent::__construct( 'textarea', $label, $id, $value );

		if ( o3_form_base_class::$o3_form_base_current_knockout ) {
			//Add knockout update by keypress
			$this->field_bind( 'valueUpdate', "'keyup'" );

				//Add knockout value
			$this->field_bind( 'value', ( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id') );

			//Event to readonly on loading
			//$this->field_bind( "attr", "readonly: ".( $this->form() != '' ? $this->form().'.' : '' )."loading" );
		}

		//Add class to error msg
		$this->error_attr( 'class', 'o3-form-field-error' );
	}

	/*
	* Buffer
	* @return string
	*/
	public function buffer() {

		//add mandatory class
		if ( $this->mandatory() )
			$this->attr( 'class', $this->attr( 'class' ).' o3-form-field-mandatory ' );

		$buffer = '
get_attr().'>

						field_attr('id').'">'.$this->label.'';

		$buffer .= '<textarea '.$this->get_field_attr().'></textarea>';

		$buffer .= '

get_error_attr().'>'.nl2br(o3_html( isset($this->error_attr_['text']) ? $this->error_attr_['text'] : '' )).'

';

		return $buffer;
	}

	/*
	* Print the buffer
	* @return self / string
	*/
	public function flush( $output = true ) {
		global $o3;

		//if mandatory
		if ( $this->mandatory() ) {

			//update the error text
			$this->error( trim($this->error()."\n".( isset($o3) && isset($o3->lang) ? $o3->lang->_(O3_FORM_ERR_MANDATORY) : O3_FORM_ERR_MANDATORY ) ) );

			//javascript reference
			$this->field_attr('o3-form-mandatory','true');

		}

		//if validator or mandatory add error
		if ( $this->validator() != '' || $this->mandatory() )
			//data-bind
			if ( o3_form_base_class::$o3_form_base_current_knockout ) {
				$this->field_bind( "o3_validate", ( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id') );
				$this->field_bind( "css", "'o3-field-error': ".( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').".o3_showError()" );

				//show field error
				$this->error_attr( 'data-bind', 'o3_slideVisible: '.( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').'.o3_showError ? '.( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').'.o3_showError() : false' );
			}

		if ( !isset($this->error_attr_['text']) )
			$this->error_attr( 'text', $this->error() );

		$buffer = $this->buffer();
		if ( $output ) {
			echo $buffer;
			return $this;
		}
		return $buffer;
	}

}

/**
* HTML hidden input
*/
class o3_form_hidden extends o3_form_field_base_class {

	/*
	* Constructor
	*/
	function __construct( $id, $value = null ) {
		parent::__construct( 'hidden', '', $id, $value );

		if ( o3_form_base_class::$o3_form_base_current_knockout ) {
			//Add knockout value
			$this->field_bind( 'value', ( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id') );
		}

	}

	/*
	* Buffer
	* @return string
	*/
	public function buffer() {
		$buffer = '<input type="'.$this->type.'" '.$this->get_field_attr().' />';
		return $buffer;
	}

	/*
	* Print the buffer
	* @return self / string
	*/
	public function flush( $output = true ) {
		$buffer = $this->buffer();
		if ( $output ) {
			echo $buffer;
			return $this;
		}
		return $buffer;
	}

}

/**
* HTML text input
*/
class o3_form_password extends o3_form_field_base_class {

	// False input type is text else password
	public $show_characters = false;

	//password check param.
	public $min_length = 8;
	public $max_length = 32;
	public $special_chars = "-+=?!*:;.,@#$^%&";

	/*
	* Constructor
	*/
	function __construct( $label, $id, $value = null, $min_length = 8, $max_length = 32, $special_chars = "-+=?!*:;.,@#$^%&" ) {
		global $o3;
		parent::__construct( 'password', $label, $id, $value );

		//password check param.
		$this->min_length = $min_length;
		$this->max_length = $max_length;
		$this->special_chars = $special_chars;

		if ( o3_form_base_class::$o3_form_base_current_knockout ) {
			//Add knockout update by keypress
			$this->field_bind( 'valueUpdate', "'keyup'" );

			//Add knockout value
			$this->field_bind( 'value', ( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id') );

			//Event to readonly on loading
			//$this->field_bind( "attr", "readonly: ".( $this->form() != '' ? $this->form().'.' : '' )."loading" );
		}

		//validator function
		$this->validator('password');

		//Set valid decimal error message
		$this->error( sprintf( isset($o3) && isset($o3->lang) ? $o3->lang->_(O3_FORM_ERR_VALID_PASSWORD) : O3_FORM_ERR_VALID_PASSWORD, $this->min_length, $this->max_length, $this->special_chars ) );

		//Add class to error msg
		$this->error_attr( 'class', 'o3-form-field-error' );
	}

	/*
	* Input type is password or text
	*/
	public function show_characters( $value = true ) {
		$this->show_characters = true;
		return $this;
	}

	/*
	* Buffer
	* @return string
	*/
	public function buffer() {

		$buffer = '
get_attr().'>

						field_attr('id').'">'.$this->label.'';

		$buffer .= '<input type="'.( $this->show_characters ? 'text' : 'password' ).'" '.$this->get_field_attr().' />';

		$buffer .= '

get_error_attr().'>'.nl2br(o3_html( isset($this->error_attr_['text']) ? $this->error_attr_['text'] : '' )).'

';

		return $buffer;
	}

	/*
	* Print the buffer
	* @return self / string
	*/
	public function flush( $output = true ) {
		global $o3;

		//if mandatory
		if ( $this->mandatory() ) {

			//update the error text
			$this->error( trim($this->error()."\n".( isset($o3) && isset($o3->lang) ? $o3->lang->_(O3_FORM_ERR_MANDATORY) : O3_FORM_ERR_MANDATORY ) ) );

			//javascript reference
			$this->field_attr('o3-form-mandatory','true');
		}

		//if validator or mandatory add error
		if ( $this->validator() != '' || $this->mandatory() )
			if ( o3_form_base_class::$o3_form_base_current_knockout ) {
				$this->field_bind( "o3_validate", ( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id') );
				$this->field_bind( "css", "'o3-field-error': ".( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').".o3_showError()" );

				//show field error
				$this->error_attr( 'data-bind', 'o3_slideVisible: '.( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').'.o3_showError ? '.( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').'.o3_showError() : false' );
			}

		if ( !isset($this->error_attr_['text']) )
			$this->error_attr( 'text', $this->error() );

		$buffer = $this->buffer();
		if ( $output ) {
			echo $buffer;
			return $this;
		}
		return $buffer;
	}

}

/**
* HTML checkbox input
*/
class o3_form_check extends o3_form_field_base_class {

	/*
	* Constructor
	*/
	function __construct( $label, $id, $value = null ) {
		parent::__construct( 'checkbox', $label, $id, $value );

		if ( o3_form_base_class::$o3_form_base_current_knockout ) {
			//Add knockout update by keypress
			$this->field_bind( 'valueUpdate', "'keyup'" );

			//Add knockout checked
			$this->field_bind( 'checked', ( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id') );

			//Event to readonly on loading
			//$this->field_bind( "attr", "readonly: ".( $this->form() != '' ? $this->form().'.' : '' )."loading" );
		}

		//Add class to error msg
		$this->error_attr( 'class', 'o3-form-field-error' );
	}

	/*
	* Buffer
	* @return string
	*/
	public function buffer() {

		//add mandatory class
		if ( $this->mandatory() )
			$this->attr( 'class', $this->attr( 'class' ).' o3-form-field-mandatory ' );

		$buffer = '
get_attr().'>

						field_attr('id').'">'.$this->label.'';

		$buffer .= '<input type="checkbox" '.$this->get_field_attr().' />';

		$buffer .= '

get_error_attr().'>'.nl2br(o3_html( isset($this->error_attr_['text']) ? $this->error_attr_['text'] : '' )).'

';

		return $buffer;
	}

	/*
	* Print the buffer
	* @return self / string
	*/
	public function flush( $output = true ) {
		global $o3;

		if ( $this->checked() ) {
			$this->field_attr('checked','checked');
		} else {
			unset($this->field_attr_['checked']);
		}

		//if mandatory
		if ( $this->mandatory() ) {

			//update the error text
			$this->error( isset($o3) && isset($o3->lang) ? $o3->lang->_(O3_FORM_ERR_MANDATORY) : O3_FORM_ERR_MANDATORY );

			//javascript reference
			$this->field_attr('o3-form-mandatory','true');
		}

		//if validator or mandatory add error
		if ( $this->validator() != '' || $this->mandatory() )
			if ( o3_form_base_class::$o3_form_base_current_knockout ) {
				$this->field_bind( "o3_validate", ( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id') );
				$this->field_bind( "css", "'o3-field-error': ".( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').".o3_showError()" );

				//show field error
				$this->error_attr( 'data-bind', 'o3_slideVisible: '.( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').'.o3_showError ? '.( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').'.o3_showError() : false' );
			}

		if ( !isset($this->error_attr_['text']) )
			$this->error_attr( 'text', $this->error() );

		$buffer = $this->buffer();
		if ( $output ) {
			echo $buffer;
			return $this;
		}
		return $buffer;
	}

}

/**
* HTML checkbox node object
*/
class o3_form_radio_node extends o3_form_field_base_class  {

	/*
	* Constructor
	*/
	function __construct( $label, $id = '', $value = null ) {
		parent::__construct( 'radio-node', $label, $id, $value );

		if ( o3_form_base_class::$o3_form_base_current_knockout ) {
			//Add knockout update by keypress
			$this->field_bind( 'valueUpdate', "'keyup'" );

			//Event to readonly on loading
			//$this->field_bind( "attr", "readonly: ".( $this->form() != '' ? $this->form().'.' : '' )."loading" );
		}
	}

	/*
	* Buffer
	* @return string
	*/
	public function buffer() {

		$buffer = '

						<input type="radio" '.$this->get_field_attr().' />
						field_attr('id').'">'.$this->label.'

				  ';

		return $buffer;
	}

	/*
	* Print the buffer
	* @return self / string
	*/
	public function flush( $output = true, $parent_name = '', $parent_id = '' ) {
		global $o3;

		//set name
		$this->field_attr('name', $parent_name );

		//Add knockout checked
		$this->field_bind( 'checked', ( $this->form() != '' ? $this->form().'.field.' : '' ).$parent_id );

		$buffer = $this->buffer();
		if ( $output ) {
			echo $buffer;
			return $this;
		}
		return $buffer;
	}

}

/**
* HTML checkbox input
*/
class o3_form_radio extends o3_form_field_base_class {

	/*
	* Constructor
	*/
	function __construct( $label, $id, $value = null ) {
		parent::__construct( 'radio', $label, $id, $value );

		if ( o3_form_base_class::$o3_form_base_current_knockout ) {
			;
		}

		$this->field_attr( 'class', 'o3-form-radio-list-holder' );

		//Add class to error msg
		$this->error_attr( 'class', 'o3-form-field-error' );
	}

	/*
	* Buffer
	* @return string
	*/
	public function buffer() {

		//add mandatory class
		if ( $this->mandatory() )
			$this->attr( 'class', $this->attr( 'class' ).' o3-form-field-mandatory ' );

		$buffer = '
get_attr().'>

						field_attr('id').'">'.$this->label.'';

		$buffer .= '
get_field_attr().'>';

		if ( count($this->nodes) > 0  ) {
			foreach ($this->nodes as $node ) {
				$buffer .= $node->flush( false, $this->field_attr('name'), $this->field_attr('id') );
			}
		}

		$buffer .= '
';

		$buffer .= '

get_error_attr().'>'.nl2br(o3_html( isset($this->error_attr_['text']) ? $this->error_attr_['text'] : '' )).'

';

		return $buffer;
	}

	/*
	* Print the buffer
	* @return self / string
	*/
	public function flush( $output = true ) {
		global $o3;

		/*
		todo: radio logic
		if ( $this->checked() ) {
			$this->field_attr('checked','checked');
		} else {
			unset($this->field_attr_['checked']);
		}

		//if mandatory
		if ( $this->mandatory() ) {

			//update the error text
			$this->error( isset($o3) && isset($o3->lang) ? $o3->lang->_(O3_FORM_ERR_MANDATORY) : O3_FORM_ERR_MANDATORY );

			//javascript reference
			$this->field_attr('o3-form-mandatory','true');
		}

		//if validator or mandatory add error
		if ( $this->validator() != '' || $this->mandatory() )
			if ( o3_form_base_class::$o3_form_base_current_knockout ) {
				$this->field_bind( "o3_validate", ( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id') );
				$this->field_bind( "css", "'o3-field-error': ".( $this->form() != '' ? $this->form().'.' : '' )."field.".$this->field_attr('id').".o3_showError()" );

				//show field error
				$this->error_attr( 'data-bind', 'o3_slideVisible: '.( $this->form() != '' ? $this->form().'.' : '' ).'field.'.$this->field_attr('id').'.o3_showError ? '.( $this->form() != '' ? $this->form().'.' : '' ).'field.'.$this->field_attr('id').'.o3_showError() : false' );
			}

		if ( !isset($this->error_attr_['text']) )
			$this->error_attr( 'text', $this->error() );
		*/

		$buffer = $this->buffer();
		if ( $output ) {
			echo $buffer;
			return $this;
		}
		return $buffer;
	}

}

/**
* HTML file input value
*/
class o3_form_file extends o3_form_field_base_class {

	//attributes for upload (input/select)
	public $upload_attr_ = '';

	//data-bind attribute for upload (input/select)
	public $upload_bind_ = array();

	//attributes for upload holder (input/select)
	public $upload_holder_attr_ = '';

	//data-bind attribute for upload holder (input/select)
	public $upload_holder_bind_ = array();

	//upload holder label
	public $upload_holder_label = null;

	//attributes for result (input/select)
	public $result_attr_ = '';

	//data-bind attribute for result (input/select)
	public $result_bind_ = array();

	//accept file type
	public $accept = '';

	//max allowed file size
	public $max_upload_size = 0;

	/*
	* Constructor
	*/
	function __construct( $label, $id, $value = null, $filename = null ) {
		global $o3;

		$filename = $filename == null || $filename == '' ? '' : $filename;
		$value = $value == null || $value == '' ? '' : $value.( $filename != '' ? O3_FORM_FILE_NAME_PATH_SEP.$filename : '' );
		parent::__construct( 'file', $label, $id, $value );

		//set max allowed upload size
		$this->max_upload_size( o3_upload_max_size() );

		//load upclick - file uploader
		$o3->head_res( 'o3_upclick' );

		//setup upload attr id
		$this->upload_attr( 'id', $id.'_'.md5(time()) );

		//field attr
		$this->field_attr( 'data-o3-upload-field', $this->upload_attr( 'id' ) );
		$this->field_attr( 'data-o3-upload-value', $value );

		//setup result attr
		$this->result_attr( 'id', $this->upload_attr( 'id' ).'_result' );
		$this->result_attr( 'class', 'o3-form-field-file-display' );

		//set container id
		$this->attr( 'id', 'o3-form-field-'.( $this->form() != '' ? $this->form().'-' : '' ).$this->field_attr('id') );
		$this->attr( 'class', 'o3-form-field-holder o3-form-field-holder-'.$this->type );

		//add placeholder
		//$this->field_attr( 'placeholder', o3_html(isset($o3) && isset($o3->lang) ? $o3->lang->_(O3_FORM_FILE_NO_FILE_SELECTED) : O3_FORM_FILE_NO_FILE_SELECTED) );

		if ( o3_form_base_class::$o3_form_base_current_knockout ) {
			//Add knockout update by keypress
			$this->field_bind( 'valueUpdate', "'keyup'" );

			//Add knockout value
			$this->field_bind( 'value', ( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id') );

			//Event to readonly on loading
			//$this->field_bind( "attr", "readonly: ".( $this->form() != '' ? $this->form().'.' : '' )."loading" );

			//upload
			$this->upload_bind( 'visible', ( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id')."() == '' " );
			$this->upload_holder_bind( 'visible', ( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id')."() == '' " );

			//result
			$this->result_bind( 'visible', ( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id')."() != '' " );

		}

		//Add class to error msg
		$this->error_attr( 'class', 'o3-form-field-error' );
	}

	/*
	* Set/get max allowed upload size
	*/
	public function max_upload_size() {
		$args = func_get_args();
		if ( count($args) > 0 ) {
			$this->max_upload_size = $args[0];
			$this->max_upload_size = $this->max_upload_size > o3_upload_max_size() ? o3_upload_max_size() : $this->max_upload_size;
			return $this;
		}
		return $this->max_upload_size;
	}

	/*
	* Set/get accept file type
	*/
	public function accept() {
		$args = func_get_args();
		if ( count($args) > 0 ) {
			$this->accept = $args[0];
			return $this;
		}
		return $this->accept;
	}

	/*
	* Buffer
	* @return string
	*/
	public function buffer() {
		global $o3;

		$buffer = '
get_attr().'>

						field_attr('id').'">'.$this->label.'';

		$field_name = ( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id');

		$buffer .= '<input type="hidden" '.$this->get_field_attr().' />

get_upload_holder_attr().'>
							'.( $this->upload_holder_label !== null ? $this->upload_holder_label : ( isset($o3) && isset($o3->lang) ? $o3->lang->_(O3_FORM_FILE_SELECT_FILE) : O3_FORM_FILE_SELECT_FILE ) ).'
							<input type="file" '.$this->get_upload_attr().' />

get_result_attr().'>

									<input type="text" readonly="readonly" data-bind="value: '.$field_name.'.filename()" />

 -1, text: '.$field_name.'.progress()+\'%\'">
									0%

									X

';

		$buffer .= '

get_error_attr().'>'.nl2br(o3_html( isset($this->error_attr_['text']) ? $this->error_attr_['text'] : '' )).'

';

		return $buffer;
	}

	/*
	* Print the buffer
	* @return self / string
	*/
	public function flush( $output = true ) {
		global $o3;

		//if mandatory
		if ( $this->mandatory() ) {

			//update the error text
			$this->error( trim($this->error()."\n".( isset($o3) && isset($o3->lang) ? $o3->lang->_(O3_FORM_ERR_MANDATORY) : O3_FORM_ERR_MANDATORY ) ) );

			//javascript reference
			$this->field_attr('o3-form-mandatory','true');
		}

		//if validator or mandatory add error
		if ( $this->validator() != '' || $this->mandatory() )
			if ( o3_form_base_class::$o3_form_base_current_knockout ) {
				$this->field_bind( "o3_validate", ( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id') );
				$this->upload_bind( "css", "'o3-field-error': ".( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').".o3_showError()" );

				//show field error
				$this->error_attr( 'data-bind', 'o3_slideVisible: '.( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').'.o3_showError ? '.( $this->form() != '' ? $this->form().'.field.' : '' ).$this->field_attr('id').'.o3_showError() : false' );
			}

		if ( !isset($this->error_attr_['text']) )
			$this->error_attr( 'text', $this->error() );

		//set accept
		$this->upload_attr( 'accept', $this->accept() );

		//set accept
		$this->upload_attr( 'data-o3-form-field-file-max-upload', $this->max_upload_size() );

		$buffer = $this->buffer();
		if ( $output ) {
			echo $buffer;
			return $this;
		}
		return $buffer;
	}

	/*
	* Returns attributes string for input
	*/
	public function get_upload_attr() {

		$bind = $this->get_upload_bind();
		if ( $bind != '' )
			$this->upload_attr( 'data-bind', $bind );

		$attrs = array();
		foreach ( $this->upload_attr_ as $key => $value )
			$attrs[] = ' '.$key.'="'.o3_html($value,ENT_COMPAT).'" ';

		return implode( ' ', $attrs);
	}

	/*
	* Returns data-bind attribute value
	*/
	public function get_upload_bind() {
		$binds = array();
		foreach ( $this->upload_bind_ as $key => $value ) {
			if ( $key == 'css' || $key == 'event' || $key == 'attr' )
				$value = '{ '.$value.' }';
			$binds[] = ' '.$key.': '.$value.' ';
		}
		return implode(', ', $binds);
	}

	/*
	* Set or get upload attributes
	*
	* @param $attr_name Name of the attribute to get or set
	* @param $attr_value (optional) The value to set to the attribute
	* @param $append (optional) If true the attribute is replaced with the value, else is appended
	*
	* @return mixed If 2nd parameter omited the value of attribute else the object itself
	*/
	public function upload_attr() {
		$args = func_get_args();
		if ( func_num_args() > 1 ) {
			if ( isset($args[2]) && $args[2] === true ) {
				//replace
				$this->upload_attr_[$args[0]] = $args[1];
			} else {
				//append
				$this->upload_attr_[$args[0]] = trim( ( isset($this->upload_attr_[$args[0]]) ? $this->upload_attr_[$args[0]].' ' : '' ).$args[1] );
			}
		} else if ( func_num_args() > 0 ) {
			return $this->upload_attr_[$args[0]];
		}
		return $this;
	}

	/*
	* Set or get data-bind attribute values
	*
	* @param $bind_name Name of the attribute to get or set
	* @param $bind_value (optional) The value to set to the attribute
	* @param $append (optional) If true the attribute is replaced with the value, else is appended
	*
	* @return mixed If 2nd parameter omited the value of attribute else the object itself
	*/
	public function upload_bind() {
		$args = func_get_args();
		if ( func_num_args() > 1 ) {
			if ( isset($args[2]) && $args[2] === true ) {
				//replace
				$this->upload_bind_[$args[0]] = $args[1];
			} else {
				//append and trim the sep. comma
				$this->upload_bind_[$args[0]] = o3_trim( ( isset($this->upload_bind_[$args[0]]) ? $this->upload_bind_[$args[0]].', ' : '' ).o3_trim( $args[1], ',' ), ',' );
			}
		} else if ( func_num_args() > 0 ) {
			return $this->upload_bind_[$args[0]];
		}
		return $this;
	}

	/*
	* Set/get upload holder label
	*/
	public function upload_holder_label() {
		$args = func_get_args();
		if ( func_num_args() == 1 ) {
			//append
			$this->upload_holder_label = $args[0];
			return $this;
		}
		return $this->upload_holder_label;
	}

	/*
	* Returns attributes string for input
	*/
	public function get_upload_holder_attr() {

		$bind = $this->get_upload_holder_bind();
		if ( $bind != '' )
			$this->upload_holder_attr( 'data-bind', $bind );

		$attrs = array();
		foreach ( $this->upload_holder_attr_ as $key => $value )
			$attrs[] = ' '.$key.'="'.o3_html($value,ENT_COMPAT).'" ';

		return implode( ' ', $attrs);
	}

	/*
	* Returns data-bind attribute value
	*/
	public function get_upload_holder_bind() {
		$binds = array();
		foreach ( $this->upload_holder_bind_ as $key => $value ) {
			if ( $key == 'css' || $key == 'event' || $key == 'attr' )
				$value = '{ '.$value.' }';
			$binds[] = ' '.$key.': '.$value.' ';
		}
		return implode(', ', $binds);
	}

	/*
	* Set or get upload holder attributes
	*
	* @param $attr_name Name of the attribute to get or set
	* @param $attr_value (optional) The value to set to the attribute
	* @param $append (optional) If true the attribute is replaced with the value, else is appended
	*
	* @return mixed If 2nd parameter omited the value of attribute else the object itself
	*/
	public function upload_holder_attr() {
		$args = func_get_args();
		if ( func_num_args() > 1 ) {
			if ( isset($args[2]) && $args[2] === true ) {
				//replace
				$this->upload_holder_attr_[$args[0]] = $args[1];
			} else {
				//append
				$this->upload_holder_attr_[$args[0]] = trim( ( isset($this->upload_holder_attr_[$args[0]]) ? $this->upload_holder_attr_[$args[0]].' ' : '' ).$args[1] );
			}
		} else if ( func_num_args() > 0 ) {
			return $this->upload_holder_attr_[$args[0]];
		}
		return $this;
	}

	/*
	* Set or get data-bind attribute values
	*
	* @param $bind_name Name of the attribute to get or set
	* @param $bind_value (optional) The value to set to the attribute
	* @param $append (optional) If true the attribute is replaced with the value, else is appended
	*
	* @return mixed If 2nd parameter omited the value of attribute else the object itself
	*/
	public function upload_holder_bind() {
		$args = func_get_args();
		if ( func_num_args() > 1 ) {
			if ( isset($args[2]) && $args[2] === true ) {
				//replace
				$this->upload_holder_bind_[$args[0]] = $args[1];
			} else {
				//append and trim the sep. comma
				$this->upload_holder_bind_[$args[0]] = o3_trim( ( isset($this->upload_holder_bind_[$args[0]]) ? $this->upload_holder_bind_[$args[0]].', ' : '' ).o3_trim( $args[1], ',' ), ',' );
			}
		} else if ( func_num_args() > 0 ) {
			return $this->upload_holder_bind_[$args[0]];
		}
		return $this;
	}

	/*
	* Returns attributes string for input
	*/
	public function get_result_attr() {

		$bind = $this->get_result_bind();
		if ( $bind != '' )
			$this->result_attr( 'data-bind', $bind );

		$attrs = array();
		foreach ( $this->result_attr_ as $key => $value )
			$attrs[] = ' '.$key.'="'.o3_html($value,ENT_COMPAT).'" ';

		return implode( ' ', $attrs);
	}

	/*
	* Returns data-bind attribute value
	*/
	public function get_result_bind() {
		$binds = array();
		foreach ( $this->result_bind_ as $key => $value ) {
			if ( $key == 'css' || $key == 'event' || $key == 'attr' )
				$value = '{ '.$value.' }';
			$binds[] = ' '.$key.': '.$value.' ';
		}
		return implode(', ', $binds);
	}

	/*
	* Set or get result attributes
	*
	* @param $attr_name Name of the attribute to get or set
	* @param $attr_value (optional) The value to set to the attribute
	* @param $append (optional) If true the attribute is replaced with the value, else is appended
	*
	* @return mixed If 2nd parameter omited the value of attribute else the object itself
	*/
	public function result_attr() {
		$args = func_get_args();
		if ( func_num_args() > 1 ) {
			if ( isset($args[2]) && $args[2] === true ) {
				//replace
				$this->result_attr_[$args[0]] = $args[1];
			} else {
				//append
				$this->result_attr_[$args[0]] = trim( ( isset($this->result_attr_[$args[0]]) ? $this->result_attr_[$args[0]].' ' : '' ).$args[1] );
			}
		} else if ( func_num_args() > 0 ) {
			return $this->result_attr_[$args[0]];
		}
		return $this;
	}

	/*
	* Set or get data-bind attribute values
	*
	* @param $bind_name Name of the attribute to get or set
	* @param $bind_value (optional) The value to set to the attribute
	* @param $append (optional) If true the attribute is replaced with the value, else is appended
	*
	* @return mixed If 2nd parameter omited the value of attribute else the object itself
	*/
	public function result_bind() {
		$args = func_get_args();
		if ( func_num_args() > 1 ) {
			if ( isset($args[2]) && $args[2] === true ) {
				//replace
				$this->result_bind_[$args[0]] = $args[1];
			} else {
				//append and trim the sep. comma
				$this->result_bind_[$args[0]] = o3_trim( ( isset($this->result_bind_[$args[0]]) ? $this->result_bind_[$args[0]].', ' : '' ).o3_trim( $args[1], ',' ), ',' );
			}
		} else if ( func_num_args() > 0 ) {
			return $this->result_bind_[$args[0]];
		}
		return $this;
	}

}

/**
* HTML button
*/
class o3_form_button extends o3_form_base_class {

	/*
	* Constructor
	*/
	function __construct( $value = '', $id = '' ) {
		parent::__construct( 'button', '', $id, $value );

		if ( o3_form_base_class::$o3_form_base_current_knockout ) {
			//Event to disable on loading
			//$this->field_bind( "disable", ( $this->form() != '' ? $this->form().'.' : '' )."loading" );
		}

		//add class
		$this->field_attr('class','o3-form-button');
	}

	/*
	* Buffer
	* @return string
	*/
	public function buffer() {
		$buffer = '
get_attr().'><input type="'.$this->type.'" '.$this->get_field_attr().' />
';
		return $buffer;
	}

	/*
	* Print the buffer
	* @return self / string
	*/
	public function flush( $output = true ) {
		$buffer = $this->buffer();
		if ( $output ) {
			echo $buffer;
			return $this;
		}
		return $buffer;
	}

}

/**
* HTML submit
*/
class o3_form_submit extends o3_form_base_class {

	/*
	* Constructor
	*/
	function __construct( $value = '', $id = '' ) {
		parent::__construct( 'submit', '', $id, $value );

		if ( o3_form_base_class::$o3_form_base_current_knockout ) {
			//Event to disable on loading
			$this->field_bind( "disable", ( $this->form() != '' ? $this->form().'.' : '' )."loading" );
		}

		//add class
		$this->field_attr('class','o3-form-submit');
	}

	/*
	* Buffer
	* @return string
	*/
	public function buffer() {
		$buffer = '
get_attr().'><input type="'.$this->type.'" '.$this->get_field_attr().' />
';
		return $buffer;
	}

	/*
	* Print the buffer
	* @return self / string
	*/
	public function flush( $output = true ) {
		$buffer = $this->buffer();
		if ( $output ) {
			echo $buffer;
			return $this;
		}
		return $buffer;
	}

}

/**
* HTML form openeing tag
*/
class o3_form_open extends o3_form_base_class {

	//auto load javascript controller
	public $js_autoload_ = true;

	//security code for post
	private $security_code_ = '';

	/*
	* Constructor
	*/
	function __construct( $id = '', $action = '', $method = 'POST' ) {
		global $o3;
		parent::__construct( 'form', '', $id, '' );

		//set form scope fior fields
		o3_form_base_class::$o3_form_base_current_form = $id;

		//Has no value attribute, we need to remove
		unset($this->field_attr_['value']);

		//add class
		$this->field_attr('class','o3-form');

		//set form action and method attr
		$this->field_attr('method',$method);
		$this->field_attr('action',$action);

	}

	/*
	* Set javascript controller autoload true / false or get value
	*/
	public function autoload() {
		$args = func_get_args();
		if ( func_num_args() > 0 ) {
			$this->js_autoload_ = $args[0];
		} else {
			return $this->js_autoload_;
		}
		return $this;
	}

	/*
	* Create knockout bindings in form
	*/
	public function knockout() {
		$args = func_get_args();
		if ( func_num_args() > 0 ) {
			o3_form_base_class::$o3_form_base_current_knockout = $args[0];

			if ( o3_form_base_class::$o3_form_base_current_knockout ) {
				//set submit in data-bind
				$this->field_bind("submit", $this->field_attr('id').".submit");
			}

		} else {
			return o3_form_base_class::$o3_form_base_current_knockout;
		}
		return $this;
	}

	/**
	 * Generate new scurity code for the form
	 *
	 * @return string
	 */
	private function security_code() {

		if ( $this->security_code_ == '' ) {

			//security code list
			$_SESSION['o3_form_security_code'] = !isset($_SESSION['o3_form_security_code']) ? array() : $_SESSION['o3_form_security_code'];

			//generate security code
			$this->security_code_ = substr(md5(o3_micro_time()),0,8);
			while ( isset($_SESSION['o3_form_security_code'][$this->security_code_]) )
				$this->security_code_ = substr(md5(o3_micro_time()),0,8);

			$_SESSION['o3_form_security_code'][$this->security_code_] = $this->security_code_;

		}

		return $this->security_code_;
	}

	/*
	* Buffer
	* @return string
	*/
	public function buffer() {
		$buffer = '
get_attr().'><form '.$this->get_field_attr().' o3-form-code="'.o3_html($this->security_code()).'">';
		return $buffer;
	}

	/*
	* Print the buffer
	* @return self / string
	*/
	public function flush( $output = true ) {

		//set autoload
		$this->field_attr('o3-form-autoload', $this->autoload() ? 'true' : 'false' );

		$this->field_attr('o3-form-method',$this->field_attr('method'));
		unset($this->field_attr_['method']);

		$this->field_attr('o3-form-action',$this->field_attr('action'));
		unset($this->field_attr_['action']);

		//on autoload we need to disable external binding
		$this->bind('o3_stopBinding', $this->autoload() ? 'true' : 'false' );

		$buffer = $this->buffer();
		if ( $output ) {
			echo $buffer;
			return $this;
		}
		return $buffer;
	}

}

/**
* HTML form closing tag
*/
class o3_form_close extends o3_form_base_class {

	/*
	* Constructor
	*/
	function __construct() {
		o3_form_base_class::$o3_form_base_current_form = '';
		o3_form_base_class::$o3_form_base_current_knockout = false;
		parent::__construct( 'form', '', '', '' );
	}

	/*
	* Buffer
	* @return string
	*/
	public function buffer() {
		$buffer = '</form>
';
		return $buffer;
	}

	/*
	* Print the buffer
	* @return self / string
	*/
	public function flush( $output = true ) {
		$buffer = $this->buffer();
		if ( $output ) {
			echo $buffer;
			return $this;
		}
		return $buffer;
	}

}

/**
* HTML inner part opening tag, this is hidden on loading
*/
class o3_form_inner_open extends o3_form_base_class {

	/*
	* Constructor
	*/
	function __construct() {
		parent::__construct( 'inner_open', '', '', '' );

		//Has no value, id and name attribute, we need to remove
		unset($this->field_attr_['value']);
		unset($this->field_attr_['id']);
		unset($this->field_attr_['name']);

		if ( o3_form_base_class::$o3_form_base_current_knockout ) {
			//Add event to hide on loading
			$this->field_bind( 'o3_slideVisible', '!'.( $this->form() != '' ? $this->form().'.' : '' ).'loading()' );
		}

		//add class
		$this->field_attr('class','o3-form-inner-open');

	}

	/*
	* Buffer
	* @return string
	*/
	public function buffer() {
		$buffer = '
get_field_attr().'>';
		return $buffer;
	}

	/*
	* Print the buffer
	* @return self / string
	*/
	public function flush( $output = true ) {
		$buffer = $this->buffer();
		if ( $output ) {
			echo $buffer;
			return $this;
		}
		return $buffer;
	}

}

/**
* HTML inner part closing tag, this is hidden on loading
*/
class o3_form_inner_close extends o3_form_base_class {

	/*
	* Constructor
	*/
	function __construct() {
		parent::__construct( 'inner_close', '', '', '' );
		//Has no value attribute, we need to remove
		unset($this->field_attr_['value']);
	}

	/*
	* Buffer
	* @return string
	*/
	public function buffer() {
		$buffer = '
';
		return $buffer;
	}

	/*
	* Print the buffer
	* @return self / string
	*/
	public function flush( $output = true ) {
		$buffer = $this->buffer();
		if ( $output ) {
			echo $buffer;
			return $this;
		}
		return $buffer;
	}

}

/**
* HTML error message holder. Only showed when is an error
*/
class o3_form_error extends o3_form_base_class {

	/*
	* Constructor
	*/
	function __construct() {
		parent::__construct( 'error', '', '', '' );

		//Has no value, id and name attribute, we need to remove
		unset($this->field_attr_['value']);
		unset($this->field_attr_['id']);
		unset($this->field_attr_['name']);

		//add class
		$this->field_attr('class','o3-form-error');

		//Add event to show if error set
		if ( o3_form_base_class::$o3_form_base_current_knockout ) {
			$this->field_bind( 'o3_slideVisible', ( $this->form() != '' ? $this->form().'.' : '' ).'error() != \'\'' );
			$this->field_bind( 'text', ( $this->form() != '' ? $this->form().'.' : '' ).'error' );
		}

	}

	/*
	* Buffer
	* @return string
	*/
	public function buffer() {
		$buffer = '
get_field_attr().'>
';
		return $buffer;
	}

	/*
	* Print the buffer
	* @return self / string
	*/
	public function flush( $output = true ) {
		$buffer = $this->buffer();
		if ( $output ) {
			echo $buffer;
			return $this;
		}
		return $buffer;
	}

}

/**
* HTML success message holder. Only showed when is a success message
*/
class o3_form_success extends o3_form_base_class {

	/*
	* Constructor
	*/
	function __construct() {
		parent::__construct( 'success', '', '', '' );

		//Has no value, id and name attribute, we need to remove
		unset($this->field_attr_['value']);
		unset($this->field_attr_['id']);
		unset($this->field_attr_['name']);

		//add class
		$this->field_attr('class','o3-form-success');

		//Add event to show if success set
		if ( o3_form_base_class::$o3_form_base_current_knockout ) {
			$this->field_bind( 'o3_slideVisible', ( $this->form() != '' ? $this->form().'.' : '' ).'success() != \'\'' );
			$this->field_bind( 'text', ( $this->form() != '' ? $this->form().'.' : '' ).'success' );
		}

	}

	/*
	* Buffer
	* @return string
	*/
	public function buffer() {
		$buffer = '
get_field_attr().'>
';
		return $buffer;
	}

	/*
	* Print the buffer
	* @return self / string
	*/
	public function flush( $output = true ) {
		$buffer = $this->buffer();
		if ( $output ) {
			echo $buffer;
			return $this;
		}
		return $buffer;
	}

}

/**
* HTML form loader part
*/
class o3_form_loader extends o3_form_base_class {

	//laoding message
	var $loading_text_ = '';

	/*
	* Constructor
	*/
	function __construct( $loading_text = null ) {
		global $o3;
		parent::__construct( 'loader', '', '', '' );

		//Has no value, id and name attribute, we need to remove
		unset($this->field_attr_['value']);
		unset($this->field_attr_['id']);
		unset($this->field_attr_['name']);

		//add class
		$this->field_attr('class','o3-form-loader');

		//Add event to show on loading
		if ( o3_form_base_class::$o3_form_base_current_knockout ) {
			$this->field_bind( 'o3_slideVisible', ( $this->form() != '' ? $this->form().'.' : '' ).'loading()' );
		}

		//set loading message
		$this->text( $loading_text != null ? $loading_text : ( isset($o3) && isset($o3->lang) ? $o3->lang->_(O3_FORM_TXT_LOADING) : O3_FORM_TXT_LOADING ) );
	}

	/*
	* Set loading message or get value
	*/
	public function text() {
		$args = func_get_args();
		if ( func_num_args() > 0 ) {
			$this->loading_text_ = $args[0];
		} else {
			return $this->loading_text_;
		}
		return $this;
	}

	/*
	* Buffer
	* @return string
	*/
	public function buffer() {
		$buffer = '
get_field_attr().'>
						 '.o3_html($this->text()).'

';
		return $buffer;
	}

	/*
	* Print the buffer
	* @return self / string
	*/
	public function flush( $output = true ) {
		$buffer = $this->buffer();
		if ( $output ) {
			echo $buffer;
			return $this;
		}
		return $buffer;
	}

}

/**
* Class for form ajax post result
*/
class o3_form_result extends o3_ajax_result {

	private $id = '';
	private $security_code_ = '';
	private $post = array();

	//custom data
	public $data_ = array();

 	/*
	* Constructor
	*/
	public function __construct( $id ) {
		global $o3;
		$this->id = $id;
		$this->success_ = true;
		$this->success_msg_ = $this->success_msg_default_ = 'Data has been transferred successfully.';
		$this->error_msg_ = $this->error_msg_default_ = 'An error occurred. Please try again.';
		$this->redirect_ = '';
		$this->security_code_ = $this->security_code();

		if ( isset($_POST[$this->id]) )
			$this->post = gettype($_POST[$this->id]) == 'string' ? json_decode($_POST[$this->id],true) : $_POST[$this->id];

		if ( isset($o3) && isset($o3->lang) ) {
			$this->success_msg_ = $this->success_msg_default_ = $o3->lang->_($this->success_msg_);
			$this->error_msg_ = $this->error_msg_default_ = $o3->lang->_($this->error_msg_);
		}

	}

	/*
	* Check field is posted
	*/
	public function is( $field ) {
		return isset($this->post[$field]);
	}

	/*
	* Check value of field posted
	*/
	public function value( $field ) {
		return $this->is( $field) ? $this->post[$field] : null;
	}

	/*
	* Check filename of field posted
	*/
	public function filename( $field ) {
		$file = $this->is( $field) ? $this->post[$field] : null;
		$file = explode(O3_FORM_FILE_NAME_PATH_SEP, $file);
		return isset($file[1]) ? $file[1] : basename($file[0]);
	}

	/*
	* Check filepath of field posted
	*/
	public function filepath( $field ) {
		$file = $this->is( $field) ? $this->post[$field] : null;
		$file = explode(O3_FORM_FILE_NAME_PATH_SEP, $file);
		return $file[0];
	}

	/*
	* Get array with all the poster fields
	*/
	public function all() {
		return $this->post;
	}

	/**
	 * Generate new scurity code for the form
	 *
	 * @return string
	 */
	private function security_code() {

		if ( $this->security_code_ == '' ) {

			//security code list
			$_SESSION['o3_form_security_code'] = !isset($_SESSION['o3_form_security_code']) ? array() : $_SESSION['o3_form_security_code'];

			//generate security code
			$this->security_code_ = substr(md5(o3_micro_time()),0,8);
			while ( isset($_SESSION['o3_form_security_code'][$this->security_code_]) )
				$this->security_code_ = substr(md5(o3_micro_time()),0,8);

			$_SESSION['o3_form_security_code'][$this->security_code_] = $this->security_code_;

		}

		return $this->security_code_;
	}

	/*
	* Print out data as json
	* @return self
	*/
	public function flush() {
		$result = array(
			'success' => $this->success_,
			'success_msg' => $this->success_msg_,
			'error_msg' => $this->error_msg_,
			'redirect' => $this->redirect_,
			'o3-form-code' => $this->security_code_,
			'data' => $this->data_
		);
		die(json_encode($result));
	}

}

/*
* Check for form in post data
* If no valid  form post data send header 404
*/
function o3_form_posted( $id, $validate_form_code = true ) {
	//file upload
	if ( isset($_FILES[$id]) ) {
		$o3_form_result = new o3_form_result( $id );

		foreach ( $_FILES[$id]['name'] as $key => $value ) {
			$filename = isset($_FILES[$id]['name'][$key][0]) ? $_FILES[$id]['name'][$key][0] : $_FILES[$id]['name'][$key];
			$tmp_name = isset($_FILES[$id]['tmp_name'][$key][0]) ? $_FILES[$id]['tmp_name'][$key][0] : $_FILES[$id]['tmp_name'][$key];
			//keep file for 5 min
			$filepath = o3_temp_cache_file( strtolower($flags.$dpi.$background.filesize($source).filemtime($source).'-'.basename($filename)), 300 );

			//upload file
			if ( move_uploaded_file( $tmp_name, $filepath ) ) {
				//set data
				$o3_form_result->data( 'filepath', $filepath );
				$o3_form_result->data( 'filename', $filename );
			};
		};

		$o3_form_result->flush();
	};

	//form post
	if ( isset($_POST[$id]) ) {
		$o3_form_result = new o3_form_result( $id );
		if ( $validate_form_code === true && !isset($_SESSION['o3_form_security_code'][$_POST['o3-form-code']]) ) {
			global $o3;
			//security check fail send 404
			//o3_header_code( 404 );
			//$o3_form_result->error( isset($o3) && isset($o3->lang) ? $o3->lang->_(O3_FORM_ERR_GENERAL) : O3_FORM_ERR_GENERAL );
			$o3_form_result->flush();
		}
		return $o3_form_result;
	};
	return false;
}

?>


text:
document.getElementById('184_103').checked = true;
document.getElementById('185_103').checked = true;
document.getElementById('186_103').checked = true;
document.getElementById('187_103').checked = true;
document.getElementById('188_103').checked = true;
document.getElementById('189_103').checked = true;
document.getElementById('190_103').checked = true;
document.getElementById('191_103').checked = true;
document.getElementById('192_103').checked = true;
document.getElementById('193_103').checked = true;
document.getElementById('194_103').checked = true;
document.getElementById('195_103').checked = true;
document.getElementById('198_103').checked = true;
document.getElementById('199_103').checked = true;
document.getElementById('200_103').checked = true;
document.getElementById('196_103').checked = true;
document.getElementById('197_103').checked = true;
document.getElementById('rateit-range-2').setAttribute("aria-valuenow", 5);
document.getElementById('backing4').value = 5;
document.getElementsByClassName('rateit-selected')[0].style = 'height: 32px; width: 160px; display: block;';
document.getElementById('merit').value = "课程特色鲜明,内容取舍合理,组织严密,逻辑性强,讲授思路清晰,概念清楚。";
document.getElementById('flaw').value = "治学严整、言传身教,希望增加互动环节,减少课程作业,降低学习难度。";
document.getElementById('suggest').value = "课程难度,作业数量,课程实用程度,层次是否分明,学生能够学到哪些知识";
document.getElementById("sb1").click();


text:
package org.culturegraph.mf.stream.pipe;

import java.io.FileNotFoundException;

import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

import org.culturegraph.mf.exceptions.MetafactureException;
import org.culturegraph.mf.framework.DefaultObjectPipe;
import org.culturegraph.mf.framework.ObjectReceiver;
import org.culturegraph.mf.framework.annotations.Description;
import org.culturegraph.mf.framework.annotations.FluxCommand;
import org.culturegraph.mf.framework.annotations.In;
import org.culturegraph.mf.framework.annotations.Out;
import org.culturegraph.mf.util.ResourceUtil;

/**
 * Executes the function process(obj) in a given jscript.
 *
 * @author Markus Geipel
 *
 */
@Description("executes the function process(obj) in a given jscript")
@In(Object.class)
@Out(Object.class)
@FluxCommand("jscript")
public final class JScriptObjectPipe extends DefaultObjectPipe<Object, ObjectReceiver<Object>> {

	private static final String PROCESS = "process";
	private String invoke = PROCESS;
	private Invocable invocable;

	public JScriptObjectPipe(final String script) {
		setScript(script);
	}

	public void setInvoke(final String invoke) {
		this.invoke = invoke;
	}

	private void setScript(final String file) {

		final ScriptEngineManager manager = new ScriptEngineManager();
		final ScriptEngine engine = manager.getEngineByName("JavaScript");
		try {
			// LOG.info("loading code from '" + file + "'");
			engine.eval(ResourceUtil.getReader(file));
		} catch (ScriptException e) {
			throw new MetafactureException("Error in script", e);
		} catch (FileNotFoundException e) {
			throw new MetafactureException("Error loading script '" + file + "'", e);
		}
		invocable = (Invocable) engine;
	}

	@Override
	public void process(final Object obj) {
		assert !isClosed();
		try {

			// LOG.info("processing: " + value);
			final Object retObj = invocable.invokeFunction(invoke, obj);
			// LOG.info("returning: " + obj);

			getReceiver().process(retObj);

		} catch (ScriptException e) {
			throw new MetafactureException("Error in script while evaluating 'process' method", e);
		} catch (NoSuchMethodException e) {
			throw new MetafactureException("'process' method is missing in script", e);
		}
	}

}


text:
package de.haw.vs.neptr.parser;

import de.haw.vs.neptr.idlmodel.IDLClass;
import de.haw.vs.neptr.idlmodel.IDLModule;
import de.haw.vs.neptr.idlmodel.MethodData;
import de.haw.vs.neptr.idlmodel.SupportedDataTypes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class Parser {
    private final String BEGIN_REGEX = "\\{";
    private final String END = "};";
    private final String MODULE = "module";
    private final String CLASS = "class";
    private final String PARENTHESES = "[(|)]";
    private final String PARAM_SEPARATOR = ",";
    private final String IDL_KEYWORD_INT = "int";
    private final String IDL_KEYWORD_DOUBLE = "double";
    private final String IDL_KEYWORD_STRING = "string";
    private final Logger logger = LoggerFactory.getLogger(Parser.class);

    /**
     * For printing compilation errors
     */
    private void printError(int lineNo, String text) {
        logger.warn("Line " + lineNo + ": " + text);
    }

    /**
     * Parses IDLFile at the given location and returns it as a module
     *
     * @param file String file location
     * @return IDLModule of parsed content of file
     * @throws IOException Throws if files were not found
     */
    public IDLModule parse(String file) throws IOException {
        IDLFileReader in = new IDLFileReader(new FileReader(file));
        return this.parseModule(in);
    }

    /**
     * Parse IDL Module in given file.
     */
    private IDLModule parseModule(IDLFileReader in) throws IOException {
        String line = in.readLine();
        String tokens[] = (line.split(BEGIN_REGEX)[0]).trim().split(" ");
        IDLClass newClass;

        if (tokens != null && tokens.length > 1 && tokens[0].equals(MODULE) && tokens[1] != null && tokens[1].length() > 0) {
            IDLModule currentModule = new IDLModule(tokens[1]);
            do {
                // parse containing classes
                newClass = parseClass(in, currentModule.getModuleName());
                if (newClass != null) currentModule.addClass(newClass);
            } while (newClass != null);

            return currentModule;
        } else {
            printError(in.getLineNo(), "Error parsing module. '" + line + "'");
            return null;
        }
    }

    /**
     * Parse (next) class in a file/module.
     *
     * @param in                file reader
     * @param currentModuleName name of the module currently being parsed.
     * @return the class parsed or null if there is no class left in the file
     * @throws IOException thrown when file reader can not read anymore
     */
    private IDLClass parseClass(IDLFileReader in, String currentModuleName) throws IOException {
        List<MethodData> methodList = new ArrayList<>();
        String line = in.readLine();

        if (line != null) {
            String tokens[] = (line.split(BEGIN_REGEX)[0]).trim().split(" ");
            if (tokens != null && tokens.length > 1 && tokens[0].equals(CLASS) && tokens[1] != null && tokens[1].length() > 0) {
                // name of this class
                String className = tokens[1];

                // read methods
                line = in.readLine();
                while (line != null && !line.contains(END)) {
                    String[] tokens2 = line.trim().split(PARENTHESES);

                    String[] tokens3 = tokens2[0].split(" ");
                    String rTypeString = tokens3[0]; // return value
                    String methodName = tokens3[1]; // method name

                    SupportedDataTypes paramTypes[] = parseParams(in.getLineNo(), tokens2[1]);

                    // into data container
                    methodList.add(new MethodData(methodName, getSupportedTypeForKeyword(rTypeString), paramTypes));
                    line = in.readLine();
                }

                // read class end
                if (line == null || !line.contains(END)) {
                    printError(in.getLineNo(), "Error parsing class " + className + ": no end mark '" + line + "'");
                }

                // method data -> array
                MethodData methodArray[] = new MethodData[methodList.size()];

                //return IDL class
                return new IDLClass(className, currentModuleName, methodList.toArray(methodArray));
            } else {
                if (line.contains(END)) {
                    return null;
                } else {
                    printError(in.getLineNo(), "Error parsing class.'" + line + "'");
                    return null;
                }
            }
        } else {
            printError(in.getLineNo(), "Attempt to read beyond end of file.");
            return null;
        }
    }

    /**
     * Evaluate parameter list. (No reading done here!)
     */
    private SupportedDataTypes[] parseParams(int lineNo, String paramList) {
        if (paramList != null && paramList.length() > 0) {
            String[] paramEntries = paramList.trim().split(PARAM_SEPARATOR);

            // param data container
            SupportedDataTypes paramTypes[] = new SupportedDataTypes[paramEntries.length];

            for (int i = 0; i < paramEntries.length; i++) {
                String[] typeAndParamName = paramEntries[i].trim().split(" ");

                // 0: type, 1: name
                paramTypes[i] = getSupportedTypeForKeyword(typeAndParamName[0]);
                if (paramTypes[i] == null) {
                    printError(lineNo, "Error parsing param list");
                    return null;
                }
            }
            return paramTypes;
        } else {
            return new SupportedDataTypes[0];  // empty list
        }
    }

    /**
     * Get supported data type for given keyword.
     */
    private SupportedDataTypes getSupportedTypeForKeyword(String keyword) {
        switch (keyword) {
            case IDL_KEYWORD_DOUBLE:
                return SupportedDataTypes.DOUBLE;
            case IDL_KEYWORD_INT:
                return SupportedDataTypes.INT;
            case IDL_KEYWORD_STRING:
                return SupportedDataTypes.STRING;
            default:
                return null;
        }
    }
}


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
null

#### Original name
Tremella boletiformis Engl.

### Remarks
null


text: javascript formbuilder


text:
layout: shows/episode
title: "BlinkOn 6 Day 1 Talk 3: 3rd party content"
youtubeID: "wQGa_6CRc9I"
youtubeThumbnail: "https://i.ytimg.com/vi/wQGa_6CRc9I/hqdefault.jpg"
published_on: 2016-06-23
updated_on: 2016-06-23
---

Stefan Zager and Ojan Vafai

Slides: https://docs.google.com/presentation/d/1yD5nmmzQGAbV6Zn3aiuEOAFccgbWjXomLCDFM4dYMF4/edit


text:
package com.nextbreakpoint;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import java.util.function.Function;
import java.util.function.Predicate;

import static org.mockito.Mockito.*;

public class FilterTest {
	@Rule
	public ExpectedException exception = ExpectedException.none();

	@Test
	public void shouldThrowNullPointerExceptionWhenFilterIsNull() {
		exception.expect(NullPointerException.class);
		Try.failure(new Exception()).filter(null);
	}

	@Test
	public void shouldNotCallWhenFailure() {
		Function<Object, Object> function = mock(Function.class);
		Predicate<Object> filter = mock(Predicate.class);
		when(function.apply("X")).thenReturn("Y");
		when(filter.test("X")).thenReturn(true);
		Try.failure(new Exception()).filter(filter).map(function).isFailure();
		verify(filter, times(0)).test("X");
	}

	@Test
	public void shouldCallFilterWhenValueIsNotNull() {
		Function<String, Object> function = mock(Function.class);
		Predicate<Object> filter = mock(Predicate.class);
		when(function.apply("X")).thenReturn("Y");
		when(filter.test("X")).thenReturn(true);
		Try.success("X").filter(filter).map(function).get();
		verify(filter, times(1)).test("X");
	}

	@Test
	public void shouldCallFilterWhenCallableReturnsValue() {
		Function<String, Object> function = mock(Function.class);
		Predicate<Object> filter = mock(Predicate.class);
		when(function.apply("X")).thenReturn("Y");
		when(filter.test("X")).thenReturn(true);
		Try.of(() -> "X").filter(filter).map(function).get();
		verify(filter, times(1)).test("X");
	}
}


text: These are middleman client libraries for different languages.


text:
BaseErrorModel = function(options) {
  this._filters = [];
};

BaseErrorModel.prototype.addFilter = function(filter) {
  if(typeof filter === 'function') {
    this._filters.push(filter);
  } else {
    throw new Error("Error filter must be a function");
  }
};

BaseErrorModel.prototype.removeFilter = function(filter) {
  var index = this._filters.indexOf(filter);
  if(index >= 0) {
    this._filters.splice(index, 1);
  }
};

BaseErrorModel.prototype.applyFilters = function(type, message, error, subType) {
  for(var lc=0; lc<this._filters.length; lc++) {
    var filter = this._filters[lc];
    try {
      var validated = filter(type, message, error, subType);
      if(!validated) return false;
    } catch (ex) {
      // we need to remove this filter
      // we may ended up in a error cycle
      this._filters.splice(lc, 1);
      throw new Error("an error thrown from a filter you've suplied", ex.message);
    }
  }

  return true;
};


text:
window.onload = newWinLinks;

function newWinLinks() {
	for(var i=0;i<document.links.length;i++){
		if(document.links[i].className=="newWin"){
			document.links[i].onclick=newWindow;
		}
	}
}

function newWindow() {
	var catWindow = window.open(this.href,"catWin","width=350,height=260");
	catWindow.focus();
	//这里使用focus()方法使得我们新打开的窗口位于最前面。
	return false;
}


text:
//
// FlyoutExample.xaml.cpp
// Implementation of the FlyoutExample class
//

#include "pch.h"
#include "FlyoutExample.xaml.h"

using namespace CascadeDemoCPP;

using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;

// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236

FlyoutExample::FlyoutExample()
{
	InitializeComponent();
}

void CascadeDemoCPP::FlyoutExample::Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
	MenuFlyout^ flyout = ref new MenuFlyout();
	flyout->Placement = FlyoutPlacementMode::Bottom;

	MenuFlyoutItem^ item = ref new MenuFlyoutItem();
	item->Text = "From a design perspective, though, I wouldn't recommend it.";
	item->SetBinding(MenuFlyoutItem::ForegroundProperty, ref new Binding());

	flyout->Items->Append(item);

	FrameworkElement^ flyoutContext = Sibbiheim::Cascade::FlyoutService::GetFlyoutContext(this);
	Sibbiheim::Cascade::FlyoutService::SetFlyoutContext(flyout, flyoutContext);
	flyout->ShowAt(flyoutContext);
}