|
<?php defined('SYSPATH') or die('No direct script access.');
|
|
/**
|
|
* FORGE (FORm GEneration) library.
|
|
*
|
|
* $Id: Forge.php 1923 2008-02-05 14:49:08Z Shadowhand $
|
|
*
|
|
* @package Forge
|
|
* @author Kohana Team
|
|
* @copyright (c) 2007-2008 Kohana Team
|
|
* @license http://kohanaphp.com/license.html
|
|
*/
|
|
class Field
|
|
{
|
|
public $label;
|
|
public $name;
|
|
public $bool;
|
|
public $class;
|
|
public $order = True;
|
|
public $style;
|
|
public $help;
|
|
public $args;
|
|
|
|
/**
|
|
* Contruct of field, set label by its name with auto internationalization
|
|
*
|
|
* @param string $name Name of field
|
|
*/
|
|
public function __construct($name)
|
|
{
|
|
$this->name = $name;
|
|
$this->label = url_lang::lang('texts.'.$name);
|
|
}
|
|
|
|
/**
|
|
* Call method (sets properties)
|
|
*
|
|
* @param string $method
|
|
* @param array $args
|
|
* @return Field_Core
|
|
*/
|
|
public function __call($method, $args)
|
|
{
|
|
$this->$method = array_shift($args);
|
|
$this->args[$method] = $args;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Sets label of field
|
|
*
|
|
* @param string $label New label with auto internationalization
|
|
* @return Field_Core
|
|
*/
|
|
public function label($label)
|
|
{
|
|
// is there any HTML tag in label?
|
|
if (preg_match("/<.*>/", $label))
|
|
{
|
|
$this->label = $label;
|
|
}
|
|
else
|
|
{
|
|
$this->label = url_lang::lang('texts.'.$label);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Render field
|
|
*
|
|
* @return string
|
|
*/
|
|
public function render()
|
|
{
|
|
return '<strong>'.ucfirst($this->label).'</strong>';
|
|
}
|
|
|
|
/**
|
|
* Render field
|
|
*
|
|
* @return string
|
|
*/
|
|
public function __toString()
|
|
{
|
|
return $this->name;
|
|
}
|
|
}
|