Revision: 46309
Author:   tparscal
Date:     2009-01-27 01:47:10 +0000 (Tue, 27 Jan 2009)

Log Message:
-----------
Added export functionality. The widget and processing are generic enough for 
any table, but it only serves a purpose on assets right now.

Modified Paths:
--------------
    trunk/extensions/DataCenter/Controllers/Assets.php
    trunk/extensions/DataCenter/DataCenter.css
    trunk/extensions/DataCenter/DataCenter.i18n.php
    trunk/extensions/DataCenter/DataCenter.php
    trunk/extensions/DataCenter/DataCenter.ui.php
    trunk/extensions/DataCenter/UI/Widgets/FieldLinks.php
    trunk/extensions/DataCenter/Views/Assets.php

Added Paths:
-----------
    trunk/extensions/DataCenter/UI/Widgets/Export.php

Modified: trunk/extensions/DataCenter/Controllers/Assets.php
===================================================================
--- trunk/extensions/DataCenter/Controllers/Assets.php  2009-01-27 01:37:41 UTC 
(rev 46308)
+++ trunk/extensions/DataCenter/Controllers/Assets.php  2009-01-27 01:47:10 UTC 
(rev 46309)
@@ -42,6 +42,14 @@
                                'action' => 'view',
                                'id' => $path['id'],
                        );
+               } else {
+                       if ( DataCenterPage::userCan( 'export' ) ) {
+                               $this->actions['export'] = array(
+                                       'page' => 'assets',
+                                       'type' => $path['type'],
+                                       'action' => 'export',
+                               );
+                       }
                }
        }
 
@@ -59,6 +67,17 @@
                return true;
        }
 
+       public function export(
+               array $data,
+               $type
+       ) {
+               if ( !DataCenterPage::userCan( 'export' ) ) {
+                       return false;
+               }
+               DataCenterWidgetExport::export( $data );
+               return null;
+       }
+
        public function compareChanges(
                array $data,
                $type

Modified: trunk/extensions/DataCenter/DataCenter.css
===================================================================
--- trunk/extensions/DataCenter/DataCenter.css  2009-01-27 01:37:41 UTC (rev 
46308)
+++ trunk/extensions/DataCenter/DataCenter.css  2009-01-27 01:47:10 UTC (rev 
46309)
@@ -178,7 +178,47 @@
        padding-right: 8px;
 }
 
