created edlp_home, edlp_agenda, edlp_production custom modules
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 13-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_corpus.routing.yml
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
|
||||
|
||||
name: Edlp Agenda
|
||||
type: module
|
||||
description: Manage agenda for edlp d8.
|
||||
core: 8.x
|
||||
package: Edlp
|
||||
# dependencies:
|
||||
# - migrate_drupal
|
||||
# - migrate_plus
|
||||
# - migrate_tools
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 13-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_corpus.routing.yml
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
@@ -0,0 +1,23 @@
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 13-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_corpus.routing.yml
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
|
||||
edlp_agenda.agenda:
|
||||
path: '/agenda'
|
||||
defaults:
|
||||
_controller: '\Drupal\edlp_agenda\Controller\AgendaController::agenda'
|
||||
_title: 'Agenda'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
|
||||
edlp_agenda.agendaajax:
|
||||
path: '/agenda/ajax'
|
||||
defaults:
|
||||
_controller: '\Drupal\edlp_agenda\Controller\AgendaController::agendajson'
|
||||
_title: 'Agenda'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\edlp_agenda\Controller;
|
||||
|
||||
use Drupal\Core\Controller\ControllerBase;
|
||||
use Drupal\Core\Datetime\DrupalDateTime;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
|
||||
class AgendaController extends ControllerBase {
|
||||
|
||||
|
||||
private function query() {
|
||||
// @see https://www.webomelette.com/query-entities-using-dates-drupal-8
|
||||
|
||||
$now = new DrupalDateTime('now');
|
||||
$now->setTimezone(new \DateTimeZone(DATETIME_STORAGE_TIMEZONE));
|
||||
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('type', 'evenement')
|
||||
->condition('field_date', $now->format(DATETIME_DATETIME_STORAGE_FORMAT), '>=')
|
||||
->sort('field_date');
|
||||
|
||||
$this->future_nids = $query->execute();
|
||||
$this->future_nodes = entity_load_multiple('node', $this->future_nids);
|
||||
|
||||
$this->next_event = array_shift($this->future_nodes);
|
||||
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('type', 'evenement')
|
||||
->condition('field_date', $now->format(DATETIME_DATETIME_STORAGE_FORMAT), '<')
|
||||
->sort('field_date', 'DESC');
|
||||
|
||||
$this->past_nids = $query->execute();
|
||||
$this->past_nodes = entity_load_multiple('node', $this->past_nids);
|
||||
}
|
||||
|
||||
private function toRenderable(){
|
||||
$this->query();
|
||||
//
|
||||
// dpm($this->future_nodes);
|
||||
// dpm($this->next_event);
|
||||
/*
|
||||
@see https://www.drupal8.ovh/index.php/en/tutoriels/339/render-a-node-or-an-entity
|
||||
*/
|
||||
|
||||
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
|
||||
$future_list = array (
|
||||
'#theme' => 'item_list',
|
||||
'#items' => [],
|
||||
);
|
||||
foreach($this->future_nodes as $node){
|
||||
$future_list['#items'][] = $view_builder->view($node, 'teaser');
|
||||
}
|
||||
|
||||
$past_list = array (
|
||||
'#theme' => 'item_list',
|
||||
'#items' => [],
|
||||
);
|
||||
foreach($this->past_nodes as $node){
|
||||
$past_list['#items'][] = $view_builder->view($node, 'teaser');
|
||||
}
|
||||
|
||||
return array(
|
||||
"#type" => "container",
|
||||
"#attributes"=>array(
|
||||
"id"=>['agenda']
|
||||
),
|
||||
// "#markup"=> "<h2>Agenda</h2>",
|
||||
"next"=>array(
|
||||
"#type"=>"container",
|
||||
"#attributes"=>array(
|
||||
"class"=>['next-event', 'column', 'os-scroll']
|
||||
),
|
||||
"#markup"=>"<h3>Prochaine Date</h3>",
|
||||
"event"=>$view_builder->view($this->next_event, 'default')
|
||||
),
|
||||
"future_past"=>array(
|
||||
"#type"=>"container",
|
||||
"#attributes"=>array(
|
||||
"class"=>['future-past-events', 'column', 'os-scroll']
|
||||
),
|
||||
"future"=>array(
|
||||
"#type"=>"container",
|
||||
"#attributes"=>array(
|
||||
"class"=>['future-events']
|
||||
),
|
||||
"#markup"=>"<h3>Dates à venir</h3>",
|
||||
"future_events"=>$future_list
|
||||
),
|
||||
"past"=>array(
|
||||
"#type"=>"container",
|
||||
"#attributes"=>array(
|
||||
"class"=>['past-events']
|
||||
),
|
||||
"#markup"=>"<h3>Dates passées</h3>",
|
||||
"past_events"=>$past_list
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Display agenda as a page.
|
||||
*
|
||||
* @return renderable array
|
||||
*/
|
||||
public function agenda() {
|
||||
return $this->toRenderable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get agenda data as json through ajax.
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function agendajson() {
|
||||
|
||||
$response = new JsonResponse();
|
||||
$renderable = $this->toRenderable();
|
||||
$rendered = render($renderable);
|
||||
|
||||
$response->setData([
|
||||
'test'=>'hello',
|
||||
'rendered'=> $rendered
|
||||
]);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -97,10 +97,9 @@
|
||||
function onResizeCanvas() {
|
||||
_canvas.width = window.innerWidth;
|
||||
_canvas.height = window.innerHeight;
|
||||
// - _canvas_props['margin-top'] - _canvas_props['margin-bottom'];
|
||||
// _canvas.style['margin-top'] = _canvas_props['margin-top']+"px";
|
||||
// _canvas.style['margin-bottom'] = _canvas_props['margin-bottom']+"px";
|
||||
|
||||
for (var i = 0; i < _nodes.length; i++) {
|
||||
_nodes[i].onResizeCanvas();
|
||||
}
|
||||
};
|
||||
|
||||
// ___ _
|
||||
@@ -179,6 +178,16 @@
|
||||
// // this.draw();
|
||||
// };
|
||||
|
||||
Node.prototype.onResizeCanvas = function(){
|
||||
this.wall_limits = {
|
||||
top: _canvas_props.margin_top +this.real_radius,
|
||||
right: _canvas.width -_canvas_props.margin_right -this.real_radius,
|
||||
bottom: _canvas.height -_canvas_props.margin_bottom -this.real_radius,
|
||||
left: _canvas_props.margin_left +this.real_radius
|
||||
}
|
||||
// TODO: when canvas is smaller what about nodes hors champs, they are coming back alone but it's too long
|
||||
};
|
||||
|
||||
Node.prototype.onUpdate = function(){
|
||||
this.checkWallBouncing();
|
||||
this.updatePos();
|
||||
|
||||
@@ -97,10 +97,9 @@
|
||||
function onResizeCanvas() {
|
||||
_canvas.width = window.innerWidth;
|
||||
_canvas.height = window.innerHeight;
|
||||
// - _canvas_props['margin-top'] - _canvas_props['margin-bottom'];
|
||||
// _canvas.style['margin-top'] = _canvas_props['margin-top']+"px";
|
||||
// _canvas.style['margin-bottom'] = _canvas_props['margin-bottom']+"px";
|
||||
|
||||
for (var i = 0; i < _nodes.length; i++) {
|
||||
_nodes[i].onResizeCanvas();
|
||||
}
|
||||
};
|
||||
|
||||
// ___ _
|
||||
@@ -179,6 +178,16 @@
|
||||
// // this.draw();
|
||||
// };
|
||||
|
||||
Node.prototype.onResizeCanvas = function(){
|
||||
this.wall_limits = {
|
||||
top: _canvas_props.margin_top +this.real_radius,
|
||||
right: _canvas.width -_canvas_props.margin_right -this.real_radius,
|
||||
bottom: _canvas.height -_canvas_props.margin_bottom -this.real_radius,
|
||||
left: _canvas_props.margin_left +this.real_radius
|
||||
}
|
||||
// TODO: when canvas is smaller what about nodes hors champs, they are coming back alone but it's too long
|
||||
};
|
||||
|
||||
Node.prototype.onUpdate = function(){
|
||||
this.checkWallBouncing();
|
||||
this.updatePos();
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 13-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_corpus.routing.yml
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
|
||||
name: Edlp Corpus
|
||||
type: module
|
||||
description: Creates interactive map of corpus for edlp d8.
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
<?php
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 13-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_corpus.routing.yml
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
|
||||
/**
|
||||
* Implements hook_page_attachments().
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
|
||||
function template_preprocess_edlp_home(&$vars){
|
||||
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
// dpm($vars);
|
||||
|
||||
// render the presentation node
|
||||
$vars["presentation"] = $view_builder->view($vars["presentation_node"], 'default');
|
||||
|
||||
// TODO: last fil
|
||||
|
||||
// render the last production node
|
||||
$vars["last_production"] = $view_builder->view($vars['last_production_node'], 'teaser');
|
||||
|
||||
// render the next events of agenda as list
|
||||
$agenda = array (
|
||||
'#theme' => 'item_list',
|
||||
'#items' => [],
|
||||
);
|
||||
foreach($vars['agenda_items'] as $node){
|
||||
$agenda['#items'][] = $view_builder->view($node, 'teaser');
|
||||
}
|
||||
$vars['agenda'] = render($agenda);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 13-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_home.info.yml
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
|
||||
|
||||
name: Edlp Home
|
||||
type: module
|
||||
description: Manage home for edlp d8.
|
||||
core: 8.x
|
||||
package: Edlp
|
||||
# dependencies:
|
||||
# - migrate_drupal
|
||||
# - migrate_plus
|
||||
# - migrate_tools
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 13-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_home.module
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
function edlp_home_theme($existing, $type, $theme, $path) {
|
||||
// @see https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-from-custom-module
|
||||
|
||||
return array(
|
||||
'edlp_home' => array(
|
||||
// 'render element' => '',
|
||||
'file' => 'edlp_home.inc',
|
||||
'variables' => array(
|
||||
'presentation_node' => NULL,
|
||||
'last_fil_node' => NULL,
|
||||
'last_production_node' => NULL,
|
||||
'agenda_items' => NULL
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 13-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_home.routing.yml
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
|
||||
edlp_home.home:
|
||||
path: '/home'
|
||||
defaults:
|
||||
_controller: '\Drupal\edlp_home\Controller\HomeController::home'
|
||||
_title: 'Home'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\edlp_home\Controller;
|
||||
|
||||
use Drupal\Core\Controller\ControllerBase;
|
||||
use Drupal\Core\Datetime\DrupalDateTime;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
|
||||
class HomeController extends ControllerBase {
|
||||
|
||||
/**
|
||||
* Display agenda as a page.
|
||||
*
|
||||
* @return renderable array
|
||||
*/
|
||||
public function home() {
|
||||
|
||||
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
|
||||
$contents = array("#theme"=>'edlp_home');
|
||||
|
||||
// presentation
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('nid', 5890);
|
||||
|
||||
$pres_nid = $query->execute();
|
||||
$contents["#presentation_node"] = entity_load('node', array_pop($pres_nid));
|
||||
|
||||
|
||||
// TODO: last fil
|
||||
// $contents["#last_fil_node"] = "Last Fil";
|
||||
|
||||
// TODO: last production
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('type', 'page')
|
||||
->condition('field_page_type', array('1168'), 'NOT IN')
|
||||
->range(0,1)
|
||||
->sort('created', 'DESC');
|
||||
|
||||
$prod = $query->execute();
|
||||
$contents["#last_production_node"] = entity_load('node', array_pop($prod));
|
||||
|
||||
// agenda
|
||||
$now = new DrupalDateTime('now');
|
||||
$now->setTimezone(new \DateTimeZone(DATETIME_STORAGE_TIMEZONE));
|
||||
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('type', 'evenement')
|
||||
->condition('field_date', $now->format(DATETIME_DATETIME_STORAGE_FORMAT), '>=')
|
||||
->range(0,3)
|
||||
->sort('field_date');
|
||||
|
||||
$events = $query->execute();
|
||||
$contents['#agenda_items'] = entity_load_multiple('node', $events);
|
||||
|
||||
return $contents;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
{{ presentation }}
|
||||
|
||||
{{ last_fil }}
|
||||
|
||||
{{ last_production }}
|
||||
|
||||
{{ agenda }}
|
||||
@@ -0,0 +1,18 @@
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 13-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_productions.routing.yml
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
|
||||
|
||||
name: Edlp Productions
|
||||
type: module
|
||||
description: Manage productions for edlp d8.
|
||||
core: 8.x
|
||||
package: Edlp
|
||||
# dependencies:
|
||||
# - migrate_drupal
|
||||
# - migrate_plus
|
||||
# - migrate_tools
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 13-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_productions.module
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
@@ -0,0 +1,23 @@
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 13-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_corpus.routing.yml
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
|
||||
edlp_productions.productions:
|
||||
path: '/productions'
|
||||
defaults:
|
||||
_controller: '\Drupal\edlp_productions\Controller\ProductionsController::productions'
|
||||
_title: 'Agenda'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
|
||||
edlp_productions.productionsajax:
|
||||
path: '/productions/ajax'
|
||||
defaults:
|
||||
_controller: '\Drupal\edlp_productions\Controller\ProductionsController::productionsjson'
|
||||
_title: 'Agenda'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\edlp_productions\Controller;
|
||||
|
||||
use Drupal\Core\Controller\ControllerBase;
|
||||
// use Drupal\Core\Datetime\DrupalDateTime;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
|
||||
class ProductionsController extends ControllerBase {
|
||||
|
||||
/**
|
||||
* Display productions as a page.
|
||||
*
|
||||
* @return renderable array
|
||||
*/
|
||||
public function productions() {
|
||||
return array(
|
||||
"#markup"=>"Edlp Productions"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get agenda data as json through ajax.
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function productionsjson() {
|
||||
|
||||
$response = new JsonResponse();
|
||||
$renderable = array(
|
||||
"#markup"=>"Edlp Productions"
|
||||
);
|
||||
$rendered = render($renderable);
|
||||
|
||||
$response->setData([
|
||||
'test'=>'hello',
|
||||
'rendered'=> $rendered
|
||||
]);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user