parent
7e050954c3
commit
85c7132b30
@ -41,12 +41,14 @@ class LDIF extends Export
|
||||
|
||||
// Display Attributes
|
||||
foreach ($o->getObjects() as $ao) {
|
||||
foreach ($ao->values as $value) {
|
||||
$result .= $this->multiLineDisplay(
|
||||
Str::isAscii($value)
|
||||
? sprintf('%s: %s',$ao->name,$value)
|
||||
: sprintf('%s:: %s',$ao->name,base64_encode($value))
|
||||
,$this->br);
|
||||
foreach ($ao->values as $tag => $tagvalues) {
|
||||
foreach ($tagvalues as $value) {
|
||||
$result .= $this->multiLineDisplay(
|
||||
Str::isAscii($value)
|
||||
? sprintf('%s: %s',$ao->name.($tag ? ';'.$tag : ''),$value)
|
||||
: sprintf('%s:: %s',$ao->name.($tag ? ';'.$tag : ''),base64_encode($value))
|
||||
,$this->br);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -179,34 +179,34 @@ class Entry extends Model
|
||||
$result = collect();
|
||||
$entry_oc = Arr::get($this->attributes,'objectclass',[]);
|
||||
|
||||
foreach ($this->attributes as $attribute => $values) {
|
||||
foreach ($this->attributes as $attrtag => $values) {
|
||||
// If the attribute name has tags
|
||||
$matches = [];
|
||||
if (preg_match('/^([a-zA-Z]+)(;([a-zA-Z-;]+))+/',$attribute,$matches)) {
|
||||
if (preg_match('/^([a-zA-Z]+);+([a-zA-Z-;]+)/',$attrtag,$matches)) {
|
||||
$attribute = $matches[1];
|
||||
|
||||
// If the attribute doesnt exist we'll create it
|
||||
$o = Arr::get(
|
||||
$result,
|
||||
$attribute,
|
||||
Factory::create(
|
||||
$this->dn,
|
||||
$attribute,
|
||||
Arr::get($this->original,$attribute,[]),
|
||||
$entry_oc,
|
||||
));
|
||||
$o->setLangTag($matches[3],$values);
|
||||
$tags = $matches[2];
|
||||
|
||||
} else {
|
||||
$o = Factory::create($this->dn,$attribute,Arr::get($this->original,$attribute,[]),$entry_oc);
|
||||
$attribute = $attrtag;
|
||||
$tags = NULL;
|
||||
}
|
||||
|
||||
if (! $result->has($attribute)) {
|
||||
// Store our new values to know if this attribute has changed
|
||||
$o->values = collect($values);
|
||||
$orig = Arr::get($this->original,$attrtag,[]);
|
||||
|
||||
$result->put($attribute,$o);
|
||||
}
|
||||
// If the attribute doesnt exist we'll create it
|
||||
$o = Arr::get(
|
||||
$result,
|
||||
$attribute,
|
||||
Factory::create(
|
||||
$this->dn,
|
||||
$attribute,
|
||||
[$tags=>$orig],
|
||||
$entry_oc,
|
||||
));
|
||||
|
||||
$o->values = $o->values->merge([$tags=>$values]);
|
||||
|
||||
$result->put($attribute,$o);
|
||||
}
|
||||
|
||||
$sort = collect(config('pla.attr_display_order',[]))->map(fn($item)=>strtolower($item));
|
||||
@ -274,6 +274,35 @@ class Entry extends Model
|
||||
->filter(fn($item)=>$item->is_internal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify the language tags (RFC 3866) used by this entry
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getLangTags(): Collection
|
||||
{
|
||||
return $this->getObjects()
|
||||
->map(fn($item)=>$item
|
||||
->values
|
||||
->keys()
|
||||
->filter(fn($item)=>preg_match('/lang-[A-Za-z0-9-]+;?/',$item)))
|
||||
->filter(fn($item)=>$item->count());
|
||||
}
|
||||
|
||||
/**
|
||||
* Of all the items with lang tags, which ones have more than 1 lang tag
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getLangMultiTags(): Collection
|
||||
{
|
||||
return $this->getLangTags()
|
||||
->map(fn($item)=>$item->values()
|
||||
->map(fn($item)=>explode(';',$item))
|
||||
->filter(fn($item)=>count($item) > 1))
|
||||
->filter(fn($item)=>$item->count());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an attribute as an object
|
||||
*
|
||||
@ -299,6 +328,28 @@ class Entry extends Model
|
||||
return $this->objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find other attribute tags used by this entry
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getOtherTags(): Collection
|
||||
{
|
||||
return $this->getObjects()
|
||||
->map(fn($item)=>$item
|
||||
->values
|
||||
->keys()
|
||||
->filter(fn($item)=>
|
||||
$item && collect(explode(';',$item))->filter(
|
||||
fn($item)=>
|
||||
(! preg_match('/^lang-[A-Za-z0-9-]+$/',$item))
|
||||
&& (! preg_match('/^binary$/',$item))
|
||||
)
|
||||
->count())
|
||||
)
|
||||
->filter(fn($item)=>$item->count());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of attributes without any values
|
||||
*
|
||||
|
@ -0,0 +1,9 @@
|
||||
<div class="alert alert-danger p-0" style="font-size: .80em;">
|
||||
<table class="table table-borderless table-danger p-0 m-0">
|
||||
<tr>
|
||||
<td class="align-top" style="width: 5%;"><i class="fas fa-fw fa-2x fa-exclamation-triangle"></i></td>
|
||||
<td>Unable to display this attribute as it has attribute tags [<strong>{!! $tags->join('</strong>, <strong>') !!}</strong>].<br>
|
||||
You can manage it with an LDIF import.</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
@ -1,23 +1,29 @@
|
||||
<!-- $o=KrbTicketFlags::class -->
|
||||
<x-attribute.layout :edit="$edit ?? FALSE" :new="$new ?? FALSE" :o="$o">
|
||||
@foreach(($o->values->count() ? $o->values : ($new ? [0] : NULL)) as $value)
|
||||
@if($edit)
|
||||
<div id="32"></div>
|
||||
<div id="16"></div>
|
||||
<!-- krbticketflags cannot handle multivalue tags -->
|
||||
@if($o->values->keys()->count() <= 1)
|
||||
@foreach((count($o->values->first()) ? $o->values->first() : ($new ? [0] : NULL)) as $value)
|
||||
@if($edit)
|
||||
<div id="32"></div>
|
||||
<div id="16"></div>
|
||||
|
||||
<div class="input-group has-validation mb-3">
|
||||
<input type="hidden" @class(['form-control','is-invalid'=>($e=$errors->get($o->name_lc.'.'.$loop->index)),'mb-1','border-focus'=>$o->values->contains($value)]) name="{{ $o->name_lc }}[]" value="{{ $value }}" @readonly(true)>
|
||||
<div class="input-group has-validation mb-3">
|
||||
<input type="hidden" @class(['form-control','is-invalid'=>($e=$errors->get($o->name_lc.'.'.$loop->index)),'mb-1','border-focus'=>$o->values->contains($value)]) name="{{ $o->name_lc }}[]" value="{{ $value }}" @readonly(true)>
|
||||
|
||||
<div class="invalid-feedback pb-2">
|
||||
@if($e)
|
||||
{{ join('|',$e) }}
|
||||
@endif
|
||||
<div class="invalid-feedback pb-2">
|
||||
@if($e)
|
||||
{{ join('|',$e) }}
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@else
|
||||
{{ $value }}
|
||||
@endif
|
||||
@endforeach
|
||||
@else
|
||||
{{ $value }}
|
||||
@endif
|
||||
@endforeach
|
||||
|
||||
@else
|
||||
<x-alert.attribute_tags_cant_manage :tags="$o->values->keys()"/>
|
||||
@endif
|
||||
</x-attribute.layout>
|
||||
|
||||
@section($o->name_lc.'-scripts')
|
||||
|
@ -26,6 +26,12 @@
|
||||
<x-attribute :o="$o->getObject('entryuuid')" :na="__('Unknown')"/>
|
||||
</th>
|
||||
</tr>
|
||||
@if(($x=$o->getLangTags())->count())
|
||||
<tr class="mt-1">
|
||||
<td class="p-0 pe-2">Tags</td>
|
||||
<th class="p-0">{{ $x->flatMap(fn($item)=>$item->values())->unique()->join(', ') }}</th>
|
||||
</tr>
|
||||
@endif
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
Loading…
x
Reference in New Issue
Block a user