123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- namespace Grav\Plugin;
- use Grav\Common\Data;
- use Grav\Common\Plugin;
- use Grav\Common\Grav;
- use Grav\Common\Uri;
- use Grav\Common\Taxonomy;
- use Grav\Common\Page\Page;
- use RocketTheme\Toolbox\Event\Event;
- class twigDisplay extends \Twig_Extension
- {
- public function getName()
- {
- return 'ExampleTwigExtension';
- }
- public function getFunctions(): array
- {
- return [
- new \Twig_SimpleFunction('getJson', [$this, 'getJson'])
- ];
- }
- public function getJson()
- {
- $grav = Grav::instance();
- $debugger = $grav['debugger'];
-
-
- $page = $grav['page'];
- $pages = $page->evaluate(['@page.children' => '/coalitions']);
- // initialiser l'objet
- $data = array();
- $i = 0;
- $a = 0;
- foreach ($pages as $key => $coa) {
- $header = $coa->header();
- $url = $coa->url();
- /*dump(st'01/01/'+$header->info['date']))*/
- if(isset($header->member)){
-
- $coa_object = array(
- 'lane' => $i,
- 'title' => $coa->title(),
- 'coa_name' => $header->info['orga'],
- 'start' => strtotime('01/01/'.$header->info['date'])*1000,
- 'end' => strtotime(date("Y"))*1000,
- 'activist' => array()
- );
- if (isset($header->member)) {
- foreach ($header->member as $member) {
- if (strtotime($member["free"]) != "") {
- $f = strtotime($member["free"]);
- }else{
- $f = strtotime(date("Y"));
- }
- $member_array = array(
- 'id' => $member["membre"],
- 'start' => strtotime($member['prison'])*1000,
- 'end' => $f*1000,
- 'url' => $url,
- 'lane' => $i,
- 'pos' => $a
- );
- array_push($coa_object['activist'], $member_array);
- $a ++;
- }
- }
- array_push($data, $coa_object);
-
- $i ++;
-
-
-
- /*$debugger->addMessage($coa->header());*/
-
- }
- }
-
- return $data;
- }
-
- }
|