示例#1
0
 public static function render(array $parameters)
 {
     // Sets defaults
     $parameters = array_merge(self::$defaultParameters, $parameters);
     // Begins widget
     $xmlOutput = parent::begin($parameters['class']);
     // Checks for...
     if (isset($parameters['message']) && is_scalar($parameters['message']) && $parameters['message'] !== null) {
         // Checks if a subject was given
         if (isset($parameters['subject']) && $parameters['subject'] !== null) {
             // Uses subject-based message
             $message = DataCenterUI::message('body', $parameters['message'], $parameters['subject']);
             // Checks if a type was given
         } elseif ($parameters['type'] !== null) {
             // Uses type-based message
             $message = DataCenterUI::message('body', $parameters['message'], DataCenterUI::message('type', $parameters['type']));
         } else {
             // Uses plain message
             $message = DataCenterUI::message('body', $parameters['message']);
         }
         // Returns body with message
         $xmlOutput .= DataCenterXml::div(array('class' => $parameters['style']), DataCenterXml::div($message));
         // Checks if text was given
     } elseif (isset($parameters['text']) && is_scalar($parameters['text']) && $parameters['text'] !== null) {
         // Returns a body with text
         $xmlOutput .= DataCenterXml::div(array('class' => $parameters['style']), DataCenterXml::div($parameters['text']));
     }
     // Ends widget
     $xmlOutput .= parent::end();
     // Returns results
     return $xmlOutput;
 }
 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']);
     // Adds result type menu
     $currentTarget = null;
     $currentNum = null;
     $menuItems = array();
     foreach (self::$targets as $target) {
         $numMatches = DataCenterDB::numMatches($target['category'], $target['type'], $target['fields'], $parameters['query']);
         if ($numMatches == 0) {
             continue;
         }
         $fusedType = $target['category'] . '.' . $target['type'];
         if (!$path['type']) {
             $path['type'] = $fusedType;
         }
         if ($path['type'] == $fusedType) {
             $currentTarget = $target;
             $currentNum = $numMatches;
             $state = 'current';
         } else {
             $state = 'normal';
         }
         $typePath = array_merge($path, array('type' => $target['category'] . '.' . $target['type']));
         $menuItems[] = DataCenterXml::div(array('class' => 'type-' . $state), DataCenterXml::link(DataCenterUI::message('results', $target['category'] . '-' . $target['type'], $numMatches), $typePath));
     }
     $resultItems = array();
     if (!$currentTarget) {
         $xmlOutput .= DataCenterUI::renderWidget('body', array('message' => 'notice-no-results', 'style' => 'notice'));
     } else {
         $joins = array();
         if ($currentTarget['class'] == 'DataCenterDBAsset') {
             $joins = array_merge_recursive(DataCenterDB::buildJoin('model', $currentTarget['type'], 'id', 'asset', $currentTarget['type'], 'model', array('name', 'manufacturer')), DataCenterDB::buildJoin('facility', 'location', 'id', 'asset', $currentTarget['type'], 'location', array('name' => 'location_name')));
         }
         // Gets search results
         $results = DataCenterDB::getMatches($currentTarget['class'], $currentTarget['category'], $currentTarget['type'], $currentTarget['fields'], $parameters['query'], array_merge_recursive($joins, DataCenterDB::buildRange($path)));
         // Adds types
         $xmlOutput .= DataCenterXml::div(array('class' => 'types'), implode($menuItems));
         // Adds results
         $xmlOutput .= DataCenterXml::div(array('class' => 'results'), DataCenterUI::renderWidget('table', array_merge($currentTarget['table'], array('rows' => $results, 'num' => $currentNum))));
     }
     // Ends widget
     $xmlOutput .= parent::end();
     // Returns results
     return $xmlOutput;
 }
示例#3
0
 public static function render(array $parameters)
 {
     // Begins layout
     $xmlOutput = parent::begin(self::$parameters['class']);
     // Loops over each content block
     foreach ($parameters as $content) {
         // Adds row
         $xmlOutput .= DataCenterXml::div(DataCenterXml::div(array('class' => 'row'), $content));
     }
     // Ends layout
     $xmlOutput .= parent::end();
     // Returns results
     return $xmlOutput;
 }
