-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsynchronize_extract.php
158 lines (139 loc) · 4.88 KB
/
synchronize_extract.php
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
// Copyright (C) 2003-2010 National Association of REALTORS(R)
//
// All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use, copy,
// modify, merge, publish, distribute, and/or sell copies of the
// Software, and to permit persons to whom the Software is furnished
// to do so, provided that the above copyright notice(s) and this
// permission notice appear in all copies of the Software and that
// both the above copyright notice(s) and this permission notice
// appear in supporting documentation.
//------------
//
// includes
//
include_once('./controller.php');
if (array_key_exists('CANCEL', $vars)) {
locate_next_screen($vars['LOCATION']);
}
$EXTRACT = new Extract();
$CONFIGURATION = $EXTRACT->getConfiguration($vars['ELEMENT']);
//
// look at the sanity of the EXTRACT
//
$aName = $CONFIGURATION->getName();
if (!$EXTRACT->isValidConfiguration($aName)) {
$metadataStatus = 'EXTRACT [' . $aName . '] is not valid';
$HTML = new HTMLPage();
$HTML->start(PROJECT_NAME . ' Persistant Downloader');
$FORMATTER = new TableFormatter();
$items[] = $FORMATTER->renderError($metadataStatus);
$FORMATTER->printNotice($items,
'./index.php',
'Correct the definition of this EXTRACT');
$FORMATTER->finish();
$HTML->finish();
exit(0);
}
//
// determine source
//
$SOURCE = new Source();
$S_CONFIGURATION = $SOURCE->getConfiguration($CONFIGURATION->getValue('SOURCE'));
//
// local definitions
//
$submit_url = './synchronize_results.php';
//
// determine if there are any items to show
//
$query_items = $S_CONFIGURATION->getValue('QUERY_ITEMS');
if (strlen(trim($query_items)) == 0) {
$url = $submit_url .
'?LOCATION=./index.php' .
'&ELEMENT=' . $vars['ELEMENT'];
locate_next_screen($url);
}
//
// make sure metadata is valid
//
$aName = $S_CONFIGURATION->getName();
if (!$SOURCE->isValidConfiguration($aName)) {
$metadataStatus = 'Metadata for SOURCE [' . $aName . '] is not valid';
$HTML = new HTMLPage();
$HTML->start(PROJECT_NAME . ' Persistant Downloader');
$FORMATTER = new TableFormatter();
$items[] = $FORMATTER->renderError($metadataStatus);
$FORMATTER->printNotice($items,
'./index.php',
'Refresh the metadata for this SOURCE');
$FORMATTER->finish();
$HTML->finish();
exit(0);
}
//
// make sure TARGET is sane
//
$TARGET = new Target();
$T_CONFIGURATION = $TARGET->getConfiguration($CONFIGURATION->getValue('TARGET'));
$aName = $T_CONFIGURATION->getName();
if (!$TARGET->isValidConfiguration($aName)) {
$metadataStatus = 'TARGET [' . $aName . '] is not writable';
$HTML = new HTMLPage();
$HTML->start(PROJECT_NAME . ' Persistant Downloader');
$FORMATTER = new TableFormatter();
$items[] = $FORMATTER->renderError($metadataStatus);
$FORMATTER->printNotice($items,
'./index.php',
'Correct the definition for this TARGET');
$FORMATTER->finish();
$HTML->finish();
exit(0);
}
//
// render a form
//
define('ENTER_QUERY_MESSAGE','Enter Your Search Parameters Above');
$HTML = new HTMLPage();
$HTML->start(PROJECT_NAME . ' Persistant Downloader');
//
// using view.php
//
$standardNames = $S_CONFIGURATION->getBooleanValue('DETECTED_STANDARD_NAMES');
$resource = $S_CONFIGURATION->getValue('SELECTION_RESOURCE');
$METADATA_CLASS = new ClassMetadata($CONFIGURATION->getValue('SOURCE'),
$resource);
$class = $S_CONFIGURATION->getValue('SELECTION_CLASS');
$systemClass = $METADATA_CLASS->getSystemClass($class,
$standardNames);
$METADATA_TABLE = new TableMetadata($CONFIGURATION->getValue('SOURCE'),
$systemClass);
$name_translation = $METADATA_TABLE->findNames($standardNames, true);
//
// use query values from the BCF (last successful extract)
//
$query_array = $EXTRACT->getLastQueryValues($vars['ELEMENT']);
//print_r($query_array);
//
// render the form
//
$FORMATTER = new SynchronizeForms();
print($FORMATTER->renderSpecialForm($name_translation,
$query_array,
$submit_url,
'./index.php',
$vars['ELEMENT'],
'Synchronization Criteria',
$query_items,
$S_CONFIGURATION->getValue('DATE_VARIABLE'),
$EXTRACT->getLastRun($vars['ELEMENT']) ));
$FORMATTER->finish();
$HTML->finish();
//
//------------
?>