(Lea) Controller\DataIndex

Dimanche 08 Février 2026, 22:25:22

<?php/** * Lea * * GNU General Public License * * Copyright © 2010 - 2025, Yohann Schwan. All rights reserved. */namespace Lea\Controller {  class DataIndex extends \Lys\Controller  {    /**     * @trait \Lea\DataHelper     */    use DataHelper;    /**     * @var bool     */    protected $cache = true;    /**     * @var string     */    protected $sortBy = '';    /**     * @args void     * @return bool     */    function populate()    {      if(parent::populate())      {        $prefix = $this['route']['prefix_name'];        $attr = array();        $tags = array();        $rows = array();        if($key = $this->sortBy)        {          $key = $prefix . '_' . $key;        }        foreach($data = $this->data->rows() as $i => $row)        {          if($row = $this->clear($row))          {            foreach($_REQUEST as $k => $v)            {              if($w = array_value($k, $row))              {                if(empty($tags[$k][$w]))                {                  $tags[$k][$w] = 1;                }                else {                  $tags[$k][$w]++;                }              }              if($v)              {                if($v == $w)                {                  # Keep                }                else {                  $row = null;                  break;                }              }            }          }          if($row)          {            if($key)            {              $rows[$row[$key] . '.' . $i] = $row;            }            else {              $rows[] = $row;            }          }        }        if($key)        {          krsort($rows);        }        if($this->cache)        {          cache_save($prefix . '_index', $data);        }/*        foreach($tags as $k => $tags)        {          $L = array();          #          foreach($tags as $m => $i)          {            if($i > 1)            {              $L[$m] = $m;              if($v = $this->L($k . '.' . $m))              {                # Ok !              }              else {                $v = '#' . $m;              }              $attr[strtoupper('L_' . $k . '.' . $m)] = $v . '<small>(' . $i . ')</small>';            }          }          if(empty($L))          {            # Useless          }          else {            $this[$k . '_list'] = $L;          }        }*/        $this->assign($attr);        $this->append($prefix, $rows, true);        return true;      }    }  }}