#PHRAS-610 #time 1h

cleanup
This commit is contained in:
Jean-Yves Gaulier
2015-08-18 17:13:19 +02:00
parent ef7de07b1a
commit 8bbce8c0cc
2 changed files with 4 additions and 111 deletions

View File

@@ -44,115 +44,8 @@ class databox_status
); );
} }
ksort($structures); ksort($structures);
file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d) %s\n", __FILE__, __LINE__, var_export($structures, true)), FILE_APPEND);
return $structures; return $structures;
foreach ($structures as $databox_id => $structure) {
foreach($structure as $bit => $status) {
$key = RecordHelper::normalizeFlagKey($status['labelon']);
if (isset($stats[$key])) {
$status = $stats[$key];
}
$status['sbas'][] = $databox_id;
$status['bit'] = $bit;
$stats[$key] = $status;
}
}
file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d) %s\n", __FILE__, __LINE__, var_export($stats, true)), FILE_APPEND);
return $stats;
}
public static function no_getSearchStatus(Application $app)
{
$see_all = $structures = $stats = [];
foreach ($app->getAclForUser($app->getAuthenticatedUser())->get_granted_sbas() as $databox) {
$see_all[$databox->get_sbas_id()] = false;
foreach ($databox->get_collections() as $collection) {
if ($app->getAclForUser($app->getAuthenticatedUser())->has_right_on_base($collection->get_base_id(), 'chgstatus')) {
$see_all[$databox->get_sbas_id()] = true;
break;
}
}
$structures[$databox->get_sbas_id()] = $databox->getStatusStructure();
}
// order the result by bit number, ...
$tbits = [];
foreach ($structures as $databox_id => $structure) {
if (false === $see_all[$databox_id]) {
$structure = array_filter($structure->toArray(), function ($status) {
return (bool)$status['searchable'];
});
}
foreach($structure as $bit => $status) {
if(!array_key_exists($bit, $tbits)) {
$tbits[$bit] = [];
}
$tbits[$bit][$databox_id] = $status;
}
}
ksort($tbits);
// file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d) %s\n", __FILE__, __LINE__, var_export($tbits, true)), FILE_APPEND);
// ... but group the status with same name
foreach($tbits as $bit=>$tbas) {
foreach($tbas as $sbas_id=>$status) {
// the group-key is the "labelon"
$key = RecordHelper::normalizeFlagKey($status['labelon']);
if(!array_key_exists($key, $stats)) {
$stats[$key] = $status;
$stats[$key]['sbas'] = [];
// $stats[$key]['tbas'] = [];
}
else {
/*
if($stats[$key]['bit'] != $bit) {
// error : in es, 2 sb with same name MUST be at the same position
throw new UnexpectedValueException(
sprintf("statusbit '%s' found at position %d and position %d"
, $key, $stats[$key]['bit'], $bit
)
);
}
*/
}
$stats[$key]['sbas'][] = $sbas_id;
// $stats[$key]['tbas'][$sbas_id] = $status;
}
}
file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d) %s\n", __FILE__, __LINE__, var_export($stats, true)), FILE_APPEND);
return $stats;
foreach ($structures as $databox_id => $structure) {
file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d) %s\n%s\n", __FILE__, __LINE__, var_export($databox_id, true), var_export($structure->toArray(), true)), FILE_APPEND);
if (false === $see_all[$databox_id]) {
$structure = array_filter($structure->toArray(), function ($status) {
return (bool) $status['searchable'];
});
}
foreach($structure as $bit => $status) {
$key = RecordHelper::normalizeFlagKey($status['labelon']);
file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d) %d:%s\n", __FILE__, __LINE__, $bit, $key), FILE_APPEND);
if (isset($stats[$key])) {
$status = $stats[$key];
}
$status['sbas'][] = $databox_id;
$status['bit'] = $bit;
$stats[$key] = $status;
}
}
file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d) %s\n", __FILE__, __LINE__, var_export($stats, true)), FILE_APPEND);
return $stats;
} }
public static function deleteIcon(Application $app, $databox_id, $bit, $switch) public static function deleteIcon(Application $app, $databox_id, $bit, $switch)

View File

@@ -5,7 +5,7 @@
<div class="sbas_list sbas_{{sbas_id}}" style="margin-bottom: 10px;"> <div class="sbas_list sbas_{{sbas_id}}" style="margin-bottom: 10px;">
<input type="hidden" name="reference" value="{{sbas_id}}"/> <input type="hidden" name="reference" value="{{sbas_id}}"/>
<div class="clksbas"> <div class="clksbas">
<span onclick="deploy(this, '.sbascont_{{sbas_id}}' );" class="deployer_opened" ></span> <span onclick="deploy(this, '.sbascont_{{sbas_id}}' );" class="deployer_closed" ></span>
<input type="checkbox" checked style="display: none;" id="sbasChkr_{{sbas_id}}_{{unique_id}}" class="sbasChkr_{{sbas_id}}" <input type="checkbox" checked style="display: none;" id="sbasChkr_{{sbas_id}}_{{unique_id}}" class="sbasChkr_{{sbas_id}}"
onchange="clksbas(this, {{sbas_id}});" /> onchange="clksbas(this, {{sbas_id}});" />
<label id="ADVSRCH_SBAS_LABEL_{{sbas_id}}" style="display: inline" class="checkbox danger_indicator" for="sbasChkr_{{sbas_id}}_{{unique_id}}"> <label id="ADVSRCH_SBAS_LABEL_{{sbas_id}}" style="display: inline" class="checkbox danger_indicator" for="sbasChkr_{{sbas_id}}_{{unique_id}}">
@@ -15,7 +15,7 @@
</span> </span>
</label> </label>
</div> </div>
<div class="sbascont sbascont_{{sbas_id}}" style="-moz-column-width:150px; -webkit-column-width: 150px; -moz-column-gap: 20px; -webkit-column-gap: 20px;"> <div class="sbascont sbascont_{{sbas_id}}" style="display:none; -moz-column-width:150px; -webkit-column-width: 150px; -moz-column-gap: 20px; -webkit-column-gap: 20px;">
<ul style="list-style-type:none; padding:0; margin:0;" class="basChild_{{sbas_id}}"> <ul style="list-style-type:none; padding:0; margin:0;" class="basChild_{{sbas_id}}">
{% for collection in base["collections"] %} {% for collection in base["collections"] %}
{% set base_id = collection["base_id"] %} {% set base_id = collection["base_id"] %}
@@ -360,12 +360,12 @@
<thead> <thead>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<span onclick="deploy(this, '#ADVSRCH_SB_{{databox_id}}' );return false;" class="deployer_opened" ></span> <span onclick="deploy(this, '#ADVSRCH_SB_{{databox_id}}' );return false;" class="deployer_closed" ></span>
<span class="danger_indicator">{{ databox['name'] }}</span> <span class="danger_indicator">{{ databox['name'] }}</span>
</td> </td>
</tr> </tr>
</thead> </thead>
<tbody id="ADVSRCH_SB_{{databox_id}}"> <tbody id="ADVSRCH_SB_{{databox_id}}" style="display: none">
{% for status_bit, status in databox.status %} {% for status_bit, status in databox.status %}
<tr> <tr>
<td> <td>