Author: jfthomps
Date: Fri Oct 31 14:25:26 2014
New Revision: 1635782

URL: http://svn.apache.org/r1635782
Log:
VCL-776 - rework resource code to have a base class for all resources and 
inheriting classes for each resource type

resource.php:
-modified viewResources: moved printing of owner column to be included with 
general attributes; sort the fields by displayed name b
efore generating the columns
-modified addDisplayCheckboxes: sort the fields by displayed name before 
generating HTML
-modified fieldWidth: added owner as a default field that has a width set

computer.php: modified fieldWidth: added owner to have a width of 12

image.php: added fieldWidth: added so we could set width of 'os' to be a little 
wider

managementnode.php: modified fieldWidth: added owner to have a width of 12

Modified:
    vcl/trunk/web/.ht-inc/computer.php
    vcl/trunk/web/.ht-inc/image.php
    vcl/trunk/web/.ht-inc/managementnode.php
    vcl/trunk/web/.ht-inc/resource.php

Modified: vcl/trunk/web/.ht-inc/computer.php
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/computer.php?rev=1635782&r1=1635781&r2=1635782&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/computer.php (original)
+++ vcl/trunk/web/.ht-inc/computer.php Fri Oct 31 14:25:26 2014
@@ -105,6 +105,9 @@ class Computer extends Resource {
                        case 'provisioning':
                                $w = 11;
                                break;
+                       case 'owner':
+                               $w = 12;
+                               break;
                        default:
                                return '';
                }

