Commit ef9104892b17d158d17c91d81b271e76c8107acc

Authored by megan_w
1 parent 36b5498c

KTS-2746

"CLONE -Put the custom metadata fields in alphabetical order(SUP-304)"
Fixed. Added a new config under ui. Put a usort on the fields.

Committed by: Megan Watson
Reviewed by: Conrad Vermeulen



git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7781 c91229c3-7414-0410-bfa2-8a42b809f60b
config/config.ini
... ... @@ -135,6 +135,9 @@ fakeMimetype = default
135 135 ; "dot" command location
136 136 dot = dot
137 137  
  138 +; sort the metadata fields alphabetically
  139 +metadata_sort = true
  140 +
138 141 [i18n]
139 142 ; Default language for the interface
140 143 defaultLanguage = en
... ... @@ -197,7 +200,7 @@ uiUrl = ${rootUrl}/presentation/lookAndFeel/knowledgeTree
197 200  
198 201 ;dedicated feed url
199 202 ;dedicatedrsstitle = RSS Feed Title
200   -;dedicatedrssurl =
  203 +;dedicatedrssurl =
201 204  
202 205 ; files
203 206 stopwordsFile = ${fileSystemRoot}/config/stopwords.txt
... ...
lib/widgets/fieldsetDisplay.inc.php
... ... @@ -5,32 +5,32 @@
5 5 * KnowledgeTree Open Source Edition
6 6 * Document Management Made Simple
7 7 * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
8   - *
  8 + *
9 9 * This program is free software; you can redistribute it and/or modify it under
10 10 * the terms of the GNU General Public License version 3 as published by the
11 11 * Free Software Foundation.
12   - *
  12 + *
13 13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 16 * details.
17   - *
  17 + *
18 18 * You should have received a copy of the GNU General Public License
19 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20   - *
  20 + *
21 21 * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
22 22 * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com.
23   - *
  23 + *
24 24 * The interactive user interfaces in modified source and object code versions
25 25 * of this program must display Appropriate Legal Notices, as required under
26 26 * Section 5 of the GNU General Public License version 3.
27   - *
  27 + *
28 28 * In accordance with Section 7(b) of the GNU General Public License version 3,
29 29 * these Appropriate Legal Notices must retain the display of the "Powered by
30   - * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  30 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
31 31 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
32   - * must display the words "Powered by KnowledgeTree" and retain the original
33   - * copyright notice.
  32 + * must display the words "Powered by KnowledgeTree" and retain the original
  33 + * copyright notice.
34 34 * Contributor( s): ______________________________________
35 35 *
36 36 */
... ... @@ -45,20 +45,20 @@
45 45 * "document_id" => $iDocumentId
46 46 *
47 47 */
48   -
  48 +
49 49 // boilerplate
50   -require_once(KT_LIB_DIR . "/templating/templating.inc.php");
51   -require_once(KT_LIB_DIR . "/database/dbutil.inc");
  50 +require_once(KT_LIB_DIR . '/templating/templating.inc.php');
  51 +require_once(KT_LIB_DIR . '/database/dbutil.inc');
52 52  
53   -require_once(KT_LIB_DIR . "/documentmanagement/MDTree.inc"); // :(
  53 +require_once(KT_LIB_DIR . '/documentmanagement/MDTree.inc'); // :(
54 54  
55 55  
56 56  
57 57 // data acquisition
58   -require_once(KT_LIB_DIR . "/users/User.inc");
  58 +require_once(KT_LIB_DIR . '/users/User.inc');
59 59 require_once(KT_LIB_DIR . '/documentmanagement/MetaData.inc');
60   -require_once(KT_LIB_DIR . "/widgets/FieldsetDisplayRegistry.inc.php");
61   -require_once(KT_LIB_DIR . "/widgets/fieldWidgets.php");
  60 +require_once(KT_LIB_DIR . '/widgets/FieldsetDisplayRegistry.inc.php');
  61 +require_once(KT_LIB_DIR . '/widgets/fieldWidgets.php');
62 62  
63 63  
64 64 /* it may be useful to move this to a factory, eventually? */
... ... @@ -77,9 +77,9 @@ function getWidgetForMetadataField($field, $current_value, $page, $errors = null
77 77 if ($errors === null) {
78 78 $fieldErrors = array();
79 79 } else {
80   - $fieldErrors = $errors;
  80 + $fieldErrors = $errors;
81 81 }
82   -
  82 +
83 83  
84 84 // now we need to break, based on a few aspects of the oField (DocumentField)
85 85 if ($field->getHasLookup()) {
... ... @@ -90,34 +90,47 @@ function getWidgetForMetadataField($field, $current_value, $page, $errors = null
90 90 // extract the lookup.
91 91 if ($vocab === null) { // allow override
92 92 $lookups = MetaData::getEnabledByDocumentField($field);
93   - $fieldOptions["vocab"] = array(); // FIXME handle lookups
94   - $fieldOptions['vocab'][''] = _kt('Select a value');
  93 + $fieldOptions['vocab'] = array(); // FIXME handle lookups
  94 + $fieldOptions['vocab'][''] = _kt('Select a value');
95 95 foreach ($lookups as $md) {
96   - $fieldOptions["vocab"][$md->getName()] = $md->getName();
  96 + $fieldOptions['vocab'][$md->getName()] = $md->getName();
97 97 }
98 98 } else {
99   - $fieldOptions["vocab"] = $vocab;
  99 + $fieldOptions['vocab'] = $vocab;
100 100 }
101   -
102   - $oField = new KTLookupWidget($fieldLabel, $fieldDescription, $fieldName, $fieldValue, $page, $fieldRequired, null, $fieldErrors, $fieldOptions);
  101 +
  102 + $oField = new KTLookupWidget($fieldLabel, $fieldDescription, $fieldName, $fieldValue, $page, $fieldRequired, null, $fieldErrors, $fieldOptions);
103 103 } else {
104 104 // FIXME vocab's are _not_ supported for tree-inputs. this means conditional-tree-widgets are not unsupported.
105   -
  105 +
106 106 // for trees, we are currently brutal.
107 107 $fieldTree = new MDTree();
108 108 $fieldTree->buildForField($field->getId());
109 109 $fieldTree->setActiveItem($current_value);
110 110 $fieldOptions['tree'] = $fieldTree->_evilTreeRenderer($fieldTree, $fieldName);
111   -
112   - $oField = new KTTreeWidget($fieldLabel, $fieldDescription, $fieldName, $fieldValue, $page, $fieldRequired, null, $fieldErrors, $fieldOptions);
  111 +
  112 + $oField = new KTTreeWidget($fieldLabel, $fieldDescription, $fieldName, $fieldValue, $page, $fieldRequired, null, $fieldErrors, $fieldOptions);
113 113 }
114 114 } else {
115   - $oField = new KTBaseWidget($fieldLabel, $fieldDescription, $fieldName, $fieldValue, $page, $fieldRequired, null, $fieldErrors, $fieldOptions);
  115 + $oField = new KTBaseWidget($fieldLabel, $fieldDescription, $fieldName, $fieldValue, $page, $fieldRequired, null, $fieldErrors, $fieldOptions);
116 116 }
117 117  
118 118 return $oField;
119 119 }
120 120  
  121 +/**
  122 + * Compare the fields within a fieldset for alphabetising.
  123 + *
  124 + * @param object $a
  125 + * @param object $b
  126 + * @return integer
  127 + */
  128 +function compareFieldSetField($a, $b)
  129 +{
  130 + if ($a['field']->getName() == $b['field']->getName()) return 0;
  131 + if ($a['field']->getName() < $b['field']->getName()) return -1;
  132 + return 1;
  133 +}
