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: 35: 36:
37:
38: 39: 40: 41: 42: 43:
44: class UpdatesForm {
45:
46: 47: 48:
49: public $label = array(
50: 'receiveUpdates' => 'Notify me of software updates',
51: 'firstName' => 'First Name',
52: 'lastName' => 'Last Name',
53: 'email' => 'Email',
54: 'phone' => 'Phone Number',
55: 'source' => 'How you found X2CRM',
56: 'subscribe' => 'Subscribe to the newsletter',
57: 'info' => 'Comments',
58: 'requestContact' => 'Request a follow-up contact',
59: 'company' => 'Company',
60: 'position' => 'Position',
61: 'unique_id' => 'Product Key',
62: );
63:
64: 65: 66:
67: public $message = array(
68: 'updatesTitle' => 'Software Updates',
69: 'registrationTitle' => 'Registration',
70: 'registrationSuccess' => 'Software registration succeeded.',
71: 'registrationSubtext' => 'To receive software updates from X2Engine, please register your copy of X2CRM:',
72: 'registrationPostText' => 'For support or sales inquiries, please contact us',
73: 'emailIni' => 'If different from Administrator Email',
74: 'infoIni' => 'Intended use of X2CRM, goals, etc.',
75: 'intro' => 'Please help us improve X2CRM by providing the following information:',
76: 'already' => 'Software update notifications enabled.',
77: 'optionalTitle' => 'Optional Information',
78: 'title' => 'Software Updates',
79: 'emailValidation' => 'Please enter a valid email address.',
80: 'connectionErrHeader' => 'Could not connect to the updates server at this time.',
81: 'connectionErrMessage' => 'You can continue installing the application without enabling updates and try again later by going into "General Settings" under the section "App Settings" in the Admin console.',
82: 'connectionNOsMessage' => 'Make sure you have an active internet connection. If the problem persists, please contact us',
83: );
84:
85: 86: 87:
88: public $leadSources = array(
89: Null => '-----',
90: 'Google' => 'Google',
91: 'Sourceforge' => 'Sourceforge',
92: 'Github' => 'Github',
93: 'News outlet' => 'News Outlet',
94: 'Other' => 'Other',
95: );
96:
97: 98: 99:
100: public $config = array();
101:
102: 103: 104:
105: public $os = True;
106:
107:
108: public function __construct($config, $transFunc, $transFuncArgs = array()) {
109: $this->config = array(
110: 'x2_version' => '',
111: 'php_version' => phpversion(),
112: 'GD_support' => function_exists('gd_info') ? 1 : 0,
113: 'db_type' => 'MySQL',
114: 'db_version' => '',
115: 'unique_id' => 'none',
116: 'formId' => '',
117: 'submitButtonId' => '',
118: 'statusId' => '',
119: 'themeUrl' => '',
120: 'titleWrap' => array('<h2>', '</h2>'),
121: 'receiveUpdates' => 1,
122: 'serverInfo' => False,
123: 'user_agent' => $_SERVER['HTTP_USER_AGENT'],
124: 'registered' => 0,
125: 'edition' => 'opensource',
126: 'isUpgrade' => False,
127: );
128:
129: foreach ($config as $key => $value)
130: $this->config[$key] = $value;
131:
132:
133: $this->os = $config['edition']=='opensource' && ! $this->config['isUpgrade'];
134:
135: if (!$this->os)
136: if ($this->config['unique_id'] == 'none')
137: $this->config['unique_id'] = '';
138:
139:
140:
141:
142: foreach (array('label', 'message', 'leadSources') as $attr) {
143: $attrArr = $this->$attr;
144: foreach (array_keys($this->$attr) as $key)
145: $attrArr[$key] = call_user_func_array($transFunc, array_merge($transFuncArgs, array($attrArr[$key])));
146: $this->$attr = $attrArr;
147: }
148: $this->message['connectionNOsMessage'] .= ': <a href="http://www.x2crm.com/contact/">x2crm.com</a>.';
149: }
150:
151: 152: 153: 154: 155:
156: public function wrapTitle($title) {
157: return $this->config['titleWrap'][0] . $title . $this->config['titleWrap'][1];
158: }
159:
160: 161: 162: 163:
164: public function textFields($fields = array()) {
165: foreach ($fields as $field) {
166: echo '<div class="row">'."\n";
167: echo '<label for="' . $field . '">' . $this->label[$field] . '</label>';
168: echo '<input type="text" name="' . $field . '" id="' . $field . '" />';
169: echo '</div><!-- .row -->'."\n";
170: }
171: }
172:
173: 174: 175: 176:
177: public function hiddenFields($fields = array()) {
178: foreach ($fields as $field)
179: echo '<input type="hidden" name="' . $field . '" id="' . $field . '" value="' . $this->config[$field] . '">';
180: }
181:
182: public function testMessages() {
183: echo "<dl>\n";
184: foreach ($this->message as $key => $value)
185: echo "<dt>$key</dt><dd>$value</dd>\n";
186: echo "</dl>";
187: }
188:
189: }
190: ?>
191: