Computer::getTypeName PHP Method

getTypeName() static public method

Name of the type
static public getTypeName ( $nb )
$nb integer number of item in the type (default 0)
    static function getTypeName($nb = 0)
    {
        return _n('Computer', 'Computers', $nb);
    }

Usage Example

 /**
  * Print the computers disks
  *
  * @param $comp                  Computer object
  * @param $withtemplate boolean  Template or basic item (default '')
  *
  * @return Nothing (call to classes members)
  **/
 static function showForComputer(Computer $comp, $withtemplate = '')
 {
     global $DB;
     $ID = $comp->fields['id'];
     if (!$comp->getFromDB($ID) || !$comp->can($ID, READ)) {
         return false;
     }
     $canedit = $comp->canEdit($ID);
     if ($canedit && !(!empty($withtemplate) && $withtemplate == 2)) {
         echo "<div class='center firstbloc'>" . "<a class='vsubmit' href='computerdisk.form.php?computers_id={$ID}&amp;withtemplate=" . $withtemplate . "'>";
         _e('Add a volume');
         echo "</a></div>\n";
     }
     echo "<div class='center'>";
     $query = "SELECT `glpi_filesystems`.`name` AS fsname,\n                       `glpi_computerdisks`.*\n                FROM `glpi_computerdisks`\n                LEFT JOIN `glpi_filesystems`\n                          ON (`glpi_computerdisks`.`filesystems_id` = `glpi_filesystems`.`id`)\n                WHERE `computers_id` = '{$ID}'\n                      AND `is_deleted` = '0'";
     if ($result = $DB->query($query)) {
         echo "<table class='tab_cadre_fixehov table-striped table-hover'>";
         $colspan = 7;
         if (Plugin::haveImport()) {
             $colspan++;
         }
         echo "<tr class='noHover'><th colspan='{$colspan}'>" . self::getTypeName($DB->numrows($result)) . "</th></tr>";
         if ($DB->numrows($result)) {
             $header = "<tr><th>" . __('Name') . "</th>";
             if (Plugin::haveImport()) {
                 $header .= "<th>" . __('Automatic inventory') . "</th>";
             }
             $header .= "<th>" . __('Partition') . "</th>";
             $header .= "<th>" . __('Mount point') . "</th>";
             $header .= "<th>" . __('File system') . "</th>";
             $header .= "<th>" . __('Global size') . "</th>";
             $header .= "<th>" . __('Free size') . "</th>";
             $header .= "<th>" . __('Free percentage') . "</th>";
             $header .= "</tr>";
             echo $header;
             Session::initNavigateListItems(__CLASS__, sprintf(__('%1$s = %2$s'), Computer::getTypeName(1), $comp->getName()));
             $disk = new self();
             while ($data = $DB->fetch_assoc($result)) {
                 $disk->getFromDB($data['id']);
                 echo "<tr class='tab_bg_2'>";
                 echo "<td>" . $disk->getLink() . "</td>";
                 if (Plugin::haveImport()) {
                     echo "<td>" . Dropdown::getYesNo($data['is_dynamic']) . "</td>";
                 }
                 echo "<td>" . $data['device'] . "</td>";
                 echo "<td>" . $data['mountpoint'] . "</td>";
                 echo "<td>" . $data['fsname'] . "</td>";
                 //TRANS: %s is a size
                 $tmp = sprintf(__('%s Mio'), Html::formatNumber($data['totalsize'], false, 0));
                 echo "<td class='right'>{$tmp}<span class='small_space'></span></td>";
                 $tmp = sprintf(__('%s Mio'), Html::formatNumber($data['freesize'], false, 0));
                 echo "<td class='right'>{$tmp}<span class='small_space'></span></td>";
                 echo "<td>";
                 $percent = 0;
                 if ($data['totalsize'] > 0) {
                     $percent = round(100 * $data['freesize'] / $data['totalsize']);
                 }
                 Html::displayProgressBar('100', $percent, array('simple' => true, 'forcepadding' => false));
                 echo "</td>";
                 echo "</tr>";
                 Session::addToNavigateListItems(__CLASS__, $data['id']);
             }
             echo $header;
         } else {
             echo "<tr class='tab_bg_2'><th colspan='{$colspan}'>" . __('No item found') . "</th></tr>";
         }
         echo "</table>";
     }
     echo "</div><br>";
 }
All Usage Examples Of Computer::getTypeName