121 134  
122 135 // FIXME need to establish some kind of api to pass in i18n information.
123 136 class KTFieldsetDisplay {
... ... @@ -126,33 +139,33 @@ class KTFieldsetDisplay {
126 139 function KTFieldsetDisplay($oFieldset) {
127 140 $this->fieldset = $oFieldset;
128 141 }
129   -
  142 +
130 143  
131 144 function _dateHelper($dDate) {
132 145 $dColumnDate = strtotime($dDate);
133   - return date("Y-m-d H:i", $dColumnDate);
  146 + return date('Y-m-d H:i', $dColumnDate);
134 147 }
135   -
136   -
  148 +
  149 +
137 150 function _sizeHelper($size) {
138 151 $finalSize = $size;
139 152 $label = 'b';
140   -
  153 +
141 154 if ($finalSize > 1000) { $label='Kb'; $finalSize = floor($finalSize/1000); }
142 155 if ($finalSize > 1000) { $label='Mb'; $finalSize = floor($finalSize/1000); }
143 156 return $finalSize . $label;
144 157 }
145   -
  158 +
146 159 function _mimeHelper($iMimeTypeId) {
147 160 // FIXME lazy cache this.
148 161 // FIXME extend mime_types to have something useful to say.
149 162 $sQuery = 'SELECT * FROM mime_types WHERE id = ?';
150 163 $res = DBUtil::getOneResult(array($sQuery, array($iMimeTypeId)));
151   -
  164 +
152 165 if (PEAR::isError($res)) {
153 166 return _kt('unknown type');
154 167 }
155   -
  168 +
156 169 if (!empty($res['friendly_name'])) {
157 170 return _kt($res['friendly_name']);
158 171 } else {
... ... @@ -160,19 +173,19 @@ class KTFieldsetDisplay {
160 173 }
161 174  
162 175 }
163   -
164   -
  176 +
  177 +
165 178 // this should multiplex i18n_title
166 179 function getTitle() { return $this->sTitle; }
167   -
  180 +
168 181 function render($aDocumentData) {
169 182 return '<p class="ktError">Warning: Abstract Fieldset created.</p>';
170 183 }
171   -
  184 +
172 185 function renderComparison($aDocumentData, $aComparisonData) {
173 186 return '<div class="ktError">Not implemented: comparison rendering</div>';
174 187 }
175   -
  188 +
176 189 // we need the $main to (potentially) add js, etc.
177 190 function renderEdit($document_data) {
178 191 return '<div class="ktError">Not Implemented: fieldset editing.</div>';
... ... @@ -188,29 +201,29 @@ class GenericFieldsetDisplay extends KTFieldsetDisplay {
188 201  
189 202 // DON'T take anything.
190 203 function GenericFieldsetDisplay() {
191   -
  204 +
192 205 }
193   -
  206 +
194 207 function render($aDocumentData) {
195 208 // we do a fair bit of fetching, etc. in here.
196   - $document = $aDocumentData["document"];
  209 + $document = $aDocumentData['document'];
197 210  
198 211 // creation
199 212 $creator =& User::get($document->getCreatorId());
200 213 if (PEAR::isError($creator)) {
201   - $creator_name = "<span class='ktError'>" . _kt("Unable to find the document's creator") . "</span>";
  214 + $creator_name = '<span class="ktError">' . _kt("Unable to find the document's creator") . '</span>';
202 215 } else {
203 216 $creator_name = $creator->getName();
204 217 }
205 218 $owner =& User::get($document->getOwnerId());
206 219 if (PEAR::isError($owner)) {
207   - $owner_name = "<span class='ktError'>" . _kt("Unable to find the document's owner") . "</span>";
  220 + $owner_name = '<span class="ktError">' . _kt("Unable to find the document's owner") . '</span>';
208 221 } else {
209 222 $owner_name = $owner->getName();
210 223 }
211 224 $modified_user =& User::get($document->getModifiedUserId());
212 225 if (PEAR::isError($modified_user)) {
213   - $modified_user_name = "<span class='ktError'>" . _kt("Unable to find the document's modifier") . "</span>";
  226 + $modified_user_name = '<span class="ktError">' . _kt("Unable to find the document's modifier") . '</span>';
214 227 } else {
215 228 $modified_user_name = $modified_user->getName();
216 229 }
... ... @@ -218,48 +231,48 @@ class GenericFieldsetDisplay extends KTFieldsetDisplay {
218 231  
219 232 // last mod
220 233 $last_modified_date = $this->_dateHelper($document->getLastModifiedDate());
221   -
  234 +
222 235 // document type // FIXME move this to view.php
223   - $document_type = $aDocumentData["document_type"]->getName();
  236 + $document_type = $aDocumentData['document_type']->getName();
224 237  
225 238 $oWorkflow = KTWorkflowUtil::getWorkflowForDocument($document);
226 239 $oState = KTWorkflowUtil::getWorkflowStateForDocument($document);
227   -
228   -
229   - $oTemplating =& KTTemplating::getSingleton();
230   - $oTemplate = $oTemplating->loadTemplate("kt3/fieldsets/generic");
  240 +
  241 +
  242 + $oTemplating =& KTTemplating::getSingleton();
  243 + $oTemplate = $oTemplating->loadTemplate('kt3/fieldsets/generic');
231 244 $aTemplateData = array(
232   - "context" => $this,
233   - "document_data" => $aDocumentData,
234   - "document" => $aDocumentData["document"],
235   -
236   - "filename" => $document->getFileName(),
237   -
238   - "creator" => $creator_name,
239   - "owner" => $owner_name,
240   - "creation_date" => $creation_date,
241   -
242   - "last_modified_by" => $modified_user_name,
243   - "last_modified_date" => $last_modified_date,
244   -
245   - "document_type" => $document_type,
246   -
247   - "workflow_state" => $oState,
248   - "workflow" => $oWorkflow,
  245 + 'context' => $this,
  246 + 'document_data' => $aDocumentData,
  247 + 'document' => $aDocumentData['document'],
  248 +
  249 + 'filename' => $document->getFileName(),
  250 +
  251 + 'creator' => $creator_name,
  252 + 'owner' => $owner_name,
  253 + 'creation_date' => $creation_date,
  254 +
  255 + 'last_modified_by' => $modified_user_name,
  256 + 'last_modified_date' => $last_modified_date,
  257 +
  258 + 'document_type' => $document_type,
  259 +
  260 + 'workflow_state' => $oState,
  261 + 'workflow' => $oWorkflow,
249 262 );
250 263  
251   - return $oTemplate->render($aTemplateData);
  264 + return $oTemplate->render($aTemplateData);
252 265 }
253   -
  266 +
254 267 function renderComparison($aDocumentData, $aComparisonData) {
255 268 // we do a fair bit of fetching, etc. in here.
256   - $document = $aDocumentData["document"];
257   - $comparison_document = $aComparisonData["document"];
  269 + $document = $aDocumentData['document'];
  270 + $comparison_document = $aComparisonData['document'];
258 271  
259 272 // creation
260 273 $creator =& User::get($document->getCreatorId());
261 274 if (PEAR::isError($creator)) {
262   - $creator = "<span class='ktError'>" . _kt("Unable to find the document's creator") . "</span>";
  275 + $creator = '<span class="ktError">' . _kt("Unable to find the document's creator") . '</span>';
263 276 } else {
264 277 $creator = $creator->getName();
265 278 }
... ... @@ -268,30 +281,30 @@ class GenericFieldsetDisplay extends KTFieldsetDisplay {
268 281 // last mod
269 282 $last_modified_date = $this->_dateHelper($document->getVersionCreated());
270 283 $comparison_last_modified_date = $this->_dateHelper($comparison_document->getVersionCreated());
271   -
  284 +
272 285 // document type // FIXME move this to view.php
273   - $document_type = $aDocumentData["document_type"]->getName();
274   - $comparison_document_type = $aComparisonData["document_type"]->getName();
275   -
  286 + $document_type = $aDocumentData['document_type']->getName();
  287 + $comparison_document_type = $aComparisonData['document_type']->getName();
  288 +
276 289 $modified_user =& User::get($document->getVersionCreatorId());
277 290 if (PEAR::isError($modified_user)) {
278   - $modified_user = "<span class='ktError'>" . _kt("Unable to find the document's modifier") . "</span>";
  291 + $modified_user = "<span class='ktError'>" . _kt("Unable to find the document's modifier") . '</span>';
279 292 } else {
280 293 $modified_user = $modified_user->getName();
281 294 }
282 295  
283 296 $owner_user =& User::get($document->getOwnerId());
284 297 if (PEAR::isError($owner_user)) {
285   - $owner_user = "<span class='ktError'>" . _kt("Unable to find the document's owner") . "</span>";
  298 + $owner_user = "<span class='ktError'>" . _kt("Unable to find the document's owner") . '</span>';
286 299 } else {
287 300 $owner_user = $owner_user->getName();
288 301 }
289   -
  302 +
290 303  
291 304  
292 305 $comparison_modified_user =& User::get($comparison_document->getVersionCreatorId());
293 306 if (PEAR::isError($comparison_modified_user)) {
294   - $comparison_modified_user = "<span class='ktError'>" . _kt("Unable to find the document's modifier") . "</span>";
  307 + $comparison_modified_user = "<span class='ktError'>" . _kt("Unable to find the document's modifier") . '</span>';
295 308 } else {
296 309 $comparison_modified_user = $comparison_modified_user->getName();
297 310 }
... ... @@ -300,59 +313,59 @@ class GenericFieldsetDisplay extends KTFieldsetDisplay {
300 313 $oState = KTWorkflowUtil::getWorkflowStateForDocument($document);
301 314 $oComparisonWorkflow = KTWorkflowUtil::getWorkflowForDocument($comparison_document);
302 315 $oComparisonState = KTWorkflowUtil::getWorkflowStateForDocument($comparison_document);
303   -
304   -
305   - $oTemplating =& KTTemplating::getSingleton();
306   - $oTemplate = $oTemplating->loadTemplate("kt3/fieldsets/generic_versioned");
  316 +
  317 +
  318 + $oTemplating =& KTTemplating::getSingleton();
  319 + $oTemplate = $oTemplating->loadTemplate('kt3/fieldsets/generic_versioned');
307 320 $aTemplateData = array(
308   - "context" => $this,
309   - "document_data" => $aDocumentData,
310   - "document" => $aDocumentData["document"],
311   -
312   - "title" => $document->getName(),
313   - "comparison_title" => $comparison_document->getName(),
314   -
315   - "filename" => $document->getFileName(),
316   - "comparison_filename" => $comparison_document->getFileName(),
317   -
318   - "creator" => $creator,
319   - "creation_date" => $creation_date,
320   - "owner" => $owner_user,
321   -
322   - "last_modified_by" => $modified_user,
323   - "last_modified_date" => $last_modified_date,
324   -
325   - "comparison_last_modified_by" => $comparison_modified_user,
326   - "comparison_last_modified_date" => $comparison_last_modified_date,
327   -
328   - "document_type" => $document_type,
329   - "comparison_document_type" => $comparison_document_type,
330   -
331   - "workflow_state" => $oState,
332   - "comparison_workflow_state" => $oComparisonState,
333   - "workflow" => $oWorkflow,
334   - "comparison_workflow" => $oComparisonWorkflow,
335   -
336   - "comparison_document" => $aComparisonData["document"],
  321 + 'context' => $this,
  322 + 'document_data' => $aDocumentData,
  323 + 'document' => $aDocumentData['document'],
  324 +
  325 + 'title' => $document->getName(),
  326 + 'comparison_title' => $comparison_document->getName(),
  327 +
  328 + 'filename' => $document->getFileName(),
  329 + 'comparison_filename' => $comparison_document->getFileName(),
  330 +
  331 + 'creator' => $creator,
  332 + 'creation_date' => $creation_date,
  333 + 'owner' => $owner_user,
  334 +
  335 + 'last_modified_by' => $modified_user,
  336 + 'last_modified_date' => $last_modified_date,
  337 +
  338 + 'comparison_last_modified_by' => $comparison_modified_user,
  339 + 'comparison_last_modified_date' => $comparison_last_modified_date,
  340 +
  341 + 'document_type' => $document_type,
  342 + 'comparison_document_type' => $comparison_document_type,
  343 +
  344 + 'workflow_state' => $oState,
  345 + 'comparison_workflow_state' => $oComparisonState,
  346 + 'workflow' => $oWorkflow,
  347 + 'comparison_workflow' => $oComparisonWorkflow,
  348 +
  349 + 'comparison_document' => $aComparisonData['document'],
337 350 );
338   -
339   - return $oTemplate->render($aTemplateData);
  351 +
  352 + return $oTemplate->render($aTemplateData);
340 353 }
341   -
  354 +
342 355 function renderEdit($document_data) {
343 356 global $main; // FIXME remove direct access to $main
344   - $oField = new KTBaseWidget(_kt("Document Title"),
  357 + $oField = new KTBaseWidget(_kt('Document Title'),
345 358 sprintf(_kt("The document title is used as the main name of a document throughout %s&trade;."), APP_NAME),
346   - "generic_title", $document_data["document"]->getName(), $main, true, null, array());
  359 + 'generic_title', $document_data['document']->getName(), $main, true, null, array());
347 360 $aFields = array($oField); // its the only one editable from the basic set (currently).
348   -
349   - $oTemplating =& KTTemplating::getSingleton();
350   - $oTemplate = $oTemplating->loadTemplate("kt3/fieldsets/simple_editable");
  361 +
  362 + $oTemplating =& KTTemplating::getSingleton();
  363 + $oTemplate = $oTemplating->loadTemplate('kt3/fieldsets/simple_editable');
351 364 $aTemplateData = array(
352   - "context" => $this,
353   - "fields" => $aFields,
354   - "title" => _kt("Generic Document Information"),
355   - "description" => sprintf(_kt("The information in this section is stored by %s&trade; for every document."), APP_NAME),
  365 + 'context' => $this,
  366 + 'fields' => $aFields,
  367 + 'title' => _kt('Generic Document Information'),
  368 + 'description' => sprintf(_kt("The information in this section is stored by %s&trade; for every document."), APP_NAME),
356 369 );
357 370 return $oTemplate->render($aTemplateData);
358 371 }
... ... @@ -361,177 +374,184 @@ class GenericFieldsetDisplay extends KTFieldsetDisplay {
361 374  
362 375 // The generic object
363 376 class SimpleFieldsetDisplay extends KTFieldsetDisplay {
364   -
  377 +
365 378 function render($aDocumentData) {
366 379 // we do a fair bit of fetching, etc. in here.
367   - $document = $aDocumentData["document"];
368   -
  380 + $document = $aDocumentData['document'];
  381 +
369 382 // we need to extract the fields.
370 383 $fields =& $this->fieldset->getFields();
371   -
372   -
  384 +
  385 +
373 386 // we now grab that subset of items which fit in here.
374 387 // FIXME link value -> lookup where appropriate.
375 388 // FIXME probably need to be more careful about the _type_ of field here.
376 389 $fieldset_values = array();
377 390 foreach ($fields as $oField) {
378   - $val = KTUtil::arrayGet($aDocumentData["field_values"], $oField->getId(), null);
379   - $fieldset_values[] = array("field" => $oField, "value" => $val, );
  391 + $val = KTUtil::arrayGet($aDocumentData['field_values'], $oField->getId(), null);
  392 + $fieldset_values[] = array('field' => $oField, 'value' => $val, );
  393 + }
  394 +
  395 + // Alphabetise the metadata fields within a fieldset if set in config
  396 + $oKTConfig =& KTConfig::getSingleton();
  397 + $use_sort = $oKTConfig->get('ui/metadata_sort', false);
  398 +
  399 + if($use_sort){
  400 + usort($fieldset_values, 'compareFieldSetField');
380 401 }
381   -
382   -
383   -
384   - $oTemplating =& KTTemplating::getSingleton();
385   - $oTemplate = $oTemplating->loadTemplate("kt3/fieldsets/simple");
  402 +
  403 +
  404 + $oTemplating =& KTTemplating::getSingleton();
  405 + $oTemplate = $oTemplating->loadTemplate('kt3/fieldsets/simple');
386 406 $aTemplateData = array(
387   - "context" => $this,
388   - "document_data" => $aDocumentData,
389   - "document" => $aDocumentData["document"],
390   - "fieldset" => $this->fieldset,
391   - "fieldset_values" => $fieldset_values,
392   - "description" => $this->fieldset->getDescription(),
  407 + 'context' => $this,
  408 + 'document_data' => $aDocumentData,
  409 + 'document' => $aDocumentData['document'],
  410 + 'fieldset' => $this->fieldset,
  411 + 'fieldset_values' => $fieldset_values,
  412 + 'description' => $this->fieldset->getDescription(),
393 413 );
394   - return $oTemplate->render($aTemplateData);
  414 + return $oTemplate->render($aTemplateData);
395 415 }
396   -
  416 +
397 417 function renderComparison($aDocumentData, $aComparisonData) {
398 418 // we do a fair bit of fetching, etc. in here.
399   - $document = $aDocumentData["document"];
400   -
  419 + $document = $aDocumentData['document'];
  420 +
401 421 // we need to extract the fields.
402 422 $fields =& $this->fieldset->getFields();
403   -
404   -
  423 +
  424 +
405 425 // we now grab that subset of items which fit in here.
406 426 // FIXME link value -> lookup where appropriate.
407 427 // FIXME probably need to be more careful about the _type_ of field here.
408 428 $fieldset_values = array();
409 429 foreach ($fields as $oField) {
410   - $curr_val = KTUtil::arrayGet($aDocumentData["field_values"], $oField->getId(), null);
411   - $old_val = KTUtil::arrayGet($aComparisonData["field_values"], $oField->getId(), null);
412   - $fieldset_values[] = array("field" => $oField, "current_value" => $curr_val, "previous_value" => $old_val);
  430 + $curr_val = KTUtil::arrayGet($aDocumentData['field_values'], $oField->getId(), null);
  431 + $old_val = KTUtil::arrayGet($aComparisonData['field_values'], $oField->getId(), null);
  432 + $fieldset_values[] = array('field' => $oField, 'current_value' => $curr_val, 'previous_value' => $old_val);
413 433 }
414   -
415   -
416   - $oTemplating =& KTTemplating::getSingleton();
417   - $oTemplate = $oTemplating->loadTemplate("kt3/fieldsets/simple_versioned");
  434 +
  435 +
  436 + $oTemplating =& KTTemplating::getSingleton();
  437 + $oTemplate = $oTemplating->loadTemplate('kt3/fieldsets/simple_versioned');
418 438 $aTemplateData = array(
419   - "context" => $this,
420   - "document_data" => $aDocumentData,
421   - "document" => $aDocumentData["document"],
422   - "fieldset" => $this->fieldset,
423   - "fieldset_values" => $fieldset_values,
  439 + 'context' => $this,
  440 + 'document_data' => $aDocumentData,
  441 + 'document' => $aDocumentData['document'],
  442 + 'fieldset' => $this->fieldset,
  443 + 'fieldset_values' => $fieldset_values,
424 444 );
425   - return $oTemplate->render($aTemplateData);
426   - }
427   -
  445 + return $oTemplate->render($aTemplateData);
  446 + }
  447 +
428 448 function renderEdit($document_data) {
429 449 global $main; // FIXME remove direct access to $main
430   -
  450 +
431 451 $aFields = array();
432   -
  452 +
433 453 $fields =& $this->fieldset->getFields();
434   -
  454 +
435 455 foreach ($fields as $oField) {
436   - $val = KTUtil::arrayGet($document_data["field_values"], $oField->getId(), null);
437   -
  456 + $val = KTUtil::arrayGet($document_data['field_values'], $oField->getId(), null);
  457 +
438 458 $has_errors = KTUtil::arrayGet($document_data['errors'], $oField->getId(),false);
439 459 if ($has_errors !== false) {
440 460 // FIXME when the actual errors (meaningful) are passed out, fix this.
441 461 $errors = array(_kt('The system rejected your value for this field.'));
442   - } else {
  462 + } else {
443 463 $errors = null;
444 464 }
445   -
  465 +
446 466 $aFields[] = getWidgetForMetadataField($oField, $val, $main, $errors); // FIXME handle errors
447 467 }
448 468 $fieldset_name = $this->fieldset->getName();
449 469 $fieldset_description = $this->fieldset->getDescription();
450   - $oTemplating =& KTTemplating::getSingleton();
451   - $oTemplate = $oTemplating->loadTemplate("kt3/fieldsets/simple_editable");
  470 + $oTemplating =& KTTemplating::getSingleton();
  471 + $oTemplate = $oTemplating->loadTemplate('kt3/fieldsets/simple_editable');
452 472 $aTemplateData = array(
453   - "context" => $this,
454   - "fields" => $aFields,
455   - "title" => $fieldset_name,
456   - "description" => $fieldset_description,
  473 + 'context' => $this,
  474 + 'fields' => $aFields,
  475 + 'title' => $fieldset_name,
  476 + 'description' => $fieldset_description,
457 477 );
458   -
459   -
  478 +
  479 +
460 480 return $oTemplate->render($aTemplateData);
461 481 }
462   -
  482 +
463 483 }
464 484  
465 485  
466 486 // Handle the conditional case.
467 487 class ConditionalFieldsetDisplay extends SimpleFieldsetDisplay {
468   -
  488 +
469 489 function renderEdit($document_data) {
470 490 global $main; // FIXME remove direct access to $main
471 491 $oPage =& $main;
472   -
  492 +
473 493 // FIXME do this from inside the widgetry mojo.
474 494 $oPage->requireCSSResource('resources/css/kt-treewidget.css');
475   -
  495 +
476 496 // FIXME this currently doesn't work, since we use NBM's half-baked Ajax on add/bulk ;)
477 497 $oPage->requireJSResource('resources/js/taillog.js');
478 498 $oPage->requireJSResource('resources/js/conditional_usage.js');
479   -
480   - $aFields = array();
  499 +
  500 + $aFields = array();
481 501 $fields =& $this->fieldset->getFields();
482 502 $values = array();
483 503 $errors = $document_data['errors'];
484 504  
485 505 $have_values = false;
486 506 foreach ($fields as $oField) {
487   - $val = KTUtil::arrayGet($document_data["field_values"], $oField->getId(), null);
  507 + $val = KTUtil::arrayGet($document_data['field_values'], $oField->getId(), null);
488 508 if ($val !== null) {
489 509 $have_values = true;
490   -
491   - }
492   -
  510 +
  511 + }
  512 +
493 513 $values[$oField->getId()] = $val;
494   - }
  514 + }
  515 +
495 516  
496   -
497 517 // now, we need to do some extra work on conditional widgets.
498 518 // how?
499   -
  519 +
500 520 $fieldset_name = $this->fieldset->getName();
501 521 $fieldset_description = _kt($this->fieldset->getDescription()); // need a better approach. how do we handle database-resident translations?
502   - $fieldset_description .= _kt("Note that the options which are available depends on previous choices within this fieldset.");
503   -
  522 + $fieldset_description .= _kt('Note that the options which are available depends on previous choices within this fieldset.');
  523 +
504 524 // FIXME handle the editable case _with_ values.
505   -
  525 +
506 526 if ($have_values) {
507   - $oTemplating =& KTTemplating::getSingleton();
508   - $oTemplate = $oTemplating->loadTemplate("kt3/fieldsets/conditional_editable_values");
  527 + $oTemplating =& KTTemplating::getSingleton();
  528 + $oTemplate = $oTemplating->loadTemplate('kt3/fieldsets/conditional_editable_values');
509 529 $aTemplateData = array(
510   - "context" => $this,
511   - "fields" => $fields =& $this->fieldset->getFields(),
  530 + 'context' => $this,
  531 + 'fields' => $fields =& $this->fieldset->getFields(),
512 532 'fieldset_id' => $this->fieldset->getId(),
513   - "title" => $fieldset_name,
514   - "description" => $fieldset_description,
  533 + 'title' => $fieldset_name,
  534 + 'description' => $fieldset_description,
515 535 'values' => $values,
516 536 'errors' => $errors,
517 537 );
518   -
  538 +
519 539 return $oTemplate->render($aTemplateData);
520 540 } // else {
521   -
522   - $oTemplating =& KTTemplating::getSingleton();
523   - $oTemplate = $oTemplating->loadTemplate("kt3/fieldsets/conditional_editable");
  541 +
  542 + $oTemplating =& KTTemplating::getSingleton();
  543 + $oTemplate = $oTemplating->loadTemplate('kt3/fieldsets/conditional_editable');
524 544 $aTemplateData = array(
525   - "context" => $this,
526   - "field" => $oField, // first field, widget.
  545 + 'context' => $this,
  546 + 'field' => $oField, // first field, widget.
527 547 'fieldset_id' => $this->fieldset->getId(),
528   - "title" => $fieldset_name,
529   - "description" => $fieldset_description,
  548 + 'title' => $fieldset_name,
  549 + 'description' => $fieldset_description,
530 550 );
531   -
  551 +
532 552 return $oTemplate->render($aTemplateData);
533 553 }
534   -
  554 +
535 555 }
536 556  
537 557 -?>
  558 +?>
538 559 \ No newline at end of file
... ...
view.php
... ... @@ -5,64 +5,64 @@
5 5 * KnowledgeTree Open Source Edition
6 6 * Document Management Made Simple
7 7 * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
8   - *
  8 + *
9 9 * This program is free software; you can redistribute it and/or modify it under
10 10 * the terms of the GNU General Public License version 3 as published by the
11 11 * Free Software Foundation.
12   - *
  12 + *
13 13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 16 * details.
17   - *
  17 + *
18 18 * You should have received a copy of the GNU General Public License
19 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20   - *
  20 + *
21 21 * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
22 22 * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com.
23   - *
  23 + *
24 24 * The interactive user interfaces in modified source and object code versions
25 25 * of this program must display Appropriate Legal Notices, as required under
26 26 * Section 5 of the GNU General Public License version 3.
27   - *
  27 + *
28 28 * In accordance with Section 7(b) of the GNU General Public License version 3,
29 29 * these Appropriate Legal Notices must retain the display of the "Powered by
30   - * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  30 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
31 31 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
32   - * must display the words "Powered by KnowledgeTree" and retain the original
33   - * copyright notice.
  32 + * must display the words "Powered by KnowledgeTree" and retain the original
  33 + * copyright notice.
34 34 * Contributor( s): ______________________________________
35 35 */
36 36  
37 37 // boilerplate.
38   -require_once("config/dmsDefaults.php");
39   -require_once(KT_LIB_DIR . "/templating/templating.inc.php");
40   -require_once(KT_LIB_DIR . "/templating/kt3template.inc.php");
41   -require_once(KT_LIB_DIR . "/dispatcher.inc.php");
42   -require_once(KT_LIB_DIR . "/util/ktutil.inc");
43   -require_once(KT_LIB_DIR . "/database/dbutil.inc");
44   -require_once(KT_LIB_DIR . "/util/sanitize.inc");
  38 +require_once('config/dmsDefaults.php');
  39 +require_once(KT_LIB_DIR . '/templating/templating.inc.php');
  40 +require_once(KT_LIB_DIR . '/templating/kt3template.inc.php');
  41 +require_once(KT_LIB_DIR . '/dispatcher.inc.php');
  42 +require_once(KT_LIB_DIR . '/util/ktutil.inc');
  43 +require_once(KT_LIB_DIR . '/database/dbutil.inc');
  44 +require_once(KT_LIB_DIR . '/util/sanitize.inc');
45 45  
46 46 // document related includes
47   -require_once(KT_LIB_DIR . "/documentmanagement/Document.inc");
48   -require_once(KT_LIB_DIR . "/documentmanagement/DocumentType.inc");
49   -require_once(KT_LIB_DIR . "/documentmanagement/DocumentFieldLink.inc");
50   -require_once(KT_LIB_DIR . "/documentmanagement/documentmetadataversion.inc.php");
51   -require_once(KT_LIB_DIR . "/documentmanagement/documentcontentversion.inc.php");
52   -require_once(KT_LIB_DIR . "/metadata/fieldset.inc.php");
53   -require_once(KT_LIB_DIR . "/security/Permission.inc");
  47 +require_once(KT_LIB_DIR . '/documentmanagement/Document.inc');
  48 +require_once(KT_LIB_DIR . '/documentmanagement/DocumentType.inc');
  49 +require_once(KT_LIB_DIR . '/documentmanagement/DocumentFieldLink.inc');
  50 +require_once(KT_LIB_DIR . '/documentmanagement/documentmetadataversion.inc.php');
  51 +require_once(KT_LIB_DIR . '/documentmanagement/documentcontentversion.inc.php');
  52 +require_once(KT_LIB_DIR . '/metadata/fieldset.inc.php');
  53 +require_once(KT_LIB_DIR . '/security/Permission.inc');
54 54  
55 55 // widget includes.
56   -require_once(KT_LIB_DIR . "/widgets/portlet.inc.php");
57   -require_once(KT_LIB_DIR . "/widgets/fieldsetDisplay.inc.php");
58   -require_once(KT_LIB_DIR . "/widgets/FieldsetDisplayRegistry.inc.php");
59   -require_once(KT_LIB_DIR . "/actions/documentaction.inc.php");
60   -require_once(KT_LIB_DIR . "/browse/browseutil.inc.php");
  56 +require_once(KT_LIB_DIR . '/widgets/portlet.inc.php');
  57 +require_once(KT_LIB_DIR . '/widgets/fieldsetDisplay.inc.php');
  58 +require_once(KT_LIB_DIR . '/widgets/FieldsetDisplayRegistry.inc.php');
  59 +require_once(KT_LIB_DIR . '/actions/documentaction.inc.php');
  60 +require_once(KT_LIB_DIR . '/browse/browseutil.inc.php');
61 61  
62 62  
63 63 class ViewDocumentDispatcher extends KTStandardDispatcher {
64 64 var $sName = 'ktcore.actions.document.displaydetails';
65   - var $sSection = "view_details";
  65 + var $sSection = 'view_details';
66 66 var $sHelpPage = 'ktcore/browse.html';
67 67  
68 68 var $actions;
... ... @@ -77,21 +77,21 @@ class ViewDocumentDispatcher extends KTStandardDispatcher {
77 77  
78 78 function check() {
79 79 if (!parent::check()) { return false; }
80   -
  80 +
81 81 $this->persistParams(array('fDocumentId'));
82   -
  82 +
83 83 return true;
84 84 }
85 85  
86 86 // FIXME identify the current location somehow.
87 87 function addPortlets($currentaction = null) {
88 88 $currentaction = $this->sName;
89   -
  89 +
90 90 $actions = KTDocumentActionUtil::getDocumentActionsForDocument($this->oDocument, $this->oUser, 'documentinfo');
91 91 $oPortlet = new KTActionPortlet(sprintf(_kt('Document info')));
92 92 $oPortlet->setActions($actions, $currentaction);
93   - $this->oPage->addPortlet($oPortlet);
94   -
  93 + $this->oPage->addPortlet($oPortlet);
  94 +
95 95 $this->actions = KTDocumentActionUtil::getDocumentActionsForDocument($this->oDocument, $this->oUser);
96 96 $oPortlet = new KTActionPortlet(sprintf(_kt('Document actions'), $this->oDocument->getName()));
97 97 $oPortlet->setActions($this->actions, $currentaction);
... ... @@ -100,9 +100,9 @@ class ViewDocumentDispatcher extends KTStandardDispatcher {
100 100  
101 101 function do_main() {
102 102 // fix legacy, broken items.
103   - if (KTUtil::arrayGet($_REQUEST, "fDocumentID", true) !== true) {
104   - $_REQUEST["fDocumentId"] = sanitizeForSQL(KTUtil::arrayGet($_REQUEST, "fDocumentID"));
105   - unset($_REQUEST["fDocumentID"]);
  103 + if (KTUtil::arrayGet($_REQUEST, 'fDocumentID', true) !== true) {
  104 + $_REQUEST['fDocumentId'] = sanitizeForSQL(KTUtil::arrayGet($_REQUEST, 'fDocumentID'));
  105 + unset($_REQUEST['fDocumentID']);
106 106 }
107 107  
108 108 $document_data = array();
... ... @@ -118,7 +118,7 @@ class ViewDocumentDispatcher extends KTStandardDispatcher {
118 118 return $this->do_error();
119 119 }
120 120 $document_id = $oDocument->getId();
121   - $document_data["document_id"] = $oDocument->getId();
  121 + $document_data['document_id'] = $oDocument->getId();
122 122  
123 123  
124 124 if (!KTBrowseUtil::inAdminMode($this->oUser, $oDocument->getFolderId())) {
... ... @@ -143,20 +143,20 @@ class ViewDocumentDispatcher extends KTStandardDispatcher {
143 143 $this->oPage->setSecondaryTitle($oDocument->getName());
144 144  
145 145 $aOptions = array(
146   - "documentaction" => "viewDocument",
147   - "folderaction" => "browse",
  146 + 'documentaction' => 'viewDocument',
  147 + 'folderaction' => 'browse',
148 148 );
149 149  
150 150 $this->oDocument =& $oDocument;
151 151 $this->aBreadcrumbs = kt_array_merge($this->aBreadcrumbs, KTBrowseUtil::breadcrumbsForDocument($oDocument, $aOptions));
152   - $this->oPage->setBreadcrumbDetails(_kt("document details"));
153   - $this->addPortlets("Document Details");
  152 + $this->oPage->setBreadcrumbDetails(_kt('document details'));
  153 + $this->addPortlets('Document Details');
154 154  
155   - $document_data["document"] = $oDocument;
156   - $document_data["document_type"] =& DocumentType::get($oDocument->getDocumentTypeID());
  155 + $document_data['document'] = $oDocument;
  156 + $document_data['document_type'] =& DocumentType::get($oDocument->getDocumentTypeID());
157 157 $is_valid_doctype = true;
158 158  
159   - if (PEAR::isError($document_data["document_type"])) {
  159 + if (PEAR::isError($document_data['document_type'])) {
160 160 $this->oPage->addError(_kt('The document you requested has an invalid <strong>document type</strong>. Unfortunately, this means that we cannot effectively display it.'));
161 161 $is_valid_doctype = false;
162 162 }
... ... @@ -171,7 +171,7 @@ class ViewDocumentDispatcher extends KTStandardDispatcher {
171 171  
172 172 //var_dump($field_values);
173 173  
174   - $document_data["field_values"] = $field_values;
  174 + $document_data['field_values'] = $field_values;
175 175  
176 176 // Fieldset generation.
177 177 //
... ... @@ -186,7 +186,9 @@ class ViewDocumentDispatcher extends KTStandardDispatcher {
186 186  
187 187 $fieldsetDisplayReg =& KTFieldsetDisplayRegistry::getSingleton();
188 188  
189   - foreach (KTMetadataUtil::fieldsetsForDocument($oDocument) as $oFieldset) {
  189 + $aDocFieldsets = KTMetadataUtil::fieldsetsForDocument($oDocument);
  190 +
  191 + foreach ($aDocFieldsets as $oFieldset) {
190 192 $displayClass = $fieldsetDisplayReg->getHandler($oFieldset->getNamespace());
191 193 array_push($fieldsets, new $displayClass($oFieldset));
192 194 }
... ... @@ -216,35 +218,35 @@ class ViewDocumentDispatcher extends KTStandardDispatcher {
216 218 $aViewletActions = KTDocumentActionUtil::getDocumentActionsForDocument($this->oDocument, $this->oUser, 'documentviewlet');
217 219 foreach ($aViewletActions as $oAction) {
218 220 $aInfo = $oAction->getInfo();
219   -
  221 +
220 222 if ($aInfo !== null) {
221   - $aViewlets[] = $oAction->display_viewlet(); // use the action, since we display_viewlet() later.
  223 + $aViewlets[] = $oAction->display_viewlet(); // use the action, since we display_viewlet() later.
222 224 }
223   - }
224   -
225   - $viewlet_data = implode(" ", $aViewlets);
  225 + }
  226 +
  227 + $viewlet_data = implode(' ', $aViewlets);
226 228 $viewlet_data = trim($viewlet_data);
227   -
  229 +
228 230 $content_class = 'view';
229 231 if (!empty($viewlet_data)) {
230 232 $content_class = 'view withviewlets';
231   - }
  233 + }
232 234 $this->oPage->setContentClass($content_class);
233   -
234 235  
235   -
  236 +
  237 +
236 238 $oTemplating =& KTTemplating::getSingleton();
237   - $oTemplate = $oTemplating->loadTemplate("ktcore/document/view");
  239 + $oTemplate = $oTemplating->loadTemplate('ktcore/document/view');
238 240 $aTemplateData = array(
239   - "context" => $this,
240   - "sCheckoutUser" => $checkout_user,
241   - "isCheckoutUser" => ($this->oUser->getId() == $oDocument->getCheckedOutUserId()),
242   - "canCheckin" => $bCanCheckin,
243   - "document_id" => $document_id,
244   - "document" => $oDocument,
245   - "documentName" => $oDocument->getName(),
246   - "document_data" => $document_data,
247   - "fieldsets" => $fieldsets,
  241 + 'context' => $this,
  242 + 'sCheckoutUser' => $checkout_user,
  243 + 'isCheckoutUser' => ($this->oUser->getId() == $oDocument->getCheckedOutUserId()),
  244 + 'canCheckin' => $bCanCheckin,
  245 + 'document_id' => $document_id,
  246 + 'document' => $oDocument,
  247 + 'documentName' => $oDocument->getName(),
  248 + 'document_data' => $document_data,
  249 + 'fieldsets' => $fieldsets,
248 250 'viewlet_data' => $viewlet_data,
249 251 );
250 252 //return '<pre>' . print_r($aTemplateData, true) . '</pre>';
... ... @@ -256,86 +258,86 @@ class ViewDocumentDispatcher extends KTStandardDispatcher {
256 258 // fDocumentId (document to compare against)
257 259 // fComparisonVersion (the metadata_version of the appropriate document)
258 260 function do_viewComparison() {
259   -
  261 +
260 262 $document_data = array();
261 263 $document_id = sanitizeForSQL(KTUtil::arrayGet($_REQUEST, 'fDocumentId'));
262 264 if ($document_id === null) {
263 265 $this->oPage->addError(sprintf(_kt("No document was requested. Please <a href=\"%s\">browse</a> for one."), KTBrowseUtil::getBrowseBaseUrl()));
264 266 return $this->do_error();
265 267 }
266   -
267   - $document_data["document_id"] = $document_id;
268   -
  268 +
  269 + $document_data['document_id'] = $document_id;
  270 +
269 271 $base_version = sanitizeForSQL(KTUtil::arrayGet($_REQUEST, 'fBaseVersion'));
270   -
  272 +
271 273 // try get the document.
272 274 $oDocument =& Document::get($document_id, $base_version);
273 275 if (PEAR::isError($oDocument)) {
274 276 $this->oPage->addError(sprintf(_kt("The base document you attempted to retrieve is invalid. Please <a href=\"%s\">browse</a> for one."), KTBrowseUtil::getBrowseBaseUrl()));
275 277 return $this->do_error();
276 278 }
277   -
  279 +
278 280 if (!Permission::userHasDocumentReadPermission($oDocument)) {
279 281 // FIXME inconsistent.
280 282 $this->oPage->addError(_kt('You are not allowed to view this document'));
281 283 return $this->permissionDenied();
282 284 }
283   -
  285 +
284 286 $this->oDocument =& $oDocument;
285 287 $this->oPage->setSecondaryTitle($oDocument->getName());
286 288 $aOptions = array(
287   - "documentaction" => "viewDocument",
288   - "folderaction" => "browse",
  289 + 'documentaction' => 'viewDocument',
  290 + 'folderaction' => 'browse',
289 291 );
290   -
  292 +
291 293 $this->aBreadcrumbs = kt_array_merge($this->aBreadcrumbs, KTBrowseUtil::breadcrumbsForDocument($oDocument, $aOptions));
292   - $this->oPage->setBreadcrumbDetails(_kt("compare versions"));
293   -
  294 + $this->oPage->setBreadcrumbDetails(_kt('compare versions'));
  295 +
294 296 $comparison_version = sanitizeForSQL(KTUtil::arrayGet($_REQUEST, 'fComparisonVersion'));
295 297 if ($comparison_version=== null) {
296 298 $this->oPage->addError(sprintf(_kt("No comparison version was requested. Please <a href=\"%s\">select a version</a>."), KTUtil::addQueryStringSelf('action=history&fDocumentId=' . $document_id)));
297 299 return $this->do_error();
298 300 }
299   -
  301 +
300 302 $oComparison =& Document::get($oDocument->getId(), $comparison_version);
301 303 if (PEAR::isError($oComparison)) {
302 304 $this->errorRedirectToMain(_kt('Invalid document to compare against.'));
303 305 }
304 306 $comparison_data = array();
305 307 $comparison_data['document_id'] = $oComparison->getId();
306   -
307   - $document_data["document"] = $oDocument;
  308 +
  309 + $document_data['document'] = $oDocument;
308 310 $comparison_data['document'] = $oComparison;
309   -
310   - $document_data["document_type"] =& DocumentType::get($oDocument->getDocumentTypeID());
311   - $comparison_data["document_type"] =& DocumentType::get($oComparison->getDocumentTypeID());
312   -
  311 +
  312 + $document_data['document_type'] =& DocumentType::get($oDocument->getDocumentTypeID());
  313 + $comparison_data['document_type'] =& DocumentType::get($oComparison->getDocumentTypeID());
  314 +
313 315 // follow twice: once for normal, once for comparison.
314 316 $is_valid_doctype = true;
315   -
316   - if (PEAR::isError($document_data["document_type"])) {
  317 +
  318 + if (PEAR::isError($document_data['document_type'])) {
317 319 $this->oPage->addError(_kt('The document you requested has an invalid <strong>document type</strong>. Unfortunately, this means that we cannot effectively display it.'));
318 320 $is_valid_doctype = false;
319 321 }
320   -
  322 +
321 323 // we want to grab all the md for this doc, since its faster that way.
322 324 $mdlist =& DocumentFieldLink::getList(array('metadata_version_id = ?', array($oDocument->getMetadataVersionId())));
323   -
  325 +
324 326 $field_values = array();
325 327 foreach ($mdlist as $oFieldLink) {
326 328 $field_values[$oFieldLink->getDocumentFieldID()] = $oFieldLink->getValue();
327 329 }
328   -
329   - $document_data["field_values"] = $field_values;
  330 +
  331 + $document_data['field_values'] = $field_values;
330 332 $mdlist =& DocumentFieldLink::getList(array('metadata_version_id = ?', array($comparison_version)));
331   -
  333 +
332 334 $field_values = array();
333 335 foreach ($mdlist as $oFieldLink) {
334 336 $field_values[$oFieldLink->getDocumentFieldID()] = $oFieldLink->getValue();
335 337 }
336   -
337   - $comparison_data["field_values"] = $field_values;
338   -
  338 +
  339 + $comparison_data['field_values'] = $field_values;
  340 +
339 341 // Fieldset generation.
340 342 //
341 343 // we need to create a set of FieldsetDisplay objects
... ... @@ -343,47 +345,47 @@ class ViewDocumentDispatcher extends KTStandardDispatcher {
343 345 // to the view (i.e. ZX3). Unfortunately, we don't have
344 346 // any of the plumbing to do it, so we handle this here.
345 347 $fieldsets = array();
346   -
  348 +
347 349 // we always have a generic.
348 350 array_push($fieldsets, new GenericFieldsetDisplay());
349   -
  351 +
350 352 // FIXME can we key this on fieldset namespace? or can we have duplicates?
351 353 // now we get the other fieldsets, IF there is a valid doctype.
352   -
  354 +
353 355 if ($is_valid_doctype) {
354 356 // these are the _actual_ fieldsets.
355 357 $fieldsetDisplayReg =& KTFieldsetDisplayRegistry::getSingleton();
356   -
  358 +
357 359 // and the generics
358 360 $activesets = KTFieldset::getGenericFieldsets();
359 361 foreach ($activesets as $oFieldset) {
360 362 $displayClass = $fieldsetDisplayReg->getHandler($oFieldset->getNamespace());
361 363 array_push($fieldsets, new $displayClass($oFieldset));
362 364 }
363   -
  365 +
364 366 $activesets = KTFieldset::getForDocumentType($oDocument->getDocumentTypeID());
365 367 foreach ($activesets as $oFieldset) {
366 368 $displayClass = $fieldsetDisplayReg->getHandler($oFieldset->getNamespace());
367 369 array_push($fieldsets, new $displayClass($oFieldset));
368 370 }
369 371 }
370   -
  372 +
371 373 // FIXME handle ad-hoc fieldsets.
372 374 $this->addPortlets();
373   - $oTemplate = $this->oValidator->validateTemplate("ktcore/document/compare");
  375 + $oTemplate = $this->oValidator->validateTemplate('ktcore/document/compare');
374 376 $aTemplateData = array(
375   - "context" => $this,
376   - "document_id" => $document_id,
377   - "document" => $oDocument,
378   - "document_data" => $document_data,
379   - "comparison_data" => $comparison_data,
380   - "comparison_document" => $oComparison,
381   - "fieldsets" => $fieldsets,
  377 + 'context' => $this,
  378 + 'document_id' => $document_id,
  379 + 'document' => $oDocument,
  380 + 'document_data' => $document_data,
  381 + 'comparison_data' => $comparison_data,
  382 + 'comparison_document' => $oComparison,
  383 + 'fieldsets' => $fieldsets,
382 384 );
383   - //var_dump($aTemplateData["comparison_data"]);
  385 + //var_dump($aTemplateData['comparison_data']);
384 386 return $oTemplate->render($aTemplateData);
385 387 }
386   -
  388 +
387 389 function do_error() {
388 390 return '&nbsp;'; // don't actually do anything.
389 391 }
... ... @@ -399,4 +401,4 @@ class ViewDocumentDispatcher extends KTStandardDispatcher {
399 401 $oDispatcher = new ViewDocumentDispatcher;
400 402 $oDispatcher->dispatch();
401 403  
402 404 -?>
  405 +?>
403 406 \ No newline at end of file
... ...