Location: PHPKode > projects > Dubsite > dubsite-3.1/plugins/Loginform/Form/Show.php
<?php
class Loginform_Form_Show {

	public static function get($loginform, $str_username, $loginform_callback) {
		$form = new Html_Form();
		$form->getView()->setScriptPath(APP_DIR . '/plugins/Loginform/views/scripts');
		$form->setName('loginform'.$loginform['id']);
		$form->setAction(Dub_Core::url());

		// loginform_id
		$loginform_id = new Html_Form_Element_Hidden(array(
			'name' => 'loginform_id',
			'value' => $loginform['id'],
			'attribs' => array(
				'id' => 'loginform_id' . $loginform['id']
			)
		));

		// loginform_callback
		$loginform_callback = new Html_Form_Element_Hidden(array(
			'name' => 'loginform_callback',
			'value' => $loginform_callback,
			'attribs' => array(
				'id' => 'loginform_callback' . $loginform['id']
			)
		));

		$form->addElements(array(
			$loginform_id,
			$loginform_callback
		));

		if (!$str_username || $loginform['show_form']) {
			// not logged in or force form to display
			// username
			$username = new Html_Form_Element_Text(array(
				'name' => 'username',
				'label' => Dub_Locale::_('Username', 'Loginform'),
				'required' => true,
				'validators' => array(
					array('NotEmpty', false, array(
						'messages' => array(
							'isEmpty' => Dub_Locale::_('Username is empty', 'Loginform')
						)
					))
				),
				'attribs' => array(
					'class' => 'loginform_username',
					'id' => 'username' . $loginform['id']
				),
			));

			// userpassword
			$userpassword = new Html_Form_Element_Password(array(
				'name' => 'userpassword',
				'label' => Dub_Locale::_('Password', 'Loginform'),
				'required' => true,
				'validators' => array(
					array('NotEmpty', false, array(
						'messages' => array(
							'isEmpty' => Dub_Locale::_('Password is empty', 'Loginform')
						)
					))
				),
				'attribs' => array(
					'class' => 'loginform_userpassword',
					'id' => 'userpassword' . $loginform['id']
				),
			));

			// loginform_login
			$loginform_login = new Html_Form_Element_Submit(array(
				'name' => 'loginform_login',
				'label' => Dub_Locale::_('Login', 'Loginform'),
				'attribs' => array(
					'id' => 'loginform_login' . $loginform['id']
				),
			));

			$form->addElements(array(
				$username,
				$userpassword,
				$loginform_login
			));
		}

		if ($str_username && $loginform['show_logout_button']) {
			// loginform_logout
			$loginform_logout = new Html_Form_Element_Submit(array(
				'name' => 'loginform_logout',
				'label' => Dub_Locale::_('Logout', 'Loginform'),
				'attribs' => array(
					'id' => 'loginform_logout' . $loginform['id']
				),
			));

			$form->addElements(array(
				$loginform_logout
			));
		}
		
		$form->setDecorators(array(
			array('viewScript', array(
				'viewScript' => 'show.phtml',
				'form' => $form,
				'loginform' => $loginform,
				'str_username' => $str_username
			))
		));
		return $form;
	}

}
Return current item: Dubsite