示例#4
0
 private static function markerOptions(array $parameters, $location)
 {
     // Begins window
     $xmlOutput = DataCenterXml::open('div', array('class' => 'window'));
     // Adds heading
     $xmlOutput .= DataCenterXml::div(array('class' => 'heading'), DataCenterXml::link($location->get('name'), array('page' => 'facilities', 'type' => 'location', 'action' => 'view', 'id' => $location->getId())));
     // Gets number of spaces in location
     $numSpaces = DataCenterDB::numSpaces(DataCenterDB::buildCondition('facility', 'space', 'location', $location->getId()));
     // Adds body
     $xmlOutput .= DataCenterXml::div(array('class' => 'body'), DataCenterXml::div(array('class' => 'region'), $location->get('region')) . DataCenterXml::div(array('class' => 'spaces'), DataCenterUI::message('label', 'num-spaces', $numSpaces)));
     // Ends window
     $xmlOutput .= DataCenterXml::close('div');
     // Returns JavaScript object of options
     return DataCenterJs::toObject(array('content' => $xmlOutput));
 }
示例#5
0
 public static function render(array $parameters)
 {
     // Sets defaults
     $parameters = array_merge_recursive(self::$defaultParameters, $parameters);
     // Begins widget
     $xmlOutput = parent::begin($parameters['class']);
     // Gets current path
     $path = DataCenterPage::getPath();
     // Begins icons
     $xmlOutput .= DataCenterXml::open('div', array('class' => 'icons'));
     // Loops over each row
     foreach ($parameters['rows'] as $row) {
         // Sets div attributes
         $divAttributes = array('class' => 'icon');
         // Checks if a list of types was specified
         if (count($parameters['types']) > 0) {
             // Adds list of type classes
             foreach ($parameters['types'] as $type) {
                 $divAttributes['class'] .= ' ' . $type . '-' . $row->get($type);
             }
         } else {
             // Adds generic class
             $divAttributes['class'] .= ' generic';
         }
         if (is_array($parameters['label'])) {
             $label = '';
             foreach ($parameters['label'] as $key => $value) {
                 $label .= DataCenterXml::div(array('class' => 'label-' . $key), $row->get($value));
             }
         } else {
             $label = DataCenterXml::div(array('class' => 'label-0'), $row->get($parameters['label']));
         }
         $divAttributes = array_merge($divAttributes, DataCenterXml::buildEffects($parameters['effects'], $row), DataCenterXml::buildLink($parameters['link'], $row));
         if (count($parameters['link']) > 0) {
             $divAttributes['class'] .= ' link';
         }
         // Adds icon
         $xmlOutput .= DataCenterXml::div($divAttributes, $label);
     }
     // Clears floating
     $xmlOutput .= DataCenterXml::clearFloating();
     // Ends icon view
     $xmlOutput .= DataCenterXml::close('div');
     // Ends widget
     $xmlOutput .= parent::end();
     // Returns XML
     return $xmlOutput;
 }
示例#6
0
 public static function render(array $parameters)
 {
     // Begins layout
     $xmlOutput = parent::begin(self::$parameters['class']);
     // Calculates split percentage
     $split = round(100 / count($parameters));
     // Loops over each content block
     foreach ($parameters as $content) {
         // Adds column
         $xmlOutput .= DataCenterXml::div(array('style' => "width:{$split}%;float:left;"), DataCenterXml::div(array('class' => 'column'), $content));
     }
     // Ends layout
     $xmlOutput .= parent::end();
     // Returns results
     return $xmlOutput;
 }
示例#7
0
 private static function renderModel($parameters, $structure, $level = 0)
 {
     $xmlOutput = '';
     foreach ($structure as $model) {
         $modelLink = DataCenterDB::getModelLink($model->get('link'));
         if (!DataCenterPage::userCan('change')) {
             $rowAttributes = array();
         } elseif ($level == 0 && count($parameters['link']) > 0) {
             $rowAttributes = array_merge(array('class' => 'link'), DataCenterXml::buildLink($parameters['link'], $model));
         } else {
             $rowAttributes = array('class' => 'mute');
         }
         $xmlOutput .= DataCenterXml::row($rowAttributes, DataCenterXml::cell(DataCenterXml::div(array('style' => 'padding-left:' . $level * 15 . 'px'), $modelLink->get('name'))) . DataCenterXml::cell(array('align' => 'right'), $modelLink->get('quantity')) . DataCenterXml::cell($model->get('name')) . DataCenterXml::cell(DataCenterUI::message('type', $model->getType())));
         $xmlOutput .= self::renderModel($parameters, $model->getStructure(), $level + 1);
     }
     return $xmlOutput;
 }
示例#8
0
 public static function render(array $parameters)
 {
     // Sets defaults
     $parameters = array_merge(self::$defaultParameters, $parameters);
     // Checks for permissions
     if (!DataCenterPage::userCan($parameters['rights'])) {
         return null;
     }
     // Begins widget
     $xmlOutput = parent::begin($parameters['class']);
     // Checks if links is an array
     if (is_array($parameters['links'])) {
         // Loops over each link
         foreach ($parameters['links'] as $label => $link) {
             // Checks if link is not an array
             if (!is_array($link)) {
                 // Skips the invalid data
                 continue;
             }
             // Checks if a label was not given but an action was
             if (is_int($label) && isset($link['action'])) {
                 // Uses action as label
                 $label = $link['action'];
             }
             if (is_array($link[$parameters['subject']])) {
                 $subject = current($link[$parameters['subject']]);
             } else {
                 $subject = $link[$parameters['subject']];
             }
             // Builds label
             $label = DataCenterUI::message('action', $label . '-type', DataCenterUI::message('type', $subject));
             // Builds link
             $link = DataCenterXml::link($label, $link);
             // Adds action link
             $xmlOutput .= DataCenterXml::div(array('class' => 'action'), $link);
         }
     }
     // Ends widget
     $xmlOutput .= parent::end();
     $xmlOutput .= DataCenterXml::clearFloating();
     // Returns results
     return $xmlOutput;
 }
 /**
  * Builds and stores menus in output cache
  * @param	pages			Array of pages for main menu, with keys as page
  * 							names
  * @param	controller		DataCenterController of the current page's
  * 							controller
  * @param	path			Array of link parameters of current path
  */
 public static function setDestinations(array $pages, DataCenterController $controller, array $path)
 {
     global $wgUser;
     // Adds main menu
     self::$output['menu'] .= DataCenterXml::open('div', array('class' => 'menu'));
     foreach ($pages as $page => $classes) {
         if ($classes['display']) {
             $state = $page == $path['page'] ? 'current' : 'normal';
             self::$output['menu'] .= DataCenterXml::div(array('class' => 'item-' . $state), DataCenterXml::link(self::message('page', $page), array('page' => $page)));
         }
     }
     self::$output['menu'] .= DataCenterXml::close('div');
     // Adds search
     self::$output['menu'] .= DataCenterUI::renderWidget('search', array());
     // Adds sub menu
     self::$output['menu'] .= DataCenterXml::open('div', array('class' => 'toolbar'));
     // Type tabs
     if (count($controller->types) > 0) {
         self::$output['menu'] .= DataCenterXml::div(array('class' => 'type-label'), self::message('label', 'browse-by'));
         foreach ($controller->types as $label => $type) {
             $state = $label == $path['type'] ? 'current' : 'normal';
             self::$output['menu'] .= DataCenterXml::div(array('class' => 'type-' . $state), DataCenterXml::link(self::message('type', $label), $type));
         }
     }
     // Trail steps
     $count = 1;
     foreach ($controller->trail as $label => $step) {
         $end = $count == count($controller->trail) ? '-end' : '';
         self::$output['menu'] .= DataCenterXml::div(array('class' => 'breadcrumb' . $end), DataCenterXml::link($label, $step));
         $count++;
     }
     // Action tabs
     foreach ($controller->actions as $label => $action) {
         $state = $label == $path['action'] ? 'current' : 'normal';
         self::$output['menu'] .= DataCenterXml::div(array('class' => 'action-' . $state), DataCenterXml::link(self::message('action', $label), $action));
     }
     self::$output['menu'] .= DataCenterXml::close('div');
 }