+
 /*
+ * Export Widget
+ */
+.datacenter-ui div.widget-export form {
+       margin: 0px;
+       padding: 0px;
+}
+.datacenter-ui div.widget-export input.reset {
+       margin-right: 10px;
+}
+div.datacenter-ui div.widget-export tr td {
+       padding-top: 8px;
+       padding-bottom: 8px;
+       padding-left: 8px;
+       padding-right: 8px;
+}
+.datacenter-ui div.widget-export input.reset {
+       margin-right: 10px;
+}
+div.datacenter-ui div.widget-export table {
+       background-color: white;
+       border: solid 1px #DDDDDD;
+       width: 100%;
+}
+div.datacenter-ui div.widget-export th {
+       background-color: #DDDDDD;
+       color: #999999;
+       padding-top: 4px;
+       padding-bottom: 4px;
+       padding-left: 8px;
+       padding-right: 8px;
+}
+div.datacenter-ui div.widget-export tr td {
+       padding-top: 4px;
+       padding-bottom: 4px;
+       padding-left: 8px;
+       padding-right: 8px;
+}
+
+/*
  * History Widget
  */
 .datacenter-ui div.widget-history form {

Modified: trunk/extensions/DataCenter/DataCenter.i18n.php
===================================================================
--- trunk/extensions/DataCenter/DataCenter.i18n.php     2009-01-27 01:37:41 UTC 
(rev 46308)
+++ trunk/extensions/DataCenter/DataCenter.i18n.php     2009-01-27 01:47:10 UTC 
(rev 46309)
@@ -12,83 +12,88 @@
  * @author Trevor Parscal
  */
 $messages['en'] = array(
+       // Groups
+       'group-dc-admin' => 'DataCenter Administrators',
+       'group-dc-admin-member' => 'DataCenter Administrator',
        'group-dc-viewer' => 'DataCenter Viewers',
-       'group-dc-admin' => 'DataCenter Administrators',
        'group-dc-viewer-member' => 'DataCenter Viewer',
-       'group-dc-admin-member' => 'DataCenter Administrator',
+       // Page
        'datacenter' => 'DataCenter',
+       // Description
        'datacenter-desc' => 'DataCenter Planing and Asset Tracking System',
        // Pages
+       'datacenter-ui-page-assets' => 'Assets',
+       'datacenter-ui-page-facilities' => 'Facilities',
+       'datacenter-ui-page-models' => 'Models',
        'datacenter-ui-page-overview' => 'Overview',
-       'datacenter-ui-page-facilities' => 'Facilities',
        'datacenter-ui-page-plans' => 'Plans',
-       'datacenter-ui-page-assets' => 'Assets',
-       'datacenter-ui-page-models' => 'Models',
        'datacenter-ui-page-repairs' => 'Repairs',
        'datacenter-ui-page-settings' => 'Settings',
        // Types
-       'datacenter-ui-type-plan' => 'Plan',
+       'datacenter-ui-type-attachment' => 'Attachment',
+       'datacenter-ui-type-field' => 'Field',
        'datacenter-ui-type-location' => 'Location',
-       'datacenter-ui-type-space' => 'Space',
-       'datacenter-ui-type-rack' => 'Rack',
+       'datacenter-ui-type-model' => 'Model',
        'datacenter-ui-type-object' => 'Object',
+       'datacenter-ui-type-plan' => 'Plan',
        'datacenter-ui-type-port' => 'Port',
-       'datacenter-ui-type-model' => 'Model',
-       'datacenter-ui-type-attachment' => 'Attachment',
-       'datacenter-ui-type-field' => 'Field',
+       'datacenter-ui-type-rack' => 'Rack',
+       'datacenter-ui-type-space' => 'Space',
        // Categories
+       'datacenter-ui-category-asset' => 'Asset',
        'datacenter-ui-category-facility' => 'Facility',
-       'datacenter-ui-category-asset' => 'Asset',
-       'datacenter-ui-category-model' => 'Model',
        'datacenter-ui-category-link' => 'Link',
        'datacenter-ui-category-meta' => 'Meta',
+       'datacenter-ui-category-model' => 'Model',
        // Actions
+       'datacenter-ui-action-add-type' => 'Add $1',
+       'datacenter-ui-action-apply-type' => 'Apply $1',
+       'datacenter-ui-action-attach' => 'Attach',
+       'datacenter-ui-action-attach-type' => 'Attach $1',
        'datacenter-ui-action-configure' => 'Configure',
+       'datacenter-ui-action-create' => 'Create',
+       'datacenter-ui-action-create-type' => 'Create $1',
+       'datacenter-ui-action-deploy' => 'Deploy',
+       'datacenter-ui-action-deploy-type' => 'Deploy $1',
+       'datacenter-ui-action-design-type' => 'Design and Deploy $1',
        'datacenter-ui-action-edit' => 'Edit',
-       'datacenter-ui-action-remove' => 'Remove',
-       'datacenter-ui-action-view' => 'View',
-       'datacenter-ui-action-deploy' => 'Deploy',
+       'datacenter-ui-action-export' => 'Export',
+       'datacenter-ui-action-history' => 'History',
        'datacenter-ui-action-manage' => 'Manage',
-       'datacenter-ui-action-create' => 'Create',
        'datacenter-ui-action-modify' => 'Modify',
-       'datacenter-ui-action-attach' => 'Attach',
-       'datacenter-ui-action-add-type' => 'Add $1',
-       'datacenter-ui-action-attach-type' => 'Attach $1',
-       'datacenter-ui-action-deploy-type' => 'Deploy $1',
-       'datacenter-ui-action-create-type' => 'Create $1',
-       'datacenter-ui-action-design-type' => 'Design and Deploy $1',
+       'datacenter-ui-action-remove' => 'Remove',
        'datacenter-ui-action-select-type' => 'Select and Attach $1',
-       'datacenter-ui-action-apply-type' => 'Apply $1',
-       'datacenter-ui-action-history' => 'History',
+       'datacenter-ui-action-view' => 'View',
        // Options
+       'datacenter-ui-option-back' => 'Back',
+       'datacenter-ui-option-boolean' => 'Boolean (yes/no)',
+       'datacenter-ui-option-false' => 'False',
        'datacenter-ui-option-front' => 'Front',
-       'datacenter-ui-option-back' => 'Back',
+       'datacenter-ui-option-future' => 'Future',
+       'datacenter-ui-option-number' => 'Number',
+       'datacenter-ui-option-past' => 'Past',
+       'datacenter-ui-option-present' => 'Present',
+       'datacenter-ui-option-string' => 'String (single-link)',
+       'datacenter-ui-option-tag' => 'Tag',
+       'datacenter-ui-option-text' => 'Text (multi-line)',
+       'datacenter-ui-option-true' => 'True',
+    'datacenter-ui-option-analog' => 'Analog',
+    'datacenter-ui-option-audio' => 'Audio',
+    'datacenter-ui-option-desktop' => 'Desktop',
+    'datacenter-ui-option-digital' => 'Digital',
+    'datacenter-ui-option-mixed' => 'Mixed',
+    'datacenter-ui-option-module' => 'AddOn Module',
     'datacenter-ui-option-network' => 'Network',
+    'datacenter-ui-option-none' => 'None',
+    'datacenter-ui-option-other' => 'Other',
+    'datacenter-ui-option-portable' => 'Portable',
     'datacenter-ui-option-power' => 'Power',
-    'datacenter-ui-option-audio' => 'Audio',
-    'datacenter-ui-option-video' => 'Video',
+    'datacenter-ui-option-rackunit' => 'Rack Unit',
     'datacenter-ui-option-sensor' => 'Sensor',
     'datacenter-ui-option-serial' => 'Serial',
-    'datacenter-ui-option-other' => 'Other',
-    'datacenter-ui-option-analog' => 'Analog',
-    'datacenter-ui-option-digital' => 'Digital',
-    'datacenter-ui-option-mixed' => 'Mixed',
+    'datacenter-ui-option-video' => 'Video',
     'datacenter-ui-option-virtual' => 'Virtual',
-    'datacenter-ui-option-none' => 'None',
-    'datacenter-ui-option-rackunit' => 'Rack Unit',
-    'datacenter-ui-option-module' => 'AddOn Module',
-    'datacenter-ui-option-desktop' => 'Desktop',
-    'datacenter-ui-option-portable' => 'Portable',
-       'datacenter-ui-option-past' => 'Past',
-       'datacenter-ui-option-present' => 'Present',
-       'datacenter-ui-option-future' => 'Future',
-       'datacenter-ui-option-true' => 'True',
-       'datacenter-ui-option-false' => 'False',
-       'datacenter-ui-option-boolean' => 'Boolean (yes/no)',
-       'datacenter-ui-option-string' => 'String (single-link)',
-       'datacenter-ui-option-text' => 'Text (multi-line)',
-       'datacenter-ui-option-number' => 'Number',
-       'datacenter-ui-option-tag' => 'Tag',
+    'datacenter-ui-option-csv' => 'Comma Separated Values (.csv)',
        // Errors
        'datacenter-ui-error-insufficient-data' => 'You have provided 
insufficient data',
        'datacenter-ui-error-invalid-data' => 'You have provided invalid data',
@@ -97,133 +102,137 @@
        'datacenter-ui-error-no-rows' => 'No records found',
        'datacenter-ui-error-no-ui-widget' => 'The user-interface widget "$1" 
doesn\'t exist',
        // Fields
-       'datacenter-ui-field-name' => 'Name',
-       'datacenter-ui-field-space' => 'Space',
-       'datacenter-ui-field-region' => 'Region',
+       'datacenter-ui-field-asset' => 'Asset Tag',
+       'datacenter-ui-field-category' => 'Category',
+       'datacenter-ui-field-change-summary' => 'Change Summary',
+       'datacenter-ui-field-component' => 'Component',
+       'datacenter-ui-field-component_type' => 'Component Type',
+       'datacenter-ui-field-confirm' => 'Enter "yes" to confirm',
+       'datacenter-ui-field-date' => 'Date',
+       'datacenter-ui-field-depth' => 'Depth',
+       'datacenter-ui-field-form-factor' => 'Form Factor',
+       'datacenter-ui-field-format' => 'Format',
+       'datacenter-ui-field-global-position' => 'Global Position',
+       'datacenter-ui-field-grid-position' => 'Grid Position',
+       'datacenter-ui-field-height' => 'Height',
+       'datacenter-ui-field-id' => 'ID',
+       'datacenter-ui-field-include-meta' => 'Include Meta',
+       'datacenter-ui-field-interface' => 'Interface',
+       'datacenter-ui-field-kind' => 'Kind',
+       'datacenter-ui-field-latitude' => 'Latitude',
+       'datacenter-ui-field-location' => 'Location',
        'datacenter-ui-field-longitude' => 'Longitude',
-       'datacenter-ui-field-latitude' => 'Latitude',
-       'datacenter-ui-field-spaces' => 'Spaces',
        'datacenter-ui-field-lookup' => 'LookUp',
-       'datacenter-ui-field-location' => 'Location',
-       'datacenter-ui-field-racks' => 'Racks',
-       'datacenter-ui-field-size' => 'Size',
-       'datacenter-ui-field-power' => 'Power',
+       'datacenter-ui-field-manufacturer' => 'Manufacturer',
+       'datacenter-ui-field-model' => 'Model',
+       'datacenter-ui-field-name' => 'Name',
+       'datacenter-ui-field-note' => 'Note',
+       'datacenter-ui-field-object' => 'Object',
        'datacenter-ui-field-objects' => 'Objects',
-       'datacenter-ui-field-width' => 'Width',
-       'datacenter-ui-field-height' => 'Height',
-       'datacenter-ui-field-depth' => 'Depth',
-       'datacenter-ui-field-global-position' => 'Global Position',
-       'datacenter-ui-field-grid-position' => 'Grid Position',
+       'datacenter-ui-field-orientation' => 'Orientation',
+       'datacenter-ui-field-parent' => 'Parent',
+       'datacenter-ui-field-ports' => 'Ports',
+       'datacenter-ui-field-position' => 'Position',
        'datacenter-ui-field-position-x' => 'X',
        'datacenter-ui-field-position-y' => 'Y',
-       'datacenter-ui-field-orientation' => 'Orientation',
-       'datacenter-ui-field-units' => 'Units',
-       'datacenter-ui-field-model' => 'Model',
-       'datacenter-ui-field-ports' => 'Ports',
-       'datacenter-ui-field-id' => 'ID',
-       'datacenter-ui-field-parent' => 'Parent',
+       'datacenter-ui-field-power' => 'Power',
+       'datacenter-ui-field-quantity' => 'Quantity',
        'datacenter-ui-field-rack' => 'Rack',
-       'datacenter-ui-field-object' => 'Object',
-       'datacenter-ui-field-interface' => 'Interface',
+       'datacenter-ui-field-racks' => 'Racks',
+       'datacenter-ui-field-region' => 'Region',
+       'datacenter-ui-field-serial' => 'Serial Number',
+       'datacenter-ui-field-side' => 'Side',
+       'datacenter-ui-field-size' => 'Size',
+       'datacenter-ui-field-space' => 'Space',
+       'datacenter-ui-field-spaces' => 'Spaces',
+       'datacenter-ui-field-tense' => 'Tense',
+       'datacenter-ui-field-type' => 'Type',
+       'datacenter-ui-field-u-depth' => 'Depth',
        'datacenter-ui-field-u-height' => 'Height',
-       'datacenter-ui-field-u-depth' => 'Depth',
-       'datacenter-ui-field-side' => 'Side',
-       'datacenter-ui-field-position' => 'Position',
-       'datacenter-ui-field-date' => 'Date',
+       'datacenter-ui-field-units' => 'Units',
        'datacenter-ui-field-username' => 'User Name',
-       'datacenter-ui-field-type' => 'Type',
-       'datacenter-ui-field-component_type' => 'Component Type',
-       'datacenter-ui-field-component' => 'Component',
-       'datacenter-ui-field-note' => 'Note',
-       'datacenter-ui-field-category' => 'Category',
-       'datacenter-ui-field-format' => 'Format',
-       'datacenter-ui-field-serial' => 'Serial Number',
-       'datacenter-ui-field-asset' => 'Asset Tag',
-       'datacenter-ui-field-quantity' => 'Quantity',
-       'datacenter-ui-field-kind' => 'Kind',
-       'datacenter-ui-field-form-factor' => 'Form Factor',
-       'datacenter-ui-field-manufacturer' => 'Manufacturer',
-       'datacenter-ui-field-tense' => 'Tense',
-       'datacenter-ui-field-change-summary' => 'Change Summary',
        'datacenter-ui-field-uses' => 'Uses',
-       'datacenter-ui-field-confirm' => 'Enter "yes" to confirm',
+       'datacenter-ui-field-width' => 'Width',
        // Label
+       'datacenter-ui-label-add' => 'Add',
+       'datacenter-ui-label-add-type' => 'Add $1',
+       'datacenter-ui-label-attach' => 'Attach',
+       'datacenter-ui-label-browse-by' => 'Browse by:',
+       'datacenter-ui-label-cancel' => 'Cancel',
+       'datacenter-ui-label-change-blank-user' => 'System',
+       'datacenter-ui-label-change-state-meta' => 'Meta Fields',
+       'datacenter-ui-label-change-state-row' => 'Core Fields',
        'datacenter-ui-label-compare-changes' => 'Compare selected changes',
-       'datacenter-ui-label-reset' => 'Reset',
-       'datacenter-ui-label-cancel' => 'Cancel',
-       'datacenter-ui-label-remove' => 'Remove',
-       'datacenter-ui-label-save' => 'Save',
+       'datacenter-ui-label-create' => 'Create',
+       'datacenter-ui-label-degrees-value' => '$1°',
        'datacenter-ui-label-deploy' => 'Deploy',
-       'datacenter-ui-label-create' => 'Create',
-       'datacenter-ui-label-attach' => 'Attach',
+       'datacenter-ui-label-export' => 'Export',
+       'datacenter-ui-label-export-type' => '$1 Export',
        'datacenter-ui-label-lookup' => 'LookUp',
-       'datacenter-ui-label-add' => 'Add',
-       'datacenter-ui-label-add-type' => 'Add $1',
-       'datacenter-ui-label-browse-by' => 'Browse by:',
        'datacenter-ui-label-num-spaces' => '$1 {{PLURAL:$1|space|spaces}}',
        'datacenter-ui-label-num-uses' => '$1 {{PLURAL:$1|use|uses}}',
-       'datacenter-ui-label-degrees-value' => '$1°',
-       'datacenter-ui-label-change-state-row' => 'Core Fields',
-       'datacenter-ui-label-change-state-meta' => 'Meta Fields',
-       'datacenter-ui-label-change-blank-user' => 'System',
        'datacenter-ui-label-range' => '$1 {{PLURAL:$1|item|items}}',
+       'datacenter-ui-label-remove' => 'Remove',
+       'datacenter-ui-label-reset' => 'Reset',
+       'datacenter-ui-label-save' => 'Save',
        // Defaults
        'datacenter-ui-default-new-type' => 'New $1',
        // List Headings
+       'datacenter-ui-heading-applied-components' => 'Applied Components',
+       'datacenter-ui-heading-fields' => 'Fields',
        'datacenter-ui-heading-history' => 'History',
+       'datacenter-ui-heading-locations' => 'Locations',
+       'datacenter-ui-heading-objects' => 'Objects',
        'datacenter-ui-heading-plans' => 'Plans',
-       'datacenter-ui-heading-locations' => 'Locations',
+       'datacenter-ui-heading-racks' => 'Racks',
        'datacenter-ui-heading-spaces' => 'Spaces',
-       'datacenter-ui-heading-racks' => 'Racks',
-       'datacenter-ui-heading-objects' => 'Objects',
-       'datacenter-ui-heading-fields' => 'Fields',
-       'datacenter-ui-heading-applied-components' => 'Applied Components',
        // Information Headings
+       'datacenter-ui-heading-asset' => 'Asset',
+       'datacenter-ui-heading-configuration' => 'Configuration',
        'datacenter-ui-heading-details' => 'Details',
-       'datacenter-ui-heading-model-attachments' => 'Model Attachments',
-       'datacenter-ui-heading-asset' => 'Asset',
-       'datacenter-ui-heading-model' => 'Model',
+       'datacenter-ui-heading-export' => 'Export Data',
        'datacenter-ui-heading-facility' => 'Facility',
+       'datacenter-ui-heading-field' => 'Field',
        'datacenter-ui-heading-location' => 'Location',
+       'datacenter-ui-heading-model' => 'Model',
+       'datacenter-ui-heading-model-attachments' => 'Model Attachments',
        'datacenter-ui-heading-space' => 'Space',
-       'datacenter-ui-heading-configuration' => 'Configuration',
-       'datacenter-ui-heading-field' => 'Field',
        // Type-based Headings
-       'datacenter-ui-heading-history-type' => '$1 History',
-       'datacenter-ui-heading-remove-type' => 'Remove $1?',
+       'datacenter-ui-heading-adding-type' => 'Adding $1',
        'datacenter-ui-heading-asset-type' => '$1 Asset',
-       'datacenter-ui-heading-editing-type' => 'Editing $1',
-       'datacenter-ui-heading-adding-type' => 'Adding $1',
        'datacenter-ui-heading-assets-type' => '$1 Assets',
-       'datacenter-ui-heading-models-type' => '$1 Models',
+       'datacenter-ui-heading-attaching-type' => 'Attaching $1',
+       'datacenter-ui-heading-configuring-type' => 'Configuring $1',
+       'datacenter-ui-heading-creating-model-type' => 'Creating $1 Model',
        'datacenter-ui-heading-deploying-asset-type' => 'Deploying $1 Asset',
+       'datacenter-ui-heading-editing-type' => 'Editing $1',
+       'datacenter-ui-heading-history-type' => '$1 History',
        'datacenter-ui-heading-managing-asset-type' => 'Managing $1 Asset',
        'datacenter-ui-heading-model-type' => '$1 Model',
-       'datacenter-ui-heading-creating-model-type' => 'Creating $1 Model',
+       'datacenter-ui-heading-models-type' => '$1 Models',
        'datacenter-ui-heading-modifying-model-type' => 'Modifying $1 Model',
+       'datacenter-ui-heading-remove-type' => 'Remove $1?',
        'datacenter-ui-heading-select-attach-type' => 'Select $1 to Attach',
        'datacenter-ui-heading-select-deploy-type' => 'Select $1 to Deploy',
-       'datacenter-ui-heading-attaching-type' => 'Attaching $1',
-       'datacenter-ui-heading-configuring-type' => 'Configuring $1',
        // Bodies
-       'datacenter-ui-body-notice-removing-type' => 'Removing this $1 will 
result in the removal of the following links and cannot be recovered from. Do 
you want to continue with the removal?',
-       'datacenter-ui-body-notice-removing-field' => 'Removing this field will 
result in the removal of the following links and all data associated with them 
and cannot be recovered from. Do you want to continue with the removal?',
+       'datacenter-ui-body-error-invalid-request' => 'You have requested a 
page with an invalid path.',
        'datacenter-ui-body-important-configuring-field' => 'Changing the 
format of this field may cause related data to be interpreted incorectly, 
espcially when switching between textual, numeric and boolean formats.',
+       'datacenter-ui-body-important-settings' => 'These settings may affect 
the system in irreversable ways. Please be careful when making adjustments.',
        'datacenter-ui-body-important-welcome' => 'Welcome to the beta-testing 
of DataCenter. Please poke around and give feedback to 
[http://www.mediawiki.org/wiki/User:Trevor_Parscal Trevor Parscal]. If want to 
help out, take a look at the MediaWiki extension page for 
[http://www.mediawiki.org/wiki/Extension:DataCenter DataCenter] which has a 
list of feature priorities.',
-       'datacenter-ui-body-important-settings' => 'These settings may affect 
the system in irreversable ways. Please be careful when making adjustments.',
-       'datacenter-ui-body-error-invalid-request' => 'You have requested a 
page with an invalid path.',
+       'datacenter-ui-body-notice-removing-field' => 'Removing this field will 
result in the removal of the following links and all data associated with them 
and cannot be recovered from. Do you want to continue with the removal?',
+       'datacenter-ui-body-notice-removing-type' => 'Removing this $1 will 
result in the removal of the following links and cannot be recovered from. Do 
you want to continue with the removal?',
        // Tabs
-       'datacenter-ui-tab-racks' => 'Racks',
        'datacenter-ui-tab-details' => 'Details',
+       'datacenter-ui-tab-future' => 'Future',
+       'datacenter-ui-tab-interfaces' => 'Interfaces',
+       'datacenter-ui-tab-local' => 'Local',
        'datacenter-ui-tab-objects' => 'Objects',
-       'datacenter-ui-tab-spaces' => 'Spaces',
-       'datacenter-ui-tab-interfaces' => 'Interfaces',
        'datacenter-ui-tab-past' => 'Past',
-       'datacenter-ui-tab-present' => 'Present',
-       'datacenter-ui-tab-future' => 'Future',
        'datacenter-ui-tab-plan' => 'Plan',
-       'datacenter-ui-tab-space' => 'Space',
        'datacenter-ui-tab-plans' => 'Plans',
-       'datacenter-ui-tab-local' => 'Local',
+       'datacenter-ui-tab-present' => 'Present',
+       'datacenter-ui-tab-racks' => 'Racks',
        'datacenter-ui-tab-remote' => 'Remote',
+       'datacenter-ui-tab-space' => 'Space',
+       'datacenter-ui-tab-spaces' => 'Spaces',
 );

Modified: trunk/extensions/DataCenter/DataCenter.php
===================================================================
--- trunk/extensions/DataCenter/DataCenter.php  2009-01-27 01:37:41 UTC (rev 
46308)
+++ trunk/extensions/DataCenter/DataCenter.php  2009-01-27 01:47:10 UTC (rev 
46309)
@@ -90,6 +90,7 @@
        'DataCenterWidgetActions' => $dir . 'UI/Widgets/Actions.php',
        'DataCenterWidgetBody' => $dir . 'UI/Widgets/Body.php',
        'DataCenterWidgetDetails' => $dir . 'UI/Widgets/Details.php',
+       'DataCenterWidgetExport' => $dir . 'UI/Widgets/Export.php',
        'DataCenterWidgetFieldLinks' => $dir . 'UI/Widgets/FieldLinks.php',
        'DataCenterWidgetForm' => $dir . 'UI/Widgets/Form.php',
        'DataCenterWidgetGallery' => $dir . 'UI/Widgets/Gallery.php',

Modified: trunk/extensions/DataCenter/DataCenter.ui.php
===================================================================
--- trunk/extensions/DataCenter/DataCenter.ui.php       2009-01-27 01:37:41 UTC 
(rev 46308)
+++ trunk/extensions/DataCenter/DataCenter.ui.php       2009-01-27 01:47:10 UTC 
(rev 46309)
@@ -877,6 +877,7 @@
                'actions' => 'DataCenterWidgetActions',
                'body' => 'DataCenterWidgetBody',
                'details' => 'DataCenterWidgetDetails',
+               'export' => 'DataCenterWidgetExport',
                'fieldlinks' => 'DataCenterWidgetFieldLinks',
                'form' => 'DataCenterWidgetForm',
                'gallery' => 'DataCenterWidgetGallery',
@@ -930,9 +931,12 @@
         */
        public static function message(
                $type,
-               $name,
+               $name = null,
                $arguments = null
        ) {
+               if ( !$name ) {
+                       return wfMsg( $type );
+               }
                return wfMsgExt(
                        "datacenter-ui-{$type}-{$name}",
                        array( 'parsemag', 'parseinline' ),

Added: trunk/extensions/DataCenter/UI/Widgets/Export.php
===================================================================
--- trunk/extensions/DataCenter/UI/Widgets/Export.php                           
(rev 0)
+++ trunk/extensions/DataCenter/UI/Widgets/Export.php   2009-01-27 01:47:10 UTC 
(rev 46309)
@@ -0,0 +1,356 @@
+<?php
+
+/**
+ * UI Class for DataCenter extension
+ *
+ * @file
+ * @ingroup Extensions
+ */
+
+class DataCenterWidgetExport extends DataCenterWidget {
+
+       /* Private Static Members */
+
+       private static $defaultParameters = array(
+               /**
+                * XML ID attribute of widget
+                * @datatype    string
+                */
+               'id' => 'export',
+               /**
+                * CSS class of widget
+                * @datatype    string
+                */
+               'class' => 'widget-export',
+               /**
+                * Name of category of table to export
+                * @datatype    string
+                */
+               'category' => null,
+               /**
+                * Name of type of table to export
+                * @datatype    string
+                */
+               'type' => null,
+       );
+
+       private static $defaultAttributes = array(
+               /**
+                * Default XML attributes for table
+                */
+               'table' => array(
+                       'width' => '100%',
+                       'cellpadding' => 5,
+                       'cellspacing' => 0,
+                       'border' => 0,
+               ),
+               /**
+                * Default XML attributes for heading cell
+                */
+               'heading' => array(
+                       'align' => 'left',
+                       'colspan' => 3
+               ),
+               /**
+                * Default XML attributes for label cell
+                */
+               'label' => array(
+                       'class' => 'label',
+                       'align' => 'left',
+                       'nowrap' => 'nowrap',
+               ),
+               /**
+                * Default XML attributes for label cell
+                */
+               'input' => array(
+                       'class' => 'input',
+                       'align' => 'left',
+                       'width' => '200',
+               ),
+               /**
+                * Default XML attributes for buttons cell
+                */
+               'buttons' => array(
+                       'class' => 'buttons',
+                       'align' => 'right',
+                       'colspan' => 3
+               ),
+       );
+
+       /* Static Functions */
+
+       public static function render(
+               array $parameters
+       ) {
+               global $wgUser;
+               // Gets current path
+               $path = DataCenterPage::getPath();
+               // Sets Defaults
+               $parameters = array_merge( self::$defaultParameters, 
$parameters );
+               // Begins widget
+               $xmlOutput = parent::begin( $parameters['class'] );
+               // Builds form attributes
+               $formAttributes = array(
+                       'id' => 'form_export',
+                       'name' => 'form_export',
+                       'method' => 'post',
+                       'action' => DataCenterXml::url( $path ),
+               );
+               // Begins form
+               $xmlOutput .= DataCenterXml::open( 'form', $formAttributes );
+               // Begins table
+               $xmlOutput .= DataCenterXml::open(
+                       'table', self::$defaultAttributes['table']
+               );
+               // Adds ...
+               $xmlOutput .= DataCenterXml::row(
+                       DataCenterXml::cell(
+                               self::$defaultAttributes['label'],
+                               DataCenterUI::message( 'field', 'format' )
+                       ),
+                       DataCenterXml::cell(
+                               self::$defaultAttributes['input'],
+                               DataCenterUI::renderInput(
+                                       'list',
+                                       array(
+                                               'name' => 'meta[format]',
+                                               'options' => array( 'csv' => 
'csv' )
+                                       )
+                               )
+                       )
+               );
+               $xmlOutput .= DataCenterXml::row(
+                       DataCenterXml::cell(
+                               self::$defaultAttributes['label'],
+                               DataCenterUI::message( 'field', 'include-meta' )
+                       ),
+                       DataCenterXml::cell(
+                               self::$defaultAttributes['input'],
+                               DataCenterUI::renderInput(
+                                       'boolean',
+                                       array(
+                                               'name' => 'meta[include-meta]',
+                                               'value' => true,
+                                       )
+                               )
+                       )
+               );
+               if ( DataCenterPage::userCan( 'export' ) ) {
+                       // Adds reset and submit button
+                       $xmlOutput .= DataCenterXML::row(
+                               DataCenterXml::cell(
+                                       self::$defaultAttributes['buttons'],
+                                       DataCenterXml::tag(
+                                               'input',
+                                               array(
+                                                       'type' => 'reset',
+                                                       'name' => 'reset',
+                                                       'class' => 'reset',
+                                                       'value' => 
DataCenterUI::message(
+                                                               'label', 'reset'
+                                                       ),
+                                               )
+                                       ) .
+                                       DataCenterXml::tag(
+                                               'input',
+                                               array(
+                                                       'type' => 'submit',
+                                                       'name' => 'submit',
+                                                       'class' => 'submit',
+                                                       'value' => 
DataCenterUI::message(
+                                                               'label', 
'export'
+                                                       ),
+                                               )
+                                       )
+                               )
+                       );
+               }
+               $xmlOutput .= DataCenterXml::close( 'table' );
+               // Adds category field
+               $xmlOutput .= DataCenterXml::tag(
+                       'input', array(
+                               'type' => 'hidden',
+                               'name' => 'meta[category]',
+                               'value' => $parameters['category'],
+                       )
+               );
+               // Adds type field
+               $xmlOutput .= DataCenterXml::tag(
+                       'input', array(
+                               'type' => 'hidden',
+                               'name' => 'meta[type]',
+                               'value' => $parameters['type'],
+                       )
+               );
+               // Adds do field
+               $xmlOutput .= DataCenterXml::tag(
+                       'input', array(
+                               'type' => 'hidden',
+                               'name' => 'do',
+                               'value' => 'export'
+                       )
+               );
+               // Adds token field
+               $xmlOutput .= DataCenterXml::tag(
+                       'input', array(
+                               'type' => 'hidden',
+                               'name' => 'token',
+                               'value' => $wgUser->editToken()
+                       )
+               );
+               // Adds success field
+               $xmlOutput .= DataCenterXml::tag(
+                       'input',
+                       array(
+                               'type' => 'hidden',
+                               'name' => 'success',
+                               'value' => DataCenterXml::url( $path )
+                       )
+               );
+               // Adds failure field
+               $xmlOutput .= DataCenterXml::tag(
+                       'input',
+                       array(
+                               'type' => 'hidden',
+                               'name' => 'failure',
+                               'value' => DataCenterXml::url( $path )
+                       )
+               );
+               // Adds canellation field
+               $xmlOutput .= DataCenterXml::tag(
+                       'input',
+                       array(
+                               'type' => 'hidden',
+                               'name' => 'cancellation',
+                               'value' => DataCenterXml::url( $path )
+                       )
+               );
+               $xmlOutput .= DataCenterXml::close( 'form' );
+               // Ends widget
+               $xmlOutput .= parent::end();
+               // Returns results
+               return $xmlOutput;
+       }
+
+       public static function export(
+               array $data
+       ) {
+               global $wgOut;
+               // Disables mediawiki output
+               $wgOut->disable();
+               // Gets current path
+               $path = DataCenterPage::getPath();
+               // Gets time in a nice format
+               $date = date( 'Y-m-d' );
+               $fileName = DataCenterUI::message( 'datacenter' ) .
+                       ' - ' .
+                       DataCenterUI::message(
+                               'label',
+                               'export-type',
+                               DataCenterUI::message( 'type', 
$data['meta']['type'] ) .
+                               ' ' .
+                               DataCenterUI::message( 'category', 
$data['meta']['category'] )
+                       ) .
+                       ' - ' . $date . '.' . $data['meta']['format'];
+               // Sets headers for downloading CSV file
+               header("Content-type: application/octet-stream");
+               header("Content-Disposition: attachment; 
filename=\"{$fileName}\"");
+               $rows = DataCenterDB::getRows(
+                       'DataCenterDBRow',
+                       $data['meta']['category'],
+                       $data['meta']['type']
+               );
+               $useMeta = (
+                       $data['meta']['include-meta'] == 1 &&
+                       (
+                               (
+                                       $data['meta']['category'] == 'facility' 
&&
+                                       DataCenterDB::isFacilityType( 
$data['meta']['type'] )
+                               ) ||
+                               (
+                                       $data['meta']['category'] == 'asset' &&
+                                       DataCenterDB::isAssetType( 
$data['meta']['type'] )
+                               ) ||
+                               (
+                                       $data['meta']['category'] == 'model' &&
+                                       DataCenterDB::isModelType( 
$data['meta']['type'] )
+                               )
+                       )
+               );
+               if ( $data['meta']['format'] == 'csv' ) {
+                       $metaFieldsTable = null;
+                       $lines = array();
+                       $fieldNames = '';
+                       $first = true;
+                       foreach ( $rows as $row ) {
+                               $line = '';
+                               $fields = $row->get();
+                               foreach ( $fields as $field => $value ) {
+                                       $line .= self::exportValue( $value );
+                               }
+                               if ( $first ) {
+                                       foreach ( $fields as $field => $value ) 
{
+                                               $fieldNames .= 
self::exportValue(
+                                                       DataCenterUI::message( 
'field', $field )
+                                               );
+                                       }
+                               }
+                               if ( $useMeta ) {
+                                       $component = 
DataCenterDBComponent::newFromClass(
+                                               'DataCenterDBComponent',
+                                               $data['meta']['category'],
+                                               $data['meta']['type'],
+                                               $fields
+                                       );
+                                       if ( !$metaFieldsTable ) {
+                                               $metaFields = 
$component->getMetaFields();
+                                               $metaFieldsTable = array();
+                                               foreach ( $metaFields as 
$metaField ) {
+                                                       $metaFieldsTable[] = 
$metaField->get( 'field' );
+                                               }
+                                               if ( $first ) {
+                                                       foreach ( $metaFields 
as $metaField ) {
+                                                               $fieldNames .= 
self::exportValue(
+                                                                       
$metaField->get( 'name' )
+                                                               );
+                                                       }
+                                               }
+                                       }
+                                       $metaValues = 
$component->getMetaValues();
+                                       $metaValuesTable = array();
+                                       foreach ( $metaValues as $metaValue ) {
+                                               
$metaValuesTable[$metaValue->get( 'field' )] =
+                                                       $metaValue->get( 
'value' );
+                                       }
+                                       foreach ( $metaFieldsTable as 
$metaField ) {
+                                               if ( isset( 
$metaValuesTable[$metaField] ) ) {
+                                                       $line .= 
self::exportValue(
+                                                               
$metaValuesTable[$metaField]
+                                                       );
+                                               } else {
+                                                       $line .=  ',';
+                                               }
+                                       }
+                               }
+                               $lines[] = rtrim( $line, ',' ) . "\r\n";
+                               $first = false;
+                       }
+                       echo rtrim( $fieldNames, ',' ) . "\r\n";
+                       echo implode( $lines );
+               }
+       }
+
+       private static function exportValue(
+               $value
+       ) {
+               if (
+                       strpos( $value, ',' ) !== false ||
+                       strpos( $value, '"' ) !== false ||
+                       strpos( $value, "\n" ) !== false
+               ) {
+                       return '"' . str_replace( '"', '""', $value ) . '",';
+               } else {
+                       return $value . ',';
+               }
+       }
+}
\ No newline at end of file

Modified: trunk/extensions/DataCenter/UI/Widgets/FieldLinks.php
===================================================================
--- trunk/extensions/DataCenter/UI/Widgets/FieldLinks.php       2009-01-27 
01:37:41 UTC (rev 46308)
+++ trunk/extensions/DataCenter/UI/Widgets/FieldLinks.php       2009-01-27 
01:47:10 UTC (rev 46309)
@@ -27,11 +27,6 @@
                 * @datatype    DataCenterField
                 */
                'field' => null,
-               /**
-                * Current Path
-                * @datatype    array
-                */
-               'path' => null,
        );
 
        private static $targets = array(
@@ -102,6 +97,8 @@
                array $parameters
        ) {
                global $wgUser;
+               // Gets current path
+               $path = DataCenterPage::getPath();
                // Sets Defaults
                $parameters = array_merge( self::$defaultParameters, 
$parameters );
                // Begins widget
@@ -123,7 +120,7 @@
                        'id' => 'form_fieldlinks',
                        'name' => 'form_fieldlinks',
                        'method' => 'post',
-                       'action' => DataCenterXml::url( $parameters['path'] ),
+                       'action' => DataCenterXml::url( $path ),
                );
                // Begins form
                $xmlOutput .= DataCenterXml::open( 'form', $formAttributes );
@@ -249,7 +246,7 @@
                        array(
                                'type' => 'hidden',
                                'name' => 'success',
-                               'value' => DataCenterXml::url( 
$parameters['path'] )
+                               'value' => DataCenterXml::url( $path )
                        )
                );
                // Adds failure field
@@ -258,7 +255,7 @@
                        array(
                                'type' => 'hidden',
                                'name' => 'failure',
-                               'value' => DataCenterXml::url( 
$parameters['path'] )
+                               'value' => DataCenterXml::url( $path )
                        )
                );
                // Adds canellation field
@@ -267,7 +264,7 @@
                        array(
                                'type' => 'hidden',
                                'name' => 'cancellation',
-                               'value' => DataCenterXml::url( 
$parameters['path'] )
+                               'value' => DataCenterXml::url( $path )
                        )
                );
                $xmlOutput .= DataCenterXml::close( 'form' );

Modified: trunk/extensions/DataCenter/Views/Assets.php
===================================================================
--- trunk/extensions/DataCenter/Views/Assets.php        2009-01-27 01:37:41 UTC 
(rev 46308)
+++ trunk/extensions/DataCenter/Views/Assets.php        2009-01-27 01:47:10 UTC 
(rev 46309)
@@ -156,6 +156,33 @@
                );
        }
 
+       public function export(
+               $path
+       ) {
+               // Returns single columm layout with a table
+               return DataCenterUI::renderLayout(
+                       'columns',
+                       array(
+                               DataCenterUI::renderLayout(
+                                       'rows',
+                                       array(
+                                               DataCenterUI::renderWidget(
+                                                       'heading', array( 
'message' => 'export' )
+                                               ),
+                                               DataCenterUI::renderWidget(
+                                                       'export',
+                                                       array(
+                                                               'category' => 
'asset',
+                                                               'type' => 
$path['type']
+                                                       )
+                                               ),
+                                       )
+                               ),
+                               ' '
+                       )
+               );
+       }
+
        public function view(
                $path
        ) {



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to