diff options
| author | polo <ordipolo@gmx.fr> | 2026-10-23 00:47:32 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2026-10-23 00:47:32 +0200 |
| commit | f27cca08ff786ceff1870147f6d6bad14d71117f (patch) | |
| tree | d36597a72025313d6faf4ed228755fa267ebe2f6 /src/model/Position.php | |
| parent | c7309f900ef05bd5cb313110ec159b761af394ec (diff) | |
| download | cms-f27cca08ff786ceff1870147f6d6bad14d71117f.tar.gz cms-f27cca08ff786ceff1870147f6d6bad14d71117f.tar.bz2 cms-f27cca08ff786ceff1870147f6d6bad14d71117f.zip | |
dossiers avec majuscule, namespace pour toutes les classes, autoload psr-4, UserDataService::createZip déplacé dans Backup
Diffstat (limited to 'src/model/Position.php')
| -rw-r--r-- | src/model/Position.php | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/src/model/Position.php b/src/model/Position.php deleted file mode 100644 index fdba271..0000000 --- a/src/model/Position.php +++ /dev/null | |||
| @@ -1,50 +0,0 @@ | |||
| 1 | <?php | ||
| 2 | // src/modele/Position.php | ||
| 3 | // | ||
| 4 | // pour Node et Page | ||
| 5 | |||
| 6 | declare(strict_types=1); | ||
| 7 | |||
| 8 | trait Position | ||
| 9 | { | ||
| 10 | // tri par insertion du tableau des enfants | ||
| 11 | public function sortChildren(bool $reindexation = false): void | ||
| 12 | { | ||
| 13 | for($i = 1; $i < count($this->children); $i++) | ||
| 14 | { | ||
| 15 | $tmp = $this->children[$i]; | ||
| 16 | $j = $i - 1; | ||
| 17 | |||
| 18 | // Déplacez les éléments du tableau qui sont plus grands que la clé à une position devant leur position actuelle | ||
| 19 | while($j >= 0 && $this->children[$j]->getPosition() > $tmp->getPosition()) { | ||
| 20 | $this->children[$j + 1] = $this->children[$j]; | ||
| 21 | $j--; | ||
| 22 | } | ||
| 23 | $this->children[$j + 1] = $tmp; | ||
| 24 | } | ||
| 25 | |||
| 26 | // récursivité (utile dans Menu et chemin) | ||
| 27 | // appel dans Page et dans MenuAndPathController (un tri supplémentaire à faire?) | ||
| 28 | if(self::class === 'App\Entity\Page'){ | ||
| 29 | foreach($this->children as $child) { | ||
| 30 | if(count($child->children) > 0) { | ||
| 31 | $child->sortChildren($reindexation); | ||
| 32 | } | ||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 36 | if($reindexation){ | ||
| 37 | $this->reindexPositions(); | ||
| 38 | } | ||
| 39 | } | ||
| 40 | |||
| 41 | // nouvelles positions (tableau $children => BDD) | ||
| 42 | public function reindexPositions(): void | ||
| 43 | { | ||
| 44 | $i = 1; | ||
| 45 | foreach($this->children as $child){ | ||
| 46 | $child->setPosition($i); | ||
| 47 | $i++; | ||
| 48 | } | ||
| 49 | } | ||
| 50 | } \ No newline at end of file | ||