Modified: vcl/trunk/web/.ht-inc/image.php
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/image.php?rev=1635782&r1=1635781&r2=1635782&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/image.php (original)
+++ vcl/trunk/web/.ht-inc/image.php Fri Oct 31 14:25:26 2014
@@ -71,6 +71,37 @@ class Image extends Resource {
 
        
/////////////////////////////////////////////////////////////////////////////
        ///
+       /// \fn fieldWidth($field)
+       ///
+       /// \param $field - name of a resource field
+       ///
+       /// \return string for setting width of field (includes width= part)
+       ///
+       /// \brief generates the required width for the field; can return an 
empty
+       /// string if field should default to auto width
+       ///
+       
/////////////////////////////////////////////////////////////////////////////
+       function fieldWidth($field) {
+               switch($field) {
+                       case 'owner':
+                               $w = 12;
+                               break;
+                       case 'os':
+                               $w = 7;
+                               break;
+                       default:
+                               return '';
+               }
+               if(preg_match('/MSIE/i', $_SERVER['HTTP_USER_AGENT']) ||
+                  preg_match('/Trident/i', $_SERVER['HTTP_USER_AGENT']))
+                       $w = round($w * 11.5) . 'px';
+               else
+                       $w = "{$w}em";
+               return "width=\"$w\"";
+       }
+
+       
/////////////////////////////////////////////////////////////////////////////
+       ///
        /// \fn fieldDisplayName($field)
        ///
        /// \param $field - name of a resource field

Modified: vcl/trunk/web/.ht-inc/managementnode.php
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/managementnode.php?rev=1635782&r1=1635781&r2=1635782&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/managementnode.php (original)
+++ vcl/trunk/web/.ht-inc/managementnode.php Fri Oct 31 14:25:26 2014
@@ -99,6 +99,7 @@ class ManagementNode extends Resource {
                                $w = 9.5;
                                break;
                        case 'keys':
+                       case 'owner':
                        case 'sharedmailbox':
                                $w = 12;
                                break;

Modified: vcl/trunk/web/.ht-inc/resource.php
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/resource.php?rev=1635782&r1=1635781&r2=1635782&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/resource.php (original)
+++ vcl/trunk/web/.ht-inc/resource.php Fri Oct 31 14:25:26 2014
@@ -298,7 +298,6 @@ class Resource {
                $h .= "<div id=\"gridcontainer\">\n";
                $h .= "<table dojoType=\"dojox.grid.DataGrid\" 
jsId=\"resourcegrid\" ";
                $h .= "sortInfo=3 store=\"resourcestore\" autoWidth=\"true\" 
style=\"";
-               #$h .= "height: 580px;\" query=\"{type: new 
RegExp('normal|federated|courseroll')}\">\n";
                if($this->deletetoggled)
                        $h .= "height: 580px;\" query=\"{deleted: '0'}\">\n";
                else
@@ -307,20 +306,21 @@ class Resource {
                $h .= "<tr>\n";
                if(preg_match('/MSIE/i', $_SERVER['HTTP_USER_AGENT']) ||
                   preg_match('/Trident/i', $_SERVER['HTTP_USER_AGENT']))
-                       $w = array('64px', '38px', '200px', '142px');
+                       $w = array('64px', '38px', '200px');
                else
-                       $w = array('5em', '3em', '17em', '12em');
+                       $w = array('5em', '3em', '17em');
                $h .= "<th field=\"id\" id=\"delcolth\" width=\"{$w[0]}\" 
formatter=\"resource.DeleteBtn\" styles=\"text-align: center;\">&nbsp;</th>\n";
                $h .= "<th field=\"id\" width=\"{$w[1]}\" 
formatter=\"resource.EditBtn\" styles=\"text-align: center;\">&nbsp;</th>\n";
                $h .= "<th field=\"name\" width=\"{$w[2]}\">Name</th>\n";
-               if(array_key_exists('owner', $selfields) && ! 
$selfields['owner'])
-                       $h .= "<th field=\"owner\" width=\"{$w[3]}\" 
hidden=\"true\">Owner</th>\n";
-               else
-                       $h .= "<th field=\"owner\" 
width=\"{$w[3]}\">Owner</th>\n";
-               foreach($fields as $field) {
+               if(! array_key_exists('owner', $selfields))
+                       $selfields['owner'] = 1;
+               foreach($fields as $field)
+                       $names[$field] = $this->fieldDisplayName($field);
+               uasort($names, 'sortKeepIndex');
+               foreach($names as $field => $name) {
                        if($field == $this->namefield ||
                           $field == 'name' ||
-                          $field == 'owner' ||
+                          #$field == 'owner' ||
                           is_array($resdata[$testid][$field]) ||
                           preg_match('/id$/', $field))
                                continue;
@@ -329,8 +329,7 @@ class Resource {
                                $h .= "<th field=\"$field\" $w 
formatter=\"resource.colformatter\">";
                        else
                                $h .= "<th field=\"$field\" $w hidden=\"true\" 
formatter=\"resource.colformatter\">";
-                       $h .= $this->fieldDisplayName($field);
-                       $h .= "</th>\n";
+                       $h .= "$name</th>\n";
                }
                $h .= "</tr>\n";
                $h .= "</thead>\n";
@@ -369,6 +368,7 @@ class Resource {
        
/////////////////////////////////////////////////////////////////////////////
        function addDisplayCheckboxes($allfields, $sample, $selfields) {
                $fields = array('owner');
+               $names = array('owner' => $this->fieldDisplayName('owner'));
                foreach($allfields as $field) {
                        if($field == $this->namefield ||
                           $field == 'name' ||
@@ -377,29 +377,29 @@ class Resource {
                           preg_match('/id$/', $field))
                                continue;
                        $fields[] = $field;
+                       $names[$field] = $this->fieldDisplayName($field);
                }
+               uasort($names, 'sortKeepIndex');
                $h = '';
                $fieldcnt = count($fields);
                $cols = $fieldcnt / 4;
                if($cols > 4)
                        $cols = 4;
                if($fieldcnt < 6) {
-                       foreach($fields as $field) {
+                       foreach($names as $field => $name) {
                                if($field == 'owner' && (! 
array_key_exists('owner', $selfields) || $selfields['owner']))
                                        $h .= "<input type=checkbox 
id=chk$field checked onClick=\"resource.toggleResFieldDisplay(this, 
'$field')\">";
                                elseif($field == 'name' || 
(array_key_exists($field, $selfields) && $selfields[$field]))
                                        $h .= "<input type=checkbox 
id=chk$field checked onClick=\"resource.toggleResFieldDisplay(this, 
'$field')\">";
                                else
                                        $h .= "<input type=checkbox 
id=chk$field onClick=\"resource.toggleResFieldDisplay(this, '$field')\">";
-                               $h .= "<label for=chk$field>";
-                               $h .= $this->fieldDisplayName($field);
-                               $h .= "</label><br>\n";
+                               $h .= "<label 
for=chk$field>$name</label><br>\n";
                        }
                }
                else {
                        $h .= "<table>\n";
                        $cnt = 0;
-                       foreach($fields as $field) {
+                       foreach($names as $field => $name) {
                                $mod = $cols;
                                if($cnt % $mod == 0)
                                        $h .= "<tr>\n";
@@ -409,9 +409,7 @@ class Resource {
                                        $h .= "  <td><input type=checkbox 
id=chk$field checked onClick=\"resource.toggleResFieldDisplay(this, 
'$field')\">";
                                else
                                        $h .= "  <td><input type=checkbox 
id=chk$field onClick=\"resource.toggleResFieldDisplay(this, '$field')\">";
-                               $h .= "<label for=chk$field>";
-                               $h .= $this->fieldDisplayName($field);
-                               $h .= "</label><br></td>\n";
+                               $h .= "<label 
for=chk$field>$name</label><br></td>\n";
                                $cnt++;
                                if($cnt % $mod == 0)
                                        $h .= "</tr>\n";
@@ -436,7 +434,19 @@ class Resource {
        ///
        
/////////////////////////////////////////////////////////////////////////////
        function fieldWidth($field) {
-               return '';
+               switch($field) {
+                       case 'owner':
+                               $w = 12;
+                               break;
+                       default:
+                               return '';
+               }
+               if(preg_match('/MSIE/i', $_SERVER['HTTP_USER_AGENT']) ||
+                  preg_match('/Trident/i', $_SERVER['HTTP_USER_AGENT']))
+                       $w = round($w * 11.5) . 'px';
+               else
+                       $w = "{$w}em";
+               return "width=\"$w\"";
        }
 
        
/////////////////////////////////////////////////////////////////////////////


Reply via email to