示例#10
0
    public static function render(array $parameters)
    {
        // Increment the number of tabbed layouts in existence
        self::$sets++;
        // Gets id for this set
        $set = self::$sets;
        // Begins layout
        $xmlOutput = parent::begin(self::$parameters['class']);
        $xmlOutput .= DataCenterXml::open('div', array('class' => 'tabs'));
        // Loops over each content block
        $state = 'current';
        $tab = 0;
        foreach ($parameters as $name => $content) {
            if ($content !== null) {
                // Adds row
                $xmlOutput .= DataCenterXml::div(array('class' => 'item-' . $state, 'id' => 'tabs_' . $set . '_tab_' . $tab, 'onclick' => DataCenterJs::callFunction('dataCenter.ui.layouts.tabs.select', array(DataCenterJs::toScalar($set), DataCenterJs::toScalar($tab)))), DataCenterUI::message('tab', $name));
                $state = 'normal';
                $tab++;
            } else {
                $xmlOutput .= DataCenterXml::div(array('class' => 'item-disabled'), DataCenterUI::message('tab', $name));
            }
        }
        $xmlOutput .= DataCenterXml::close('div');
        $xmlOutput .= DataCenterXml::clearFloating();
        // Loops over each content block
        $display = 'block';
        $tab = 0;
        foreach ($parameters as $content) {
            if ($content !== null) {
                // Adds row
                $xmlOutput .= DataCenterXml::div(DataCenterXml::div(array('class' => 'page', 'id' => 'tabs_' . $set . '_page_' . $tab, 'style' => 'display:' . $display), $content));
                $display = 'none';
                $tab++;
            }
        }
        // Ends layout
        $xmlOutput .= parent::end();
        // Builds javascript for layout
        $jsOutput = <<<END
\t\t\tif ( !dataCenter.ui.layouts.tabs ) {
\t\t\t\tdataCenter.ui.layouts.tabs = {
\t\t\t\t\tsets: {},
\t\t\t\t\tselect: function(
\t\t\t\t\t\tsetID, tabID
\t\t\t\t\t) {
\t\t\t\t\t\tif ( this.sets[setID] ) {
\t\t\t\t\t\t\tfor ( var i = 0; i < this.sets[setID].count; i++ ) {
\t\t\t\t\t\t\t\tvar page = document.getElementById(
\t\t\t\t\t\t\t\t\t'tabs_' + setID + '_page_' + i
\t\t\t\t\t\t\t\t);
\t\t\t\t\t\t\t\tvar tab = document.getElementById(
\t\t\t\t\t\t\t\t\t'tabs_' + setID + '_tab_' + i
\t\t\t\t\t\t\t\t);
\t\t\t\t\t\t\t\tif ( tab && page ) {
\t\t\t\t\t\t\t\t\tif ( i == tabID ) {
\t\t\t\t\t\t\t\t\t\tpage.style.display = 'block';
\t\t\t\t\t\t\t\t\t\ttab.className = 'item-current';
\t\t\t\t\t\t\t\t\t} else {
\t\t\t\t\t\t\t\t\t\tpage.style.display = 'none';
\t\t\t\t\t\t\t\t\t\ttab.className = 'item-normal';
\t\t\t\t\t\t\t\t\t}
\t\t\t\t\t\t\t\t}
\t\t\t\t\t\t\t}
\t\t\t\t\t\t}
\t\t\t\t\t},
\t\t\t\t\taddSet: function( name, count ) {
\t\t\t\t\t\tthis.sets[name] = {};
\t\t\t\t\t\tthis.sets[name].count = count;
\t\t\t\t\t}
\t\t\t\t}
\t\t\t}
\t\t\t// Add information for this set
\t\t\tdataCenter.ui.layouts.tabs.addSet( {$set}, {$tab} );
END;
        // Adds script
        $xmlOutput .= DataCenterXml::script($jsOutput);
        // Returns results
        return $xmlOutput;
    }