Exemplo n.º 1
0
 /**
  * Get list of domain for a specific host
  *
  *
  * @method get
  * @route /domain/[i:id]/icon
  */
 public function iconForDomainAction()
 {
     $di = Di::getDefault();
     $router = $di->get('router');
     $requestParam = $this->getParams('named');
     $finalIconList = array();
     $iconId = Domain::get($requestParam['id'], "icon_id");
     if (is_array($iconId) && count($iconId) > 0) {
         $icon = Image::getIcon($iconId['icon_id']);
         if (count($icon) > 0) {
             $filenameExploded = explode('.', $icon['filename']);
             $nbOfOccurence = count($filenameExploded);
             $fileFormat = $filenameExploded[$nbOfOccurence - 1];
             $filenameLength = strlen($icon['filename']);
             $routeAttr = array('image' => substr($icon['filename'], 0, $filenameLength - (strlen($fileFormat) + 1)), 'format' => '.' . $fileFormat);
             $imgSrc = $router->getPathFor('/uploads/[*:image][png|jpg|gif|jpeg:format]', $routeAttr);
             $finalIconList = array("id" => $icon['binary_id'], "text" => $icon['filename'], "theming" => '<img src="' . $imgSrc . '" style="width:20px;height:20px;"> ' . $icon['filename']);
         }
     }
     $router->response()->json($finalIconList);
 }
Exemplo n.º 2
0
 /**
  * 
  * @param string $domain
  * @param boolean $withChildren
  * @return array
  */
 public static function getDomain($domain, $withChildren = false)
 {
     $domainList = array();
     $mainDomainId = Domain::getIdByParameter('name', array($domain));
     if (count($mainDomainId) > 0) {
         $domainList[] = Domain::get($mainDomainId[0]);
         if ($withChildren) {
             array_merge($domainList, Domain::getList('*', -1, 0, null, 'ASC', array('parent_id' => $mainDomainId[0])));
         }
     }
     return $domainList;
 }
Exemplo n.º 3
0
 /**
  * Get the full text of a numeric value
  *
  * @param string $name The key name
  * @param int $value The numeric value
  * @return string
  */
 public static function getTextValue($name, $value)
 {
     switch ($name) {
         case 'domain_id':
             $domain = Domain::get($value);
             return $domain['name'];
         case 'command_command_id':
         case 'command_command_id2':
             $command = Command::get($value);
             return $command['command_name'];
         case 'timeperiod_tp_id':
             $timeperiod = Timeperiod::get($value);
             return $timeperiod['tp_name'];
         case 'service_is_volatile':
         case 'service_active_checks_enabled':
         case 'service_passive_checks_enabled':
         case 'service_obsess_over_service':
         case 'service_check_freshness':
         case 'service_event_handler_enabled':
         case 'service_flap_detection_enabled':
             if ($value == 0) {
                 return _('No');
             } else {
                 if ($value == 1) {
                     return _('Yes');
                 } else {
                     return _('Default');
                 }
             }
         default:
             return $value;
     }
 }
Exemplo n.º 4
0
 public function testGetColumns()
 {
     $this->assertEquals(array('domain_id', 'name', 'description', 'isroot', 'parent_id', 'icon_id'), Domain::getColumns());
 }