new: Use the new OrgImg helper for fetching org logos in a more consistent fashion

pull/2883/head
iglocska 2018-01-19 15:55:27 +01:00
parent 843d81854b
commit 4a5c11d426
12 changed files with 60 additions and 65 deletions

View File

@ -20,10 +20,7 @@
<td class="short"><a href="<?php echo $baseurl;?>/events/view/<?php echo h($event['Event']['id']); ?>"><?php echo h($event['Event']['id']); ?></a></td>
<td class="short">
<?php
$imgRelativePath = 'orgs' . DS . h($event['Event']['Orgc']['name']) . '.png';
$imgAbsolutePath = APP . WEBROOT_DIR . DS . 'img' . DS . $imgRelativePath;
if (file_exists($imgAbsolutePath)) echo $this->Html->image('orgs/' . h($event['Event']['Orgc']['name']) . '.png', array('alt' => h($event['Event']['Orgc']['name']), 'title' => h($event['Event']['Orgc']['name']), 'style' => 'width:24px; height:24px'));
else echo $this->Html->tag('span', h($event['Event']['Orgc']['name']), array('class' => 'welcome', 'style' => 'float:left;'));
echo $this->OrgImg->getOrgImg(array('name' => $event['Event']['Orgc']['name'], 'id' => $event['Event']['Orgc']['id'], 'size' => 24));
?>
</td>
<td>

View File

@ -79,26 +79,7 @@ foreach ($attributes as $attribute):
<?php if (Configure::read('MISP.showorg') || $isAdmin): ?>
<td class="short" ondblclick="document.location.href ='<?php echo $baseurl;?>/events/view/<?php echo $attribute['Event']['id'];?>'">
<?php
$imgRelativePath = 'orgs' . DS . h($orgs[$attribute['Event']['orgc_id']]) . '.png';
$imgAbsolutePath = APP . WEBROOT_DIR . DS . 'img' . DS . $imgRelativePath;
if (file_exists($imgAbsolutePath)) {
echo $this->Html->image(
'orgs/' . h($orgs[$attribute['Event']['orgc_id']]) . '.png',
array('alt' => h($orgs[$attribute['Event']['orgc_id']]),
'title' => h($orgs[$attribute['Event']['orgc_id']]),
'style' => 'width:24px; height:24px'
)
);
} else {
echo $this->Html->tag(
'span',
h($orgs[$attribute['Event']['orgc_id']]),
array(
'class' => 'welcome',
'style' => 'float:left;'
)
);
}
echo $this->OrgImg->getOrgImg(array('name' => $event['Event']['Orgc']['name'], 'id' => $event['Event']['Orgc']['id'], 'size' => 24));
?>
&nbsp;
</td>

View File

