forked from shivam01990/php-contacts-importer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.doc.html
136 lines (135 loc) · 6.5 KB
/
example.doc.html
1
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<html>
/*! \page page1 Example Code Documentation
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title>Svetlozar.NET Contacts Importer</title>
</head>
<body>
<span style="font-weight: bold;">Example Code Documentation<br>
<br>
<br>
./index.php:</span><br>
All logic moved to ContactsHandler class (./example/contacts.main.php)<br>
<div style="margin-left: 40px;">
<pre>include_once 'example/contacts.main.php';</pre>
<pre>$handler = new ContactsHandler();</pre>
<pre>$handler->handle_request($_POST);</pre>
</div>
<br>
<span style="font-weight: bold;">./example/contacts.main.php</span>
(this is where most of the code is, the rest of the files are templates
for forms and pages)<br>
Please see comments within the file, I've tried
tried to explain almost every single step<br>
The main method is handle_request<br>
<br>
<span style="font-weight: bold;">Forms:</span><br>
A note for all forms: the instance of ContactsHandler is made available
in the forms (so $this->[property] points to propery of
ContactsHandler), forms are loaded within handle_request scope<br>
<br>
<span style="font-weight: bold;">./example/contacts.import.php</span><br>
Based on the type of contacts importer class display:<br>
- username and password (+
captcha if captcha response is returned)<br>
- or just a button to open the
external authentication window<br>
<br>
<span style="font-weight: bold;">./example/contacts.invite.php</span><br>
Display a list of imported contacts for user
selection (if your implementation requires to do so)<br>
<br>
<span style="font-weight: bold;">./example/contacts.done.php</span><br>
Any feedback to the user after
submitting selected contacts<br>
<br>
<span style="font-weight: bold;">./contacts.page.php</span><br>
Javascript documentation:<br>
Important parts<br>
<span
style="font-weight: bold;">form_ready</span> global (available to the
whole page) is set to True if the form is simple import form
(username/password), or for external authentication forms, it is True
only after the user clicks the button for external authentication (used
in the onclick event of the button so that form submission is not
triggered during opening the external authentication window)<br>
External authentication does trigger form submission
but only when the user goes through the process of authorizing the
request (at that point the popup window calls back its parent window
and as a result the form is submitted with any additional data that the
popup window may provide)<br>
<br>
More Javascript
(second block)<br>
(function(){...}) is used to create local scope (not
creating any globals, not necessary otherwise)<br>
<span style="font-weight: bold;">external_auth</span>
- url to the page that will handle external authentication redirection
(url used in opening the popup window)<br>
<span style="font-weight: bold;">submit_form</span>
- replaces (wraps) the onsubmit event of the form (it is a decorator),
makes sure the form is only submitted when form_ready is true and opens
up the external authentication window otherwise<br>
<span style="font-weight: bold;">toggle_checked</span>,
<span style="font-weight: bold;">cancel_propagation</span>, <span
style="font-weight: bold;">set_checked</span> - provided for user
friendliness (allow for checking all checkboxes at once, clicking on
table row toggles on/off the checkbox on that row), you may use any
javascript library to provide the same<br>
<br>
The last part of the javascript code is where the
form submit event is wrapped in a call to submit_form<br>
<br>
<div style="margin-left: 40px;">
var import_form = document.getElementById("import_form");<br>
if (import_form)<br>
{<br>
import_form.onsubmit = submit_form(import_form);<br>
}<br>
<br>
<span style="font-weight: bold;"></span><br>
</div>
<span style="font-weight: bold;">./external.php</span><br>
Contains definition of ExternalAuthHandler which
overrides handle_request from ContactsHandler (again, it will be most
useful if you follow the comments in the code for handle_request)<br>
<br>
<span style="font-weight: bold;">./example/external.page.php</span><br>
A template page for the external
authentication page<br>
<span style="font-weight: bold;">QueryParms
</span>= the query string parsed into dictionary (or associative array
in PHP terms), we need to extract oauth_verifier from it when the user
authorizes the request<br>
<span style="font-weight: bold;">ReturnToParent()</span>
- sets form_ready in the parent window to true, and passes
oauth_verifier to ImportContacts function in the parent window (which
will trigger submission of the form with oauth_verifier as part of the
"state" of the form)<br>
<br>
<br>
<span style="font-weight: bold;">Settings<br>
Svetlozar.NET/settings.php </span>(comments include urls for getting
private keys/secret for your application. I could not find one for
Plaxo)<span style="font-weight: bold;"><br>
</span> Sign up for your own keys and enter them here<span
style="font-weight: bold;"><span style="font-weight: bold;"> </span></span>(this
file may remotely look like a file of global definitions but it is
actually included within the scope of SPUserSettings::init())<span
style="font-weight: bold;"><br>
</span>
</body>
*/
</html>