Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
page_remote_content_management.inc
1 <?php
17 require_once SQ_INCLUDE_PATH.'/asset_management.inc';
18 
30 {
31 
32 
38  {
39  $this->Asset_Management($pm);
40 
41  $this->vars = Array(
42  'remote_url' => Array(
43  'added' => '0.1',
44  'type' => 'text',
45  'default' => 'http://www.squizsuite.net',
46  'is_admin' => 0
47  ),
48  'load_links' => Array(
49  'added' => '0.1',
50  'type' => 'boolean',
51  'default' => TRUE,
52  'parameters' => Array('allow_empty' => FALSE),
53  ),
54  'verify_ssl' => Array(
55  'added' => '1.7',
56  'type' => 'boolean',
57  'default' => TRUE,
58  'parameters' => Array('allow_empty' => FALSE),
59  ),
60  'allow_redirect' => Array(
61  'added' => '0.1',
62  'type' => 'boolean',
63  'default' => TRUE,
64  'parameters' => Array('allow_empty' => FALSE),
65  ),
66  'username' => Array(
67  'added' => '0.1',
68  'type' => 'text',
69  'default' => '',
70  ),
71  'password' => Array(
72  'added' => '0.1',
73  'type' => 'password',
74  'default' => '',
75  ),
76  'include_tags' => Array (
77  'added' => '0.1',
78  'type' => 'boolean',
79  'default' => TRUE,
80  'parameters' => Array('allow_empty' => FALSE),
81  ),
82  'start_tag' => Array(
83  'added' => '0.1',
84  'type' => 'text',
85  'default' => '',
86  ),
87  'end_tag' => Array(
88  'added' => '0.1',
89  'type' => 'text',
90  'default' => '',
91  ),
92  'multi_occurence' => Array (
93  'added' => '0.1',
94  'type' => 'boolean',
95  'default' => TRUE,
96  'parameters' => Array('allow_empty' => FALSE),
97  ),
98  'no_tag_clear' => Array(
99  'added' => '1.6',
100  'type' => 'boolean',
101  'default' => FALSE,
102  'parameters' => Array('allow_empty' => FALSE),
103  ),
104  'timeout' => Array(
105  'added' => '0.1',
106  'type' => 'int',
107  'default' => '30',
108  'parameters' => Array('allow_negative' => FALSE),
109  ),
110  'error_message' => Array(
111  'added' => '0.1',
112  'type' => 'wysiwyg',
113  'default' => '<p>Content cannot be accessed</p>',
114  'is_contextable' => TRUE,
115  ),
116  'display_error' => Array(
117  'added' => '0.1',
118  'type' => 'boolean',
119  'default' => TRUE,
120  'parameters' => Array('allow_empty' => FALSE),
121  ),
122  'binary_message' => Array(
123  'added' => '0.1',
124  'type' => 'wysiwyg',
125  'default' => "<p>
126  The requested document appears to be a binary file.
127  Please click the url to open it in another window.<br />
128  <a href='%remote_url%' target='_blank'>%remote_url%</a>
129  </p>",
130  'is_contextable' => TRUE,
131  ),
132  'strip_images' => Array(
133  'added' => '1.4',
134  'type' => 'boolean',
135  'default' => FALSE,
136  'parameters' => Array('allow_empty' => FALSE),
137  ),
138  'tunnel_images' => Array(
139  'added' => '1.4',
140  'type' => 'boolean',
141  'default' => FALSE,
142  'parameters' => Array('allow_empty' => FALSE),
143  ),
144  'tunnel_media' => Array(
145  'added' => '1.4',
146  'type' => 'boolean',
147  'default' => FALSE,
148  'parameters' => Array('allow_empty' => FALSE),
149  ),
150  'tunnel_scripts' => Array(
151  'added' => '1.4',
152  'type' => 'boolean',
153  'default' => FALSE,
154  'parameters' => Array('allow_empty' => FALSE),
155  ),
156  'post_variables' => Array(
157  'added' => '1.5',
158  'type' => 'serialise',
159  'default' => Array(),
160  ),
161  'tag_replacements' => Array(
162  'added' => '1.6',
163  'type' => 'serialise',
164  'default' => Array(),
165  ),
166  'url_white_list' => Array(
167  'added' => '1.5',
168  'type' => 'serialise',
169  'default' => Array(),
170  ),
171  'url_rewriting_options' => Array(
172  'added' => '1.7',
173  'type' => 'serialise',
174  'default' => Array(
175  'all' => FALSE,
176  'remote_url' => FALSE,
177  'remote_domain' => TRUE,
178  'white_list' => FALSE,
179  ),
180  ),
181  );
182 
183  }//end constructor
184 
185 
194  function _upgrade($current_version)
195  {
196  if (!parent::_upgrade($current_version)) return FALSE;
197 
198  if (version_compare($current_version, '1.7','<')) {
199  pre_echo('UPGRADING REMOTE CONTENT FROM v'.$current_version.' to v1.7');
200  $ids = $GLOBALS['SQ_SYSTEM']->am->getTypeAssetids('page_remote_content');
201  foreach ($ids as $id) {
202  $asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($id);
203  $white_list = $asset->attr('url_white_list');
204  $options = Array(
205  'all' => FALSE,
206  'remote_url' => FALSE,
207  'remote_domain' => FALSE,
208  'white_list' => FALSE,
209  );
210  if ($asset->attr('only_local_links')) {
211  if (empty($white_list)) {
212  // restrict to local domain
213  $options['remote_domain'] = TRUE;
214  } else {
215  // white list URLs plus local domain
216  $options['remote_domain'] = TRUE;
217  $options['white_list'] = TRUE;
218  }
219  } else {
220  if (empty($white_list)) {
221  $options['all'] = TRUE;
222  } else {
223  $options['white_list'] = TRUE;
224  $options['remote_url'] = TRUE;
225  }
226  }
227  $asset->setAttrValue('url_rewriting_options', $options);
228  $asset->saveAttributes();
229  }
230  pre_echo('UPGRADE COMPLETE - '.count($ids).' REMOTE CONTENT PAGES UPGRADED');
231  }//end if version matches
232 
233  return TRUE;
234 
235  }//end _upgrade()
236 
237 
238 }//end class
239 ?>