1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34: class Mage_XmlConnect_Block_Customer_Form extends Mage_Core_Block_Template
35: {
36: 37: 38: 39: 40:
41: protected function _toHtml()
42: {
43: $editFlag = (int)$this->getRequest()->getParam('edit');
44: $customer = $this->getCustomer();
45:
46: $xmlModel = Mage::getModel('xmlconnect/simplexml_element', '<node></node>');
47:
48: if ($editFlag == 1 && $customer && $customer->getId()) {
49: $firstname = $xmlModel->escapeXml($customer->getFirstname());
50: $lastname = $xmlModel->escapeXml($customer->getLastname());
51: $email = $xmlModel->escapeXml($customer->getEmail());
52: } else {
53: $firstname = $lastname = $email = '';
54: }
55:
56: if ($editFlag) {
57: $passwordManageXml = '
58: <field name="change_password" type="checkbox" label="' . $xmlModel->escapeXml($this->__('Change Password')) . '"/>
59: </fieldset>
60: <fieldset>
61: <field name="current_password" type="password" label="' . $xmlModel->escapeXml($this->__('Current Password')) . '"/>
62: <field name="password" type="password" label="' . $xmlModel->escapeXml($this->__('New Password')) . '"/>
63: <field name="confirmation" type="password" label="' . $xmlModel->escapeXml($this->__('Confirm New Password')) . '">
64: <validators>
65: <validator type="confirmation" message="' . $xmlModel->escapeXml($this->__('Regular and confirmation passwords must be equal')) . '">password</validator>
66: </validators>
67: </field>
68: </fieldset>';
69: } else {
70: $passwordManageXml = '
71: <field name="password" type="password" label="' . $xmlModel->escapeXml($this->__('Password')) . '" required="true"/>
72: <field name="confirmation" type="password" label="' . $xmlModel->escapeXml($this->__('Confirm Password')) . '" required="true">
73: <validators>
74: <validator type="confirmation" message="' . $xmlModel->escapeXml($this->__('Regular and confirmation passwords must be equal')) . '">password</validator>
75: </validators>
76: </field>
77: </fieldset>';
78: }
79:
80: $xml = <<<EOT
81: <form name="account_form" method="post">
82: <fieldset>
83: <field name="firstname" type="text" label="{$xmlModel->escapeXml($this->__('First Name'))}" required="true" value="$firstname" />
84: <field name="lastname" type="text" label="{$xmlModel->escapeXml($this->__('Last Name'))}" required="true" value="$lastname" />
85: <field name="email" type="text" label="{$xmlModel->escapeXml($this->__('Email'))}" required="true" value="$email">
86: <validators>
87: <validator type="email" message="{$xmlModel->escapeXml($this->__('Wrong email format'))}"/>
88: </validators>
89: </field>
90: $passwordManageXml
91: </form>
92: EOT;
93:
94: return $xml;
95: }
96: }
97: