mirror of https://github.com/MISP/MISP
new: [WIP] tag collections WIP
parent
54bb5f3d01
commit
3ba8c360bf
|
@ -519,6 +519,39 @@ class TagsController extends AppController
|
|||
$this->render('/Attributes/ajax/ajaxAttributeTags');
|
||||
}
|
||||
|
||||
public function showTagControllerTag($id)
|
||||
{
|
||||
$this->loadModel('TagCollection');
|
||||
$tagCollection = $this->TagCollection->find('first', array(
|
||||
'recursive' => -1,
|
||||
'contain' => array('TagCollection'),
|
||||
'conditions' => array('TagCollection.id' => $id)
|
||||
));
|
||||
if (empty($tagCollection) || (!$this->_isSiteAdmin() && $tagCollection['org_id'] !== $this->Auth->user('org_id'))) {
|
||||
throw new MethodNotAllowedException('Invalid tag_collection.');
|
||||
}
|
||||
$this->loadModel('GalaxyCluster');
|
||||
$cluster_names = $this->GalaxyCluster->find('list', array('fields' => array('GalaxyCluster.tag_name'), 'group' => array('GalaxyCluster.id', 'GalaxyCluster.tag_name')));
|
||||
$this->helpers[] = 'TextColour';
|
||||
$tags = $this->TagCollection->TagCollectionElement->find('all', array(
|
||||
'conditions' => array(
|
||||
'tag_collection_id' => $id,
|
||||
'Tag.name !=' => $cluster_names
|
||||
),
|
||||
'contain' => array('Tag'),
|
||||
'fields' => array('Tag.id', 'Tag.colour', 'Tag.name'),
|
||||
));
|
||||
$this->set('tags', $tags);
|
||||
$event = $this->Tag->EventTag->Event->find('first', array(
|
||||
'recursive' => -1,
|
||||
'fields' => array('Event.id', 'Event.orgc_id', 'Event.org_id', 'Event.user_id'),
|
||||
'conditions' => array('Event.id' => $id)
|
||||
));
|
||||
$this->set('event', $event);
|
||||
$this->layout = 'ajax';
|
||||
$this->render('/Events/ajax/ajaxTags');
|
||||
}
|
||||
|
||||
public function viewTag($id)
|
||||
{
|
||||
$tag = $this->Tag->find('first', array(
|
||||
|
@ -534,7 +567,7 @@ class TagsController extends AppController
|
|||
}
|
||||
|
||||
|
||||
public function selectTaxonomy($id, $attributeTag = false)
|
||||
public function selectTaxonomy($id, $scope = 'event')
|
||||
{
|
||||
if (!$this->_isSiteAdmin() && !$this->userRole['perm_tagger']) {
|
||||
throw new NotFoundException('You don\'t have permission to do that.');
|
||||
|
@ -548,16 +581,14 @@ class TagsController extends AppController
|
|||
unset($options[$k]);
|
||||
}
|
||||
}
|
||||
if ($attributeTag !== false) {
|
||||
$this->set('attributeTag', true);
|
||||
}
|
||||
$this->set('scope', $scope);
|
||||
$this->set('object_id', $id);
|
||||
$this->set('options', $options);
|
||||
$this->set('favourites', $favourites);
|
||||
$this->render('ajax/taxonomy_choice');
|
||||
}
|
||||
|
||||
public function selectTag($id, $taxonomy_id, $attributeTag = false, $filterData = '')
|
||||
public function selectTag($id, $taxonomy_id, $scope = 'event', $filterData = '')
|
||||
{
|
||||
if (!$this->_isSiteAdmin() && !$this->userRole['perm_tagger']) {
|
||||
throw new NotFoundException('You don\'t have permission to do that.');
|
||||
|
@ -587,10 +618,12 @@ class TagsController extends AppController
|
|||
} else {
|
||||
$taxonomies = $this->Taxonomy->getTaxonomy($taxonomy_id);
|
||||
$options = array();
|
||||
foreach ($taxonomies['entries'] as $entry) {
|
||||
if (!empty($entry['existing_tag']['Tag'])) {
|
||||
$options[$entry['existing_tag']['Tag']['id']] = $entry['existing_tag']['Tag']['name'];
|
||||
$expanded[$entry['existing_tag']['Tag']['id']] = $entry['expanded'];
|
||||
if (!empty($taxonomies['entries'])) {
|
||||
foreach ($taxonomies['entries'] as $entry) {
|
||||
if (!empty($entry['existing_tag']['Tag'])) {
|
||||
$options[$entry['existing_tag']['Tag']['id']] = $entry['existing_tag']['Tag']['name'];
|
||||
$expanded[$entry['existing_tag']['Tag']['id']] = $entry['expanded'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -624,9 +657,7 @@ class TagsController extends AppController
|
|||
unset($options[$hidden_tag]);
|
||||
unset($expanded[$hidden_tag]);
|
||||
}
|
||||
if ($attributeTag !== false && $attributeTag !== "false") {
|
||||
$this->set('attributeTag', true);
|
||||
}
|
||||
$this->set('scope', $scope);
|
||||
$this->set('object_id', $id);
|
||||
foreach ($options as $k => $v) {
|
||||
if (substr($v, 0, strlen('misp-galaxy:')) === 'misp-galaxy:') {
|
||||
|
|
|
@ -14,7 +14,14 @@ class TagCollection extends AppModel
|
|||
'roleModel' => 'Role',
|
||||
'roleKey' => 'role_id',
|
||||
'change' => 'full'
|
||||
)
|
||||
),
|
||||
'Containable'
|
||||
);
|
||||
|
||||
public $hasMany = array(
|
||||
'TagCollectionElement' => array(
|
||||
'dependent' => true
|
||||
)
|
||||
);
|
||||
|
||||
public $whitelistedItems = false;
|
||||
|
@ -30,4 +37,14 @@ class TagCollection extends AppModel
|
|||
),
|
||||
)
|
||||
);
|
||||
|
||||
public function beforeValidate($options = array())
|
||||
{
|
||||
parent::beforeValidate();
|
||||
// generate UUID if it doesn't exist
|
||||
if (empty($this->data['TagCollection']['uuid'])) {
|
||||
$this->data['TagCollection']['uuid'] = CakeText::uuid();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,20 +6,26 @@ class TagCollectionElement extends AppModel
|
|||
{
|
||||
public $useTable = 'tag_collection_elements';
|
||||
|
||||
public $displayField = 'name';
|
||||
|
||||
public $actsAs = array(
|
||||
'Trim',
|
||||
'SysLogLogable.SysLogLogable' => array(
|
||||
'roleModel' => 'Role',
|
||||
'roleKey' => 'role_id',
|
||||
'change' => 'full'
|
||||
)
|
||||
),
|
||||
'Containable'
|
||||
);
|
||||
|
||||
public $whitelistedItems = false;
|
||||
public $belongsTo = array(
|
||||
'TagCollection' => array(
|
||||
'className' => 'TagCollection',
|
||||
),
|
||||
'Tag' => array(
|
||||
'className' => 'Tag',
|
||||
)
|
||||
);
|
||||
|
||||
public $validate = array(
|
||||
|
||||
|
||||
);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
foreach ($items as $item):
|
||||
?>
|
||||
<tr>
|
||||
<td class="short"><?php echo h($item['TagCollection']['id']);?> </td>
|
||||
<td class="short"><?php echo h($item['TagCollection']['uuid']);?> </td>
|
||||
<td class="short"><?php echo h($item['TagCollection']['name']);?> </td>
|
||||
<td class="shortish">
|
||||
<div class="attributeTagContainer" id="#Tag_Collection_<?php echo h($item['TagCollection']['id']);?>_tr .attributeTagContainer">
|
||||
<?php
|
||||
echo $this->element(
|
||||
'ajaxTagCollectionTags',
|
||||
array(
|
||||
'attributeId' => $item['TagCollection']['id'],
|
||||
'attributeTags' => $item['TagCollectionElement'],
|
||||
'tagAccess' => ($isSiteAdmin || $me['org_id'] == $item['TagCollection']['org_id']),
|
||||
'context' => 'tagCollection',
|
||||
'tagCollection' => $item
|
||||
)
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
</td>
|
||||
<td class="shortish">
|
||||
<?php
|
||||
echo $this->element('galaxyQuickViewMini', array(
|
||||
'mayModify' => true,
|
||||
'isAclTagger' => true,
|
||||
'data' => array(),
|
||||
'target_id' => h($item['TagCollection']['id']),
|
||||
'target_type' => 'tag_collection'
|
||||
));
|
||||
?>
|
||||
</td>
|
||||
<td><?php echo h($item['TagCollection']['description']);?> </td>
|
||||
<td class="short action-links">
|
||||
<?php echo $this->Html->link('', array('action' => 'edit', $item['TagCollection']['id']), array('class' => 'icon-edit', 'title' => 'Edit'));?>
|
||||
<?php echo $this->Form->postLink('', array('admin' => true, 'action' => 'delete', $item['TagCollection']['id']), array('class' => 'icon-trash', 'title' => 'Delete'), __('Are you sure you want to delete "%s"?', $item['TagCollection']['name']));?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
endforeach;
|
|
@ -39,7 +39,7 @@
|
|||
if ($full) {
|
||||
$addTagButton = sprintf(
|
||||
'<button id="addTagButton" class="btn btn-inverse noPrint" style="line-height:10px; padding: 4px 4px;" onClick="getPopup(%s);">+</button>',
|
||||
sprintf("'%s/true', 'tags', 'selectTaxonomy'", h($attributeId))
|
||||
sprintf("'%s/attributes', 'tags', 'selectTaxonomy'", h($attributeId))
|
||||
);
|
||||
}
|
||||
echo $addTagButton;
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
<div style="width:100%;display:inline-block;">
|
||||
<?php
|
||||
if (empty($context)) {
|
||||
$context = 'event';
|
||||
}
|
||||
$full = $isAclTagger && $tagAccess;
|
||||
foreach ($tagCollection['TagCollectionElement'] as $tag):
|
||||
if (!isset($tag['Tag'])) $tag = array('Tag' => $tag);
|
||||
$tagClass = $full ? 'tagFirstHalf' : 'tag';
|
||||
?>
|
||||
<div style="padding:1px; overflow:hidden; white-space:nowrap; display:flex; float:left; margin-right:2px;">
|
||||
<div class="<?php echo $tagClass; ?>" style="display:inline-block; background-color:<?php echo h($tag['Tag']['colour']);?>;color:<?php echo $this->TextColour->getTextColour($tag['Tag']['colour']);?>"><?php echo h($tag['Tag']['name']); ?></div>
|
||||
<?php
|
||||
if ($full):
|
||||
?>
|
||||
<div class="tagSecondHalf useCursorPointer noPrint" title="<?php echo __('Remove tag');?>" role="button" tabindex="0" aria-label="<?php echo __('Remove tag');?>" onClick="removeObjectTagPopup('tag_collection', '<?php echo h($tagCollection['TagCollection']['id']); ?>', '<?php echo h($tag['Tag']['id']); ?>');">x</div>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
endforeach;
|
||||
?>
|
||||
<div style="float:left">
|
||||
<?php
|
||||
$addTagButton = ' ';
|
||||
if ($full) {
|
||||
$addTagButton = sprintf(
|
||||
'<button id="addTagButton" class="btn btn-inverse noPrint" style="line-height:10px; padding: 4px 4px;" onClick="getPopup(%s);">+</button>',
|
||||
sprintf("'%s/tag_collection', 'tags', 'selectTaxonomy'", h($tagCollection['TagCollection']['id']))
|
||||
);
|
||||
}
|
||||
echo $addTagButton;
|
||||
?>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
$this->Paginator->options(array(
|
||||
'update' => '.span12',
|
||||
'evalScripts' => true,
|
||||
'before' => '$(".progress").show()',
|
||||
'complete' => '$(".progress").hide()',
|
||||
));
|
||||
$title = sprintf('<h2>%s</h2>', Inflector::humanize($controller));
|
||||
if (!empty($description)) {
|
||||
$description = sprintf('<p>%s</p>', Inflector::humanize($description));
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
$pagination = sprintf(
|
||||
'<div class="pagination"><ul>%s%s%s</ul></div>',
|
||||
$this->Paginator->prev('« ' . __('previous'), array('tag' => 'li', 'escape' => false), null, array('tag' => 'li', 'class' => 'prev disabled', 'escape' => false, 'disabledTag' => 'span')),
|
||||
$this->Paginator->numbers(array('modulus' => 20, 'separator' => '', 'tag' => 'li', 'currentClass' => 'active', 'currentTag' => 'span')),
|
||||
$this->Paginator->next(__('next') . ' »', array('tag' => 'li', 'escape' => false), null, array('tag' => 'li', 'class' => 'next disabled', 'escape' => false, 'disabledTag' => 'span'))
|
||||
);
|
||||
$table_headers = '';
|
||||
foreach ($headers as $header => $data) {
|
||||
if (!empty($data['sort'])) {
|
||||
if (!empty($data['alias'])) {
|
||||
$header_data = $this->Paginator->sort($header, $data['alias']);
|
||||
} else {
|
||||
$header_data = $this->Paginator->sort($header);
|
||||
}
|
||||
} else {
|
||||
$header_data = Inflector::humanize(h($header));
|
||||
}
|
||||
$action = ($header === 'Actions') ? ' class="actions"' : '';
|
||||
$table_headers .= '<th' . $action . '>' . $header_data . '</th>';
|
||||
}
|
||||
$table_contents = $this->element($row_path, array(
|
||||
'items' => $items
|
||||
));
|
||||
$table = sprintf(
|
||||
'<table class="table table-striped table-hover table-condensed">%s%s</table>',
|
||||
$table_headers,
|
||||
$table_contents
|
||||
);
|
||||
$pagination_details = sprintf(
|
||||
'<p>%s</p>',
|
||||
$this->Paginator->counter(
|
||||
array(
|
||||
'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
|
||||
)
|
||||
)
|
||||
);
|
||||
echo sprintf(
|
||||
'<div class="%s index">%s%s%s%s%s%s</div>',
|
||||
$controller,
|
||||
$title,
|
||||
$description,
|
||||
$pagination,
|
||||
$table,
|
||||
$pagination_details,
|
||||
$pagination
|
||||
);
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
$this->Paginator->options(array(
|
||||
'update' => '.span12',
|
||||
'evalScripts' => true,
|
||||
'before' => '$(".progress").show()',
|
||||
'complete' => '$(".progress").hide()',
|
||||
));
|
||||
$title = sprintf('<h2>%s index</h2>', Inflector::humanize($controller));
|
||||
if (!empty($description)) {
|
||||
$description = sprintf('<p>%s</p>', Inflector::humanize($description));
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
$pagination = sprintf(
|
||||
'<div class="pagination"><ul>%s%s%s</ul></div>',
|
||||
$this->Paginator->prev('« ' . __('previous'), array('tag' => 'li', 'escape' => false), null, array('tag' => 'li', 'class' => 'prev disabled', 'escape' => false, 'disabledTag' => 'span')),
|
||||
$this->Paginator->numbers(array('modulus' => 20, 'separator' => '', 'tag' => 'li', 'currentClass' => 'active', 'currentTag' => 'span')),
|
||||
$this->Paginator->next(__('next') . ' »', array('tag' => 'li', 'escape' => false), null, array('tag' => 'li', 'class' => 'next disabled', 'escape' => false, 'disabledTag' => 'span'))
|
||||
);
|
||||
$table_headers = '';
|
||||
foreach ($headers as $header => $data) {
|
||||
if (!empty($data['sort'])) {
|
||||
if (!empty($data['alias'])) {
|
||||
$header_data = $this->Paginator->sort($header, $data['alias']);
|
||||
} else {
|
||||
$header_data = $this->Paginator->sort($header);
|
||||
}
|
||||
} else {
|
||||
$header_data = '<th>' . h($header) . '</th>';
|
||||
}
|
||||
$table_headers .= $header_data;
|
||||
}
|
||||
$table_contents = $this->element($row_path, array(
|
||||
'items' => $items
|
||||
));
|
||||
$table = sprintf(
|
||||
'<table class="table table-striped table-hover table-condensed">%s%s</table>',
|
||||
$table_header,
|
||||
$table_contents
|
||||
);
|
||||
$pagination_details = sprintf(
|
||||
'<p>%s</p>',
|
||||
$this->Paginator->counter(
|
||||
array(
|
||||
'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
|
||||
)
|
||||
)
|
||||
);
|
||||
echo sprintf(
|
||||
'<div class="%s index">%s%s%s%s%s%s</div>',
|
||||
$controller,
|
||||
$title,
|
||||
$description,
|
||||
$pagination,
|
||||
$table,
|
||||
$pagination_details,
|
||||
$pagination
|
||||
);
|
||||
echo $this->element('side_menu', array('menuList' => 'whitelist', 'menuItem' => 'index'));
|
|
@ -33,6 +33,7 @@
|
|||
<li><a href="<?php echo $baseurl;?>/events/proposalEventIndex"><?php echo __('Events with proposals');?></a></li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="<?php echo $baseurl;?>/tags/index"><?php echo __('List Tags');?></a></li>
|
||||
<li><a href="<?php echo $baseurl;?>/tag_collections/index"><?php echo __('List Tag Collections');?></a></li>
|
||||
<?php if ($isAclTagEditor): ?>
|
||||
<li><a href="<?php echo $baseurl;?>/tags/add"><?php echo __('Add Tag');?></a></li>
|
||||
<?php endif; ?>
|
||||
|
|
|
@ -181,6 +181,25 @@
|
|||
}
|
||||
break;
|
||||
|
||||
case 'tag-collections':
|
||||
echo $this->element('/side_menu_link', array(
|
||||
'url' => '/tag_collections/index',
|
||||
'text' => __('List Tag Collections')
|
||||
));
|
||||
if ($isAclTagEditor) {
|
||||
echo $this->element('/side_menu_link', array(
|
||||
'url' => '/tag_collections/add',
|
||||
'text' => __('Add Tag Collection')
|
||||
));
|
||||
if (($menuItem === 'edit')) {
|
||||
echo $this->element('/side_menu_link', array(
|
||||
'url' => '/tag_collections/edit/' . $id,
|
||||
'text' => __('Add Tag Collection')
|
||||
));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'event-collection':
|
||||
echo $this->element('/side_menu_link', array(
|
||||
'element_id' => 'index',
|
||||
|
|
|
@ -9,14 +9,9 @@ foreach ($events as $key => $event) {
|
|||
$events[$key]['GalaxyCluster'] = $event['GalaxyCluster'];
|
||||
}
|
||||
if (isset($event['EventTag'])) $events[$key]['EventTag'] = $event['EventTag'];
|
||||
if (!empty($events[$key]['SharingGroup'])) $events[$key]['SharingGroup'] = $event['SharingGroup'];
|
||||
|
||||
// cleanup the array from things we do not want to expose
|
||||
unset($events[$key]['user_id']);
|
||||
// hide the org field if we are not in showorg mode
|
||||
if (!Configure::read('MISP.showorg')) {
|
||||
unset($events[$key]['Org']);
|
||||
unset($events[$key]['Orgc']);
|
||||
if (!empty($event['SharingGroup'])) {
|
||||
$events[$key]['SharingGroup'] = $event['SharingGroup'];
|
||||
}
|
||||
unset($events[$key]['user_id']);
|
||||
}
|
||||
echo json_encode($events);
|
||||
|
|
|
@ -2,10 +2,12 @@
|
|||
<legend><?php echo __('Select Tag');?></legend>
|
||||
<div style="display:none;">
|
||||
<?php
|
||||
if (isset($attributeTag)) {
|
||||
if ($scope === 'attribute') {
|
||||
echo $this->Form->create('Attribute', array('url' => '/attributes/addTag/' . $object_id, 'style' => 'margin:0px;'));
|
||||
} else {
|
||||
} elseif ($scope === 'event') {
|
||||
echo $this->Form->create('Event', array('url' => '/events/addTag/' . $object_id, 'style' => 'margin:0px;'));
|
||||
} elseif ($scope === 'tag_collection') {
|
||||
echo $this->Form->create('TagCollection', array('url' => '/tag_collections/addTag/' . $object_id, 'style' => 'margin:0px;'));
|
||||
}
|
||||
echo $this->Form->input('attribute_ids', array('style' => 'display:none;', 'label' => false));
|
||||
echo $this->Form->input('tag', array('value' => 0));
|
||||
|
@ -19,16 +21,23 @@
|
|||
<table style="width:100%;">
|
||||
<?php foreach ($options as $k => &$option): ?>
|
||||
<tr style="border-top:1px solid black;" class="templateChoiceButton shown" id="field_<?php echo h($k); ?>">
|
||||
<?php if (isset($attributeTag)): ?>
|
||||
<td style="padding-left:10px;padding-right:10px; text-align:center;width:100%;" onClick="quickSubmitAttributeTagForm('<?php echo h($object_id);?>', '<?php echo h($k); ?>');" title="<?php echo h($expanded[$k]);?>" role="button" tabindex="0" aria-label="Attach tag <?php echo h($option); ?>"><?php echo h($option); ?></td>
|
||||
<?php else: ?>
|
||||
<td style="padding-left:10px;padding-right:10px; text-align:center;width:100%;" onClick="quickSubmitTagForm('<?php echo h($object_id);?>', '<?php echo h($k); ?>');" title="<?php echo h($expanded[$k]);?>" role="button" tabindex="0" aria-label="<?php echo __('Attach tag');?> <?php echo h($option); ?>"><?php echo h($option); ?></td>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
$onClickForm = 'quickSubmitTagForm';
|
||||
if ($scope === 'attribute') {
|
||||
$onClickForm = 'quickSubmitAttributeTagForm';
|
||||
}
|
||||
if ($scope === 'tag_collection') {
|
||||
$onClickForm = 'quickSubmitTagCollectionTagForm';
|
||||
}
|
||||
echo '<td style="padding-left:10px;padding-right:10px; text-align:center;width:100%;" onClick="' . $onClickForm .
|
||||
'(\'' . h($object_id) . '\', \'' . h($k) . '\');" title="' . h($expanded[$k]) . '" role="button" tabindex="0" aria-label="' .
|
||||
__('Attach tag') . ' ' . h($option) . '">' . h($option) . '</td>';
|
||||
?>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</div>
|
||||
<div role="button" tabindex="0" aria-label="<?php echo __('Return to taxonomy selection');?>" class="popover-back useCursorPointer" onClick="getPopup('<?php echo h($object_id); if (isset($attributeTag)) echo '/true'; ?>', 'tags', 'selectTaxonomy');" title="<?php echo __('Select Taxonomy');?>"><?php echo __('Back to Taxonomy Selection');?></div>
|
||||
<div role="button" tabindex="0" aria-label="<?php echo __('Return to taxonomy selection');?>" class="popover-back useCursorPointer" onClick="getPopup('<?php echo h($object_id) . '/' . h($scope); ?>', 'tags', 'selectTaxonomy');" title="<?php echo __('Select Taxonomy');?>"><?php echo __('Back to Taxonomy Selection');?></div>
|
||||
<div role="button" tabindex="0" aria-label="<?php echo __('Cancel');?>" class="templateChoiceButton templateChoiceButtonLast" onClick="cancelPopoverForm();"><?php echo __('Cancel');?></div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
|
@ -64,4 +73,4 @@
|
|||
resizePopoverBody();
|
||||
});
|
||||
</script>
|
||||
<?php echo $this->Html->script('tag-selection-keyboard-navigation.js'); ?>
|
||||
<?php echo $this->Html->script('tag-selection-keyboard-navigation.js'); ?>
|
||||
|
|
|
@ -5,22 +5,60 @@
|
|||
</div>
|
||||
<div class="popover_choice_main" id ="popover_choice_main">
|
||||
<table style="width:100%;">
|
||||
<?php if ($favourites): ?>
|
||||
<tr style="border-bottom:1px solid black;" class="templateChoiceButton">
|
||||
<td style="padding-left:10px;padding-right:10px; text-align:center;width:100%;" onClick="getPopup('<?php echo h($object_id); ?>/favourites<?php if (isset($attributeTag)) echo '/true' ?>', 'tags', 'selectTag');"><?php echo __('Favourite Tags');?></td>
|
||||
</tr>
|
||||
<?php endif;?>
|
||||
<tr style="border-bottom:1px solid black;" class="templateChoiceButton">
|
||||
<td style="padding-left:10px;padding-right:10px; text-align:center;width:100%;" onClick="getPopup('<?php echo h($object_id); ?>/0<?php if (isset($attributeTag)) echo '/true'; ?>', 'tags', 'selectTag');"><?php echo __('Custom Tags');?></td>
|
||||
</tr>
|
||||
<tr style="border-bottom:1px solid black;" class="templateChoiceButton">
|
||||
<td id="allTags" style="padding-left:10px;padding-right:10px; text-align:center;width:100%;" data-url="<?php echo h($object_id); ?>/all<?php if (isset($attributeTag)) echo '/true/'; else echo '/false/'; ?>" onClick="getPopup(this.getAttribute('data-url') + $('#filterField').val(), 'tags', 'selectTag');"><?php echo __('All Tags');?></td>
|
||||
</tr>
|
||||
<?php foreach ($options as $k => &$option): ?>
|
||||
<tr style="border-bottom:1px solid black;" class="templateChoiceButton">
|
||||
<td style="padding-left:10px;padding-right:10px; text-align:center;width:100%;" onClick="getPopup('<?php echo h($object_id); ?>/<?php echo h($k); if (isset($attributeTag)) echo '/true'; ?>', 'tags', 'selectTag');"><?php echo __('Taxonomy Library');?>: <?php echo h($option); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php
|
||||
if ($favourites) {
|
||||
echo sprintf(
|
||||
'<tr style="border-bottom:1px solid black;" class="templateChoiceButton">%s</tr>',
|
||||
sprintf(
|
||||
'<td style="padding-left:10px;padding-right:10px; text-align:center;width:100%%;" onClick="getPopup(\'%s/favourites/%s\', \'tags\', \'selectTag\');">%s</td>',
|
||||
h($object_id),
|
||||
h($scope),
|
||||
__('Favourite Tags')
|
||||
)
|
||||
);
|
||||
}
|
||||
if ($scope !== 'tag_collection') {
|
||||
echo sprintf(
|
||||
'<tr style="border-bottom:1px solid black;" class="templateChoiceButton">%s</tr>',
|
||||
sprintf(
|
||||
'<td style="padding-left:10px;padding-right:10px; text-align:center;width:100%%;" onClick="getPopup(\'%s/collections/%s\', \'tags\', \'selectTag\');">%s</td>',
|
||||
h($object_id),
|
||||
h($scope),
|
||||
__('Tag Collections')
|
||||
)
|
||||
);
|
||||
}
|
||||
echo sprintf(
|
||||
'<tr style="border-bottom:1px solid black;" class="templateChoiceButton">%s</tr>',
|
||||
sprintf(
|
||||
'<td style="padding-left:10px;padding-right:10px; text-align:center;width:100%%;" onClick="getPopup(\'%s/0/%s\', \'tags\', \'selectTag\');">%s</td>',
|
||||
h($object_id),
|
||||
h($scope),
|
||||
__('Custom Tags')
|
||||
)
|
||||
);
|
||||
echo sprintf(
|
||||
'<tr style="border-bottom:1px solid black;" class="templateChoiceButton">%s</tr>',
|
||||
sprintf(
|
||||
'<td id="allTags" style="padding-left:10px;padding-right:10px; text-align:center;width:100%%;" data-url="%s/all/%s" onClick="getPopup(this.getAttribute(\'data-url\') + $(\'#filterField\').val(), \'tags\', \'selectTag\');">%s</td>',
|
||||
h($object_id),
|
||||
h($scope),
|
||||
__('All Tags')
|
||||
)
|
||||
);
|
||||
foreach ($options as $k => &$option) {
|
||||
echo sprintf(
|
||||
'<tr style="border-bottom:1px solid black;" class="templateChoiceButton">%s</tr>',
|
||||
sprintf(
|
||||
'<td style="padding-left:10px;padding-right:10px; text-align:center;width:100%%;" onClick="getPopup(\'%s/%s\', \'tags\', \'selectTag\');">%s: %s</td>',
|
||||
h($object_id),
|
||||
h($scope),
|
||||
__('Taxonomy Library'),
|
||||
h($option)
|
||||
)
|
||||
);
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</div>
|
||||
<div class="templateChoiceButton templateChoiceButtonLast" onClick="cancelPopoverForm();"><?php echo __('Cancel');?></div>
|
||||
|
@ -50,7 +88,7 @@
|
|||
}
|
||||
}
|
||||
}, 500);
|
||||
|
||||
|
||||
}
|
||||
|
||||
$('#filterField').keyup(onKeyUp);
|
||||
|
|
|
@ -610,6 +610,31 @@ function quickSubmitAttributeTagForm(attribute_id, tag_id) {
|
|||
return false;
|
||||
}
|
||||
|
||||
function quickSubmitTagCollectionTagForm(tag_collection_id, tag_id) {
|
||||
$('#TagCollectionTag').val(tag_id);
|
||||
$.ajax({
|
||||
data: $('#TagCollectionSelectTagForm').closest("form").serialize(),
|
||||
beforeSend: function (XMLHttpRequest) {
|
||||
$(".loading").show();
|
||||
},
|
||||
success:function (data, textStatus) {
|
||||
handleGenericAjaxResponse(data);
|
||||
},
|
||||
error:function() {
|
||||
showMessage('fail', 'Could not add tag.');
|
||||
loadTagCollectionTags(tag_collection_id);
|
||||
},
|
||||
complete:function() {
|
||||
$("#popover_form").fadeOut();
|
||||
$("#gray_out").fadeOut();
|
||||
$(".loading").hide();
|
||||
},
|
||||
type:"post",
|
||||
url:"/tag_collections/addTag/" + tag_collection_id
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function handleAjaxEditResponse(data, name, type, id, field, event) {
|
||||
responseArray = data;
|
||||
if (type == 'Attribute') {
|
||||
|
@ -841,6 +866,17 @@ function loadEventTags(id) {
|
|||
});
|
||||
}
|
||||
|
||||
function loadTagCollectionTags(id) {
|
||||
$.ajax({
|
||||
dataType:"html",
|
||||
cache: false,
|
||||
success:function (data, textStatus) {
|
||||
$(".tagCollectionTagContainer").html(data);
|
||||
},
|
||||
url:"/tags/showEventTag/" + id,
|
||||
});
|
||||
}
|
||||
|
||||
function removeEventTag(event, tag) {
|
||||
var answer = confirm("Are you sure you want to remove this tag from the event?");
|
||||
if (answer) {
|
||||
|
@ -898,6 +934,8 @@ function removeObjectTag(context, object, tag) {
|
|||
$("#gray_out").fadeOut();
|
||||
if (context == 'Attribute') {
|
||||
loadAttributeTags(object);
|
||||
} else if (context == 'TagCollection') {
|
||||
|
||||
} else {
|
||||
loadEventTags(object);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue