Exemple #1
0
 static function getSpecificValueToDisplay($field, $values, array $options = array())
 {
     if (!is_array($values)) {
         $values = array($field => $values);
     }
     switch ($field) {
         case 'field':
             if (isset($values['itemtype']) && !empty($values['itemtype'])) {
                 $target = getItemForItemtype($values['itemtype']);
                 $searchOption = $target->getSearchOptionByField('field', $values[$field]);
                 //                if (empty($searchOption)) {
                 //                   if ($table = getTableNameForForeignKeyField($values[$field])) {
                 //                      $searchOption = $target->getSearchOptionByField('field', 'name', $table);
                 //                   }
                 //                   echo $table.'--';
                 //                }
                 return $searchOption['name'];
             }
             break;
         case 'value':
             if (isset($values['itemtype']) && !empty($values['itemtype'])) {
                 $target = getItemForItemtype($values['itemtype']);
                 if (isset($values['field']) && !empty($values['field'])) {
                     $searchOption = $target->getSearchOptionByField('field', $values['field']);
                     // MoYo : do not know why this part ?
                     //                   if ($table = getTableNameForForeignKeyField($values['field'])) {
                     //                      $searchOption = $target->getSearchOptionByField('field', 'name', $table);
                     //                   }
                     return $target->getValueToDisplay($searchOption, $values[$field]);
                 }
             }
             break;
     }
     return parent::getSpecificValueToDisplay($field, $values, $options);
 }
Exemple #2
0
 /**
  * @param $field
  * @param $values
  * @param $options   array
  */
 static function getSpecificValueToDisplay($field, $values, array $options = array())
 {
     if (!is_array($values)) {
         $values = array($field => $values);
     }
     switch ($field) {
         case 'type':
             $types = self::getTypes();
             return $types[$values[$field]];
     }
     return parent::getSpecificValueToDisplay($field, $values, $options);
 }
 /**
  * @since version 0.84
  *
  * @param $field
  * @param $values
  * @param $options   array
  **/
 static function getSpecificValueToDisplay($field, $values, array $options = array())
 {
     if (!is_array($values)) {
         $values = array($field => $values);
     }
     switch ($field) {
         case 'fields':
             if (isset($values['itemtype']) && !empty($values['itemtype'])) {
                 if ($target = getItemForItemtype($values['itemtype'])) {
                     $searchOption = $target->getSearchOptionByField('field', $values[$field]);
                     $fields = explode(',', $values[$field]);
                     $message = array();
                     foreach ($fields as $field) {
                         $searchOption = $target->getSearchOptionByField('field', $field);
                         if (isset($searchOption['name'])) {
                             $message[] = $searchOption['name'];
                         }
                     }
                     return implode(', ', $message);
                 }
             }
             break;
     }
     return parent::getSpecificValueToDisplay($field, $values, $options);
 }
 /**
  * @since version 0.84
  **/
 static function getSpecificValueToDisplay($field, $values, array $options = array())
 {
     if (!is_array($values)) {
         $values = array($field => $values);
     }
     switch ($field) {
         case 'icon':
             if (!empty($values[$field])) {
                 return "&nbsp;<img style='vertical-align:middle;' alt='' src='" . $CFG_GLPI["typedoc_icon_dir"] . "/" . $values[$field] . "'>";
             }
     }
     return parent::getSpecificValueToDisplay($field, $values, $options);
 }
 /**
  * @since version 0.84
  *
  * @param $field
  * @param $values
  * @param $options   array
  **/
 static function getSpecificValueToDisplay($field, $values, array $options = array())
 {
     if (!is_array($values)) {
         $values = array($field => $values);
     }
     switch ($field) {
         case 'periodicity':
             if (preg_match('/([0-9]+)MONTH/', $values[$field], $matches)) {
                 return sprintf(_n('%d month', '%d months', $matches[1]), $matches[1]);
             }
             if (preg_match('/([0-9]+)YEAR/', $values[$field], $matches)) {
                 return sprintf(_n('%d year', '%d years', $matches[1]), $matches[1]);
             }
             return Html::timestampToString($values[$field], false);
             break;
     }
     return parent::getSpecificValueToDisplay($field, $values, $options);
 }
Exemple #6
0
 static function getSpecificValueToDisplay($field, $values, array $options = array())
 {
     if (!is_array($values)) {
         $values = array($field => $values);
     }
     switch ($field) {
         case 'field':
             if (isset($values['itemtype']) && !empty($values['itemtype'])) {
                 $target = getItemForItemtype($values['itemtype']);
                 $searchOption = $target->getSearchOptionByField('field', $values[$field]);
                 return $searchOption['name'];
             }
             break;
         case 'value':
             if (isset($values['itemtype']) && !empty($values['itemtype'])) {
                 $target = getItemForItemtype($values['itemtype']);
                 if (isset($values['field']) && !empty($values['field'])) {
                     $searchOption = $target->getSearchOptionByField('field', $values['field']);
                     return $target->getValueToDisplay($searchOption, $values[$field]);
                 }
             }
             break;
     }
     return parent::getSpecificValueToDisplay($field, $values, $options);
 }