Horde_Form::singleton PHP Méthode

singleton() public méthode

public singleton ( $form, &$vars, $title = '', $name = null )
    function singleton($form, &$vars, $title = '', $name = null)
    {
        static $instances = array();
        $signature = serialize(array($form, $vars, $title, $name));
        if (!isset($instances[$signature])) {
            if (class_exists($form)) {
                $instances[$signature] = new $form($vars, $title, $name);
            } else {
                $instances[$signature] = new Horde_Form($vars, $title, $name);
            }
        }
        return $instances[$signature];
    }

Usage Example

Exemple #1
0
    return $out;
}
/* Set up VFS. */
require_once HORDE_LIBS . 'VFS.php';
$vfs_type = $conf['vfs']['type'];
$vfs_args = Horde::getDriverConfig('vfs', $vfs_type);
$vfs_args['user'] = Auth::getAuth();
$vfs =& VFS::singleton($vfs_type, $vfs_args);
@define('TEMPLATES_VFS_PATH', '.horde_templates');
/* Require Horde_Form libs. */
require_once HORDE_LIBS . 'Horde/Form.php';
require_once HORDE_LIBS . 'Horde/Form/Renderer.php';
require_once HORDE_LIBS . 'Horde/Form/Action.php';
/* Set up Horde_Form. */
$vars =& Variables::getDefaultVariables();
$form =& Horde_Form::singleton('TemplatesForm', $vars);
$action =& Horde_Form_Action::factory('submit');
/* Set up form fields. */
$apps = _setValuesToKeys($registry->listApps());
$select_app =& $form->addVariable(_("Application"), 'app', 'enum', true, false, null, array($apps));
$select_app->setAction($action);
$form->addHidden('', 'old_app', 'text', false, false);
/* Set up some variables. */
$formname = $vars->get('formname');
$app = $vars->get('app');
$old_app = $vars->get('old_app');
$template_path = $vars->get('template_path');
$template_orig = $vars->get('template_orig');
$old_template_orig = $vars->get('old_template_orig');
$has_changed = false;
if ($app != $old_app) {
All Usage Examples Of Horde_Form::singleton