示例#1
0
 /**
  * метод загружает кол-во записей для каждого аудита
  */
 public static function getAuditStatistic($dateTo)
 {
     $RESULT = array();
     $statistic = AdminAuditBean::inst()->getProcessStatistic($dateTo);
     /* @var $audit BaseAudit */
     foreach (BaseAudit::getAll() as $code => $audit) {
         foreach ($audit->getActions() as $actionName => $actionCode) {
             $RESULT[] = array('name' => $audit->getClass(), 'action' => "{$actionName} ({$actionCode})", 'cnt' => array_get_value_in(array($code, $actionCode), $statistic));
         }
     }
     return $RESULT;
 }
示例#2
0
 public function getMappedParam2($key, $mapKey, $mapKey2, $default = null)
 {
     return array_get_value_in(array($mapKey, $mapKey2), $this->getParam($key));
 }
示例#3
0
 /**
  * Возвращает дочерние сущности заданного типа, от которых зависит данная группа кеширования.
  */
 public function getChildsForValidate($type, $group)
 {
     return to_array(array_get_value_in(array($type, $group), $this->TREE_VAL));
 }
 /**
  * Метод, выполняющий всё вычисление и всю обработку
  */
 private function doProcess($cells)
 {
     PsProfiler::inst(__CLASS__)->start('Unioning cells');
     if ($this->LOGGER->isEnabled()) {
         $this->LOGGER->infoBox('Unioning ' . count($cells) . ' cells, user check: ' . var_export($this->checkUser, true));
         $this->LOGGER->info();
         $this->LOGGER->info('Before sorting and indexing:');
         $this->LOGGER->info(print_r($cells, true));
     }
     //Расположим ячейки от левого верхнего угла до правого нижнего (как при письме)
     usort($cells, function ($c1, $c2) {
         if ($c1['y_cell'] == $c2['y_cell']) {
             return $c1['x_cell'] > $c2['x_cell'] ? 1 : -1;
         }
         return $c1['y_cell'] > $c2['y_cell'] ? 1 : -1;
     });
     $this->cells = array();
     //Проиндексируем массив
     foreach ($cells as $cell) {
         $cell['x_cell'] = 1 * $cell['x_cell'];
         $cell['y_cell'] = 1 * $cell['y_cell'];
         $cell['id_user'] = 1 * $cell['id_user'];
         $this->cells[$cell['x_cell'] . 'x' . $cell['y_cell']] = $cell;
     }
     if ($this->LOGGER->isEnabled()) {
         $this->LOGGER->info();
         $this->LOGGER->info('After sorting and indexing:');
         $this->LOGGER->info(print_r($this->cells, true));
         $this->LOGGER->info();
     }
     //Пробегаем по всем ячейкам, объединяя их и исключая те ячейки, с которыми мы объединились
     $unioned = 0;
     foreach ($this->cells as $ident => $cell) {
         if (!array_key_exists($ident, $this->cells)) {
             //Видимо уже удаили ячейку из списка ячеек
             continue;
         }
         $x = $cell['x_cell'];
         $y = $cell['y_cell'];
         $id_user = $cell['id_user'];
         $dx = $this->getRightCellsCnt($x, $y, $id_user);
         if ($dx > 0) {
             //Объединяемся с ячейками справа
             $x1 = ($x - 1) * $this->w;
             $y1 = ($y - 1) * $this->h;
             $x2 = ($x + $dx) * $this->w;
             $y2 = $y * $this->h;
             for ($delta = 1; $delta <= $dx; $delta++) {
                 $cident = $x + $delta . 'x' . $y;
                 if ($this->LOGGER->isEnabled()) {
                     $cid_user = array_get_value_in(array($cident, 'id_user'), $this->cells);
                     $this->LOGGER->info(++$unioned . ". [{$ident}]({$id_user}) + [{$cident}]({$cid_user})");
                 }
                 unset($this->cells[$cident]);
             }
             $this->result[] = array($x1, $y1, $x2, $y2, $id_user);
             continue;
         }
         $dy = $this->getBottomCellsCnt($x, $y, $id_user);
         if ($dy > 0) {
             //Объединяемся с ячейками снизу
             $x1 = ($x - 1) * $this->w;
             $y1 = ($y - 1) * $this->h;
             $x2 = $x * $this->w;
             $y2 = ($y + $dy) * $this->h;
             for ($delta = 1; $delta <= $dy; $delta++) {
                 $cident = $x . 'x' . ($y + $delta);
                 if ($this->LOGGER->isEnabled()) {
                     $cid_user = array_get_value_in(array($cident, 'id_user'), $this->cells);
                     $this->LOGGER->info(++$unioned . ". [{$ident}]({$id_user}) + [{$cident}]({$cid_user})");
                 }
                 unset($this->cells[$cident]);
             }
             $this->result[] = array($x1, $y1, $x2, $y2, $id_user);
             continue;
         }
         //Не с кем объединяться, берём только эту ячейку
         $x1 = ($x - 1) * $this->w;
         $y1 = ($y - 1) * $this->h;
         $x2 = $x * $this->w;
         $y2 = $y * $this->h;
         $this->result[] = array($x1, $y1, $x2, $y2, $id_user);
     }
     $secundomer = PsProfiler::inst(__CLASS__)->stop();
     if ($this->LOGGER->isEnabled()) {
         $this->LOGGER->info();
         $this->LOGGER->info('Unioned cells:');
         $this->LOGGER->info(print_r($this->result, true));
         $this->LOGGER->info('Compression: {}%', round(count($this->result) / count($cells) * 100));
         if ($secundomer) {
             $this->LOGGER->info('Done in ' . $secundomer->getAverage() . ' seconds');
         }
     }
 }