@ -56,9 +56,7 @@
<?php
if ($object['objectType'] != 0) {
if (isset($object['Org']['name'])) {
$imgAbsolutePath = APP . WEBROOT_DIR . DS . 'img' . DS . 'orgs' . DS . h($object['Org']['name']) . '.png';
if (file_exists($imgAbsolutePath)) echo $this->Html->image('orgs/' . h($object['Org']['name']) . '.png', array('alt' => h($object['Org']['name']), 'title' => h($object['Org']['name']), 'style' => 'width:24px; height:24px'));
else echo h($object['Org']['name']);
echo $this->OrgImg->getOrgImg(array('name' => $object['Org']['name'], 'id' => $object['Org']['id'], 'size' => 24));
}
} else { ?>
&nbsp;

View File

@ -90,10 +90,7 @@
<?php if (Configure::read('MISP.showorg') || $isAdmin): ?>
<td class="short" ondblclick="document.location.href ='<?php echo $baseurl . "/events/index/searchorg:" . $event['Orgc']['id'];?>'">
<?php
$imgRelativePath = 'orgs' . DS . h($event['Orgc']['name']) . '.png';
$imgAbsolutePath = APP . WEBROOT_DIR . DS . 'img' . DS . $imgRelativePath;
if (file_exists($imgAbsolutePath)) echo $this->Html->image('orgs/' . h($event['Orgc']['name']) . '.png', array('alt' => h($event['Orgc']['name']), 'title' => h($event['Orgc']['name']), 'style' => 'width:24px; height:24px'));
else echo $this->Html->tag('span', h($event['Orgc']['name']), array('class' => 'welcome', 'style' => 'float:left;'));
echo $this->OrgImg->getOrgImg(array('name' => $event['Orgc']['name'], 'id' => $event['Orgc']['id'], 'size' => 24));
?>
&nbsp;
</td>
@ -101,10 +98,7 @@
<?php if ($isSiteAdmin || (Configure::read('MISP.showorgalternate') && Configure::read('MISP.showorg'))): ?>
<td class="short" ondblclick="document.location.href ='<?php echo $baseurl . "/events/index/searchorg:" . $event['Org']['id'];?>'">
<?php
$imgRelativePath = 'orgs' . DS . h($event['Org']['name']) . '.png';
$imgAbsolutePath = APP . WEBROOT_DIR . DS . 'img' . DS . $imgRelativePath;
if (file_exists($imgAbsolutePath)) echo $this->Html->image('orgs/' . h($event['Org']['name']) . '.png', array('alt' => h($event['Org']['name']), 'title' => h($event['Org']['name']), 'style' => 'width:24px; height:24px'));
else echo $this->Html->tag('span', h($event['Org']['name']), array('class' => 'welcome', 'style' => 'float:left;'));
echo $this->OrgImg->getOrgImg(array('name' => $event['Org']['name'], 'id' => $event['Org']['id'], 'size' => 24));
?>
&nbsp;
</td>

View File

@ -0,0 +1,40 @@
<?php
$branches = array('services', 'timeout', 'hover');
?>
<div class="templateTableRow ui-sortable-handle">
<div class="templateElementHeader" style="width:100%; position:relative;">
<div class="templateGlass"></div>
<div class="templateElementHeaderText"><?php echo h(__($type)); ?></div>
</div>
<div style="padding:10px;">
<div><?php echo h(__($moduleTypes[$type]['description'])); ?></div>
<div><span class="bold"><?php echo __('Status'); ?></span>: <span id="<?php echo h(strtolower($type)); ?>_type">&nbsp;</span></div>
<?php
foreach ($branches as $branch):
debug($modules[$type][$branch]);
if (isset($modules[$type][$branch])):
if (isset($modules[$type][$branch]['value'])) {
$modules[$type][$branch] = array($branch => $modules[$type][$branch]);
}
foreach ($modules[$type][$branch] as $setting => $data):
if ($branch == 'hover') $setting = 'hover_' . $setting;
if ($data['type'] == 'boolean') $data['value'] = $data['value'] ? 'Yes' : 'No';
?>
<div><span class="bold"><?php echo $setting; ?></span>: <?php echo h($data['value']); ?></div>
<?php
endforeach;
endif;
endforeach;
$moduleCounter = 0;
$enabledModuleCounter = 0;
if (!empty($modules[$type]['modules'])):
foreach ($modules[$type]['modules'] as $moduleType => $moduleSettings):
$moduleCounter++;
if ($moduleSettings['enabled']['value']) $enabledModuleCounter++;
endforeach;
endif;
debug($moduleCounter);
debug($enabledModuleCounter);
?>
</div>
</div>

View File

@ -47,9 +47,7 @@
<td class="discussionBoxTD discussionBoxTDMid discussionBoxTDMidLeft">
<?php
if (isset($post['org_name'])) {
$imgAbsolutePath = APP . WEBROOT_DIR . DS . 'img' . DS . 'orgs' . DS . h($post['org_name']) . '.png';
if (file_exists($imgAbsolutePath)) echo $this->Html->image('orgs/' . h($post['org_name']) . '.png', array('alt' => h($post['org_name']), 'title' => h($post['org_name']), 'style' => 'width:48px; height:48px'));
else echo $this->Html->tag('span', h($post['org_name']), array('class' => 'welcome', 'style' => 'float:center;'));
echo $this->OrgImg->getOrgImg(array('name' => $post['org_name'], 'id' => $post['org_id'], 'size' => 48));
} else {
echo 'Deactivated user';
}

View File

@ -59,10 +59,7 @@
<td class="short">
<?php
foreach ($event['orgArray'] as $k => $org) {
$imgRelativePath = 'orgs' . DS . h($org) . '.png';
$imgAbsolutePath = APP . WEBROOT_DIR . DS . 'img' . DS . $imgRelativePath;
if (file_exists($imgAbsolutePath)) echo $this->Html->image('orgs/' . h($orgs[$org]) . '.png', array('alt' => h($orgs[$org]), 'title' => h($orgs[$org]), 'style' => 'width:24px; height:24px'));
else echo $this->Html->tag('span', h($orgs[$org]), array('class' => 'welcome', 'style' => 'float:left;'));
echo $this->OrgImg->getOrgImg(array('name' => $orgs[$org], 'id' => $org, 'size' => 24));
if ((1 + $k) < (count($event['orgArray']))) echo '<br />';
}
?>

View File

@ -33,10 +33,7 @@ $mayPublish = ($isAclPublish && $event['Event']['orgc_id'] == $me['org_id']);
<tr>
<td class="short">
<?php
$imgRelativePath = 'orgs' . DS . h($item['Log']['org']) . '.png';
$imgAbsolutePath = APP . WEBROOT_DIR . DS . 'img' . DS . $imgRelativePath;
if (file_exists($imgAbsolutePath)) echo $this->Html->image('orgs/' . h($item['Log']['org']) . '.png', array('alt' => h($item['Log']['org']), 'title' => h($item['Log']['org']), 'style' => 'width:24px; height:24px'));
else echo $this->Html->tag('span', h($item['Log']['org']), array('class' => 'welcome', 'style' => 'float:left;'));
echo $this->OrgImg->getOrgImg(array('name' => $item['Log']['org'], 'size' => 24));
?>
&nbsp;
</td>

View File

@ -77,6 +77,7 @@
<?php endif; ?>
<th><?php echo $this->Paginator->sort('local');?></th>
<th>Users</th>
<th><?php echo $this->Paginator->sort('restrictions');?></th>
<th class="actions"><?php echo __('Actions');?></th>
</tr>
<?php
@ -85,10 +86,7 @@ foreach ($orgs as $org): ?>
<td class="short" ondblclick="document.location.href ='/organisations/view/<?php echo $org['Organisation']['id'];?>'"><?php echo h($org['Organisation']['id']); ?></td>
<td class="short" ondblclick="document.location.href ='/organisations/view/<?php echo $org['Organisation']['id'];?>'">
<?php
$imgRelativePath = 'orgs' . DS . h($org['Organisation']['name']) . '.png';
$imgAbsolutePath = APP . WEBROOT_DIR . DS . 'img' . DS . $imgRelativePath;
if (file_exists($imgAbsolutePath)) echo $this->Html->image('orgs/' . h($org['Organisation']['name']) . '.png', array('alt' => h($org['Organisation']['name']), 'title' => h($org['Organisation']['name']), 'style' => 'width:24px; height:24px'));
else echo __('N/A');
echo $this->OrgImg->getOrgImg(array('name' => $org['Organisation']['name'], 'id' => $org['Organisation']['id'], 'size' => 24));
?>
</td>
<td class="short" ondblclick="document.location.href ='/organisations/view/<?php echo $org['Organisation']['id'];?>'"><?php echo h($org['Organisation']['name']); ?></td>
@ -107,6 +105,13 @@ foreach ($orgs as $org): ?>
<?php endif; ?>
<td class="short <?php echo $org['Organisation']['local'] ? 'green' : 'red';?>" ondblclick="document.location.href ='/organisations/view/<?php echo $org['Organisation']['id'];?>'"><?php echo $org['Organisation']['local'] ? __('Yes') : __('No');?></td>
<td class="short"><?php echo isset($org['Organisation']['user_count']) ? $org['Organisation']['user_count'] : '0';?></td>
<td class="short">
<?php
if (!empty($org['Organisation']['restrictions'])) {
echo implode('<br />', h($org['Organisation']['restrictions']));
}
?>
</td>
<td class="short action-links">
<?php if ($isSiteAdmin): ?>
<a href='/admin/organisations/edit/<?php echo $org['Organisation']['id'];?>' class = "icon-edit" title = "<?php echo __('');?>Edit"></a>

View File

@ -17,13 +17,7 @@
<td class="short"><?php echo date('Y-m-d H:i:s', $item['Sighting']['date_sighting']);?></td>
<td class="short">
<?php
$imgAbsolutePath = APP . WEBROOT_DIR . DS . 'img' . DS . 'orgs' . DS . h($item['Organisation']['name']) . '.png';
if (file_exists($imgAbsolutePath)):
echo $this->Html->image('orgs/' . h($item['Organisation']['name']) . '.png', array('alt' => h($item['Organisation']['name']), 'title' => h($item['Organisation']['name']), 'style' => 'width:24px; height:24px'));
else:
echo h($item['Organisation']['name']);
endif;
echo $this->OrgImg->getOrgImg(array('name' => $item['Organisation']['name'], 'id' => $item['Organisation']['id'], 'size' => 24));
?>
</td>
<td class="short">

View File

@ -5,10 +5,7 @@
<div role="button" tabindex="0" aria-label="<?php echo h($template['Template']['description']); ?>" class="templateChoiceButton" style="width:100%;" title="<?php echo h($template['Template']['description']); ?>" onClick="document.location.href ='<?php echo $baseurl;?>/templates/populateEventFromTemplate/<?php echo h($template['Template']['id']);?>/<?php echo h($id); ?>'">
<div style="float:left;">
<?php
$imgRelativePath = 'orgs' . DS . h($template['Template']['org']) . '.png';
$imgAbsolutePath = APP . WEBROOT_DIR . DS . 'img' . DS . $imgRelativePath;
if (file_exists($imgAbsolutePath)) echo $this->Html->image('orgs/' . h($template['Template']['org']) . '.png', array('alt' => h($template['Template']['org']), 'title' => h($template['Template']['org']), 'style' => 'width:24px; height:24px'));
else echo $this->Html->tag('span', h($template['Template']['org']), array('class' => 'welcome', 'style' => 'float:left;'));
echo $this->OrgImg->getOrgImg(array('name' => $template['Template']['org'], 'size' => 24));
?>
</div>
<div><span style="position:relative;left:-12px;"><?php echo h($template['Template']['name']);?>&nbsp;</span></div>

View File

@ -32,10 +32,7 @@ foreach ($list as $item): ?>
<td class="short" onclick="document.location.href ='<?php echo $baseurl."/templates/view/".$item['Template']['id']; ?>'"><?php echo h($item['Template']['id']); ?>&nbsp;</td>
<td class="short" onclick="document.location.href ='<?php echo $baseurl."/templates/view/".$item['Template']['id']; ?>'">
<?php
$imgRelativePath = 'orgs' . DS . h($item['Template']['org']) . '.png';
$imgAbsolutePath = APP . WEBROOT_DIR . DS . 'img' . DS . $imgRelativePath;
if (file_exists($imgAbsolutePath)) echo $this->Html->image('orgs/' . h($item['Template']['org']) . '.png', array('alt' => h($item['Template']['org']), 'title' => h($item['Template']['org']), 'style' => 'width:24px; height:24px'));
else echo $this->Html->tag('span', h($item['Template']['org']), array('class' => 'welcome', 'style' => 'float:left;'));
echo $this->OrgImg->getOrgImg(array('name' => $item['Template']['org'], 'size' => 24));
?>
&nbsp;
</td>