svg
This commit is contained in:
parent
e6170cfdfc
commit
4183712317
|
@ -33,6 +33,7 @@ class AppKernel extends Kernel
|
|||
new Cadoles\SAMLBundle\CadolesSAMLBundle(),
|
||||
new Cadoles\CASBundle\CadolesCASBundle(),
|
||||
new Cadoles\CoreBundle\CadolesCoreBundle(),
|
||||
new Cadoles\CronBundle\CadolesCronBundle(),
|
||||
new Cadoles\PortalBundle\CadolesPortalBundle()
|
||||
];
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ imports:
|
|||
- { resource: security.yml }
|
||||
- { resource: services.yml }
|
||||
- { resource: "@CadolesCoreBundle/Resources/config/services.yml" }
|
||||
- { resource: "@CadolesPortalBundle/Resources/config/services.yml" }
|
||||
- { resource: twig.yml }
|
||||
|
||||
# Put parameters here that don't need to change on each machine where the app is deployed
|
||||
|
|
|
@ -2,6 +2,10 @@ core:
|
|||
resource: "@CadolesCoreBundle/Resources/config/routing.yml"
|
||||
prefix: /
|
||||
|
||||
cron:
|
||||
resource: "@CadolesCronBundle/Resources/config/routing.yml"
|
||||
prefix: /
|
||||
|
||||
portal:
|
||||
resource: "@CadolesPortalBundle/Resources/config/routing.yml"
|
||||
prefix: /
|
||||
|
|
|
@ -41,11 +41,15 @@ security:
|
|||
check_path: /saml/acs
|
||||
|
||||
access_control:
|
||||
- { path: ^/profil, roles: [ROLE_ADMIN, ROLE_MODO, ROLE_USER] }
|
||||
- { path: ^/user, roles: [ROLE_ADMIN, ROLE_MODO, ROLE_USER] }
|
||||
- { path: ^/config/home, roles: [ROLE_ADMIN, ROLE_MODO] }
|
||||
- { path: ^/config/niveau02, roles: [ROLE_ADMIN, ROLE_MODO] }
|
||||
- { path: ^/config/group, roles: [ROLE_ADMIN, ROLE_MODO] }
|
||||
- { path: ^/config/registration, roles: [ROLE_ADMIN, ROLE_MODO] }
|
||||
- { path: ^/config/user, roles: [ROLE_ADMIN, ROLE_MODO] }
|
||||
- { path: ^/config/icon, roles: [ROLE_ADMIN, ROLE_MODO] }
|
||||
- { path: ^/config/item, roles: [ROLE_ADMIN, ROLE_MODO] }
|
||||
- { path: ^/config/alert, roles: [ROLE_ADMIN, ROLE_MODO] }
|
||||
- { path: ^/config/page, roles: [ROLE_ADMIN, ROLE_MODO] }
|
||||
- { path: ^/config, roles: [ROLE_ADMIN] }
|
||||
|
||||
|
|
|
@ -17,10 +17,14 @@ parameters:
|
|||
# none = désactivation de l'inscription mais reset de password possible
|
||||
# byuser = aucune validation par un administrateur, l'utilisateur valide son inscription par lui-même
|
||||
# byadmin = validation de l'inscription par un administrateur, sauf si domaine de messagerie dans la liste blanche
|
||||
moderegistration: none
|
||||
moderegistration: byadmin
|
||||
|
||||
# Activation module
|
||||
cron_activate: true
|
||||
portal_activate: true
|
||||
|
||||
# Information de base de l'annuaire
|
||||
ldap_host: 127.0.0.1
|
||||
ldap_host: 172.27.7.61
|
||||
ldap_port: 389
|
||||
ldap_user: cn=admin,o=gouv,c=fr
|
||||
ldap_password: eole
|
||||
|
@ -117,6 +121,7 @@ doctrine:
|
|||
connection: default
|
||||
mappings:
|
||||
CadolesCoreBundle: ~
|
||||
CadolesPortalBundle: ~
|
||||
CadolesCronBundle: ~
|
||||
CadolesPortalBundle: ~
|
||||
|
||||
|
|
@ -20,7 +20,13 @@
|
|||
"doctrine/doctrine-fixtures-bundle": "^2.3",
|
||||
"doctrine/doctrine-migrations-bundle": "^1.2",
|
||||
"doctrine/orm": "^2.5",
|
||||
"egeloen/ckeditor-bundle": "^6.0",
|
||||
"gregwar/captcha-bundle": "^2.0",
|
||||
"incenteev/composer-parameter-handler": "^2.0",
|
||||
"jasig/phpcas": "~1.3",
|
||||
"lightsaml/sp-bundle": "^1.2",
|
||||
"oneup/uploader-bundle": "^1.7",
|
||||
"ramsey/uuid": "^3.7",
|
||||
"sensio/distribution-bundle": "^5.0.19",
|
||||
"sensio/framework-extra-bundle": "^5.0.0",
|
||||
"symfony/assetic-bundle": "^2.8",
|
||||
|
@ -30,16 +36,8 @@
|
|||
"symfony/polyfill-apcu": "^1.0",
|
||||
"symfony/swiftmailer-bundle": "^2.6.4",
|
||||
"symfony/symfony": "3.4.*",
|
||||
"twig/twig": "^1.0||^2.0",
|
||||
|
||||
"lightsaml/sp-bundle": "^1.2",
|
||||
"jasig/phpcas": "~1.3",
|
||||
"egeloen/ckeditor-bundle": "^6.0",
|
||||
"gregwar/captcha-bundle": "^2.0",
|
||||
"oneup/uploader-bundle": "^1.7",
|
||||
"ramsey/uuid": "^3.7",
|
||||
"tetranz/select2entity-bundle": "2.*"
|
||||
|
||||
"tetranz/select2entity-bundle": "2.*",
|
||||
"twig/twig": "^1.0||^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"sensio/generator-bundle": "^3.0",
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "3d04e5154e3db89d141ea33076fa3fd2",
|
||||
"content-hash": "a6abd6954f83c62fd9dcca07e8a0cbc3",
|
||||
"hash": "d4a96daf4f90dcf6a4600e1c27ff55a9",
|
||||
"content-hash": "9f299842b28bb339e4fc9422b33fc2ec",
|
||||
"packages": [
|
||||
{
|
||||
"name": "composer/ca-bundle",
|
||||
|
@ -3492,16 +3492,16 @@
|
|||
},
|
||||
{
|
||||
"name": "twig/twig",
|
||||
"version": "v2.7.2",
|
||||
"version": "v2.7.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/twigphp/Twig.git",
|
||||
"reference": "70c59531da43afe598c66135e39cac39475a2f51"
|
||||
"reference": "52b9a5bd41c8c53a1d784f90ca25e33bf558a6b3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/70c59531da43afe598c66135e39cac39475a2f51",
|
||||
"reference": "70c59531da43afe598c66135e39cac39475a2f51",
|
||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/52b9a5bd41c8c53a1d784f90ca25e33bf558a6b3",
|
||||
"reference": "52b9a5bd41c8c53a1d784f90ca25e33bf558a6b3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -3555,7 +3555,7 @@
|
|||
"keywords": [
|
||||
"templating"
|
||||
],
|
||||
"time": "2019-03-12 18:48:26"
|
||||
"time": "2019-03-21 14:53:02"
|
||||
},
|
||||
{
|
||||
"name": "zendframework/zend-code",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
cd /var/www/html/cadolesuser
|
||||
php bin/console Core:Cron
|
||||
php bin/console Cron:Exec
|
|
@ -25,6 +25,7 @@ php bin/console doctrine:schema:update --force --env=prod --no-debug
|
|||
|
||||
# Insertion data de base
|
||||
php bin/console Core:InitData
|
||||
php bin/console Cron:InitData
|
||||
php bin/console Portal:InitData
|
||||
|
||||
# Generation des assets
|
||||
|
|
|
@ -1,72 +0,0 @@
|
|||
<?php
|
||||
namespace Cadoles\CoreBundle\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Doctrine\DBAL\Connection as DBALConnection;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Symfony\Component\Validator\Constraints\DateTime;
|
||||
|
||||
use Cadoles\CoreBundle\Entity\Registration;
|
||||
|
||||
class CronCommand extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
// the name of the command (the part after "bin/console")
|
||||
->setName('Core:Cron')
|
||||
|
||||
// the short description shown while running "php bin/console list"
|
||||
->setDescription('Tâches Cron')
|
||||
|
||||
// the full command description shown when running the command with
|
||||
// the "--help" option
|
||||
->setHelp('This command CRON for Core')
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$kernel = new \AppKernel('dev', true);
|
||||
$kernel->boot();
|
||||
$kernel->loadClassCache();
|
||||
$em = $kernel->getContainer()->get('service_container')->get('doctrine.orm.default_entity_manager');
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('=====================================================');
|
||||
$output->writeln('== CRON =============================================');
|
||||
$output->writeln('=====================================================');
|
||||
$now=new \DateTime('now');
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('== PURGE OBSOLETE REGISTRATION ======================');
|
||||
|
||||
$datas = $em ->createQueryBuilder()
|
||||
->select('table')
|
||||
->from('CadolesCoreBundle:Registration','table')
|
||||
->where('table.keyexpire<:now')
|
||||
->setParameter("now",$now->format("Y-m-d H:i:s"))
|
||||
->getQuery()
|
||||
->getResult();
|
||||
foreach($datas as $data) {
|
||||
$output->writeln(' - Inscription supprimée = '.$data->getkeyexpire()->format("Y-m-d H:i:s")." >> ".$data->getUsername());
|
||||
$em->remove($data);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('');
|
||||
}
|
||||
|
||||
protected static function determineKernelRootDir(Event $event) {
|
||||
$extra = $event->getComposer()->getPackage()->getExtra();
|
||||
$rootdir = rtrim(getcwd(), '/');
|
||||
return $rootdir . '/' . trim($extra['symfony-app-dir'], '/');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
namespace Cadoles\CoreBundle\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Doctrine\DBAL\Connection as DBALConnection;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Symfony\Component\Validator\Constraints\DateTime;
|
||||
|
||||
use Cadoles\CoreBundle\Entity\Registration;
|
||||
|
||||
class PurgeRegistrationCommand extends Command
|
||||
{
|
||||
private $container;
|
||||
private $em;
|
||||
private $output;
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('Core:PurgeRegistration')
|
||||
->setDescription('Purge Registration')
|
||||
->setHelp('This command Purge the obsolete Registration')
|
||||
->addArgument('cronid', InputArgument::OPTIONAL, 'ID Cron Job')
|
||||
->addArgument('lastchance', InputArgument::OPTIONAL, 'Lastchance to run the cron')
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->container = $this->getApplication()->getKernel()->getContainer();
|
||||
$this->em = $this->container->get('doctrine')->getEntityManager();
|
||||
$this->output = $output;
|
||||
|
||||
$this->writelnred('');
|
||||
$this->writelnred('== Core:PurgeRegistration');
|
||||
$this->writelnred('=====================================================');
|
||||
|
||||
$now=new \DateTime('now');
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('== PURGE OBSOLETE REGISTRATION ======================');
|
||||
|
||||
$datas = $this->em
|
||||
->createQueryBuilder()
|
||||
->select('table')
|
||||
->from('CadolesCoreBundle:Registration','table')
|
||||
->where('table.keyexpire<:now')
|
||||
->setParameter("now",$now->format("Y-m-d H:i:s"))
|
||||
->getQuery()
|
||||
->getResult();
|
||||
foreach($datas as $data) {
|
||||
$this->writeln(' - Inscription supprimée = '.$data->getkeyexpire()->format("Y-m-d H:i:s")." >> ".$data->getUsername());
|
||||
$this->em->remove($data);
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
|
||||
$this->writeln('');
|
||||
}
|
||||
|
||||
private function writelnred($string) { $this->output->writeln('<fg=red>'.$string.'</>'); }
|
||||
private function writeln($string) { $this->output->writeln($string); }
|
||||
}
|
|
@ -21,122 +21,120 @@ global $config;
|
|||
|
||||
class SynchroCommand extends Command
|
||||
{
|
||||
private $container;
|
||||
private $em;
|
||||
private $output;
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
// the name of the command (the part after "bin/console")
|
||||
->setName('Core:Synchro')
|
||||
|
||||
// the short description shown while running "php bin/console list"
|
||||
->setDescription('Synchronisation Annuaire')
|
||||
|
||||
// the full command description shown when running the command with
|
||||
// the "--help" option
|
||||
->setHelp('This command Synchro for Core')
|
||||
|
||||
->addArgument('simulate', InputArgument::OPTIONAL, 'true to simulate / false to run')
|
||||
->addArgument('cronid', InputArgument::OPTIONAL, 'ID Cron Job')
|
||||
->addArgument('lastchance', InputArgument::OPTIONAL, 'Lastchance to run the cron')
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$kernel = new \AppKernel('dev', true);
|
||||
$kernel->boot();
|
||||
$kernel->loadClassCache();
|
||||
$em = $kernel->getContainer()->get('service_container')->get('doctrine.orm.default_entity_manager');
|
||||
$this->container = $this->getApplication()->getKernel()->getContainer();
|
||||
$this->em = $this->container->get('doctrine')->getEntityManager();
|
||||
$this->output = $output;
|
||||
|
||||
$this->writelnred('');
|
||||
$this->writelnred('== Core:Synchro');
|
||||
$this->writelnred('=====================================================');
|
||||
|
||||
setlocale( LC_CTYPE, 'fr_FR' );
|
||||
$labelniveau01 = mb_strtoupper($kernel->getContainer()->getParameter('labelniveau01'));
|
||||
$labelniveau02 = mb_strtoupper($kernel->getContainer()->getParameter('labelniveau02'));
|
||||
$masteridentity = $kernel->getContainer()->getParameter('masteridentity');
|
||||
$labelniveau01 = mb_strtoupper($this->container->getParameter('labelniveau01'));
|
||||
$labelniveau02 = mb_strtoupper($this->container->getParameter('labelniveau02'));
|
||||
$masteridentity = $this->container->getParameter('masteridentity');
|
||||
|
||||
$simulate = $input->getArgument('simulate');
|
||||
if($simulate=="") $simulate="true";
|
||||
|
||||
if($simulate!="true"&&$simulate!="false") {
|
||||
$output->writeln('Paramétre incorrect');
|
||||
$this->writeln('Paramétre incorrect');
|
||||
return;
|
||||
}
|
||||
$simulate=($simulate=="true");
|
||||
|
||||
$output->writeln('');
|
||||
if($simulate) $output->writeln('** SIMULATION');
|
||||
else $output->writeln('** REEL');
|
||||
$this->writeln('');
|
||||
if($simulate) $this->writeln('** SIMULATION');
|
||||
else $this->writeln('** REEL');
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('=====================================================');
|
||||
$output->writeln('== SYNCHONISATION ANNUAIRE ==========================');
|
||||
$output->writeln('=====================================================');
|
||||
$this->writeln('');
|
||||
$this->writeln('=====================================================');
|
||||
$this->writeln('== SYNCHONISATION ANNUAIRE ==========================');
|
||||
$this->writeln('=====================================================');
|
||||
|
||||
$ldap = $kernel->getContainer()->get('cadoles.core.service.ldap');
|
||||
$ldap = $this->container->get('cadoles.core.service.ldap');
|
||||
if(!$ldap->isEnabled()) {
|
||||
if($masteridentity !="LDAP") {
|
||||
$output->writeln('');
|
||||
$output->writeln(' Synchronisation annuaire désactivée');
|
||||
}
|
||||
else {
|
||||
$output->writeln('');
|
||||
$output->writeln('=====================================================');
|
||||
$output->writeln('== SYNCHONISATION LDAP TO BUNDLE ====================');
|
||||
$output->writeln('=====================================================');
|
||||
if($masteridentity =="LDAP") {
|
||||
$this->writeln('');
|
||||
$this->writeln('=====================================================');
|
||||
$this->writeln('== SYNCHONISATION LDAP TO BUNDLE ====================');
|
||||
$this->writeln('=====================================================');
|
||||
|
||||
|
||||
$ldap_basedn = $kernel->getContainer()->getParameter('ldap_basedn');
|
||||
$ldap_template = $kernel->getContainer()->getParameter('ldap_template');
|
||||
$ldap_username = $kernel->getContainer()->getParameter('ldap_username');
|
||||
$ldap_firstname = $kernel->getContainer()->getParameter('ldap_firstname');
|
||||
$ldap_lastname = $kernel->getContainer()->getParameter('ldap_lastname');
|
||||
$ldap_email = $kernel->getContainer()->getParameter('ldap_email');
|
||||
$ldap_usersadmin = $kernel->getContainer()->getParameter('ldap_usersadmin');
|
||||
$ldap_basedn = $this->container->getParameter('ldap_basedn');
|
||||
$ldap_template = $this->container->getParameter('ldap_template');
|
||||
$ldap_username = $this->container->getParameter('ldap_username');
|
||||
$ldap_firstname = $this->container->getParameter('ldap_firstname');
|
||||
$ldap_lastname = $this->container->getParameter('ldap_lastname');
|
||||
$ldap_email = $this->container->getParameter('ldap_email');
|
||||
$ldap_usersadmin = $this->container->getParameter('ldap_usersadmin');
|
||||
$fieldstoread = array($ldap_username,$ldap_firstname,$ldap_lastname,$ldap_email);
|
||||
$ldapusers = array();
|
||||
|
||||
if($ldap_template=="scribe") {
|
||||
$output->writeln('');
|
||||
$output->writeln('== PROFILS ==========================================');
|
||||
$this->writeln('');
|
||||
$this->writeln('== PROFILS ==========================================');
|
||||
|
||||
// Eleves
|
||||
$ldapfilter="(&(uid=*)(ENTPersonProfils=eleve))";
|
||||
$label="PROFIL = Elèves";
|
||||
$output->writeln(" - $label");
|
||||
if(!$simulate) $this->addmodGroup($em,$label,$ldapfilter);
|
||||
$this->writeln(" - $label");
|
||||
if(!$simulate) $this->addmodGroup($label,$ldapfilter);
|
||||
|
||||
// Enseignants
|
||||
$ldapfilter="(|(&(uid=*)(ENTPersonProfils=enseignant))(&(uid=*)(typeadmin=0))(&(uid=*)(typeadmin=2)))";
|
||||
$label="PROFIL = Enseignants";
|
||||
$output->writeln(" - $label");
|
||||
if(!$simulate) $this->addmodGroup($em,$label,$ldapfilter);
|
||||
$this->writeln(" - $label");
|
||||
if(!$simulate) $this->addmodGroup($label,$ldapfilter);
|
||||
|
||||
// Responsables
|
||||
$ldapfilter="(&(uid=*)(ENTPersonProfils=responsable))";
|
||||
$label="PROFIL = Responsables";
|
||||
$output->writeln(" - $label");
|
||||
if(!$simulate) $this->addmodGroup($em,$label,$ldapfilter);
|
||||
$this->writeln(" - $label");
|
||||
if(!$simulate) $this->addmodGroup($label,$ldapfilter);
|
||||
|
||||
// Administratifs
|
||||
$ldapfilter="(&(uid=*)(ENTPersonProfils=administratif))";
|
||||
$label="PROFIL = Administratifs";
|
||||
$output->writeln(" - $label");
|
||||
if(!$simulate) $this->addmodGroup($em,$label,$ldapfilter);
|
||||
$this->writeln(" - $label");
|
||||
if(!$simulate) $this->addmodGroup($label,$ldapfilter);
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('== CLASSES ==========================================');
|
||||
$this->writeln('');
|
||||
$this->writeln('== CLASSES ==========================================');
|
||||
$results = $ldap->search("type=Classe", ['cn','description','gidNumber'], $ldap_basedn);
|
||||
foreach($results as $result) {
|
||||
$cn=$result["cn"];
|
||||
$ldapfilter="(|(&(type=Classe)(cn=$cn))(&(type=Equipe)(cn=profs-$cn))(&(ENTPersonProfils=Administratif)(divcod=$cn)))";
|
||||
|
||||
$label="CLASSE = ".$result["cn"];
|
||||
$output->writeln(" - $label");
|
||||
if(!$simulate) $this->addmodGroup($em,$label,$ldapfilter);
|
||||
$this->writeln(" - $label");
|
||||
if(!$simulate) $this->addmodGroup($label,$ldapfilter);
|
||||
}
|
||||
}
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('== USERS ============================================');
|
||||
$this->writeln('');
|
||||
$this->writeln('== USERS ============================================');
|
||||
|
||||
// On parcours les niveaux 01 pour connaitre les filtres ldap associé
|
||||
$datas=$em->createQueryBuilder()->select('table')->from('CadolesCoreBundle:Niveau01','table')->where('table.ldapfilter IS NOT NULL')->getQuery()->getResult();
|
||||
$datas=$this->em->createQueryBuilder()->select('table')->from('CadolesCoreBundle:Niveau01','table')->where('table.ldapfilter IS NOT NULL')->getQuery()->getResult();
|
||||
foreach($datas as $data) {
|
||||
// On execute le filtre d'appartenance à ce niveau
|
||||
$results = $ldap->search($data->getLdapfilter(), $fieldstoread, $ldap_basedn);
|
||||
|
@ -147,29 +145,29 @@ class SynchroCommand extends Command
|
|||
array_push($ldapusers,$result[$ldap_username]);
|
||||
|
||||
// Création ou Modification du user
|
||||
$user=$em->getRepository('CadolesCoreBundle:User')->findBy(array('username' => $result[$ldap_username]));
|
||||
$user=$this->em->getRepository('CadolesCoreBundle:User')->findBy(array('username' => $result[$ldap_username]));
|
||||
if(!$user) {
|
||||
$output->writeln(" - Création dans Bundle >> ".$result[$ldap_username]);
|
||||
if(!$simulate) $this->addUser($em,$data,$result[$ldap_username],$result[$ldap_firstname],$result[$ldap_lastname],$result[$ldap_email],$ldap_usersadmin);
|
||||
$this->writeln(" - Création dans Bundle >> ".$result[$ldap_username]);
|
||||
if(!$simulate) $this->addUser($data,$result[$ldap_username],$result[$ldap_firstname],$result[$ldap_lastname],$result[$ldap_email],$ldap_usersadmin);
|
||||
}
|
||||
else {
|
||||
$output->writeln(" - Modification dans Bundle >> ".$result[$ldap_username]);
|
||||
if(!$simulate) $this->modUser($em,$user[0],$result[$ldap_username],$result[$ldap_firstname],$result[$ldap_lastname],$result[$ldap_email],$ldap_usersadmin);
|
||||
$this->writeln(" - Modification dans Bundle >> ".$result[$ldap_username]);
|
||||
if(!$simulate) $this->modUser($user[0],$result[$ldap_username],$result[$ldap_firstname],$result[$ldap_lastname],$result[$ldap_email],$ldap_usersadmin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('== USERS GROUP ======================================');
|
||||
$this->writeln('');
|
||||
$this->writeln('== USERS GROUP ======================================');
|
||||
|
||||
$groups=$em->getRepository('CadolesCoreBundle:Group')->findAll();
|
||||
$groups=$this->em->getRepository('CadolesCoreBundle:Group')->findAll();
|
||||
foreach($groups as $group) {
|
||||
$ldapusersgroup=array();
|
||||
|
||||
$ldapfilter=$group->getLdapfilter();
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('== '.$group->getLabel());
|
||||
$this->writeln('');
|
||||
$this->writeln('== '.$group->getLabel());
|
||||
|
||||
if(!is_null($ldapfilter)) {
|
||||
$results = $ldap->search($ldapfilter,[$ldap_username,"memberuid"] , $ldap_basedn);
|
||||
|
@ -179,86 +177,87 @@ class SynchroCommand extends Command
|
|||
if(is_array($result["memberuid"])) {
|
||||
foreach($result["memberuid"] as $key => $value) {
|
||||
if(is_int($key)) {
|
||||
$user=$em->getRepository('CadolesCoreBundle:User')->findOneBy(array('username' => $value));
|
||||
$user=$this->em->getRepository('CadolesCoreBundle:User')->findOneBy(array('username' => $value));
|
||||
if($user) {
|
||||
array_push($ldapusersgroup,$value);
|
||||
$output->writeln(" - Rattacher >> ".$value);
|
||||
if(!$simulate) $this->addtoGroup($em,$user,$group);
|
||||
$this->writeln(" - Rattacher >> ".$value);
|
||||
if(!$simulate) $this->addtoGroup($user,$group);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// sinon m'a qu'un seul uid
|
||||
else {
|
||||
$user=$em->getRepository('CadolesCoreBundle:User')->findOneBy(array('username' => $result["memberuid"]));
|
||||
$user=$this->em->getRepository('CadolesCoreBundle:User')->findOneBy(array('username' => $result["memberuid"]));
|
||||
if($user) {
|
||||
array_push($ldapusersgroup,$result["memberuid"]);
|
||||
$output->writeln(" - Rattacher >> ".$result["memberuid"]);
|
||||
if(!$simulate) $this->addtoGroup($em,$user,$group);
|
||||
$this->writeln(" - Rattacher >> ".$result["memberuid"]);
|
||||
if(!$simulate) $this->addtoGroup($user,$group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($result[$ldap_username])) {
|
||||
$user=$em->getRepository('CadolesCoreBundle:User')->findOneBy(array('username' => $result[$ldap_username]));
|
||||
$user=$this->em->getRepository('CadolesCoreBundle:User')->findOneBy(array('username' => $result[$ldap_username]));
|
||||
if($user) {
|
||||
array_push($ldapusersgroup,$result[$ldap_username]);
|
||||
$output->writeln(" - Rattacher >> ".$result[$ldap_username]);
|
||||
if(!$simulate) $this->addtoGroup($em,$user,$group);
|
||||
$this->writeln(" - Rattacher >> ".$result[$ldap_username]);
|
||||
if(!$simulate) $this->addtoGroup($user,$group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$members=$em->getRepository('CadolesCoreBundle:UserGroup')->findBy(array('group' => $group));
|
||||
$members=$this->em->getRepository('CadolesCoreBundle:UserGroup')->findBy(array('group' => $group));
|
||||
foreach($members as $member) {
|
||||
if(!in_array($member->getUser()->getUsername(),$ldapusersgroup)) {
|
||||
$output->writeln(" - Détattacher >> ".$member->getUser()->getUsername());
|
||||
$this->writeln(" - Détattacher >> ".$member->getUser()->getUsername());
|
||||
if(!$simulate) {
|
||||
$em->remove($member);
|
||||
$em->flush();
|
||||
$this->em->remove($member);
|
||||
$this->em->flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('=====================================================');
|
||||
$output->writeln('== SYNCHONISATION BUNDLE TO LDAP ====================');
|
||||
$output->writeln('=====================================================');
|
||||
$this->writeln('');
|
||||
$this->writeln('=====================================================');
|
||||
$this->writeln('== SYNCHONISATION BUNDLE TO LDAP ====================');
|
||||
$this->writeln('=====================================================');
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('== USERS ============================================');
|
||||
$this->writeln('');
|
||||
$this->writeln('== USERS ============================================');
|
||||
|
||||
// Pour chaque utilisateur de la base
|
||||
$users=$em->getRepository('CadolesCoreBundle:User')->findAll();
|
||||
$users=$this->em->getRepository('CadolesCoreBundle:User')->findAll();
|
||||
foreach($users as $user) {
|
||||
// Si l'utilisateur n'est pas dans la liste des users ldap : on le supprime
|
||||
if(!in_array($user->getUsername(),$ldapusers)) {
|
||||
$output->writeln(" - Suppression dans Bundle >> ".$user->getUsername());
|
||||
$this->writeln(" - Suppression dans Bundle >> ".$user->getUsername());
|
||||
if(!$simulate) {
|
||||
$em->remove($user);
|
||||
$em->flush();
|
||||
$this->em->remove($user);
|
||||
$this->em->flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$output->writeln('');
|
||||
$output->writeln('=====================================================');
|
||||
$output->writeln('== SYNCHONISATION BUNDLE TO LDAP ====================');
|
||||
$output->writeln('=====================================================');
|
||||
$this->writeln('');
|
||||
$this->writeln('=====================================================');
|
||||
$this->writeln('== SYNCHONISATION BUNDLE TO LDAP ====================');
|
||||
$this->writeln('=====================================================');
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('== NIVEAU01 =========================================');
|
||||
$baseNiveau01 = $kernel->getContainer()->getParameter('ldap_baseniveau01');
|
||||
$this->writeln('');
|
||||
$this->writeln('== NIVEAU01 =========================================');
|
||||
$baseNiveau01 = $this->container->getParameter('ldap_baseniveau01');
|
||||
|
||||
$datas = $em ->createQueryBuilder()
|
||||
->select('table')
|
||||
->from('CadolesCoreBundle:Niveau01','table')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
$datas = $this->em
|
||||
->createQueryBuilder()
|
||||
->select('table')
|
||||
->from('CadolesCoreBundle:Niveau01','table')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
foreach($datas as $data) {
|
||||
$criteria = '(cn='.$data->getLabel().')';
|
||||
$subbranch=$baseNiveau01;
|
||||
|
@ -266,25 +265,26 @@ class SynchroCommand extends Command
|
|||
|
||||
// Mise à jour si elle existe
|
||||
if(count($results) > 0) {
|
||||
$output->writeln(' - Modification dans annuaire >> '.$data->getLabel());
|
||||
$this->writeln(' - Modification dans annuaire >> '.$data->getLabel());
|
||||
if(!$simulate) $ldap->modifyNiveau01($data,$data->getLabel());
|
||||
}
|
||||
// Sinon création de la fiche
|
||||
else {
|
||||
$output->writeln(' - Création dans annuaire >> '.$data->getLabel());
|
||||
$this->writeln(' - Création dans annuaire >> '.$data->getLabel());
|
||||
if(!$simulate) $ldap->addNiveau01($data);
|
||||
}
|
||||
}
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('== NIVEAU02 =========================================');
|
||||
$baseNiveau02 = $kernel->getContainer()->getParameter('ldap_baseniveau02');
|
||||
$this->writeln('');
|
||||
$this->writeln('== NIVEAU02 =========================================');
|
||||
$baseNiveau02 = $this->container->getParameter('ldap_baseniveau02');
|
||||
|
||||
$datas = $em ->createQueryBuilder()
|
||||
->select('table')
|
||||
->from('CadolesCoreBundle:Niveau02','table')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
$datas = $this->em
|
||||
->createQueryBuilder()
|
||||
->select('table')
|
||||
->from('CadolesCoreBundle:Niveau02','table')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
foreach($datas as $data) {
|
||||
$criteria = '(cn='.$data->getLabel().')';
|
||||
$subbranch=$baseNiveau02;
|
||||
|
@ -292,25 +292,26 @@ class SynchroCommand extends Command
|
|||
|
||||
// Mise à jour si elle existe
|
||||
if(count($results) > 0) {
|
||||
$output->writeln(' - Modification dans annuaire >> '.$data->getLabel());
|
||||
$this->writeln(' - Modification dans annuaire >> '.$data->getLabel());
|
||||
if(!$simulate) $ldap->modifyNiveau02($data,$data->getLabel());
|
||||
}
|
||||
// Sinon création de la fiche
|
||||
else {
|
||||
$output->writeln(' - Création dans annuaire >> '.$data->getLabel());
|
||||
$this->writeln(' - Création dans annuaire >> '.$data->getLabel());
|
||||
if(!$simulate) $ldap->addNiveau02($data);
|
||||
}
|
||||
}
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('== GROUP ============================================');
|
||||
$baseGroup = $kernel->getContainer()->getParameter('ldap_basegroup');
|
||||
$this->writeln('');
|
||||
$this->writeln('== GROUP ============================================');
|
||||
$baseGroup = $this->container->getParameter('ldap_basegroup');
|
||||
|
||||
$datas = $em ->createQueryBuilder()
|
||||
->select('table')
|
||||
->from('CadolesCoreBundle:Group','table')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
$datas = $this->em
|
||||
->createQueryBuilder()
|
||||
->select('table')
|
||||
->from('CadolesCoreBundle:Group','table')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
foreach($datas as $data) {
|
||||
$criteria = '(cn='.$data->getLabel().')';
|
||||
$subbranch=$baseGroup;
|
||||
|
@ -318,25 +319,26 @@ class SynchroCommand extends Command
|
|||
|
||||
// Mise à jour si elle existe
|
||||
if(count($results) > 0) {
|
||||
$output->writeln(' - Modification dans annuaire >> '.$data->getLabel());
|
||||
$this->writeln(' - Modification dans annuaire >> '.$data->getLabel());
|
||||
if(!$simulate) $ldap->modifyGroup($data,$data->getLabel());
|
||||
}
|
||||
// Sinon création de la fiche
|
||||
else {
|
||||
$output->writeln(' - Création dans annuaire >> '.$data->getLabel());
|
||||
$this->writeln(' - Création dans annuaire >> '.$data->getLabel());
|
||||
if(!$simulate) $ldap->addGroup($data);
|
||||
}
|
||||
}
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('== USER =============================================');
|
||||
$baseUser = $kernel->getContainer()->getParameter('ldap_baseuser');
|
||||
$this->writeln('');
|
||||
$this->writeln('== USER =============================================');
|
||||
$baseUser = $this->container->getParameter('ldap_baseuser');
|
||||
|
||||
$datas = $em ->createQueryBuilder()
|
||||
->select('table')
|
||||
->from('CadolesCoreBundle:User','table')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
$datas = $this->em
|
||||
->createQueryBuilder()
|
||||
->select('table')
|
||||
->from('CadolesCoreBundle:User','table')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
foreach($datas as $data) {
|
||||
$criteria = '(uid='.$data->getUsername().')';
|
||||
$subbranch=$baseUser;
|
||||
|
@ -356,12 +358,12 @@ class SynchroCommand extends Command
|
|||
|
||||
// Mise à jour si elle existe
|
||||
if(count($results) > 0) {
|
||||
$output->writeln(' - Modification dans annuaire >> '.$data->getUsername());
|
||||
$this->writeln(' - Modification dans annuaire >> '.$data->getUsername());
|
||||
if(!$simulate) $ldap->modifyUser($data);
|
||||
}
|
||||
// Sinon création de la fiche
|
||||
else {
|
||||
$output->writeln(' - Création dans annuaire >> '.$data->getUsername());
|
||||
$this->writeln(' - Création dans annuaire >> '.$data->getUsername());
|
||||
if(!$simulate) $ldap->addUser($data);
|
||||
}
|
||||
|
||||
|
@ -369,15 +371,16 @@ class SynchroCommand extends Command
|
|||
if(!$simulate) $ldap->addGroupUser($data);
|
||||
}
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('== USER GROUP =======================================');
|
||||
$baseGroup = $kernel->getContainer()->getParameter('ldap_basegroup');
|
||||
$this->writeln('');
|
||||
$this->writeln('== USER GROUP =======================================');
|
||||
$baseGroup = $this->container->getParameter('ldap_basegroup');
|
||||
|
||||
$datas = $em ->createQueryBuilder()
|
||||
->select('table')
|
||||
->from('CadolesCoreBundle:Group','table')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
$datas = $this->em
|
||||
->createQueryBuilder()
|
||||
->select('table')
|
||||
->from('CadolesCoreBundle:Group','table')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
foreach($datas as $data) {
|
||||
$criteria = '(cn='.$data->getLabel().')';
|
||||
$subbranch=$baseGroup;
|
||||
|
@ -385,7 +388,7 @@ class SynchroCommand extends Command
|
|||
|
||||
// Mise à jour des membres du groupes
|
||||
if(count($results) > 0) {
|
||||
$output->writeln(' - '.$data->getLabel());
|
||||
$this->writeln(' - '.$data->getLabel());
|
||||
$dn=$ldap->getGroupDN($data->getLabel());
|
||||
$attrs["memberuid"]=array();
|
||||
$attrs["cadolesMember"]=array();
|
||||
|
@ -393,162 +396,160 @@ class SynchroCommand extends Command
|
|||
foreach($data->getUsers() as $usergroupe) {
|
||||
array_push($attrs["memberuid"],$usergroupe->getUser()->getUsername());
|
||||
array_push($attrs["cadolesMember"],$ldap->getUserDN($usergroupe->getUser()));
|
||||
$output->writeln(' > '.$usergroupe->getUser()->getUsername());
|
||||
$this->writeln(' > '.$usergroupe->getUser()->getUsername());
|
||||
}
|
||||
if(!$simulate) $ldap->ldapModify($dn, $attrs);
|
||||
}
|
||||
}
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('=====================================================');
|
||||
$output->writeln('== SYNCHONISATION LDAP TO BUNDLE ====================');
|
||||
$output->writeln('=====================================================');
|
||||
$this->writeln('');
|
||||
$this->writeln('=====================================================');
|
||||
$this->writeln('== SYNCHONISATION LDAP TO BUNDLE ====================');
|
||||
$this->writeln('=====================================================');
|
||||
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('== NIVEAU01 =========================================');
|
||||
$baseNiveau01 = $kernel->getContainer()->getParameter('ldap_baseniveau01');
|
||||
$this->writeln('');
|
||||
$this->writeln('== NIVEAU01 =========================================');
|
||||
$baseNiveau01 = $this->container->getParameter('ldap_baseniveau01');
|
||||
|
||||
$criteria = '(cn=*)';
|
||||
$subbranch=$baseNiveau01;
|
||||
$results = $ldap->search($criteria, array('cn'), $subbranch);
|
||||
foreach($results as $result) {
|
||||
$data = $em->getRepository('CadolesCoreBundle:Niveau01')->findBy(array('label' => $result["cn"]));
|
||||
if($data) $output->writeln(' - Existe dans bundle >> '.$result["cn"]);
|
||||
$data = $this->em->getRepository('CadolesCoreBundle:Niveau01')->findBy(array('label' => $result["cn"]));
|
||||
if($data) $this->writeln(' - Existe dans bundle >> '.$result["cn"]);
|
||||
else {
|
||||
$output->writeln(' - A supprimer dans annuaire >> '.$result["cn"]);
|
||||
$this->writeln(' - A supprimer dans annuaire >> '.$result["cn"]);
|
||||
$dn=$ldap->getNiveau01DN($result["cn"]);
|
||||
if(!$simulate) $ldap->deleteByDN($dn);
|
||||
}
|
||||
}
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('== NIVEAU02 =========================================');
|
||||
$baseNiveau02 = $kernel->getContainer()->getParameter('ldap_baseniveau02');
|
||||
$this->writeln('');
|
||||
$this->writeln('== NIVEAU02 =========================================');
|
||||
$baseNiveau02 = $this->container->getParameter('ldap_baseniveau02');
|
||||
|
||||
$criteria = '(cn=*)';
|
||||
$subbranch=$baseNiveau02;
|
||||
$results = $ldap->search($criteria, array('cn'), $subbranch);
|
||||
foreach($results as $result) {
|
||||
$data = $em->getRepository('CadolesCoreBundle:Niveau02')->findBy(array('label' => $result["cn"]));
|
||||
if($data) $output->writeln(' - Existe dans bundle >> '.$result["cn"]);
|
||||
$data = $this->em->getRepository('CadolesCoreBundle:Niveau02')->findBy(array('label' => $result["cn"]));
|
||||
if($data) $this->writeln(' - Existe dans bundle >> '.$result["cn"]);
|
||||
else {
|
||||
$output->writeln(' - A supprimer dans annuaire >> '.$result["cn"]);
|
||||
$this->writeln(' - A supprimer dans annuaire >> '.$result["cn"]);
|
||||
$dn=$ldap->getNiveau02DN($result["cn"]);
|
||||
if(!$simulate) $ldap->deleteByDN($dn);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('== GROUP ============================================');
|
||||
$baseGroup = $kernel->getContainer()->getParameter('ldap_basegroup');
|
||||
$this->writeln('');
|
||||
$this->writeln('== GROUP ============================================');
|
||||
$baseGroup = $this->container->getParameter('ldap_basegroup');
|
||||
|
||||
$criteria = '(cn=*)';
|
||||
$subbranch=$baseGroup;
|
||||
$results = $ldap->search($criteria, array('cn'), $subbranch);
|
||||
foreach($results as $result) {
|
||||
$data = $em->getRepository('CadolesCoreBundle:Group')->findBy(array('label' => $result["cn"]));
|
||||
if($data) $output->writeln(' - Existe dans bundle >> '.$result["cn"]);
|
||||
$data = $this->em->getRepository('CadolesCoreBundle:Group')->findBy(array('label' => $result["cn"]));
|
||||
if($data) $this->writeln(' - Existe dans bundle >> '.$result["cn"]);
|
||||
else {
|
||||
$output->writeln(' - A supprimer dans annuaire >> '.$result["cn"]);
|
||||
$this->writeln(' - A supprimer dans annuaire >> '.$result["cn"]);
|
||||
$dn=$ldap->getGroupDN($result["cn"]);
|
||||
if(!$simulate) $ldap->deleteByDN($dn);
|
||||
}
|
||||
}
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('== USER =============================================');
|
||||
$baseUser = $kernel->getContainer()->getParameter('ldap_baseuser');
|
||||
$this->writeln('');
|
||||
$this->writeln('== USER =============================================');
|
||||
$baseUser = $this->container->getParameter('ldap_baseuser');
|
||||
|
||||
$criteria = '(uid=*)';
|
||||
$subbranch=$baseUser;
|
||||
$results = $ldap->search($criteria, array('uid'), $subbranch);
|
||||
foreach($results as $result) {
|
||||
$data = $em->getRepository('CadolesCoreBundle:User')->findBy(array('username' => $result["uid"]));
|
||||
if($data) $output->writeln(' - Existe dans bundle >> '.$result["uid"]);
|
||||
$data = $this->em->getRepository('CadolesCoreBundle:User')->findBy(array('username' => $result["uid"]));
|
||||
if($data) $this->writeln(' - Existe dans bundle >> '.$result["uid"]);
|
||||
else {
|
||||
$output->writeln(' - A supprimer dans annuaire >> '.$result["uid"]);
|
||||
$this->writeln(' - A supprimer dans annuaire >> '.$result["uid"]);
|
||||
$dn='uid='.$result["uid"].','.$baseUser;
|
||||
if(!$simulate) $ldap->deleteByDN($dn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$eportail = $this->container->get('cadoles.core.service.eportail');
|
||||
if($eportail->isEnabled()) {
|
||||
$this->writeln('');
|
||||
$this->writeln('=====================================================');
|
||||
$this->writeln('== SYNCHONISATION BUNDLE TO EPORTAIL ================');
|
||||
$this->writeln('=====================================================');
|
||||
|
||||
$this->writeln('');
|
||||
$this->writeln('== NIVEAU01 =========================================');
|
||||
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('=====================================================');
|
||||
$output->writeln('== SYNCHONISATION BUNDLE TO EPORTAIL ================');
|
||||
$output->writeln('=====================================================');
|
||||
|
||||
$eportail = $kernel->getContainer()->get('cadoles.core.service.eportail');
|
||||
if(!$eportail->isEnabled()) {
|
||||
$output->writeln('');
|
||||
$output->writeln(' Synchronisation ePortail désactivée');
|
||||
}
|
||||
else {
|
||||
$output->writeln('');
|
||||
$output->writeln('== NIVEAU01 =========================================');
|
||||
|
||||
$datas = $em ->createQueryBuilder()
|
||||
->select('table')
|
||||
->from('CadolesCoreBundle:Niveau01','table')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
$datas = $this->em
|
||||
->createQueryBuilder()
|
||||
->select('table')
|
||||
->from('CadolesCoreBundle:Niveau01','table')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
foreach($datas as $data) {
|
||||
$output->writeln(' - Synchronisation eportail >> '.$data->getLabel());
|
||||
$this->writeln(' - Synchronisation eportail >> '.$data->getLabel());
|
||||
if(!$simulate) $eportail->syncNiveau01($data,$data->getLabel());
|
||||
}
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('== NIVEAU02 =========================================');
|
||||
$this->writeln('');
|
||||
$this->writeln('== NIVEAU02 =========================================');
|
||||
|
||||
$datas = $em ->createQueryBuilder()
|
||||
->select('table')
|
||||
->from('CadolesCoreBundle:Niveau02','table')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
$datas = $this->em
|
||||
->createQueryBuilder()
|
||||
->select('table')
|
||||
->from('CadolesCoreBundle:Niveau02','table')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
foreach($datas as $data) {
|
||||
$output->writeln(' - Synchronisation eportail >> '.$data->getLabel());
|
||||
$this->writeln(' - Synchronisation eportail >> '.$data->getLabel());
|
||||
if(!$simulate) $eportail->syncNiveau02($data,$data->getLabel());
|
||||
}
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('== GROUP ============================================');
|
||||
$this->writeln('');
|
||||
$this->writeln('== GROUP ============================================');
|
||||
|
||||
$datas = $em ->createQueryBuilder()
|
||||
->select('table')
|
||||
->from('CadolesCoreBundle:Group','table')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
$datas = $this->em
|
||||
->createQueryBuilder()
|
||||
->select('table')
|
||||
->from('CadolesCoreBundle:Group','table')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
foreach($datas as $data) {
|
||||
$output->writeln(' - Synchronisation eportail >> '.$data->getLabel());
|
||||
$this->writeln(' - Synchronisation eportail >> '.$data->getLabel());
|
||||
if(!$simulate) $eportail->syncGroup($data,$data->getLabel());
|
||||
}
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('== USER =============================================');
|
||||
$this->writeln('');
|
||||
$this->writeln('== USER =============================================');
|
||||
|
||||
$datas = $em ->createQueryBuilder()
|
||||
->select('table')
|
||||
->from('CadolesCoreBundle:User','table')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
$datas = $this->em
|
||||
->createQueryBuilder()
|
||||
->select('table')
|
||||
->from('CadolesCoreBundle:User','table')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
foreach($datas as $data) {
|
||||
$output->writeln(' - Synchronisation eportail >> '.$data->getUsername());
|
||||
$this->writeln(' - Synchronisation eportail >> '.$data->getUsername());
|
||||
if(!$simulate) $eportail->syncUser($data);
|
||||
}
|
||||
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('=====================================================');
|
||||
$output->writeln('== SYNCHONISATION EPORTAIL TO BUNDLE ================');
|
||||
$output->writeln('=====================================================');
|
||||
$dbeportail= $kernel->getContainer()->get('service_container')->get('doctrine.orm.eportail_entity_manager')->getConnection();
|
||||
$this->writeln('');
|
||||
$this->writeln('=====================================================');
|
||||
$this->writeln('== SYNCHONISATION EPORTAIL TO BUNDLE ================');
|
||||
$this->writeln('=====================================================');
|
||||
$dbeportail= $this->container->get('service_container')->get('doctrine.orm.eportail_entity_manager')->getConnection();
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('== GROUP ============================================');
|
||||
$this->writeln('');
|
||||
$this->writeln('== GROUP ============================================');
|
||||
|
||||
$sql = "SELECT * FROM env_group WHERE group_id>0";
|
||||
$query = $dbeportail->prepare($sql);
|
||||
|
@ -557,65 +558,63 @@ class SynchroCommand extends Command
|
|||
$fgOK=false;
|
||||
if (strpos($row["group_name"], $labelniveau01.' = ') === 0) {
|
||||
$tmp=str_replace("$labelniveau01 = ","",$row["group_name"]);
|
||||
$data = $em->getRepository('CadolesCoreBundle:Niveau01')->findBy(array('label' =>$tmp));
|
||||
$data = $this->em->getRepository('CadolesCoreBundle:Niveau01')->findBy(array('label' =>$tmp));
|
||||
if($data) {
|
||||
$fgOK=true;
|
||||
$output->writeln(' - Existe dans bundle >> '.$row["group_name"]);
|
||||
$this->writeln(' - Existe dans bundle >> '.$row["group_name"]);
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($row["group_name"], $labelniveau02.' = ') === 0) {
|
||||
$tmp=str_replace("$labelniveau01 = ","",$row["group_name"]);
|
||||
$data = $em->getRepository('CadolesCoreBundle:Niveau02')->findBy(array('label' =>$tmp));
|
||||
$data = $this->em->getRepository('CadolesCoreBundle:Niveau02')->findBy(array('label' =>$tmp));
|
||||
if($data) {
|
||||
$fgOK=true;
|
||||
$output->writeln(' - Existe dans bundle >> '.$row["group_name"]);
|
||||
$this->writeln(' - Existe dans bundle >> '.$row["group_name"]);
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($row["group_name"], 'GROUPE = ') === 0) {
|
||||
$tmp=str_replace("GROUPE = ","",$row["group_name"]);
|
||||
$data = $em->getRepository('CadolesCoreBundle:Group')->findBy(array('label' =>$tmp));
|
||||
$data = $this->em->getRepository('CadolesCoreBundle:Group')->findBy(array('label' =>$tmp));
|
||||
if($data) {
|
||||
$fgOK=true;
|
||||
$output->writeln(' - Existe dans bundle >> '.$row["group_name"]);
|
||||
$this->writeln(' - Existe dans bundle >> '.$row["group_name"]);
|
||||
}
|
||||
}
|
||||
|
||||
if(!$fgOK) {
|
||||
$output->writeln(' - A supprimer dans eportail >> '.$row["group_name"]);
|
||||
$this->writeln(' - A supprimer dans eportail >> '.$row["group_name"]);
|
||||
if(!$simulate) delGroup($row["group_id"]);
|
||||
}
|
||||
}
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('== USER =============================================');
|
||||
$this->writeln('');
|
||||
$this->writeln('== USER =============================================');
|
||||
|
||||
$sql = "SELECT * FROM env_user WHERE user_id>0";
|
||||
$query = $dbeportail->prepare($sql);
|
||||
$query->execute();
|
||||
while($row=$query->fetch()){
|
||||
$data = $em->getRepository('CadolesCoreBundle:User')->findBy(array('username' =>$row["user_login"]));
|
||||
if($data) $output->writeln(' - Existe dans bundle >> '.$row["user_login"]);
|
||||
$data = $this->em->getRepository('CadolesCoreBundle:User')->findBy(array('username' =>$row["user_login"]));
|
||||
if($data) $this->writeln(' - Existe dans bundle >> '.$row["user_login"]);
|
||||
else {
|
||||
$output->writeln(' - A supprimer dans eportail >> '.$row["user_login"]);
|
||||
$this->writeln(' - A supprimer dans eportail >> '.$row["user_login"]);
|
||||
if(!$simulate) delUser($row["user_id"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('');
|
||||
$this->writeln('');
|
||||
$this->writeln('');
|
||||
}
|
||||
|
||||
protected static function determineKernelRootDir(Event $event) {
|
||||
$extra = $event->getComposer()->getPackage()->getExtra();
|
||||
$rootdir = rtrim(getcwd(), '/');
|
||||
return $rootdir . '/' . trim($extra['symfony-app-dir'], '/');
|
||||
}
|
||||
private function writelnred($string) { $this->output->writeln('<fg=red>'.$string.'</>'); }
|
||||
private function writeln($string) { $this->output->writeln($string); }
|
||||
|
||||
protected static function addmodGroup($em,$label,$ldapfilter) {
|
||||
$group=$em->getRepository('CadolesCoreBundle:Group')->findOneBy(array('fgtemplate' => true, 'label' => $label));
|
||||
protected function addmodGroup($label,$ldapfilter) {
|
||||
|
||||
$group=$this->em->getRepository('CadolesCoreBundle:Group')->findOneBy(array('fgtemplate' => true, 'label' => $label));
|
||||
if(!$group) {
|
||||
$group=new Group();
|
||||
}
|
||||
|
@ -626,23 +625,23 @@ class SynchroCommand extends Command
|
|||
$group->setLdapfilter($ldapfilter);
|
||||
$group->setFgtemplate(true);
|
||||
|
||||
$em->persist($group);
|
||||
$em->flush();
|
||||
$this->em->persist($group);
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
protected static function addtoGroup($em,$user,$group) {
|
||||
$member=$em->getRepository('CadolesCoreBundle:UserGroup')->findOneBy(array('group' => $group, 'user' => $user));
|
||||
protected function addtoGroup($user,$group) {
|
||||
$member=$this->em->getRepository('CadolesCoreBundle:UserGroup')->findOneBy(array('group' => $group, 'user' => $user));
|
||||
if(!$member) {
|
||||
$member= new UserGroup();
|
||||
$member->setGroup($group);
|
||||
$member->setUser($user);
|
||||
|
||||
$em->persist($member);
|
||||
$em->flush();
|
||||
$this->em->persist($member);
|
||||
$this->em->flush();
|
||||
}
|
||||
}
|
||||
|
||||
protected static function addUser($em,$niveau01,$username,$firstname,$lastname,$email,$usersadmin) {
|
||||
protected function addUser($niveau01,$username,$firstname,$lastname,$email,$usersadmin) {
|
||||
$user = new User();
|
||||
|
||||
$user->setUsername($username);
|
||||
|
@ -661,11 +660,11 @@ class SynchroCommand extends Command
|
|||
else
|
||||
$user->setRole("ROLE_USER");
|
||||
|
||||
$em->persist($user);
|
||||
$em->flush();
|
||||
$this->em->persist($user);
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
protected static function modUser($em,$user,$username,$firstname,$lastname,$email,$usersadmin) {
|
||||
protected function modUser($user,$username,$firstname,$lastname,$email,$usersadmin) {
|
||||
$user->setLastname($lastname);
|
||||
$user->setFirstname($firstname);
|
||||
$user->setEmail($email);
|
||||
|
@ -673,8 +672,8 @@ class SynchroCommand extends Command
|
|||
if(in_array($username,$usersadmin))
|
||||
$user->setRole("ROLE_ADMIN");
|
||||
|
||||
$em->persist($user);
|
||||
$em->flush();
|
||||
$this->em->persist($user);
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,21 +10,29 @@ INSERT IGNORE INTO `niveau01` (`id`, `label`, `siren`) VALUES
|
|||
INSERT IGNORE INTO `user` (`id`, `niveau01_id`, `username`, `firstname`, `lastname`, `password`, `email`, `avatar`, `role`,`siren`,`authlevel`) VALUES
|
||||
(-100, -100, 'admin', 'Administrateur', 'ldapbundle', 'PWD_CAS', 'admin@ldapbundle.ac-arno.fr', 'admin.jpg', 'ROLE_ADMIN', '0000000A', 'simple');
|
||||
|
||||
TRUNCATE TABLE sidebar;
|
||||
INSERT IGNORE INTO `sidebar` (`id`, `parent_id`, `roworder`, `label`, `path`, `fonticon`, `permission`) VALUES
|
||||
(1000, NULL, 1000, 'CONFIGIRATION', NULL, 'fa-gear', 'ROLE_ADMIN,ROLE_MODO'),
|
||||
(1010, 1000, 1010, 'Générale', 'cadoles_core_config_commun', 'fa-table', 'ROLE_ADMIN'),
|
||||
(1200, 1000, 1200, 'Organisations', NULL, 'fa-sitemap', 'ROLE_ADMIN,ROLE_MODO'),
|
||||
(1210, 1200, 1210, 'Listes Blanche', 'cadoles_core_config_whitelist', 'fa-tasks', 'ROLE_ADMIN'),
|
||||
(1220, 1200, 1220, 'Niveau 01', 'cadoles_core_config_niveau01', 'fa-building', 'ROLE_ADMIN'),
|
||||
(1240, 1200, 1240, 'Groupes', 'cadoles_core_config_group', 'fa-users', 'ROLE_ADMIN,ROLE_MODO'),
|
||||
(1250, 1200, 1250, 'Inscriptions', 'cadoles_core_config_registration', 'fa-pencil-square-o', 'ROLE_ADMIN,ROLE_MODO'),
|
||||
(1260, 1200, 1260, 'Utilisateurs', 'cadoles_core_config_user', 'fa-child', 'ROLE_ADMIN,ROLE_MODO'),
|
||||
|
||||
(1500, NULL, 1500, 'PORTAIL', NULL, 'fa-cubes', 'ROLE_ADMIN,ROLE_MODO'),
|
||||
(1510, 1500, 1510, 'Icônes', 'cadoles_portal_config_icon', 'fa-bug', 'ROLE_ADMIN,ROLE_MODO'),
|
||||
(1520, 1500, 1520, 'Items', 'cadoles_portal_config_item', 'fa-desktop', 'ROLE_ADMIN,ROLE_MODO'),
|
||||
(1530, 1500, 1530, 'Annonces', 'cadoles_portal_config_alert', 'fa-warning', 'ROLE_ADMIN,ROLE_MODO');
|
||||
|
||||
TRUNCATE TABLE sidebar;
|
||||
INSERT IGNORE INTO `sidebar` (`id`, `parent_id`, `roworder`, `label`, `path`, `fonticon`, `permission`, `appactivate`) VALUES
|
||||
(1000, NULL, 1000, 'CONFIGIRATION', '', 'fa-gear', 'ROLE_ADMIN,ROLE_MODO',''),
|
||||
(1010, 1000, 1010, 'Générale', 'cadoles_core_config_commun', 'fa-table', 'ROLE_ADMIN',''),
|
||||
(1200, NULL, 1200, 'ORGANISATION', NULL, 'fa-sitemap', 'ROLE_ADMIN,ROLE_MODO',''),
|
||||
(1210, 1200, 1210, 'Listes Blanche', 'cadoles_core_config_whitelist', 'fa-tasks', 'ROLE_ADMIN',''),
|
||||
(1220, 1200, 1220, 'Niveau 01', 'cadoles_core_config_niveau01', 'fa-building', 'ROLE_ADMIN',''),
|
||||
(1240, 1200, 1240, 'Groupes', 'cadoles_core_config_group', 'fa-users', 'ROLE_ADMIN,ROLE_MODO',''),
|
||||
(1250, 1200, 1250, 'Inscriptions', 'cadoles_core_config_registration', 'fa-pencil-square-o', 'ROLE_ADMIN,ROLE_MODO',''),
|
||||
(1260, 1200, 1260, 'Utilisateurs', 'cadoles_core_config_user', 'fa-child', 'ROLE_ADMIN,ROLE_MODO',''),
|
||||
|
||||
(1500, NULL, 1500, 'PORTAIL', NULL, 'fa-cubes', 'ROLE_ADMIN,ROLE_MODO','portal_activate'),
|
||||
(1510, 1500, 1510, 'Icônes', 'cadoles_portal_config_icon', 'fa-bug', 'ROLE_ADMIN,ROLE_MODO','portal_activate'),
|
||||
(1520, 1500, 1520, 'Items', 'cadoles_portal_config_item', 'fa-desktop', 'ROLE_ADMIN,ROLE_MODO','portal_activate'),
|
||||
(1530, 1500, 1530, 'Annonces', 'cadoles_portal_config_alert', 'fa-bell', 'ROLE_ADMIN,ROLE_MODO','portal_activate'),
|
||||
(1540, 1500, 1540, 'Pages', 'cadoles_portal_config_page', 'fa-file', 'ROLE_ADMIN,ROLE_MODO','portal_activate'),
|
||||
|
||||
(7000, NULL, 7000, 'CRON', NULL, 'fa-bolt', 'ROLE_ADMIN,ROLE_MODO', 'cron_activate'),
|
||||
(7010, 7000, 7010, 'Jobs', 'cadoles_cron_config', 'fa-bullseye', 'ROLE_ADMIN,ROLE_MODO', 'cron_activate');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -35,7 +43,7 @@ INSERT IGNORE INTO `config` (`order`, `visible`, `changeable`, `required`, `type
|
|||
('003', 1, 1, 0, 'string', 'subappname', 'Portail', '', 'Le sous titre de votre site'),
|
||||
('004', 1, 1, 1, 'logo', 'logo', 'uploads/logo/logo.png', '', 'Le logo de votre site'),
|
||||
|
||||
('040', 1, 1, 1, 'boolean', 'fgheader', '0', '', 'Utiliser une image en bannière du site'),
|
||||
('040', 1, 1, 1, 'boolean', 'fgheader', '1', '', 'Utiliser une image en bannière du site'),
|
||||
('041', 1, 1, 1, 'header', 'header', 'uploads/header/header.png', 'fgheader', 'Image en bannière du site'),
|
||||
('042', 1, 1, 1, 'integer', 'heightheader', '100', 'fgheader', 'Hauteur de la bannière du site'),
|
||||
|
||||
|
@ -45,6 +53,6 @@ INSERT IGNORE INTO `config` (`order`, `visible`, `changeable`, `required`, `type
|
|||
('060', 1, 1, 1, 'font', 'fontfacetitle', 'Anton-Regular', '', 'Police des titres de votre site'),
|
||||
('061', 1, 1, 1, 'font', 'fontfacebody', 'Helvetica', '', 'Police des titres de votre site'),
|
||||
|
||||
('200', 1, 1, 1, 'boolean', 'PROXYactivate', '1', '', 'Définit un Proxy'),
|
||||
('201', 1, 1, 1, 'string', 'PROXYserver', '192.168.57.160', 'PROXYactivate','Adresse du Proxy'),
|
||||
('202', 1, 1, 1, 'string', 'PROXYport', '8080', 'PROXYactivate','Port du Proxy');
|
||||
('200', 1, 0, 1, 'boolean', 'PROXYactivate', '1', '', 'Définit un Proxy'),
|
||||
('201', 1, 0, 1, 'string', 'PROXYserver', '192.168.57.160', 'PROXYactivate','Adresse du Proxy'),
|
||||
('202', 1, 0, 1, 'string', 'PROXYport', '8080', 'PROXYactivate','Port du Proxy');
|
||||
|
|
|
@ -12,7 +12,11 @@ class ConfigController extends Controller
|
|||
{
|
||||
public function homeAction(Request $request)
|
||||
{
|
||||
return $this->render('CadolesCoreBundle:Core:config.html.twig');
|
||||
return $this->render('CadolesCoreBundle:Core:config.html.twig',[
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function listAction()
|
||||
|
@ -28,7 +32,12 @@ class ConfigController extends Controller
|
|||
->getQuery()
|
||||
->getResult();
|
||||
|
||||
return $this->render('CadolesCoreBundle:Config:list.html.twig', array('configs' => $configs));
|
||||
return $this->render('CadolesCoreBundle:Config:list.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
'configs' => $configs
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateAction($id,Request $request)
|
||||
|
@ -76,11 +85,14 @@ class ConfigController extends Controller
|
|||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render('CadolesCoreBundle:Config:update.html.twig', array(
|
||||
'config' => $config,
|
||||
'type' => $type,
|
||||
'form' => $form->createView()
|
||||
));
|
||||
return $this->render('CadolesCoreBundle:Config:update.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
'config' => $config,
|
||||
'type' => $type,
|
||||
'form' => $form->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
public function deleteAction($id,Request $request)
|
||||
|
@ -93,17 +105,25 @@ class ConfigController extends Controller
|
|||
$em->persist($config);
|
||||
$em->flush();
|
||||
}
|
||||
return $this->redirectToRoute('cadoles_core_config_commun');
|
||||
return $this->redirectToRoute('cadoles_core_config_commun',['usesidebar'=>true]);
|
||||
}
|
||||
|
||||
public function logoAction()
|
||||
{
|
||||
return $this->render('CadolesCoreBundle:Config:logo.html.twig');
|
||||
return $this->render('CadolesCoreBundle:Config:logo.html.twig',[
|
||||
'useheader' => false,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
public function headerAction()
|
||||
{
|
||||
return $this->render('CadolesCoreBundle:Config:header.html.twig');
|
||||
return $this->render('CadolesCoreBundle:Config:header.html.twig',[
|
||||
'useheader' => false,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getConfig($id)
|
||||
|
|
|
@ -11,11 +11,10 @@ class CoreController extends Controller
|
|||
public function homeAction(Request $request)
|
||||
{
|
||||
$framed=$request->query->get('framed');
|
||||
return $this->render('CadolesCoreBundle:Core:home.html.twig');
|
||||
}
|
||||
|
||||
public function refreshAction(Request $request)
|
||||
{
|
||||
return $this->render('CadolesCoreBundle:Core:refresh.html.twig');
|
||||
return $this->render('CadolesCoreBundle:Core:home.html.twig',[
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => false,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,11 @@ class CropController extends Controller
|
|||
// Etape 01 - Téléchargement de l'image
|
||||
public function crop01Action()
|
||||
{
|
||||
return $this->render('CadolesCoreBundle:Crop:crop01.html.twig');
|
||||
return $this->render('CadolesCoreBundle:Crop:crop01.html.twig',[
|
||||
'useheader' => false,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
// Etape 02 - Couper votre l'image
|
||||
|
@ -59,7 +63,12 @@ class CropController extends Controller
|
|||
$cropped = $this->resizeThumbnailImage($thumb_image_location, $large_image_location,$data["w"],$data["h"],$data["x1"],$data["y1"],$scale);
|
||||
}
|
||||
|
||||
return $this->render('CadolesCoreBundle:Crop:crop02.html.twig', array('form' => $form->createView()));
|
||||
return $this->render('CadolesCoreBundle:Crop:crop02.html.twig', [
|
||||
'useheader' => false,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => false,
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
// Calcul de la hauteur
|
||||
|
|
|
@ -23,7 +23,11 @@ class GroupController extends Controller
|
|||
|
||||
public function listAction()
|
||||
{
|
||||
return $this->render('CadolesCoreBundle:Group:list.html.twig');
|
||||
return $this->render('CadolesCoreBundle:Group:list.html.twig',[
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function ajaxlistAction(Request $request)
|
||||
|
@ -438,11 +442,14 @@ class GroupController extends Controller
|
|||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'submit',
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateAction($id,Request $request)
|
||||
|
@ -484,11 +491,14 @@ class GroupController extends Controller
|
|||
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function deleteAction($id,Request $request)
|
||||
|
@ -523,11 +533,14 @@ class GroupController extends Controller
|
|||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'delete',
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function usersAction($id,Request $request)
|
||||
|
@ -536,9 +549,12 @@ class GroupController extends Controller
|
|||
$data=$this->getData($id);
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':users.html.twig', array(
|
||||
return $this->render($this->labelentity.':users.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getDatas()
|
||||
|
|
|
@ -21,7 +21,11 @@ class Niveau01Controller extends Controller
|
|||
|
||||
public function listAction()
|
||||
{
|
||||
return $this->render('CadolesCoreBundle:Niveau01:list.html.twig');
|
||||
return $this->render('CadolesCoreBundle:Niveau01:list.html.twig',[
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function ajaxlistAction(Request $request)
|
||||
|
@ -120,11 +124,14 @@ class Niveau01Controller extends Controller
|
|||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'submit',
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateAction($id,Request $request)
|
||||
|
@ -162,11 +169,14 @@ class Niveau01Controller extends Controller
|
|||
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function deleteAction($id,Request $request)
|
||||
|
@ -199,11 +209,14 @@ class Niveau01Controller extends Controller
|
|||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'delete',
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getDatas()
|
||||
|
|
|
@ -21,7 +21,11 @@ class Niveau02Controller extends Controller
|
|||
|
||||
public function listAction()
|
||||
{
|
||||
return $this->render('CadolesCoreBundle:Niveau02:list.html.twig');
|
||||
return $this->render('CadolesCoreBundle:Niveau02:list.html.twig',[
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function ajaxlistAction(Request $request)
|
||||
|
@ -116,11 +120,14 @@ class Niveau02Controller extends Controller
|
|||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'submit',
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateAction($id,Request $request)
|
||||
|
@ -154,11 +161,14 @@ class Niveau02Controller extends Controller
|
|||
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView(),
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function deleteAction($id,Request $request)
|
||||
|
@ -187,11 +197,14 @@ class Niveau02Controller extends Controller
|
|||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'delete',
|
||||
'form' => $form->createView(),
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getDatas()
|
||||
|
|
|
@ -32,7 +32,11 @@ class RegistrationController extends Controller
|
|||
if($moderegistration=="none"||$masteridentity!="SQL")
|
||||
throw $this->createNotFoundException('Permission denied');
|
||||
|
||||
return $this->render($this->labelentity.':list.html.twig');
|
||||
return $this->render($this->labelentity.':list.html.twig',[
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function ajaxlistAction(Request $request)
|
||||
|
@ -315,17 +319,23 @@ class RegistrationController extends Controller
|
|||
$em->flush();
|
||||
|
||||
// A voir retour sur un écran d'info indiquant si validation par admion ou s'il doit matter ses email
|
||||
return $this->render($this->labelentity.':info.html.twig', array(
|
||||
return $this->render($this->labelentity.':info.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => false,
|
||||
'info' => $info,
|
||||
'mode' => "info"
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => false,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'submit',
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
|
@ -397,11 +407,14 @@ class RegistrationController extends Controller
|
|||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'send',
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function validationAction($key,Request $request)
|
||||
|
@ -475,10 +488,13 @@ class RegistrationController extends Controller
|
|||
}
|
||||
|
||||
|
||||
return $this->render($this->labelentity.':info.html.twig', array(
|
||||
return $this->render($this->labelentity.':info.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => false,
|
||||
'info' => $info,
|
||||
'mode' => $mode
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -513,11 +529,14 @@ class RegistrationController extends Controller
|
|||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'delete',
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function resetpwd01Action(Request $request)
|
||||
|
@ -594,16 +613,22 @@ class RegistrationController extends Controller
|
|||
// Info
|
||||
$info="Vous allez recevoir un mail avec lien qui vous permettra de réinitialiser votre mot de passe";
|
||||
$mode="success";
|
||||
return $this->render($this->labelentity.':info.html.twig', array(
|
||||
return $this->render($this->labelentity.':info.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => false,
|
||||
'info' => $info,
|
||||
'mode' => $mode
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':resetpwd01.html.twig', array(
|
||||
return $this->render($this->labelentity.':resetpwd01.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => false,
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function resetpwd02Action($key,Request $request)
|
||||
|
@ -630,10 +655,13 @@ class RegistrationController extends Controller
|
|||
$info="Clé de validation invalide";
|
||||
$mode="danger";
|
||||
|
||||
return $this->render($this->labelentity.':info.html.twig', array(
|
||||
return $this->render($this->labelentity.':info.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => false,
|
||||
'info' => $info,
|
||||
'mode' => $mode
|
||||
));
|
||||
]);
|
||||
}
|
||||
else {
|
||||
// Création du formulaire
|
||||
|
@ -691,17 +719,23 @@ class RegistrationController extends Controller
|
|||
$mode="success";
|
||||
|
||||
|
||||
return $this->render($this->labelentity.':info.html.twig', array(
|
||||
return $this->render($this->labelentity.':info.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => false,
|
||||
'info' => $info,
|
||||
'mode' => $mode
|
||||
));
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':resetpwd02.html.twig', array(
|
||||
return $this->render($this->labelentity.':resetpwd02.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => false,
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,8 +38,11 @@ class SecurityController extends Controller
|
|||
$lastUsername = $authUtils->getLastUsername();
|
||||
|
||||
return $this->render('CadolesCoreBundle:Security:login.html.twig', array(
|
||||
'last_username' => $lastUsername,
|
||||
'error' => $error
|
||||
'useheader' => false,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => false,
|
||||
'last_username' => $lastUsername,
|
||||
'error' => $error
|
||||
));
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,12 @@ class UserController extends Controller
|
|||
|
||||
public function listAction($access)
|
||||
{
|
||||
return $this->render('CadolesCoreBundle:User:list.html.twig',array('access' => $access));
|
||||
return $this->render('CadolesCoreBundle:User:list.html.twig',[
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => ($access=="config"),
|
||||
'access' => $access
|
||||
]);
|
||||
}
|
||||
|
||||
public function ajaxlistAction($access, Request $request)
|
||||
|
@ -312,14 +317,17 @@ class UserController extends Controller
|
|||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'submit',
|
||||
'access' => 'config',
|
||||
'listgroups' => $this->getListGroups("config"),
|
||||
'listmodos' => $this->getListModos(),
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateAction($id,$access,Request $request)
|
||||
|
@ -465,14 +473,17 @@ class UserController extends Controller
|
|||
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => ($access=="config"),
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'update',
|
||||
'access' => $access,
|
||||
'listgroups' => $this->getListGroups($access),
|
||||
'listmodos' => $this->getListModos(),
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function deleteAction($id,Request $request)
|
||||
|
@ -520,14 +531,17 @@ class UserController extends Controller
|
|||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'delete',
|
||||
'access' => 'config',
|
||||
'listgroups' => $this->getListGroups("config"),
|
||||
'listmodos' => $this->getListModos(),
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function syncAction(Request $request)
|
||||
|
@ -535,27 +549,28 @@ class UserController extends Controller
|
|||
$kernel = $this->get('kernel');
|
||||
$application = new Application($kernel);
|
||||
$application->setAutoExit(false);
|
||||
$command = $application->find('Core:Synchro');
|
||||
|
||||
$input = new ArrayInput([
|
||||
'command' => 'Core:Synchro',
|
||||
'simulate' => 'false',
|
||||
]);
|
||||
$parameter = new ArrayInput(['simulate' => 'false']);
|
||||
|
||||
$output = new BufferedOutput(OutputInterface::VERBOSITY_NORMAL,false);
|
||||
$application->run($input, $output);
|
||||
$command->run($parameter, $output);
|
||||
$content = $output->fetch();
|
||||
|
||||
return $this->render('CadolesCoreBundle:Core:command.html.twig', array(
|
||||
"title"=>"Synchronisation avec Annuaire",
|
||||
"return_path"=>"cadoles_core_config_user",
|
||||
"content"=>$content
|
||||
));
|
||||
return $this->render('CadolesCoreBundle:Core:command.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
"title" =>"Synchronisation avec Annuaire",
|
||||
"return_path" =>"cadoles_core_config_user",
|
||||
"content" =>$content
|
||||
]);
|
||||
}
|
||||
|
||||
public function profilAction(Request $request)
|
||||
{
|
||||
$user = $this->get('security.token_storage')->getToken()->getUser();
|
||||
return $this->updateAction($user->getId(),"profil",$request);
|
||||
return $this->updateAction($user->getId(),"user",$request);
|
||||
}
|
||||
|
||||
protected function getDatas()
|
||||
|
|
|
@ -21,7 +21,11 @@ class WhitelistController extends Controller
|
|||
|
||||
public function listAction()
|
||||
{
|
||||
return $this->render('CadolesCoreBundle:Whitelist:list.html.twig');
|
||||
return $this->render('CadolesCoreBundle:Whitelist:list.html.twig',[
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function ajaxlistAction(Request $request)
|
||||
|
@ -116,11 +120,14 @@ class WhitelistController extends Controller
|
|||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'submit',
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateAction($id,Request $request)
|
||||
|
@ -154,11 +161,14 @@ class WhitelistController extends Controller
|
|||
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function deleteAction($id,Request $request)
|
||||
|
@ -187,11 +197,14 @@ class WhitelistController extends Controller
|
|||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'delete',
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getDatas()
|
||||
|
|
|
@ -46,6 +46,10 @@ class Sidebar
|
|||
*/
|
||||
private $permission;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=250, nullable=true)
|
||||
*/
|
||||
private $appactivate;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Sidebar", inversedBy="childs")
|
||||
|
@ -60,16 +64,8 @@ class Sidebar
|
|||
* @ORM\OneToMany(targetEntity="Sidebar", mappedBy="parent", cascade={"persist"}, orphanRemoval=false)
|
||||
* @ORM\OrderBy({"roworder" = "ASC"})
|
||||
*/
|
||||
private $childs;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->childs = new \Doctrine\Common\Collections\ArrayCollection();
|
||||
}
|
||||
|
||||
private $childs;
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
|
@ -200,6 +196,30 @@ class Sidebar
|
|||
return $this->permission;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set appactivate
|
||||
*
|
||||
* @param string $appactivate
|
||||
*
|
||||
* @return Sidebar
|
||||
*/
|
||||
public function setAppactivate($appactivate)
|
||||
{
|
||||
$this->appactivate = $appactivate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get appactivate
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAppactivate()
|
||||
{
|
||||
return $this->appactivate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set parent
|
||||
*
|
||||
|
@ -223,6 +243,13 @@ class Sidebar
|
|||
{
|
||||
return $this->parent;
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->childs = new \Doctrine\Common\Collections\ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add child
|
||||
|
|
|
@ -57,6 +57,10 @@
|
|||
if($curentuser=="anon.") $roles="";
|
||||
else $roles=$curentuser->getRoles();
|
||||
|
||||
// App activate
|
||||
$portal_activate =$this->container->getParameter('portal_activate');
|
||||
$cron_activate =$this->container->getParameter('cron_activate');
|
||||
|
||||
// Masteridentity
|
||||
$masteridentity =$this->container->getParameter('masteridentity');
|
||||
$session->set('masteridentity',$masteridentity);
|
||||
|
@ -87,6 +91,16 @@
|
|||
"path" => $nv1->getPath(),
|
||||
);
|
||||
|
||||
if($nv1->getAppactivate()=="portal_activate"&&!$portal_activate) {
|
||||
unset($sidebar[$nv1->getRoworder()]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if($nv1->getAppactivate()=="cron_activate"&&!$cron_activate) {
|
||||
unset($sidebar[$nv1->getRoworder()]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if($nv1->getPath()=="cadoles_core_config_niveau01") {
|
||||
$sidebar[$nv1->getRoworder()]["label"]=$labelsniveau01;
|
||||
$sidebar[$nv1->getRoworder()]["fonticon"]=$iconniveau01;
|
||||
|
@ -128,6 +142,10 @@
|
|||
if($moderegistration=="none")
|
||||
unset($sidebar[$nv1->getRoworder()]["childs"][$nv2->getRoworder()]);
|
||||
}
|
||||
if($nv2->getPath()=="cadoles_core_config_registration") {
|
||||
if($moderegistration=="none")
|
||||
unset($sidebar[$nv1->getRoworder()]["childs"][$nv2->getRoworder()]);
|
||||
}
|
||||
|
||||
foreach($nv2->getChilds() as $nv3) {
|
||||
if($this->haveRole($roles,$nv3->getPermission())) {
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
#== Home
|
||||
#== Home =================================================================================================================
|
||||
cadoles_core_home:
|
||||
path: /
|
||||
defaults: { _controller: CadolesCoreBundle:Core:home }
|
||||
|
||||
cadoles_core_refresh:
|
||||
path: /refresh
|
||||
defaults: { _controller: CadolesCoreBundle:Core:refresh }
|
||||
|
||||
#== Security Auth
|
||||
#== Security Auth ========================================================================================================
|
||||
cadoles_core_login:
|
||||
path: /login
|
||||
defaults: { _controller: CadolesCoreBundle:Security:login }
|
||||
|
@ -20,7 +16,7 @@ cadoles_core_kill:
|
|||
path: /kill
|
||||
defaults: { _controller: CadolesCoreBundle:Security:kill }
|
||||
|
||||
#== Crop Image
|
||||
#== Crop Image ===========================================================================================================
|
||||
cadoles_core_crop01:
|
||||
path: /crop01
|
||||
defaults: { _controller: CadolesCoreBundle:Crop:crop01 }
|
||||
|
@ -29,7 +25,7 @@ cadoles_core_crop02:
|
|||
path: /crop02
|
||||
defaults: { _controller: CadolesCoreBundle:Crop:crop02 }
|
||||
|
||||
#== Ajax
|
||||
#== Ajax =================================================================================================================
|
||||
cadoles_core_ajax_country_list:
|
||||
path: /ajax/country/list
|
||||
defaults: { _controller: CadolesCoreBundle:Ajax:countrylist }
|
||||
|
@ -51,42 +47,12 @@ cadoles_core_ajax_group_read:
|
|||
defaults: { _controller: CadolesCoreBundle:Ajax:groupread }
|
||||
|
||||
|
||||
#== Registration
|
||||
cadoles_core_registration:
|
||||
path: /registration
|
||||
defaults: { _controller: CadolesCoreBundle:Registration:submit }
|
||||
|
||||
cadoles_core_registration_validation:
|
||||
path: /registration/validation/{key}
|
||||
defaults: { _controller: CadolesCoreBundle:Registration:validation }
|
||||
|
||||
cadoles_core_resetpwd01:
|
||||
path: /resetpwd01
|
||||
defaults: { _controller: CadolesCoreBundle:Registration:resetpwd01 }
|
||||
|
||||
cadoles_core_resetpwd02:
|
||||
path: /resetpwd02/{key}
|
||||
defaults: { _controller: CadolesCoreBundle:Registration:resetpwd02 }
|
||||
|
||||
#== Profil
|
||||
cadoles_core_profil:
|
||||
path: /profil
|
||||
defaults: { _controller: CadolesCoreBundle:User:profil }
|
||||
|
||||
cadoles_core_profil_user_ajax_list:
|
||||
path: /profil/user/ajax/list
|
||||
defaults: { _controller: CadolesCoreBundle:User:ajaxlist, access: profil }
|
||||
|
||||
cadoles_core_profil_users:
|
||||
path: /profil/users
|
||||
defaults: { _controller: CadolesCoreBundle:User:list, access: profil }
|
||||
|
||||
#== Home Config
|
||||
#== Home Config ==========================================================================================================
|
||||
cadoles_core_config:
|
||||
path: /config/home
|
||||
defaults: { _controller: CadolesCoreBundle:Config:home }
|
||||
|
||||
#== Commun Config Commun
|
||||
#== Commun Config Commun =================================================================================================
|
||||
cadoles_core_config_commun:
|
||||
path: /config/commun
|
||||
defaults: { _controller: CadolesCoreBundle:Config:list }
|
||||
|
@ -107,14 +73,15 @@ cadoles_core_config_header:
|
|||
path: /config/commun/header
|
||||
defaults: { _controller: CadolesCoreBundle:Config:header }
|
||||
|
||||
#== Config Registration
|
||||
#== Registration =========================================================================================================
|
||||
#-- Access config
|
||||
cadoles_core_config_registration:
|
||||
path: /config/registration
|
||||
defaults: { _controller: CadolesCoreBundle:Registration:list }
|
||||
|
||||
cadoles_core_config_registration_send:
|
||||
path: /config/registration/send/{id}
|
||||
defaults: { _controller: CadolesCoreBundle:Registration:send }
|
||||
defaults: { _controller: CadolesCoreBundle:Registration:send }
|
||||
|
||||
cadoles_core_config_registration_delete:
|
||||
path: /config/registration/delete/{id}
|
||||
|
@ -124,14 +91,33 @@ cadoles_core_config_registration_ajax_list:
|
|||
path: /config/registration/ajax/list
|
||||
defaults: { _controller: CadolesCoreBundle:Registration:ajaxlist }
|
||||
|
||||
#== Config User
|
||||
#-- Access user
|
||||
cadoles_core_registration:
|
||||
path: /registration
|
||||
defaults: { _controller: CadolesCoreBundle:Registration:submit }
|
||||
|
||||
cadoles_core_registration_validation:
|
||||
path: /registration/validation/{key}
|
||||
defaults: { _controller: CadolesCoreBundle:Registration:validation }
|
||||
|
||||
cadoles_core_resetpwd01:
|
||||
path: /resetpwd01
|
||||
defaults: { _controller: CadolesCoreBundle:Registration:resetpwd01 }
|
||||
|
||||
cadoles_core_resetpwd02:
|
||||
path: /resetpwd02/{key}
|
||||
defaults: { _controller: CadolesCoreBundle:Registration:resetpwd02 }
|
||||
|
||||
|
||||
#== User =================================================================================================================
|
||||
#-- Access config
|
||||
cadoles_core_config_user:
|
||||
path: /config/user
|
||||
defaults: { _controller: CadolesCoreBundle:User:list, access: config }
|
||||
|
||||
cadoles_core_config_user_submit:
|
||||
path: /config/user/submit
|
||||
defaults: { _controller: CadolesCoreBundle:User:submit }
|
||||
defaults: { _controller: CadolesCoreBundle:User:submit, access: config }
|
||||
|
||||
cadoles_core_config_user_update:
|
||||
path: /config/user/update/{id}
|
||||
|
@ -139,17 +125,31 @@ cadoles_core_config_user_update:
|
|||
|
||||
cadoles_core_config_user_delete:
|
||||
path: /config/user/delete/{id}
|
||||
defaults: { _controller: CadolesCoreBundle:User:delete }
|
||||
defaults: { _controller: CadolesCoreBundle:User:delete, access: config }
|
||||
|
||||
cadoles_core_config_user_sync:
|
||||
path: /config/user/sync
|
||||
defaults: { _controller: CadolesCoreBundle:User:sync }
|
||||
defaults: { _controller: CadolesCoreBundle:User:sync, access: config }
|
||||
|
||||
cadoles_core_config_user_ajax_list:
|
||||
path: /config/user/ajax/list
|
||||
defaults: { _controller: CadolesCoreBundle:User:ajaxlist, access: config }
|
||||
defaults: { _controller: CadolesCoreBundle:User:ajaxlist, access: config }
|
||||
|
||||
#== Config Niveau01
|
||||
#-- Access user
|
||||
cadoles_core_profil:
|
||||
path: /user
|
||||
defaults: { _controller: CadolesCoreBundle:User:profil }
|
||||
|
||||
cadoles_core_profil_user_ajax_list:
|
||||
path: /user/user/ajax/list
|
||||
defaults: { _controller: CadolesCoreBundle:User:ajaxlist, access: user }
|
||||
|
||||
cadoles_core_profil_users:
|
||||
path: /user/users
|
||||
defaults: { _controller: CadolesCoreBundle:User:list, access: user }
|
||||
|
||||
|
||||
#== Niveau01 =============================================================================================================
|
||||
cadoles_core_config_niveau01:
|
||||
path: /config/niveau01
|
||||
defaults: { _controller: CadolesCoreBundle:Niveau01:list }
|
||||
|
@ -170,7 +170,7 @@ cadoles_core_config_niveau01_ajax_list:
|
|||
path: /config/niveau01/ajax/list
|
||||
defaults: { _controller: CadolesCoreBundle:Niveau01:ajaxlist }
|
||||
|
||||
#== Config Niveau02
|
||||
#== Niveau02 =============================================================================================================
|
||||
cadoles_core_config_niveau02:
|
||||
path: /config/niveau02
|
||||
defaults: { _controller: CadolesCoreBundle:Niveau02:list }
|
||||
|
@ -191,7 +191,7 @@ cadoles_core_config_niveau02_ajax_list:
|
|||
path: /config/niveau02/ajax/list
|
||||
defaults: { _controller: CadolesCoreBundle:Niveau02:ajaxlist }
|
||||
|
||||
#== Config Group
|
||||
#== Group ================================================================================================================
|
||||
cadoles_core_config_group:
|
||||
path: /config/group
|
||||
defaults: { _controller: CadolesCoreBundle:Group:list }
|
||||
|
@ -232,7 +232,7 @@ cadoles_core_config_group_ajax_usergroup_del:
|
|||
path: /config/group/ajax/usergroupdel
|
||||
defaults: { _controller: CadolesCoreBundle:Group:usergroupdel }
|
||||
|
||||
#== Config Whitelist
|
||||
#== Whitelist ============================================================================================================
|
||||
cadoles_core_config_whitelist:
|
||||
path: /config/whitelist
|
||||
defaults: { _controller: CadolesCoreBundle:Whitelist:list }
|
||||
|
|
|
@ -4,6 +4,18 @@ function ModalLoad(idmodal,title,path) {
|
|||
}
|
||||
|
||||
$(document).on('ready', function(){
|
||||
$(".pick-a-color").pickAColor({
|
||||
showSpectrum : true,
|
||||
showSavedColors : true,
|
||||
saveColorsPerElement : true,
|
||||
fadeMenuToggle : true,
|
||||
showAdvanced : true,
|
||||
showBasicColors : true,
|
||||
showHexInput : true,
|
||||
allowBlank : true,
|
||||
inlineDropdown : true
|
||||
});
|
||||
|
||||
$("a[data-method]").on('click',function(){
|
||||
var $el = $(this);
|
||||
|
||||
|
|
|
@ -0,0 +1,2499 @@
|
|||
/*!
|
||||
* Masonry PACKAGED v4.2.0
|
||||
* Cascading grid layout library
|
||||
* http://masonry.desandro.com
|
||||
* MIT License
|
||||
* by David DeSandro
|
||||
*/
|
||||
|
||||
/**
|
||||
* Bridget makes jQuery widgets
|
||||
* v2.0.1
|
||||
* MIT license
|
||||
*/
|
||||
|
||||
/* jshint browser: true, strict: true, undef: true, unused: true */
|
||||
|
||||
( function( window, factory ) {
|
||||
// universal module definition
|
||||
/*jshint strict: false */ /* globals define, module, require */
|
||||
if ( typeof define == 'function' && define.amd ) {
|
||||
// AMD
|
||||
define( 'jquery-bridget/jquery-bridget',[ 'jquery' ], function( jQuery ) {
|
||||
return factory( window, jQuery );
|
||||
});
|
||||
} else if ( typeof module == 'object' && module.exports ) {
|
||||
// CommonJS
|
||||
module.exports = factory(
|
||||
window,
|
||||
require('jquery')
|
||||
);
|
||||
} else {
|
||||
// browser global
|
||||
window.jQueryBridget = factory(
|
||||
window,
|
||||
window.jQuery
|
||||
);
|
||||
}
|
||||
|
||||
}( window, function factory( window, jQuery ) {
|
||||
'use strict';
|
||||
|
||||
// ----- utils ----- //
|
||||
|
||||
var arraySlice = Array.prototype.slice;
|
||||
|
||||
// helper function for logging errors
|
||||
// $.error breaks jQuery chaining
|
||||
var console = window.console;
|
||||
var logError = typeof console == 'undefined' ? function() {} :
|
||||
function( message ) {
|
||||
console.error( message );
|
||||
};
|
||||
|
||||
// ----- jQueryBridget ----- //
|
||||
|
||||
function jQueryBridget( namespace, PluginClass, $ ) {
|
||||
$ = $ || jQuery || window.jQuery;
|
||||
if ( !$ ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// add option method -> $().plugin('option', {...})
|
||||
if ( !PluginClass.prototype.option ) {
|
||||
// option setter
|
||||
PluginClass.prototype.option = function( opts ) {
|
||||
// bail out if not an object
|
||||
if ( !$.isPlainObject( opts ) ){
|
||||
return;
|
||||
}
|
||||
this.options = $.extend( true, this.options, opts );
|
||||
};
|
||||
}
|
||||
|
||||
// make jQuery plugin
|
||||
$.fn[ namespace ] = function( arg0 /*, arg1 */ ) {
|
||||
if ( typeof arg0 == 'string' ) {
|
||||
// method call $().plugin( 'methodName', { options } )
|
||||
// shift arguments by 1
|
||||
var args = arraySlice.call( arguments, 1 );
|
||||
return methodCall( this, arg0, args );
|
||||
}
|
||||
// just $().plugin({ options })
|
||||
plainCall( this, arg0 );
|
||||
return this;
|
||||
};
|
||||
|
||||
// $().plugin('methodName')
|
||||
function methodCall( $elems, methodName, args ) {
|
||||
var returnValue;
|
||||
var pluginMethodStr = '$().' + namespace + '("' + methodName + '")';
|
||||
|
||||
$elems.each( function( i, elem ) {
|
||||
// get instance
|
||||
var instance = $.data( elem, namespace );
|
||||
if ( !instance ) {
|
||||
logError( namespace + ' not initialized. Cannot call methods, i.e. ' +
|
||||
pluginMethodStr );
|
||||
return;
|
||||
}
|
||||
|
||||
var method = instance[ methodName ];
|
||||
if ( !method || methodName.charAt(0) == '_' ) {
|
||||
logError( pluginMethodStr + ' is not a valid method' );
|
||||
return;
|
||||
}
|
||||
|
||||
// apply method, get return value
|
||||
var value = method.apply( instance, args );
|
||||
// set return value if value is returned, use only first value
|
||||
returnValue = returnValue === undefined ? value : returnValue;
|
||||
});
|
||||
|
||||
return returnValue !== undefined ? returnValue : $elems;
|
||||
}
|
||||
|
||||
function plainCall( $elems, options ) {
|
||||
$elems.each( function( i, elem ) {
|
||||
var instance = $.data( elem, namespace );
|
||||
if ( instance ) {
|
||||
// set options & init
|
||||
instance.option( options );
|
||||
instance._init();
|
||||
} else {
|
||||
// initialize new instance
|
||||
instance = new PluginClass( elem, options );
|
||||
$.data( elem, namespace, instance );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
updateJQuery( $ );
|
||||
|
||||
}
|
||||
|
||||
// ----- updateJQuery ----- //
|
||||
|
||||
// set $.bridget for v1 backwards compatibility
|
||||
function updateJQuery( $ ) {
|
||||
if ( !$ || ( $ && $.bridget ) ) {
|
||||
return;
|
||||
}
|
||||
$.bridget = jQueryBridget;
|
||||
}
|
||||
|
||||
updateJQuery( jQuery || window.jQuery );
|
||||
|
||||
// ----- ----- //
|
||||
|
||||
return jQueryBridget;
|
||||
|
||||
}));
|
||||
|
||||
/**
|
||||
* EvEmitter v1.0.3
|
||||
* Lil' event emitter
|
||||
* MIT License
|
||||
*/
|
||||
|
||||
/* jshint unused: true, undef: true, strict: true */
|
||||
|
||||
( function( global, factory ) {
|
||||
// universal module definition
|
||||
/* jshint strict: false */ /* globals define, module, window */
|
||||
if ( typeof define == 'function' && define.amd ) {
|
||||
// AMD - RequireJS
|
||||
define( 'ev-emitter/ev-emitter',factory );
|
||||
} else if ( typeof module == 'object' && module.exports ) {
|
||||
// CommonJS - Browserify, Webpack
|
||||
module.exports = factory();
|
||||
} else {
|
||||
// Browser globals
|
||||
global.EvEmitter = factory();
|
||||
}
|
||||
|
||||
}( typeof window != 'undefined' ? window : this, function() {
|
||||
|
||||
|
||||
|
||||
function EvEmitter() {}
|
||||
|
||||
var proto = EvEmitter.prototype;
|
||||
|
||||
proto.on = function( eventName, listener ) {
|
||||
if ( !eventName || !listener ) {
|
||||
return;
|
||||
}
|
||||
// set events hash
|
||||
var events = this._events = this._events || {};
|
||||
// set listeners array
|
||||
var listeners = events[ eventName ] = events[ eventName ] || [];
|
||||
// only add once
|
||||
if ( listeners.indexOf( listener ) == -1 ) {
|
||||
listeners.push( listener );
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
proto.once = function( eventName, listener ) {
|
||||
if ( !eventName || !listener ) {
|
||||
return;
|
||||
}
|
||||
// add event
|
||||
this.on( eventName, listener );
|
||||
// set once flag
|
||||
// set onceEvents hash
|
||||
var onceEvents = this._onceEvents = this._onceEvents || {};
|
||||
// set onceListeners object
|
||||
var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || {};
|
||||
// set flag
|
||||
onceListeners[ listener ] = true;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
proto.off = function( eventName, listener ) {
|
||||
var listeners = this._events && this._events[ eventName ];
|
||||
if ( !listeners || !listeners.length ) {
|
||||
return;
|
||||
}
|
||||
var index = listeners.indexOf( listener );
|
||||
if ( index != -1 ) {
|
||||
listeners.splice( index, 1 );
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
proto.emitEvent = function( eventName, args ) {
|
||||
var listeners = this._events && this._events[ eventName ];
|
||||
if ( !listeners || !listeners.length ) {
|
||||
return;
|
||||
}
|
||||
var i = 0;
|
||||
var listener = listeners[i];
|
||||
args = args || [];
|
||||
// once stuff
|
||||
var onceListeners = this._onceEvents && this._onceEvents[ eventName ];
|
||||
|
||||
while ( listener ) {
|
||||
var isOnce = onceListeners && onceListeners[ listener ];
|
||||
if ( isOnce ) {
|
||||
// remove listener
|
||||
// remove before trigger to prevent recursion
|
||||
this.off( eventName, listener );
|
||||
// unset once flag
|
||||
delete onceListeners[ listener ];
|
||||
}
|
||||
// trigger listener
|
||||
listener.apply( this, args );
|
||||
// get next listener
|
||||
i += isOnce ? 0 : 1;
|
||||
listener = listeners[i];
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
return EvEmitter;
|
||||
|
||||
}));
|
||||
|
||||
/*!
|
||||
* getSize v2.0.2
|
||||
* measure size of elements
|
||||
* MIT license
|
||||
*/
|
||||
|
||||
/*jshint browser: true, strict: true, undef: true, unused: true */
|
||||
/*global define: false, module: false, console: false */
|
||||
|
||||
( function( window, factory ) {
|
||||
'use strict';
|
||||
|
||||
if ( typeof define == 'function' && define.amd ) {
|
||||
// AMD
|
||||
define( 'get-size/get-size',[],function() {
|
||||
return factory();
|
||||
});
|
||||
} else if ( typeof module == 'object' && module.exports ) {
|
||||
// CommonJS
|
||||
module.exports = factory();
|
||||
} else {
|
||||
// browser global
|
||||
window.getSize = factory();
|
||||
}
|
||||
|
||||
})( window, function factory() {
|
||||
'use strict';
|
||||
|
||||
// -------------------------- helpers -------------------------- //
|
||||
|
||||
// get a number from a string, not a percentage
|
||||
function getStyleSize( value ) {
|
||||
var num = parseFloat( value );
|
||||
// not a percent like '100%', and a number
|
||||
var isValid = value.indexOf('%') == -1 && !isNaN( num );
|
||||
return isValid && num;
|
||||
}
|
||||
|
||||
function noop() {}
|
||||
|
||||
var logError = typeof console == 'undefined' ? noop :
|
||||
function( message ) {
|
||||
console.error( message );
|
||||
};
|
||||
|
||||
// -------------------------- measurements -------------------------- //
|
||||
|
||||
var measurements = [
|
||||
'paddingLeft',
|
||||
'paddingRight',
|
||||
'paddingTop',
|
||||
'paddingBottom',
|
||||
'marginLeft',
|
||||
'marginRight',
|
||||
'marginTop',
|
||||
'marginBottom',
|
||||
'borderLeftWidth',
|
||||
'borderRightWidth',
|
||||
'borderTopWidth',
|
||||
'borderBottomWidth'
|
||||
];
|
||||
|
||||
var measurementsLength = measurements.length;
|
||||
|
||||
function getZeroSize() {
|
||||
var size = {
|
||||
width: 0,
|
||||
height: 0,
|
||||
innerWidth: 0,
|
||||
innerHeight: 0,
|
||||
outerWidth: 0,
|
||||
outerHeight: 0
|
||||
};
|
||||
for ( var i=0; i < measurementsLength; i++ ) {
|
||||
var measurement = measurements[i];
|
||||
size[ measurement ] = 0;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
// -------------------------- getStyle -------------------------- //
|
||||
|
||||
/**
|
||||
* getStyle, get style of element, check for Firefox bug
|
||||
* https://bugzilla.mozilla.org/show_bug.cgi?id=548397
|
||||
*/
|
||||
function getStyle( elem ) {
|
||||
var style = getComputedStyle( elem );
|
||||
if ( !style ) {
|
||||
logError( 'Style returned ' + style +
|
||||
'. Are you running this code in a hidden iframe on Firefox? ' +
|
||||
'See http://bit.ly/getsizebug1' );
|
||||
}
|
||||
return style;
|
||||
}
|
||||
|
||||
// -------------------------- setup -------------------------- //
|
||||
|
||||
var isSetup = false;
|
||||
|
||||
var isBoxSizeOuter;
|
||||
|
||||
/**
|
||||
* setup
|
||||
* check isBoxSizerOuter
|
||||
* do on first getSize() rather than on page load for Firefox bug
|
||||
*/
|
||||
function setup() {
|
||||
// setup once
|
||||
if ( isSetup ) {
|
||||
return;
|
||||
}
|
||||
isSetup = true;
|
||||
|
||||
// -------------------------- box sizing -------------------------- //
|
||||
|
||||
/**
|
||||
* WebKit measures the outer-width on style.width on border-box elems
|
||||
* IE & Firefox<29 measures the inner-width
|
||||
*/
|
||||
var div = document.createElement('div');
|
||||
div.style.width = '200px';
|
||||
div.style.padding = '1px 2px 3px 4px';
|
||||
div.style.borderStyle = 'solid';
|
||||
div.style.borderWidth = '1px 2px 3px 4px';
|
||||
div.style.boxSizing = 'border-box';
|
||||
|
||||
var body = document.body || document.documentElement;
|
||||
body.appendChild( div );
|
||||
var style = getStyle( div );
|
||||
|
||||
getSize.isBoxSizeOuter = isBoxSizeOuter = getStyleSize( style.width ) == 200;
|
||||
body.removeChild( div );
|
||||
|
||||
}
|
||||
|
||||
// -------------------------- getSize -------------------------- //
|
||||
|
||||
function getSize( elem ) {
|
||||
setup();
|
||||
|
||||
// use querySeletor if elem is string
|
||||
if ( typeof elem == 'string' ) {
|
||||
elem = document.querySelector( elem );
|
||||
}
|
||||
|
||||
// do not proceed on non-objects
|
||||
if ( !elem || typeof elem != 'object' || !elem.nodeType ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var style = getStyle( elem );
|
||||
|
||||
// if hidden, everything is 0
|
||||
if ( style.display == 'none' ) {
|
||||
return getZeroSize();
|
||||
}
|
||||
|
||||
var size = {};
|
||||
size.width = elem.offsetWidth;
|
||||
size.height = elem.offsetHeight;
|
||||
|
||||
var isBorderBox = size.isBorderBox = style.boxSizing == 'border-box';
|
||||
|
||||
// get all measurements
|
||||
for ( var i=0; i < measurementsLength; i++ ) {
|
||||
var measurement = measurements[i];
|
||||
var value = style[ measurement ];
|
||||
var num = parseFloat( value );
|
||||
// any 'auto', 'medium' value will be 0
|
||||
size[ measurement ] = !isNaN( num ) ? num : 0;
|
||||
}
|
||||
|
||||
var paddingWidth = size.paddingLeft + size.paddingRight;
|
||||
var paddingHeight = size.paddingTop + size.paddingBottom;
|
||||
var marginWidth = size.marginLeft + size.marginRight;
|
||||
var marginHeight = size.marginTop + size.marginBottom;
|
||||
var borderWidth = size.borderLeftWidth + size.borderRightWidth;
|
||||
var borderHeight = size.borderTopWidth + size.borderBottomWidth;
|
||||
|
||||
var isBorderBoxSizeOuter = isBorderBox && isBoxSizeOuter;
|
||||
|
||||
// overwrite width and height if we can get it from style
|
||||
var styleWidth = getStyleSize( style.width );
|
||||
if ( styleWidth !== false ) {
|
||||
size.width = styleWidth +
|
||||
// add padding and border unless it's already including it
|
||||
( isBorderBoxSizeOuter ? 0 : paddingWidth + borderWidth );
|
||||
}
|
||||
|
||||
var styleHeight = getStyleSize( style.height );
|
||||
if ( styleHeight !== false ) {
|
||||
size.height = styleHeight +
|
||||
// add padding and border unless it's already including it
|
||||
( isBorderBoxSizeOuter ? 0 : paddingHeight + borderHeight );
|
||||
}
|
||||
|
||||
size.innerWidth = size.width - ( paddingWidth + borderWidth );
|
||||
size.innerHeight = size.height - ( paddingHeight + borderHeight );
|
||||
|
||||
size.outerWidth = size.width + marginWidth;
|
||||
size.outerHeight = size.height + marginHeight;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
return getSize;
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* matchesSelector v2.0.2
|
||||
* matchesSelector( element, '.selector' )
|
||||
* MIT license
|
||||
*/
|
||||
|
||||
/*jshint browser: true, strict: true, undef: true, unused: true */
|
||||
|
||||
( function( window, factory ) {
|
||||
/*global define: false, module: false */
|
||||
'use strict';
|
||||
// universal module definition
|
||||
if ( typeof define == 'function' && define.amd ) {
|
||||
// AMD
|
||||
define( 'desandro-matches-selector/matches-selector',factory );
|
||||
} else if ( typeof module == 'object' && module.exports ) {
|
||||
// CommonJS
|
||||
module.exports = factory();
|
||||
} else {
|
||||
// browser global
|
||||
window.matchesSelector = factory();
|
||||
}
|
||||
|
||||
}( window, function factory() {
|
||||
'use strict';
|
||||
|
||||
var matchesMethod = ( function() {
|
||||
var ElemProto = window.Element.prototype;
|
||||
// check for the standard method name first
|
||||
if ( ElemProto.matches ) {
|
||||
return 'matches';
|
||||
}
|
||||
// check un-prefixed
|
||||
if ( ElemProto.matchesSelector ) {
|
||||
return 'matchesSelector';
|
||||
}
|
||||
// check vendor prefixes
|
||||
var prefixes = [ 'webkit', 'moz', 'ms', 'o' ];
|
||||
|
||||
for ( var i=0; i < prefixes.length; i++ ) {
|
||||
var prefix = prefixes[i];
|
||||
var method = prefix + 'MatchesSelector';
|
||||
if ( ElemProto[ method ] ) {
|
||||
return method;
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
return function matchesSelector( elem, selector ) {
|
||||
return elem[ matchesMethod ]( selector );
|
||||
};
|
||||
|
||||
}));
|
||||
|
||||
/**
|
||||
* Fizzy UI utils v2.0.4
|
||||
* MIT license
|
||||
*/
|
||||
|
||||
/*jshint browser: true, undef: true, unused: true, strict: true */
|
||||
|
||||
( function( window, factory ) {
|
||||
// universal module definition
|
||||
/*jshint strict: false */ /*globals define, module, require */
|
||||
|
||||
if ( typeof define == 'function' && define.amd ) {
|
||||
// AMD
|
||||
define( 'fizzy-ui-utils/utils',[
|
||||
'desandro-matches-selector/matches-selector'
|
||||
], function( matchesSelector ) {
|
||||
return factory( window, matchesSelector );
|
||||
});
|
||||
} else if ( typeof module == 'object' && module.exports ) {
|
||||
// CommonJS
|
||||
module.exports = factory(
|
||||
window,
|
||||
require('desandro-matches-selector')
|
||||
);
|
||||
} else {
|
||||
// browser global
|
||||
window.fizzyUIUtils = factory(
|
||||
window,
|
||||
window.matchesSelector
|
||||
);
|
||||
}
|
||||
|
||||
}( window, function factory( window, matchesSelector ) {
|
||||
|
||||
|
||||
|
||||
var utils = {};
|
||||
|
||||
// ----- extend ----- //
|
||||
|
||||
// extends objects
|
||||
utils.extend = function( a, b ) {
|
||||
for ( var prop in b ) {
|
||||
a[ prop ] = b[ prop ];
|
||||
}
|
||||
return a;
|
||||
};
|
||||
|
||||
// ----- modulo ----- //
|
||||
|
||||
utils.modulo = function( num, div ) {
|
||||
return ( ( num % div ) + div ) % div;
|
||||
};
|
||||
|
||||
// ----- makeArray ----- //
|
||||
|
||||
// turn element or nodeList into an array
|
||||
utils.makeArray = function( obj ) {
|
||||
var ary = [];
|
||||
if ( Array.isArray( obj ) ) {
|
||||
// use object if already an array
|
||||
ary = obj;
|
||||
} else if ( obj && typeof obj == 'object' &&
|
||||
typeof obj.length == 'number' ) {
|
||||
// convert nodeList to array
|
||||
for ( var i=0; i < obj.length; i++ ) {
|
||||
ary.push( obj[i] );
|
||||
}
|
||||
} else {
|
||||
// array of single index
|
||||
ary.push( obj );
|
||||
}
|
||||
return ary;
|
||||
};
|
||||
|
||||
// ----- removeFrom ----- //
|
||||
|
||||
utils.removeFrom = function( ary, obj ) {
|
||||
var index = ary.indexOf( obj );
|
||||
if ( index != -1 ) {
|
||||
ary.splice( index, 1 );
|
||||
}
|
||||
};
|
||||
|
||||
// ----- getParent ----- //
|
||||
|
||||
utils.getParent = function( elem, selector ) {
|
||||
while ( elem != document.body ) {
|
||||
elem = elem.parentNode;
|
||||
if ( matchesSelector( elem, selector ) ) {
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ----- getQueryElement ----- //
|
||||
|
||||
// use element as selector string
|
||||
utils.getQueryElement = function( elem ) {
|
||||
if ( typeof elem == 'string' ) {
|
||||
return document.querySelector( elem );
|
||||
}
|
||||
return elem;
|
||||
};
|
||||
|
||||
// ----- handleEvent ----- //
|
||||
|
||||
// enable .ontype to trigger from .addEventListener( elem, 'type' )
|
||||
utils.handleEvent = function( event ) {
|
||||
var method = 'on' + event.type;
|
||||
if ( this[ method ] ) {
|
||||
this[ method ]( event );
|
||||
}
|
||||
};
|
||||
|
||||
// ----- filterFindElements ----- //
|
||||
|
||||
utils.filterFindElements = function( elems, selector ) {
|
||||
// make array of elems
|
||||
elems = utils.makeArray( elems );
|
||||
var ffElems = [];
|
||||
|
||||
elems.forEach( function( elem ) {
|
||||
// check that elem is an actual element
|
||||
if ( !( elem instanceof HTMLElement ) ) {
|
||||
return;
|
||||
}
|
||||
// add elem if no selector
|
||||
if ( !selector ) {
|
||||
ffElems.push( elem );
|
||||
return;
|
||||
}
|
||||
// filter & find items if we have a selector
|
||||
// filter
|
||||
if ( matchesSelector( elem, selector ) ) {
|
||||
ffElems.push( elem );
|
||||
}
|
||||
// find children
|
||||
var childElems = elem.querySelectorAll( selector );
|
||||
// concat childElems to filterFound array
|
||||
for ( var i=0; i < childElems.length; i++ ) {
|
||||
ffElems.push( childElems[i] );
|
||||
}
|
||||
});
|
||||
|
||||
return ffElems;
|
||||
};
|
||||
|
||||
// ----- debounceMethod ----- //
|
||||
|
||||
utils.debounceMethod = function( _class, methodName, threshold ) {
|
||||
// original method
|
||||
var method = _class.prototype[ methodName ];
|
||||
var timeoutName = methodName + 'Timeout';
|
||||
|
||||
_class.prototype[ methodName ] = function() {
|
||||
var timeout = this[ timeoutName ];
|
||||
if ( timeout ) {
|
||||
clearTimeout( timeout );
|
||||
}
|
||||
var args = arguments;
|
||||
|
||||
var _this = this;
|
||||
this[ timeoutName ] = setTimeout( function() {
|
||||
method.apply( _this, args );
|
||||
delete _this[ timeoutName ];
|
||||
}, threshold || 100 );
|
||||
};
|
||||
};
|
||||
|
||||
// ----- docReady ----- //
|
||||
|
||||
utils.docReady = function( callback ) {
|
||||
var readyState = document.readyState;
|
||||
if ( readyState == 'complete' || readyState == 'interactive' ) {
|
||||
// do async to allow for other scripts to run. metafizzy/flickity#441
|
||||
setTimeout( callback );
|
||||
} else {
|
||||
document.addEventListener( 'DOMContentLoaded', callback );
|
||||
}
|
||||
};
|
||||
|
||||
// ----- htmlInit ----- //
|
||||
|
||||
// http://jamesroberts.name/blog/2010/02/22/string-functions-for-javascript-trim-to-camel-case-to-dashed-and-to-underscore/
|
||||
utils.toDashed = function( str ) {
|
||||
return str.replace( /(.)([A-Z])/g, function( match, $1, $2 ) {
|
||||
return $1 + '-' + $2;
|
||||
}).toLowerCase();
|
||||
};
|
||||
|
||||
var console = window.console;
|
||||
/**
|
||||
* allow user to initialize classes via [data-namespace] or .js-namespace class
|
||||
* htmlInit( Widget, 'widgetName' )
|
||||
* options are parsed from data-namespace-options
|
||||
*/
|
||||
utils.htmlInit = function( WidgetClass, namespace ) {
|
||||
utils.docReady( function() {
|
||||
var dashedNamespace = utils.toDashed( namespace );
|
||||
var dataAttr = 'data-' + dashedNamespace;
|
||||
var dataAttrElems = document.querySelectorAll( '[' + dataAttr + ']' );
|
||||
var jsDashElems = document.querySelectorAll( '.js-' + dashedNamespace );
|
||||
var elems = utils.makeArray( dataAttrElems )
|
||||
.concat( utils.makeArray( jsDashElems ) );
|
||||
var dataOptionsAttr = dataAttr + '-options';
|
||||
var jQuery = window.jQuery;
|
||||
|
||||
elems.forEach( function( elem ) {
|
||||
var attr = elem.getAttribute( dataAttr ) ||
|
||||
elem.getAttribute( dataOptionsAttr );
|
||||
var options;
|
||||
try {
|
||||
options = attr && JSON.parse( attr );
|
||||
} catch ( error ) {
|
||||
// log error, do not initialize
|
||||
if ( console ) {
|
||||
console.error( 'Error parsing ' + dataAttr + ' on ' + elem.className +
|
||||
': ' + error );
|
||||
}
|
||||
return;
|
||||
}
|
||||
// initialize
|
||||
var instance = new WidgetClass( elem, options );
|
||||
// make available via $().data('namespace')
|
||||
if ( jQuery ) {
|
||||
jQuery.data( elem, namespace, instance );
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
// ----- ----- //
|
||||
|
||||
return utils;
|
||||
|
||||
}));
|
||||
|
||||
/**
|
||||
* Outlayer Item
|
||||
*/
|
||||
|
||||
( function( window, factory ) {
|
||||
// universal module definition
|
||||
/* jshint strict: false */ /* globals define, module, require */
|
||||
if ( typeof define == 'function' && define.amd ) {
|
||||
// AMD - RequireJS
|
||||
define( 'outlayer/item',[
|
||||
'ev-emitter/ev-emitter',
|
||||
'get-size/get-size'
|
||||
],
|
||||
factory
|
||||
);
|
||||
} else if ( typeof module == 'object' && module.exports ) {
|
||||
// CommonJS - Browserify, Webpack
|
||||
module.exports = factory(
|
||||
require('ev-emitter'),
|
||||
require('get-size')
|
||||
);
|
||||
} else {
|
||||
// browser global
|
||||
window.Outlayer = {};
|
||||
window.Outlayer.Item = factory(
|
||||
window.EvEmitter,
|
||||
window.getSize
|
||||
);
|
||||
}
|
||||
|
||||
}( window, function factory( EvEmitter, getSize ) {
|
||||
'use strict';
|
||||
|
||||
// ----- helpers ----- //
|
||||
|
||||
function isEmptyObj( obj ) {
|
||||
for ( var prop in obj ) {
|
||||
return false;
|
||||
}
|
||||
prop = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
// -------------------------- CSS3 support -------------------------- //
|
||||
|
||||
|
||||
var docElemStyle = document.documentElement.style;
|
||||
|
||||
var transitionProperty = typeof docElemStyle.transition == 'string' ?
|
||||
'transition' : 'WebkitTransition';
|
||||
var transformProperty = typeof docElemStyle.transform == 'string' ?
|
||||
'transform' : 'WebkitTransform';
|
||||
|
||||
var transitionEndEvent = {
|
||||
WebkitTransition: 'webkitTransitionEnd',
|
||||
transition: 'transitionend'
|
||||
}[ transitionProperty ];
|
||||
|
||||
// cache all vendor properties that could have vendor prefix
|
||||
var vendorProperties = {
|
||||
transform: transformProperty,
|
||||
transition: transitionProperty,
|
||||
transitionDuration: transitionProperty + 'Duration',
|
||||
transitionProperty: transitionProperty + 'Property',
|
||||
transitionDelay: transitionProperty + 'Delay'
|
||||
};
|
||||
|
||||
// -------------------------- Item -------------------------- //
|
||||
|
||||
function Item( element, layout ) {
|
||||
if ( !element ) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.element = element;
|
||||
// parent layout class, i.e. Masonry, Isotope, or Packery
|
||||
this.layout = layout;
|
||||
this.position = {
|
||||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
|
||||
this._create();
|
||||
}
|
||||
|
||||
// inherit EvEmitter
|
||||
var proto = Item.prototype = Object.create( EvEmitter.prototype );
|
||||
proto.constructor = Item;
|
||||
|
||||
proto._create = function() {
|
||||
// transition objects
|
||||
this._transn = {
|
||||
ingProperties: {},
|
||||
clean: {},
|
||||
onEnd: {}
|
||||
};
|
||||
|
||||
this.css({
|
||||
position: 'absolute'
|
||||
});
|
||||
};
|
||||
|
||||
// trigger specified handler for event type
|
||||
proto.handleEvent = function( event ) {
|
||||
var method = 'on' + event.type;
|
||||
if ( this[ method ] ) {
|
||||
this[ method ]( event );
|
||||
}
|
||||
};
|
||||
|
||||
proto.getSize = function() {
|
||||
this.size = getSize( this.element );
|
||||
};
|
||||
|
||||
/**
|
||||
* apply CSS styles to element
|
||||
* @param {Object} style
|
||||
*/
|
||||
proto.css = function( style ) {
|
||||
var elemStyle = this.element.style;
|
||||
|
||||
for ( var prop in style ) {
|
||||
// use vendor property if available
|
||||
var supportedProp = vendorProperties[ prop ] || prop;
|
||||
elemStyle[ supportedProp ] = style[ prop ];
|
||||
}
|
||||
};
|
||||
|
||||
// measure position, and sets it
|
||||
proto.getPosition = function() {
|
||||
var style = getComputedStyle( this.element );
|
||||
var isOriginLeft = this.layout._getOption('originLeft');
|
||||
var isOriginTop = this.layout._getOption('originTop');
|
||||
var xValue = style[ isOriginLeft ? 'left' : 'right' ];
|
||||
var yValue = style[ isOriginTop ? 'top' : 'bottom' ];
|
||||
// convert percent to pixels
|
||||
var layoutSize = this.layout.size;
|
||||
var x = xValue.indexOf('%') != -1 ?
|
||||
( parseFloat( xValue ) / 100 ) * layoutSize.width : parseInt( xValue, 10 );
|
||||
var y = yValue.indexOf('%') != -1 ?
|
||||
( parseFloat( yValue ) / 100 ) * layoutSize.height : parseInt( yValue, 10 );
|
||||
|
||||
// clean up 'auto' or other non-integer values
|
||||
x = isNaN( x ) ? 0 : x;
|
||||
y = isNaN( y ) ? 0 : y;
|
||||
// remove padding from measurement
|
||||
x -= isOriginLeft ? layoutSize.paddingLeft : layoutSize.paddingRight;
|
||||
y -= isOriginTop ? layoutSize.paddingTop : layoutSize.paddingBottom;
|
||||
|
||||
this.position.x = x;
|
||||
this.position.y = y;
|
||||
};
|
||||
|
||||
// set settled position, apply padding
|
||||
proto.layoutPosition = function() {
|
||||
var layoutSize = this.layout.size;
|
||||
var style = {};
|
||||
var isOriginLeft = this.layout._getOption('originLeft');
|
||||
var isOriginTop = this.layout._getOption('originTop');
|
||||
|
||||
// x
|
||||
var xPadding = isOriginLeft ? 'paddingLeft' : 'paddingRight';
|
||||
var xProperty = isOriginLeft ? 'left' : 'right';
|
||||
var xResetProperty = isOriginLeft ? 'right' : 'left';
|
||||
|
||||
var x = this.position.x + layoutSize[ xPadding ];
|
||||
// set in percentage or pixels
|
||||
style[ xProperty ] = this.getXValue( x );
|
||||
// reset other property
|
||||
style[ xResetProperty ] = '';
|
||||
|
||||
// y
|
||||
var yPadding = isOriginTop ? 'paddingTop' : 'paddingBottom';
|
||||
var yProperty = isOriginTop ? 'top' : 'bottom';
|
||||
var yResetProperty = isOriginTop ? 'bottom' : 'top';
|
||||
|
||||
var y = this.position.y + layoutSize[ yPadding ];
|
||||
// set in percentage or pixels
|
||||
style[ yProperty ] = this.getYValue( y );
|
||||
// reset other property
|
||||
style[ yResetProperty ] = '';
|
||||
|
||||
this.css( style );
|
||||
this.emitEvent( 'layout', [ this ] );
|
||||
};
|
||||
|
||||
proto.getXValue = function( x ) {
|
||||
var isHorizontal = this.layout._getOption('horizontal');
|
||||
return this.layout.options.percentPosition && !isHorizontal ?
|
||||
( ( x / this.layout.size.width ) * 100 ) + '%' : x + 'px';
|
||||
};
|
||||
|
||||
proto.getYValue = function( y ) {
|
||||
var isHorizontal = this.layout._getOption('horizontal');
|
||||
return this.layout.options.percentPosition && isHorizontal ?
|
||||
( ( y / this.layout.size.height ) * 100 ) + '%' : y + 'px';
|
||||
};
|
||||
|
||||
proto._transitionTo = function( x, y ) {
|
||||
this.getPosition();
|
||||
// get current x & y from top/left
|
||||
var curX = this.position.x;
|
||||
var curY = this.position.y;
|
||||
|
||||
var compareX = parseInt( x, 10 );
|
||||
var compareY = parseInt( y, 10 );
|
||||
var didNotMove = compareX === this.position.x && compareY === this.position.y;
|
||||
|
||||
// save end position
|
||||
this.setPosition( x, y );
|
||||
|
||||
// if did not move and not transitioning, just go to layout
|
||||
if ( didNotMove && !this.isTransitioning ) {
|
||||
this.layoutPosition();
|
||||
return;
|
||||
}
|
||||
|
||||
var transX = x - curX;
|
||||
var transY = y - curY;
|
||||
var transitionStyle = {};
|
||||
transitionStyle.transform = this.getTranslate( transX, transY );
|
||||
|
||||
this.transition({
|
||||
to: transitionStyle,
|
||||
onTransitionEnd: {
|
||||
transform: this.layoutPosition
|
||||
},
|
||||
isCleaning: true
|
||||
});
|
||||
};
|
||||
|
||||
proto.getTranslate = function( x, y ) {
|
||||
// flip cooridinates if origin on right or bottom
|
||||
var isOriginLeft = this.layout._getOption('originLeft');
|
||||
var isOriginTop = this.layout._getOption('originTop');
|
||||
x = isOriginLeft ? x : -x;
|
||||
y = isOriginTop ? y : -y;
|
||||
return 'translate3d(' + x + 'px, ' + y + 'px, 0)';
|
||||
};
|
||||
|
||||
// non transition + transform support
|
||||
proto.goTo = function( x, y ) {
|
||||
this.setPosition( x, y );
|
||||
this.layoutPosition();
|
||||
};
|
||||
|
||||
proto.moveTo = proto._transitionTo;
|
||||
|
||||
proto.setPosition = function( x, y ) {
|
||||
this.position.x = parseInt( x, 10 );
|
||||
this.position.y = parseInt( y, 10 );
|
||||
};
|
||||
|
||||
// ----- transition ----- //
|
||||
|
||||
/**
|
||||
* @param {Object} style - CSS
|
||||
* @param {Function} onTransitionEnd
|
||||
*/
|
||||
|
||||
// non transition, just trigger callback
|
||||
proto._nonTransition = function( args ) {
|
||||
this.css( args.to );
|
||||
if ( args.isCleaning ) {
|
||||
this._removeStyles( args.to );
|
||||
}
|
||||
for ( var prop in args.onTransitionEnd ) {
|
||||
args.onTransitionEnd[ prop ].call( this );
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* proper transition
|
||||
* @param {Object} args - arguments
|
||||
* @param {Object} to - style to transition to
|
||||
* @param {Object} from - style to start transition from
|
||||
* @param {Boolean} isCleaning - removes transition styles after transition
|
||||
* @param {Function} onTransitionEnd - callback
|
||||
*/
|
||||
proto.transition = function( args ) {
|
||||
// redirect to nonTransition if no transition duration
|
||||
if ( !parseFloat( this.layout.options.transitionDuration ) ) {
|
||||
this._nonTransition( args );
|
||||
return;
|
||||
}
|
||||
|
||||
var _transition = this._transn;
|
||||
// keep track of onTransitionEnd callback by css property
|
||||
for ( var prop in args.onTransitionEnd ) {
|
||||
_transition.onEnd[ prop ] = args.onTransitionEnd[ prop ];
|
||||
}
|
||||
// keep track of properties that are transitioning
|
||||
for ( prop in args.to ) {
|
||||
_transition.ingProperties[ prop ] = true;
|
||||
// keep track of properties to clean up when transition is done
|
||||
if ( args.isCleaning ) {
|
||||
_transition.clean[ prop ] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// set from styles
|
||||
if ( args.from ) {
|
||||
this.css( args.from );
|
||||
// force redraw. http://blog.alexmaccaw.com/css-transitions
|
||||
var h = this.element.offsetHeight;
|
||||
// hack for JSHint to hush about unused var
|
||||
h = null;
|
||||
}
|
||||
// enable transition
|
||||
this.enableTransition( args.to );
|
||||
// set styles that are transitioning
|
||||
this.css( args.to );
|
||||
|
||||
this.isTransitioning = true;
|
||||
|
||||
};
|
||||
|
||||
// dash before all cap letters, including first for
|
||||
// WebkitTransform => -webkit-transform
|
||||
function toDashedAll( str ) {
|
||||
return str.replace( /([A-Z])/g, function( $1 ) {
|
||||
return '-' + $1.toLowerCase();
|
||||
});
|
||||
}
|
||||
|
||||
var transitionProps = 'opacity,' + toDashedAll( transformProperty );
|
||||
|
||||
proto.enableTransition = function(/* style */) {
|
||||
// HACK changing transitionProperty during a transition
|
||||
// will cause transition to jump
|
||||
if ( this.isTransitioning ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// make `transition: foo, bar, baz` from style object
|
||||
// HACK un-comment this when enableTransition can work
|
||||
// while a transition is happening
|
||||
// var transitionValues = [];
|
||||
// for ( var prop in style ) {
|
||||
// // dash-ify camelCased properties like WebkitTransition
|
||||
// prop = vendorProperties[ prop ] || prop;
|
||||
// transitionValues.push( toDashedAll( prop ) );
|
||||
// }
|
||||
// munge number to millisecond, to match stagger
|
||||
var duration = this.layout.options.transitionDuration;
|
||||
duration = typeof duration == 'number' ? duration + 'ms' : duration;
|
||||
// enable transition styles
|
||||
this.css({
|
||||
transitionProperty: transitionProps,
|
||||
transitionDuration: duration,
|
||||
transitionDelay: this.staggerDelay || 0
|
||||
});
|
||||
// listen for transition end event
|
||||
this.element.addEventListener( transitionEndEvent, this, false );
|
||||
};
|
||||
|
||||
// ----- events ----- //
|
||||
|
||||
proto.onwebkitTransitionEnd = function( event ) {
|
||||
this.ontransitionend( event );
|
||||
};
|
||||
|
||||
proto.onotransitionend = function( event ) {
|
||||
this.ontransitionend( event );
|
||||
};
|
||||
|
||||
// properties that I munge to make my life easier
|
||||
var dashedVendorProperties = {
|
||||
'-webkit-transform': 'transform'
|
||||
};
|
||||
|
||||
proto.ontransitionend = function( event ) {
|
||||
// disregard bubbled events from children
|
||||
if ( event.target !== this.element ) {
|
||||
return;
|
||||
}
|
||||
var _transition = this._transn;
|
||||
// get property name of transitioned property, convert to prefix-free
|
||||
var propertyName = dashedVendorProperties[ event.propertyName ] || event.propertyName;
|
||||
|
||||
// remove property that has completed transitioning
|
||||
delete _transition.ingProperties[ propertyName ];
|
||||
// check if any properties are still transitioning
|
||||
if ( isEmptyObj( _transition.ingProperties ) ) {
|
||||
// all properties have completed transitioning
|
||||
this.disableTransition();
|
||||
}
|
||||
// clean style
|
||||
if ( propertyName in _transition.clean ) {
|
||||
// clean up style
|
||||
this.element.style[ event.propertyName ] = '';
|
||||
delete _transition.clean[ propertyName ];
|
||||
}
|
||||
// trigger onTransitionEnd callback
|
||||
if ( propertyName in _transition.onEnd ) {
|
||||
var onTransitionEnd = _transition.onEnd[ propertyName ];
|
||||
onTransitionEnd.call( this );
|
||||
delete _transition.onEnd[ propertyName ];
|
||||
}
|
||||
|
||||
this.emitEvent( 'transitionEnd', [ this ] );
|
||||
};
|
||||
|
||||
proto.disableTransition = function() {
|
||||
this.removeTransitionStyles();
|
||||
this.element.removeEventListener( transitionEndEvent, this, false );
|
||||
this.isTransitioning = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* removes style property from element
|
||||
* @param {Object} style
|
||||
**/
|
||||
proto._removeStyles = function( style ) {
|
||||
// clean up transition styles
|
||||
var cleanStyle = {};
|
||||
for ( var prop in style ) {
|
||||
cleanStyle[ prop ] = '';
|
||||
}
|
||||
this.css( cleanStyle );
|
||||
};
|
||||
|
||||
var cleanTransitionStyle = {
|
||||
transitionProperty: '',
|
||||
transitionDuration: '',
|
||||
transitionDelay: ''
|
||||
};
|
||||
|
||||
proto.removeTransitionStyles = function() {
|
||||
// remove transition
|
||||
this.css( cleanTransitionStyle );
|
||||
};
|
||||
|
||||
// ----- stagger ----- //
|
||||
|
||||
proto.stagger = function( delay ) {
|
||||
delay = isNaN( delay ) ? 0 : delay;
|
||||
this.staggerDelay = delay + 'ms';
|
||||
};
|
||||
|
||||
// ----- show/hide/remove ----- //
|
||||
|
||||
// remove element from DOM
|
||||
proto.removeElem = function() {
|
||||
this.element.parentNode.removeChild( this.element );
|
||||
// remove display: none
|
||||
this.css({ display: '' });
|
||||
this.emitEvent( 'remove', [ this ] );
|
||||
};
|
||||
|
||||
proto.remove = function() {
|
||||
// just remove element if no transition support or no transition
|
||||
if ( !transitionProperty || !parseFloat( this.layout.options.transitionDuration ) ) {
|
||||
this.removeElem();
|
||||
return;
|
||||
}
|
||||
|
||||
// start transition
|
||||
this.once( 'transitionEnd', function() {
|
||||
this.removeElem();
|
||||
});
|
||||
this.hide();
|
||||
};
|
||||
|
||||
proto.reveal = function() {
|
||||
delete this.isHidden;
|
||||
// remove display: none
|
||||
this.css({ display: '' });
|
||||
|
||||
var options = this.layout.options;
|
||||
|
||||
var onTransitionEnd = {};
|
||||
var transitionEndProperty = this.getHideRevealTransitionEndProperty('visibleStyle');
|
||||
onTransitionEnd[ transitionEndProperty ] = this.onRevealTransitionEnd;
|
||||
|
||||
this.transition({
|
||||
from: options.hiddenStyle,
|
||||
to: options.visibleStyle,
|
||||
isCleaning: true,
|
||||
onTransitionEnd: onTransitionEnd
|
||||
});
|
||||
};
|
||||
|
||||
proto.onRevealTransitionEnd = function() {
|
||||
// check if still visible
|
||||
// during transition, item may have been hidden
|
||||
if ( !this.isHidden ) {
|
||||
this.emitEvent('reveal');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* get style property use for hide/reveal transition end
|
||||
* @param {String} styleProperty - hiddenStyle/visibleStyle
|
||||
* @returns {String}
|
||||
*/
|
||||
proto.getHideRevealTransitionEndProperty = function( styleProperty ) {
|
||||
var optionStyle = this.layout.options[ styleProperty ];
|
||||
// use opacity
|
||||
if ( optionStyle.opacity ) {
|
||||
return 'opacity';
|
||||
}
|
||||
// get first property
|
||||
for ( var prop in optionStyle ) {
|
||||
return prop;
|
||||
}
|
||||
};
|
||||
|
||||
proto.hide = function() {
|
||||
// set flag
|
||||
this.isHidden = true;
|
||||
// remove display: none
|
||||
this.css({ display: '' });
|
||||
|
||||
var options = this.layout.options;
|
||||
|
||||
var onTransitionEnd = {};
|
||||
var transitionEndProperty = this.getHideRevealTransitionEndProperty('hiddenStyle');
|
||||
onTransitionEnd[ transitionEndProperty ] = this.onHideTransitionEnd;
|
||||
|
||||
this.transition({
|
||||
from: options.visibleStyle,
|
||||
to: options.hiddenStyle,
|
||||
// keep hidden stuff hidden
|
||||
isCleaning: true,
|
||||
onTransitionEnd: onTransitionEnd
|
||||
});
|
||||
};
|
||||
|
||||
proto.onHideTransitionEnd = function() {
|
||||
// check if still hidden
|
||||
// during transition, item may have been un-hidden
|
||||
if ( this.isHidden ) {
|
||||
this.css({ display: 'none' });
|
||||
this.emitEvent('hide');
|
||||
}
|
||||
};
|
||||
|
||||
proto.destroy = function() {
|
||||
this.css({
|
||||
position: '',
|
||||
left: '',
|
||||
right: '',
|
||||
top: '',
|
||||
bottom: '',
|
||||
transition: '',
|
||||
transform: ''
|
||||
});
|
||||
};
|
||||
|
||||
return Item;
|
||||
|
||||
}));
|
||||
|
||||
/*!
|
||||
* Outlayer v2.1.0
|
||||
* the brains and guts of a layout library
|
||||
* MIT license
|
||||
*/
|
||||
|
||||
( function( window, factory ) {
|
||||
'use strict';
|
||||
// universal module definition
|
||||
/* jshint strict: false */ /* globals define, module, require */
|
||||
if ( typeof define == 'function' && define.amd ) {
|
||||
// AMD - RequireJS
|
||||
define( 'outlayer/outlayer',[
|
||||
'ev-emitter/ev-emitter',
|
||||
'get-size/get-size',
|
||||
'fizzy-ui-utils/utils',
|
||||
'./item'
|
||||
],
|
||||
function( EvEmitter, getSize, utils, Item ) {
|
||||
return factory( window, EvEmitter, getSize, utils, Item);
|
||||
}
|
||||
);
|
||||
} else if ( typeof module == 'object' && module.exports ) {
|
||||
// CommonJS - Browserify, Webpack
|
||||
module.exports = factory(
|
||||
window,
|
||||
require('ev-emitter'),
|
||||
require('get-size'),
|
||||
require('fizzy-ui-utils'),
|
||||
require('./item')
|
||||
);
|
||||
} else {
|
||||
// browser global
|
||||
window.Outlayer = factory(
|
||||
window,
|
||||
window.EvEmitter,
|
||||
window.getSize,
|
||||
window.fizzyUIUtils,
|
||||
window.Outlayer.Item
|
||||
);
|
||||
}
|
||||
|
||||
}( window, function factory( window, EvEmitter, getSize, utils, Item ) {
|
||||
'use strict';
|
||||
|
||||
// ----- vars ----- //
|
||||
|
||||
var console = window.console;
|
||||
var jQuery = window.jQuery;
|
||||
var noop = function() {};
|
||||
|
||||
// -------------------------- Outlayer -------------------------- //
|
||||
|
||||
// globally unique identifiers
|
||||
var GUID = 0;
|
||||
// internal store of all Outlayer intances
|
||||
var instances = {};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element, String} element
|
||||
* @param {Object} options
|
||||
* @constructor
|
||||
*/
|
||||
function Outlayer( element, options ) {
|
||||
var queryElement = utils.getQueryElement( element );
|
||||
if ( !queryElement ) {
|
||||
if ( console ) {
|
||||
console.error( 'Bad element for ' + this.constructor.namespace +
|
||||
': ' + ( queryElement || element ) );
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.element = queryElement;
|
||||
// add jQuery
|
||||
if ( jQuery ) {
|
||||
this.$element = jQuery( this.element );
|
||||
}
|
||||
|
||||
// options
|
||||
this.options = utils.extend( {}, this.constructor.defaults );
|
||||
this.option( options );
|
||||
|
||||
// add id for Outlayer.getFromElement
|
||||
var id = ++GUID;
|
||||
this.element.outlayerGUID = id; // expando
|
||||
instances[ id ] = this; // associate via id
|
||||
|
||||
// kick it off
|
||||
this._create();
|
||||
|
||||
var isInitLayout = this._getOption('initLayout');
|
||||
if ( isInitLayout ) {
|
||||
this.layout();
|
||||
}
|
||||
}
|
||||
|
||||
// settings are for internal use only
|
||||
Outlayer.namespace = 'outlayer';
|
||||
Outlayer.Item = Item;
|
||||
|
||||
// default options
|
||||
Outlayer.defaults = {
|
||||
containerStyle: {
|
||||
position: 'relative'
|
||||
},
|
||||
initLayout: true,
|
||||
originLeft: true,
|
||||
originTop: true,
|
||||
resize: true,
|
||||
resizeContainer: true,
|
||||
// item options
|
||||
transitionDuration: '0.4s',
|
||||
hiddenStyle: {
|
||||
opacity: 0,
|
||||
transform: 'scale(0.001)'
|
||||
},
|
||||
visibleStyle: {
|
||||
opacity: 1,
|
||||
transform: 'scale(1)'
|
||||
}
|
||||
};
|
||||
|
||||
var proto = Outlayer.prototype;
|
||||
// inherit EvEmitter
|
||||
utils.extend( proto, EvEmitter.prototype );
|
||||
|
||||
/**
|
||||
* set options
|
||||
* @param {Object} opts
|
||||
*/
|
||||
proto.option = function( opts ) {
|
||||
utils.extend( this.options, opts );
|
||||
};
|
||||
|
||||
/**
|
||||
* get backwards compatible option value, check old name
|
||||
*/
|
||||
proto._getOption = function( option ) {
|
||||
var oldOption = this.constructor.compatOptions[ option ];
|
||||
return oldOption && this.options[ oldOption ] !== undefined ?
|
||||
this.options[ oldOption ] : this.options[ option ];
|
||||
};
|
||||
|
||||
Outlayer.compatOptions = {
|
||||
// currentName: oldName
|
||||
initLayout: 'isInitLayout',
|
||||
horizontal: 'isHorizontal',
|
||||
layoutInstant: 'isLayoutInstant',
|
||||
originLeft: 'isOriginLeft',
|
||||
originTop: 'isOriginTop',
|
||||
resize: 'isResizeBound',
|
||||
resizeContainer: 'isResizingContainer'
|
||||
};
|
||||
|
||||
proto._create = function() {
|
||||
// get items from children
|
||||
this.reloadItems();
|
||||
// elements that affect layout, but are not laid out
|
||||
this.stamps = [];
|
||||
this.stamp( this.options.stamp );
|
||||
// set container style
|
||||
utils.extend( this.element.style, this.options.containerStyle );
|
||||
|
||||
// bind resize method
|
||||
var canBindResize = this._getOption('resize');
|
||||
if ( canBindResize ) {
|
||||
this.bindResize();
|
||||
}
|
||||
};
|
||||
|
||||
// goes through all children again and gets bricks in proper order
|
||||
proto.reloadItems = function() {
|
||||
// collection of item elements
|
||||
this.items = this._itemize( this.element.children );
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* turn elements into Outlayer.Items to be used in layout
|
||||
* @param {Array or NodeList or HTMLElement} elems
|
||||
* @returns {Array} items - collection of new Outlayer Items
|
||||
*/
|
||||
proto._itemize = function( elems ) {
|
||||
|
||||
var itemElems = this._filterFindItemElements( elems );
|
||||
var Item = this.constructor.Item;
|
||||
|
||||
// create new Outlayer Items for collection
|
||||
var items = [];
|
||||
for ( var i=0; i < itemElems.length; i++ ) {
|
||||
var elem = itemElems[i];
|
||||
var item = new Item( elem, this );
|
||||
items.push( item );
|
||||
}
|
||||
|
||||
return items;
|
||||
};
|
||||
|
||||
/**
|
||||
* get item elements to be used in layout
|
||||
* @param {Array or NodeList or HTMLElement} elems
|
||||
* @returns {Array} items - item elements
|
||||
*/
|
||||
proto._filterFindItemElements = function( elems ) {
|
||||
return utils.filterFindElements( elems, this.options.itemSelector );
|
||||
};
|
||||
|
||||
/**
|
||||
* getter method for getting item elements
|
||||
* @returns {Array} elems - collection of item elements
|
||||
*/
|
||||
proto.getItemElements = function() {
|
||||
return this.items.map( function( item ) {
|
||||
return item.element;
|
||||
});
|
||||
};
|
||||
|
||||
// ----- init & layout ----- //
|
||||
|
||||
/**
|
||||
* lays out all items
|
||||
*/
|
||||
proto.layout = function() {
|
||||
this._resetLayout();
|
||||
this._manageStamps();
|
||||
|
||||
// don't animate first layout
|
||||
var layoutInstant = this._getOption('layoutInstant');
|
||||
var isInstant = layoutInstant !== undefined ?
|
||||
layoutInstant : !this._isLayoutInited;
|
||||
this.layoutItems( this.items, isInstant );
|
||||
|
||||
// flag for initalized
|
||||
this._isLayoutInited = true;
|
||||
};
|
||||
|
||||
// _init is alias for layout
|
||||
proto._init = proto.layout;
|
||||
|
||||
/**
|
||||
* logic before any new layout
|
||||
*/
|
||||
proto._resetLayout = function() {
|
||||
this.getSize();
|
||||
};
|
||||
|
||||
|
||||
proto.getSize = function() {
|
||||
this.size = getSize( this.element );
|
||||
};
|
||||
|
||||
/**
|
||||
* get measurement from option, for columnWidth, rowHeight, gutter
|
||||
* if option is String -> get element from selector string, & get size of element
|
||||
* if option is Element -> get size of element
|
||||
* else use option as a number
|
||||
*
|
||||
* @param {String} measurement
|
||||
* @param {String} size - width or height
|
||||
* @private
|
||||
*/
|
||||
proto._getMeasurement = function( measurement, size ) {
|
||||
var option = this.options[ measurement ];
|
||||
var elem;
|
||||
if ( !option ) {
|
||||
// default to 0
|
||||
this[ measurement ] = 0;
|
||||
} else {
|
||||
// use option as an element
|
||||
if ( typeof option == 'string' ) {
|
||||
elem = this.element.querySelector( option );
|
||||
} else if ( option instanceof HTMLElement ) {
|
||||
elem = option;
|
||||
}
|
||||
// use size of element, if element
|
||||
this[ measurement ] = elem ? getSize( elem )[ size ] : option;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* layout a collection of item elements
|
||||
* @api public
|
||||
*/
|
||||
proto.layoutItems = function( items, isInstant ) {
|
||||
items = this._getItemsForLayout( items );
|
||||
|
||||
this._layoutItems( items, isInstant );
|
||||
|
||||
this._postLayout();
|
||||
};
|
||||
|
||||
/**
|
||||
* get the items to be laid out
|
||||
* you may want to skip over some items
|
||||
* @param {Array} items
|
||||
* @returns {Array} items
|
||||
*/
|
||||
proto._getItemsForLayout = function( items ) {
|
||||
return items.filter( function( item ) {
|
||||
return !item.isIgnored;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* layout items
|
||||
* @param {Array} items
|
||||
* @param {Boolean} isInstant
|
||||
*/
|
||||
proto._layoutItems = function( items, isInstant ) {
|
||||
this._emitCompleteOnItems( 'layout', items );
|
||||
|
||||
if ( !items || !items.length ) {
|
||||
// no items, emit event with empty array
|
||||
return;
|
||||
}
|
||||
|
||||
var queue = [];
|
||||
|
||||
items.forEach( function( item ) {
|
||||
// get x/y object from method
|
||||
var position = this._getItemLayoutPosition( item );
|
||||
// enqueue
|
||||
position.item = item;
|
||||
position.isInstant = isInstant || item.isLayoutInstant;
|
||||
queue.push( position );
|
||||
}, this );
|
||||
|
||||
this._processLayoutQueue( queue );
|
||||
};
|
||||
|
||||
/**
|
||||
* get item layout position
|
||||
* @param {Outlayer.Item} item
|
||||
* @returns {Object} x and y position
|
||||
*/
|
||||
proto._getItemLayoutPosition = function( /* item */ ) {
|
||||
return {
|
||||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* iterate over array and position each item
|
||||
* Reason being - separating this logic prevents 'layout invalidation'
|
||||
* thx @paul_irish
|
||||
* @param {Array} queue
|
||||
*/
|
||||
proto._processLayoutQueue = function( queue ) {
|
||||
this.updateStagger();
|
||||
queue.forEach( function( obj, i ) {
|
||||
this._positionItem( obj.item, obj.x, obj.y, obj.isInstant, i );
|
||||
}, this );
|
||||
};
|
||||
|
||||
// set stagger from option in milliseconds number
|
||||
proto.updateStagger = function() {
|
||||
var stagger = this.options.stagger;
|
||||
if ( stagger === null || stagger === undefined ) {
|
||||
this.stagger = 0;
|
||||
return;
|
||||
}
|
||||
this.stagger = getMilliseconds( stagger );
|
||||
return this.stagger;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets position of item in DOM
|
||||
* @param {Outlayer.Item} item
|
||||
* @param {Number} x - horizontal position
|
||||
* @param {Number} y - vertical position
|
||||
* @param {Boolean} isInstant - disables transitions
|
||||
*/
|
||||
proto._positionItem = function( item, x, y, isInstant, i ) {
|
||||
if ( isInstant ) {
|
||||
// if not transition, just set CSS
|
||||
item.goTo( x, y );
|
||||
} else {
|
||||
item.stagger( i * this.stagger );
|
||||
item.moveTo( x, y );
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Any logic you want to do after each layout,
|
||||
* i.e. size the container
|
||||
*/
|
||||
proto._postLayout = function() {
|
||||
this.resizeContainer();
|
||||
};
|
||||
|
||||
proto.resizeContainer = function() {
|
||||
var isResizingContainer = this._getOption('resizeContainer');
|
||||
if ( !isResizingContainer ) {
|
||||
return;
|
||||
}
|
||||
var size = this._getContainerSize();
|
||||
if ( size ) {
|
||||
this._setContainerMeasure( size.width, true );
|
||||
this._setContainerMeasure( size.height, false );
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets width or height of container if returned
|
||||
* @returns {Object} size
|
||||
* @param {Number} width
|
||||
* @param {Number} height
|
||||
*/
|
||||
proto._getContainerSize = noop;
|
||||
|
||||
/**
|
||||
* @param {Number} measure - size of width or height
|
||||
* @param {Boolean} isWidth
|
||||
*/
|
||||
proto._setContainerMeasure = function( measure, isWidth ) {
|
||||
if ( measure === undefined ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var elemSize = this.size;
|
||||
// add padding and border width if border box
|
||||
if ( elemSize.isBorderBox ) {
|
||||
measure += isWidth ? elemSize.paddingLeft + elemSize.paddingRight +
|
||||
elemSize.borderLeftWidth + elemSize.borderRightWidth :
|
||||
elemSize.paddingBottom + elemSize.paddingTop +
|
||||
elemSize.borderTopWidth + elemSize.borderBottomWidth;
|
||||
}
|
||||
|
||||
measure = Math.max( measure, 0 );
|
||||
this.element.style[ isWidth ? 'width' : 'height' ] = measure + 'px';
|
||||
};
|
||||
|
||||
/**
|
||||
* emit eventComplete on a collection of items events
|
||||
* @param {String} eventName
|
||||
* @param {Array} items - Outlayer.Items
|
||||
*/
|
||||
proto._emitCompleteOnItems = function( eventName, items ) {
|
||||
var _this = this;
|
||||
function onComplete() {
|
||||
_this.dispatchEvent( eventName + 'Complete', null, [ items ] );
|
||||
}
|
||||
|
||||
var count = items.length;
|
||||
if ( !items || !count ) {
|
||||
onComplete();
|
||||
return;
|
||||
}
|
||||
|
||||
var doneCount = 0;
|
||||
function tick() {
|
||||
doneCount++;
|
||||
if ( doneCount == count ) {
|
||||
onComplete();
|
||||
}
|
||||
}
|
||||
|
||||
// bind callback
|
||||
items.forEach( function( item ) {
|
||||
item.once( eventName, tick );
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* emits events via EvEmitter and jQuery events
|
||||
* @param {String} type - name of event
|
||||
* @param {Event} event - original event
|
||||
* @param {Array} args - extra arguments
|
||||
*/
|
||||
proto.dispatchEvent = function( type, event, args ) {
|
||||
// add original event to arguments
|
||||
var emitArgs = event ? [ event ].concat( args ) : args;
|
||||
this.emitEvent( type, emitArgs );
|
||||
|
||||
if ( jQuery ) {
|
||||
// set this.$element
|
||||
this.$element = this.$element || jQuery( this.element );
|
||||
if ( event ) {
|
||||
// create jQuery event
|
||||
var $event = jQuery.Event( event );
|
||||
$event.type = type;
|
||||
this.$element.trigger( $event, args );
|
||||
} else {
|
||||
// just trigger with type if no event available
|
||||
this.$element.trigger( type, args );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// -------------------------- ignore & stamps -------------------------- //
|
||||
|
||||
|
||||
/**
|
||||
* keep item in collection, but do not lay it out
|
||||
* ignored items do not get skipped in layout
|
||||
* @param {Element} elem
|
||||
*/
|
||||
proto.ignore = function( elem ) {
|
||||
var item = this.getItem( elem );
|
||||
if ( item ) {
|
||||
item.isIgnored = true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* return item to layout collection
|
||||
* @param {Element} elem
|
||||
*/
|
||||
proto.unignore = function( elem ) {
|
||||
var item = this.getItem( elem );
|
||||
if ( item ) {
|
||||
delete item.isIgnored;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* adds elements to stamps
|
||||
* @param {NodeList, Array, Element, or String} elems
|
||||
*/
|
||||
proto.stamp = function( elems ) {
|
||||
elems = this._find( elems );
|
||||
if ( !elems ) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.stamps = this.stamps.concat( elems );
|
||||
// ignore
|
||||
elems.forEach( this.ignore, this );
|
||||
};
|
||||
|
||||
/**
|
||||
* removes elements to stamps
|
||||
* @param {NodeList, Array, or Element} elems
|
||||
*/
|
||||
proto.unstamp = function( elems ) {
|
||||
elems = this._find( elems );
|
||||
if ( !elems ){
|
||||
return;
|
||||
}
|
||||
|
||||
elems.forEach( function( elem ) {
|
||||
// filter out removed stamp elements
|
||||
utils.removeFrom( this.stamps, elem );
|
||||
this.unignore( elem );
|
||||
}, this );
|
||||
};
|
||||
|
||||
/**
|
||||
* finds child elements
|
||||
* @param {NodeList, Array, Element, or String} elems
|
||||
* @returns {Array} elems
|
||||
*/
|
||||
proto._find = function( elems ) {
|
||||
if ( !elems ) {
|
||||
return;
|
||||
}
|
||||
// if string, use argument as selector string
|
||||
if ( typeof elems == 'string' ) {
|
||||
elems = this.element.querySelectorAll( elems );
|
||||
}
|
||||
elems = utils.makeArray( elems );
|
||||
return elems;
|
||||
};
|
||||
|
||||
proto._manageStamps = function() {
|
||||
if ( !this.stamps || !this.stamps.length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._getBoundingRect();
|
||||
|
||||
this.stamps.forEach( this._manageStamp, this );
|
||||
};
|
||||
|
||||
// update boundingLeft / Top
|
||||
proto._getBoundingRect = function() {
|
||||
// get bounding rect for container element
|
||||
var boundingRect = this.element.getBoundingClientRect();
|
||||
var size = this.size;
|
||||
this._boundingRect = {
|
||||
left: boundingRect.left + size.paddingLeft + size.borderLeftWidth,
|
||||
top: boundingRect.top + size.paddingTop + size.borderTopWidth,
|
||||
right: boundingRect.right - ( size.paddingRight + size.borderRightWidth ),
|
||||
bottom: boundingRect.bottom - ( size.paddingBottom + size.borderBottomWidth )
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Element} stamp
|
||||
**/
|
||||
proto._manageStamp = noop;
|
||||
|
||||
/**
|
||||
* get x/y position of element relative to container element
|
||||
* @param {Element} elem
|
||||
* @returns {Object} offset - has left, top, right, bottom
|
||||
*/
|
||||
proto._getElementOffset = function( elem ) {
|
||||
var boundingRect = elem.getBoundingClientRect();
|
||||
var thisRect = this._boundingRect;
|
||||
var size = getSize( elem );
|
||||
var offset = {
|
||||
left: boundingRect.left - thisRect.left - size.marginLeft,
|
||||
top: boundingRect.top - thisRect.top - size.marginTop,
|
||||
right: thisRect.right - boundingRect.right - size.marginRight,
|
||||
bottom: thisRect.bottom - boundingRect.bottom - size.marginBottom
|
||||
};
|
||||
return offset;
|
||||
};
|
||||
|
||||
// -------------------------- resize -------------------------- //
|
||||
|
||||
// enable event handlers for listeners
|
||||
// i.e. resize -> onresize
|
||||
proto.handleEvent = utils.handleEvent;
|
||||
|
||||
/**
|
||||
* Bind layout to window resizing
|
||||
*/
|
||||
proto.bindResize = function() {
|
||||
window.addEventListener( 'resize', this );
|
||||
this.isResizeBound = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Unbind layout to window resizing
|
||||
*/
|
||||
proto.unbindResize = function() {
|
||||
window.removeEventListener( 'resize', this );
|
||||
this.isResizeBound = false;
|
||||
};
|
||||
|
||||
proto.onresize = function() {
|
||||
this.resize();
|
||||
};
|
||||
|
||||
utils.debounceMethod( Outlayer, 'onresize', 100 );
|
||||
|
||||
proto.resize = function() {
|
||||
// don't trigger if size did not change
|
||||
// or if resize was unbound. See #9
|
||||
if ( !this.isResizeBound || !this.needsResizeLayout() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.layout();
|
||||
};
|
||||
|
||||
/**
|
||||
* check if layout is needed post layout
|
||||
* @returns Boolean
|
||||
*/
|
||||
proto.needsResizeLayout = function() {
|
||||
var size = getSize( this.element );
|
||||
// check that this.size and size are there
|
||||
// IE8 triggers resize on body size change, so they might not be
|
||||
var hasSizes = this.size && size;
|
||||
return hasSizes && size.innerWidth !== this.size.innerWidth;
|
||||
};
|
||||
|
||||
// -------------------------- methods -------------------------- //
|
||||
|
||||
/**
|
||||
* add items to Outlayer instance
|
||||
* @param {Array or NodeList or Element} elems
|
||||
* @returns {Array} items - Outlayer.Items
|
||||
**/
|
||||
proto.addItems = function( elems ) {
|
||||
var items = this._itemize( elems );
|
||||
// add items to collection
|
||||
if ( items.length ) {
|
||||
this.items = this.items.concat( items );
|
||||
}
|
||||
return items;
|
||||
};
|
||||
|
||||
/**
|
||||
* Layout newly-appended item elements
|
||||
* @param {Array or NodeList or Element} elems
|
||||
*/
|
||||
proto.appended = function( elems ) {
|
||||
var items = this.addItems( elems );
|
||||
if ( !items.length ) {
|
||||
return;
|
||||
}
|
||||
// layout and reveal just the new items
|
||||
this.layoutItems( items, true );
|
||||
this.reveal( items );
|
||||
};
|
||||
|
||||
/**
|
||||
* Layout prepended elements
|
||||
* @param {Array or NodeList or Element} elems
|
||||
*/
|
||||
proto.prepended = function( elems ) {
|
||||
var items = this._itemize( elems );
|
||||
if ( !items.length ) {
|
||||
return;
|
||||
}
|
||||
// add items to beginning of collection
|
||||
var previousItems = this.items.slice(0);
|
||||
this.items = items.concat( previousItems );
|
||||
// start new layout
|
||||
this._resetLayout();
|
||||
this._manageStamps();
|
||||
// layout new stuff without transition
|
||||
this.layoutItems( items, true );
|
||||
this.reveal( items );
|
||||
// layout previous items
|
||||
this.layoutItems( previousItems );
|
||||
};
|
||||
|
||||
/**
|
||||
* reveal a collection of items
|
||||
* @param {Array of Outlayer.Items} items
|
||||
*/
|
||||
proto.reveal = function( items ) {
|
||||
this._emitCompleteOnItems( 'reveal', items );
|
||||
if ( !items || !items.length ) {
|
||||
return;
|
||||
}
|
||||
var stagger = this.updateStagger();
|
||||
items.forEach( function( item, i ) {
|
||||
item.stagger( i * stagger );
|
||||
item.reveal();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* hide a collection of items
|
||||
* @param {Array of Outlayer.Items} items
|
||||
*/
|
||||
proto.hide = function( items ) {
|
||||
this._emitCompleteOnItems( 'hide', items );
|
||||
if ( !items || !items.length ) {
|
||||
return;
|
||||
}
|
||||
var stagger = this.updateStagger();
|
||||
items.forEach( function( item, i ) {
|
||||
item.stagger( i * stagger );
|
||||
item.hide();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* reveal item elements
|
||||
* @param {Array}, {Element}, {NodeList} items
|
||||
*/
|
||||
proto.revealItemElements = function( elems ) {
|
||||
var items = this.getItems( elems );
|
||||
this.reveal( items );
|
||||
};
|
||||
|
||||
/**
|
||||
* hide item elements
|
||||
* @param {Array}, {Element}, {NodeList} items
|
||||
*/
|
||||
proto.hideItemElements = function( elems ) {
|
||||
var items = this.getItems( elems );
|
||||
this.hide( items );
|
||||
};
|
||||
|
||||
/**
|
||||
* get Outlayer.Item, given an Element
|
||||
* @param {Element} elem
|
||||
* @param {Function} callback
|
||||
* @returns {Outlayer.Item} item
|
||||
*/
|
||||
proto.getItem = function( elem ) {
|
||||
// loop through items to get the one that matches
|
||||
for ( var i=0; i < this.items.length; i++ ) {
|
||||
var item = this.items[i];
|
||||
if ( item.element == elem ) {
|
||||
// return item
|
||||
return item;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* get collection of Outlayer.Items, given Elements
|
||||
* @param {Array} elems
|
||||
* @returns {Array} items - Outlayer.Items
|
||||
*/
|
||||
proto.getItems = function( elems ) {
|
||||
elems = utils.makeArray( elems );
|
||||
var items = [];
|
||||
elems.forEach( function( elem ) {
|
||||
var item = this.getItem( elem );
|
||||
if ( item ) {
|
||||
items.push( item );
|
||||
}
|
||||
}, this );
|
||||
|
||||
return items;
|
||||
};
|
||||
|
||||
/**
|
||||
* remove element(s) from instance and DOM
|
||||
* @param {Array or NodeList or Element} elems
|
||||
*/
|
||||
proto.remove = function( elems ) {
|
||||
var removeItems = this.getItems( elems );
|
||||
|
||||
this._emitCompleteOnItems( 'remove', removeItems );
|
||||
|
||||
// bail if no items to remove
|
||||
if ( !removeItems || !removeItems.length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
removeItems.forEach( function( item ) {
|
||||
item.remove();
|
||||
// remove item from collection
|
||||
utils.removeFrom( this.items, item );
|
||||
}, this );
|
||||
};
|
||||
|
||||
// ----- destroy ----- //
|
||||
|
||||
// remove and disable Outlayer instance
|
||||
proto.destroy = function() {
|
||||
// clean up dynamic styles
|
||||
var style = this.element.style;
|
||||
style.height = '';
|
||||
style.position = '';
|
||||
style.width = '';
|
||||
// destroy items
|
||||
this.items.forEach( function( item ) {
|
||||
item.destroy();
|
||||
});
|
||||
|
||||
this.unbindResize();
|
||||
|
||||
var id = this.element.outlayerGUID;
|
||||
delete instances[ id ]; // remove reference to instance by id
|
||||
delete this.element.outlayerGUID;
|
||||
// remove data for jQuery
|
||||
if ( jQuery ) {
|
||||
jQuery.removeData( this.element, this.constructor.namespace );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// -------------------------- data -------------------------- //
|
||||
|
||||
/**
|
||||
* get Outlayer instance from element
|
||||
* @param {Element} elem
|
||||
* @returns {Outlayer}
|
||||
*/
|
||||
Outlayer.data = function( elem ) {
|
||||
elem = utils.getQueryElement( elem );
|
||||
var id = elem && elem.outlayerGUID;
|
||||
return id && instances[ id ];
|
||||
};
|
||||
|
||||
|
||||
// -------------------------- create Outlayer class -------------------------- //
|
||||
|
||||
/**
|
||||
* create a layout class
|
||||
* @param {String} namespace
|
||||
*/
|
||||
Outlayer.create = function( namespace, options ) {
|
||||
// sub-class Outlayer
|
||||
var Layout = subclass( Outlayer );
|
||||
// apply new options and compatOptions
|
||||
Layout.defaults = utils.extend( {}, Outlayer.defaults );
|
||||
utils.extend( Layout.defaults, options );
|
||||
Layout.compatOptions = utils.extend( {}, Outlayer.compatOptions );
|
||||
|
||||
Layout.namespace = namespace;
|
||||
|
||||
Layout.data = Outlayer.data;
|
||||
|
||||
// sub-class Item
|
||||
Layout.Item = subclass( Item );
|
||||
|
||||
// -------------------------- declarative -------------------------- //
|
||||
|
||||
utils.htmlInit( Layout, namespace );
|
||||
|
||||
// -------------------------- jQuery bridge -------------------------- //
|
||||
|
||||
// make into jQuery plugin
|
||||
if ( jQuery && jQuery.bridget ) {
|
||||
jQuery.bridget( namespace, Layout );
|
||||
}
|
||||
|
||||
return Layout;
|
||||
};
|
||||
|
||||
function subclass( Parent ) {
|
||||
function SubClass() {
|
||||
Parent.apply( this, arguments );
|
||||
}
|
||||
|
||||
SubClass.prototype = Object.create( Parent.prototype );
|
||||
SubClass.prototype.constructor = SubClass;
|
||||
|
||||
return SubClass;
|
||||
}
|
||||
|
||||
// ----- helpers ----- //
|
||||
|
||||
// how many milliseconds are in each unit
|
||||
var msUnits = {
|
||||
ms: 1,
|
||||
s: 1000
|
||||
};
|
||||
|
||||
// munge time-like parameter into millisecond number
|
||||
// '0.4s' -> 40
|
||||
function getMilliseconds( time ) {
|
||||
if ( typeof time == 'number' ) {
|
||||
return time;
|
||||
}
|
||||
var matches = time.match( /(^\d*\.?\d*)(\w*)/ );
|
||||
var num = matches && matches[1];
|
||||
var unit = matches && matches[2];
|
||||
if ( !num.length ) {
|
||||
return 0;
|
||||
}
|
||||
num = parseFloat( num );
|
||||
var mult = msUnits[ unit ] || 1;
|
||||
return num * mult;
|
||||
}
|
||||
|
||||
// ----- fin ----- //
|
||||
|
||||
// back in global
|
||||
Outlayer.Item = Item;
|
||||
|
||||
return Outlayer;
|
||||
|
||||
}));
|
||||
|
||||
/*!
|
||||
* Masonry v4.2.0
|
||||
* Cascading grid layout library
|
||||
* http://masonry.desandro.com
|
||||
* MIT License
|
||||
* by David DeSandro
|
||||
*/
|
||||
|
||||
( function( window, factory ) {
|
||||
// universal module definition
|
||||
/* jshint strict: false */ /*globals define, module, require */
|
||||
if ( typeof define == 'function' && define.amd ) {
|
||||
// AMD
|
||||
define( [
|
||||
'outlayer/outlayer',
|
||||
'get-size/get-size'
|
||||
],
|
||||
factory );
|
||||
} else if ( typeof module == 'object' && module.exports ) {
|
||||
// CommonJS
|
||||
module.exports = factory(
|
||||
require('outlayer'),
|
||||
require('get-size')
|
||||
);
|
||||
} else {
|
||||
// browser global
|
||||
window.Masonry = factory(
|
||||
window.Outlayer,
|
||||
window.getSize
|
||||
);
|
||||
}
|
||||
|
||||
}( window, function factory( Outlayer, getSize ) {
|
||||
|
||||
|
||||
|
||||
// -------------------------- masonryDefinition -------------------------- //
|
||||
|
||||
// create an Outlayer layout class
|
||||
var Masonry = Outlayer.create('masonry');
|
||||
// isFitWidth -> fitWidth
|
||||
Masonry.compatOptions.fitWidth = 'isFitWidth';
|
||||
|
||||
var proto = Masonry.prototype;
|
||||
|
||||
proto._resetLayout = function() {
|
||||
this.getSize();
|
||||
this._getMeasurement( 'columnWidth', 'outerWidth' );
|
||||
this._getMeasurement( 'gutter', 'outerWidth' );
|
||||
this.measureColumns();
|
||||
|
||||
// reset column Y
|
||||
this.colYs = [];
|
||||
for ( var i=0; i < this.cols; i++ ) {
|
||||
this.colYs.push( 0 );
|
||||
}
|
||||
|
||||
this.maxY = 0;
|
||||
this.horizontalColIndex = 0;
|
||||
};
|
||||
|
||||
proto.measureColumns = function() {
|
||||
this.getContainerWidth();
|
||||
// if columnWidth is 0, default to outerWidth of first item
|
||||
if ( !this.columnWidth ) {
|
||||
var firstItem = this.items[0];
|
||||
var firstItemElem = firstItem && firstItem.element;
|
||||
// columnWidth fall back to item of first element
|
||||
this.columnWidth = firstItemElem && getSize( firstItemElem ).outerWidth ||
|
||||
// if first elem has no width, default to size of container
|
||||
this.containerWidth;
|
||||
}
|
||||
|
||||
var columnWidth = this.columnWidth += this.gutter;
|
||||
|
||||
// calculate columns
|
||||
var containerWidth = this.containerWidth + this.gutter;
|
||||
var cols = containerWidth / columnWidth;
|
||||
// fix rounding errors, typically with gutters
|
||||
var excess = columnWidth - containerWidth % columnWidth;
|
||||
// if overshoot is less than a pixel, round up, otherwise floor it
|
||||
var mathMethod = excess && excess < 1 ? 'round' : 'floor';
|
||||
cols = Math[ mathMethod ]( cols );
|
||||
this.cols = Math.max( cols, 1 );
|
||||
};
|
||||
|
||||
proto.getContainerWidth = function() {
|
||||
// container is parent if fit width
|
||||
var isFitWidth = this._getOption('fitWidth');
|
||||
var container = isFitWidth ? this.element.parentNode : this.element;
|
||||
// check that this.size and size are there
|
||||
// IE8 triggers resize on body size change, so they might not be
|
||||
var size = getSize( container );
|
||||
this.containerWidth = size && size.innerWidth;
|
||||
};
|
||||
|
||||
proto._getItemLayoutPosition = function( item ) {
|
||||
item.getSize();
|
||||
// how many columns does this brick span
|
||||
var remainder = item.size.outerWidth % this.columnWidth;
|
||||
var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
|
||||
// round if off by 1 pixel, otherwise use ceil
|
||||
var colSpan = Math[ mathMethod ]( item.size.outerWidth / this.columnWidth );
|
||||
colSpan = Math.min( colSpan, this.cols );
|
||||
// use horizontal or top column position
|
||||
var colPosMethod = this.options.horizontalOrder ?
|
||||
'_getHorizontalColPosition' : '_getTopColPosition';
|
||||
var colPosition = this[ colPosMethod ]( colSpan, item );
|
||||
// position the brick
|
||||
var position = {
|
||||
x: this.columnWidth * colPosition.col,
|
||||
y: colPosition.y
|
||||
};
|
||||
// apply setHeight to necessary columns
|
||||
var setHeight = colPosition.y + item.size.outerHeight;
|
||||
var setMax = colSpan + colPosition.col;
|
||||
for ( var i = colPosition.col; i < setMax; i++ ) {
|
||||
this.colYs[i] = setHeight;
|
||||
}
|
||||
|
||||
return position;
|
||||
};
|
||||
|
||||
proto._getTopColPosition = function( colSpan ) {
|
||||
var colGroup = this._getTopColGroup( colSpan );
|
||||
// get the minimum Y value from the columns
|
||||
var minimumY = Math.min.apply( Math, colGroup );
|
||||
|
||||
return {
|
||||
col: colGroup.indexOf( minimumY ),
|
||||
y: minimumY,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Number} colSpan - number of columns the element spans
|
||||
* @returns {Array} colGroup
|
||||
*/
|
||||
proto._getTopColGroup = function( colSpan ) {
|
||||
if ( colSpan < 2 ) {
|
||||
// if brick spans only one column, use all the column Ys
|
||||
return this.colYs;
|
||||
}
|
||||
|
||||
var colGroup = [];
|
||||
// how many different places could this brick fit horizontally
|
||||
var groupCount = this.cols + 1 - colSpan;
|
||||
// for each group potential horizontal position
|
||||
for ( var i = 0; i < groupCount; i++ ) {
|
||||
colGroup[i] = this._getColGroupY( i, colSpan );
|
||||
}
|
||||
return colGroup;
|
||||
};
|
||||
|
||||
proto._getColGroupY = function( col, colSpan ) {
|
||||
if ( colSpan < 2 ) {
|
||||
return this.colYs[ col ];
|
||||
}
|
||||
// make an array of colY values for that one group
|
||||
var groupColYs = this.colYs.slice( col, col + colSpan );
|
||||
// and get the max value of the array
|
||||
return Math.max.apply( Math, groupColYs );
|
||||
};
|
||||
|
||||
// get column position based on horizontal index. #873
|
||||
proto._getHorizontalColPosition = function( colSpan, item ) {
|
||||
var col = this.horizontalColIndex % this.cols;
|
||||
var isOver = colSpan > 1 && col + colSpan > this.cols;
|
||||
// shift to next row if item can't fit on current row
|
||||
col = isOver ? 0 : col;
|
||||
// don't let zero-size items take up space
|
||||
var hasSize = item.size.outerWidth && item.size.outerHeight;
|
||||
this.horizontalColIndex = hasSize ? col + colSpan : this.horizontalColIndex;
|
||||
|
||||
return {
|
||||
col: col,
|
||||
y: this._getColGroupY( col, colSpan ),
|
||||
};
|
||||
};
|
||||
|
||||
proto._manageStamp = function( stamp ) {
|
||||
var stampSize = getSize( stamp );
|
||||
var offset = this._getElementOffset( stamp );
|
||||
// get the columns that this stamp affects
|
||||
var isOriginLeft = this._getOption('originLeft');
|
||||
var firstX = isOriginLeft ? offset.left : offset.right;
|
||||
var lastX = firstX + stampSize.outerWidth;
|
||||
var firstCol = Math.floor( firstX / this.columnWidth );
|
||||
firstCol = Math.max( 0, firstCol );
|
||||
var lastCol = Math.floor( lastX / this.columnWidth );
|
||||
// lastCol should not go over if multiple of columnWidth #425
|
||||
lastCol -= lastX % this.columnWidth ? 0 : 1;
|
||||
lastCol = Math.min( this.cols - 1, lastCol );
|
||||
// set colYs to bottom of the stamp
|
||||
|
||||
var isOriginTop = this._getOption('originTop');
|
||||
var stampMaxY = ( isOriginTop ? offset.top : offset.bottom ) +
|
||||
stampSize.outerHeight;
|
||||
for ( var i = firstCol; i <= lastCol; i++ ) {
|
||||
this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
|
||||
}
|
||||
};
|
||||
|
||||
proto._getContainerSize = function() {
|
||||
this.maxY = Math.max.apply( Math, this.colYs );
|
||||
var size = {
|
||||
height: this.maxY
|
||||
};
|
||||
|
||||
if ( this._getOption('fitWidth') ) {
|
||||
size.width = this._getContainerFitWidth();
|
||||
}
|
||||
|
||||
return size;
|
||||
};
|
||||
|
||||
proto._getContainerFitWidth = function() {
|
||||
var unusedCols = 0;
|
||||
// count unused columns
|
||||
var i = this.cols;
|
||||
while ( --i ) {
|
||||
if ( this.colYs[i] !== 0 ) {
|
||||
break;
|
||||
}
|
||||
unusedCols++;
|
||||
}
|
||||
// fit container to columns that have been used
|
||||
return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
|
||||
};
|
||||
|
||||
proto.needsResizeLayout = function() {
|
||||
var previousWidth = this.containerWidth;
|
||||
this.getContainerWidth();
|
||||
return previousWidth != this.containerWidth;
|
||||
};
|
||||
|
||||
return Masonry;
|
||||
|
||||
}));
|
||||
|
|
@ -9,21 +9,11 @@ $(function() {
|
|||
// Sets the min-height of #page-wrapper to window size
|
||||
$(function() {
|
||||
$(window).bind("load resize", function() {
|
||||
topOffset = 50;
|
||||
width = (this.window.innerWidth > 0) ? this.window.innerWidth : this.screen.width;
|
||||
if (width < 768) {
|
||||
$('div.navbar-collapse').addClass('collapse');
|
||||
topOffset = 100; // 2-row-menu
|
||||
} else {
|
||||
$('div.navbar-collapse').removeClass('collapse');
|
||||
}
|
||||
|
||||
height = ((this.window.innerHeight > 0) ? this.window.innerHeight : this.screen.height) - 1;
|
||||
height = height - topOffset;
|
||||
if (height < 1) height = 1;
|
||||
if (height > topOffset) {
|
||||
$("#page-wrapper").css("min-height", (height) + "px");
|
||||
}
|
||||
var heightbody = $('html').height();
|
||||
var heightheader = $('.header').height();
|
||||
var heightpagewrapper = heightbody-heightheader;
|
||||
|
||||
$("#page-wrapper").css("min-height", (heightpagewrapper) + "px");
|
||||
});
|
||||
|
||||
var url = window.location;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends '@CadolesCore/simple.html.twig' %}
|
||||
{% extends '@CadolesCore/base.html.twig' %}
|
||||
|
||||
{% block pagewrapper %}
|
||||
<h3 class="page-header">Téléchargez votre Bannière</h3>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends '@CadolesCore/simple.html.twig' %}
|
||||
{% extends '@CadolesCore/base.html.twig' %}
|
||||
|
||||
{% block pagewrapper %}
|
||||
<h3 class="page-header">Téléchargez votre Logo</h3>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends '@CadolesCore/nosidebar.html.twig' %}
|
||||
{% extends '@CadolesCore/base.html.twig' %}
|
||||
|
||||
{% block pagewrapper %}
|
||||
<div style="width: 400px;margin: auto;text-align: center;margin-top: 100px;">
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
{% extends '@CadolesCore/base.html.twig' %}
|
||||
|
||||
{% block localjavascript %}
|
||||
$(document).ready(function() {
|
||||
var x=top.document.location.href;
|
||||
var y=location.href;
|
||||
if(y!=x) top.document.location.href=x.replace("#","");
|
||||
else top.document.location.href="/{{ alias}}";
|
||||
});
|
||||
{% endblock %}
|
|
@ -1,4 +1,4 @@
|
|||
{% extends '@CadolesCore/simple.html.twig' %}
|
||||
{% extends '@CadolesCore/base.html.twig' %}
|
||||
|
||||
{% block pagewrapper %}
|
||||
<h3 class="page-header">ETAPE 1 - Téléchargez votre image</h3>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends '@CadolesCore/simple.html.twig' %}
|
||||
{% extends '@CadolesCore/base.html.twig' %}
|
||||
|
||||
{% block pagewrapper %}
|
||||
<h3 class="page-header">ETAPE 2 - Découper votre image</h3>
|
||||
|
|
|
@ -160,13 +160,31 @@ les plus importants pour y ajouter le class imposée par Bootstrap 3 #}
|
|||
{{ date_pattern|replace({
|
||||
'{{ year }}': self.date_form_widget(form.year),
|
||||
'{{ month }}': self.date_form_widget(form.month),
|
||||
'{{ day }}': self.date_form_widget(form.day)
|
||||
})|raw }}
|
||||
'{{ day }}': self.date_form_widget(form.day),
|
||||
})|raw }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endspaceless %}
|
||||
{% endblock date_widget %}
|
||||
|
||||
{# Inline date_time
|
||||
{% block time_widget %}
|
||||
{% spaceless %}
|
||||
{% if widget == 'single_text' %}
|
||||
{{ block('form_widget_simple') }}
|
||||
{% else %}
|
||||
{% import _self as self %}
|
||||
<div class="row">
|
||||
|
||||
{{ time_pattern|replace({
|
||||
'{{ hour }}': self.date_form_widget(form.hour),
|
||||
'{{ minute }}': self.date_form_widget(form.minute),
|
||||
})|raw }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endspaceless %}
|
||||
{% endblock time_widget %}
|
||||
#}
|
||||
|
||||
{% block file_widget %}
|
||||
{% spaceless %}
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
'@CadolesCoreBundle/Resources/public/js/bootstrap-datetimepicker.js'
|
||||
'@CadolesCoreBundle/Resources/public/js/bootstrap-datetimepicker.fr.js'
|
||||
'@CadolesCoreBundle/Resources/public/js/bootstrap-slider.js'
|
||||
'@CadolesCoreBundle/Resources/public/js/masonry.pkgd.js'
|
||||
'@CadolesCoreBundle/Resources/public/js/sb-admin-2.js'
|
||||
'@CadolesCoreBundle/Resources/public/js/jquery-ui.min.js'
|
||||
'@CadolesCoreBundle/Resources/public/js/tinycolor-0.9.15.min.js'
|
||||
|
|
|
@ -39,7 +39,10 @@
|
|||
|
||||
<link rel="shortcut icon" href="/{{ alias }}/{{ app.session.get('logo') }}" />
|
||||
<style>
|
||||
html { height: 100% }
|
||||
|
||||
body.simple { background-color: transparent; }
|
||||
body { padding-right: 0 !important }
|
||||
|
||||
.header .title{
|
||||
text-decoration: none;
|
||||
|
@ -83,6 +86,12 @@
|
|||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
@media(min-width:768px) {
|
||||
#page-wrapper {
|
||||
border-left: none;
|
||||
}
|
||||
}
|
||||
|
||||
.category-list-item {
|
||||
min-height: 30px;
|
||||
}
|
||||
|
@ -100,6 +109,19 @@
|
|||
border: 2px dotted #3498db;
|
||||
}
|
||||
|
||||
.portalalert {
|
||||
color:#ffffff;
|
||||
border-radius: 0px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.portalalert .panel-heading,
|
||||
.portalalert .panel-heading a{
|
||||
color:#ffffff;
|
||||
font-size: 22px;
|
||||
padding-bottom: 0px;
|
||||
}
|
||||
|
||||
span.item-drag {
|
||||
display: block;
|
||||
position: absolute;
|
||||
|
@ -124,7 +146,7 @@
|
|||
|
||||
.grid {
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
margin: 0px;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
min-height: 30px;
|
||||
|
@ -132,11 +154,12 @@
|
|||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.grid .grid-item {
|
||||
.grid .grid-item,
|
||||
.grid .grid-sizer {
|
||||
float: left;
|
||||
margin: 2px;
|
||||
padding: 0;
|
||||
width: calc(33.333333333% - 5px); /* 1px more to fix */
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
width: 290px;
|
||||
height: 150px;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
|
@ -162,6 +185,10 @@
|
|||
color: #fff;
|
||||
}
|
||||
|
||||
.grid-item-content a:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.grid-item .item-link {
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
@ -177,7 +204,7 @@
|
|||
|
||||
.grid-item .item-link img {
|
||||
display: block;
|
||||
margin: 10 auto;
|
||||
margin: 10px auto;
|
||||
max-width: 100%;
|
||||
max-height: 110px;
|
||||
height: auto;
|
||||
|
@ -186,7 +213,7 @@
|
|||
.grid-item .grid-item-title {
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
padding-top: 15px;
|
||||
padding: 15px 5px;;
|
||||
font-size: 12px;
|
||||
width: 50%;
|
||||
line-height: 1;
|
||||
|
@ -205,6 +232,169 @@
|
|||
.grid-item-placeholder {
|
||||
border: 2px dotted #3498db;
|
||||
}
|
||||
|
||||
a.item-preview {
|
||||
display: block;
|
||||
position: absolute;
|
||||
right: 5px;
|
||||
top: 2px;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.grid-item-body {
|
||||
height:200px;
|
||||
overflow-y:auto;
|
||||
text-align: left;
|
||||
padding:15px;
|
||||
line-height:10px;
|
||||
}
|
||||
|
||||
.grid .grid-medium {
|
||||
width:150px;
|
||||
height:200px;
|
||||
}
|
||||
|
||||
.grid .grid-medium .item-link {
|
||||
height:200px;
|
||||
}
|
||||
|
||||
.grid .grid-medium .grid-item-logo {
|
||||
display: block;
|
||||
height:80px;
|
||||
width:auto;
|
||||
}
|
||||
.grid .grid-medium .grid-item-logo img {
|
||||
height: 80px;
|
||||
width: auto;
|
||||
margin: 5px auto;
|
||||
}
|
||||
.grid .grid-medium .grid-item-title {
|
||||
display: block;
|
||||
vertical-align: top;
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
text-align:center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.grid .grid-small {
|
||||
width:100px;
|
||||
height:120px;
|
||||
}
|
||||
|
||||
.grid .grid-small .item-link {
|
||||
height:120px;
|
||||
}
|
||||
|
||||
.grid .grid-small .grid-item-logo {
|
||||
display: block;
|
||||
height:60px;
|
||||
width:auto;
|
||||
}
|
||||
.grid .grid-small .grid-item-logo img {
|
||||
height: 60px;
|
||||
width: auto;
|
||||
margin: 5px auto;
|
||||
}
|
||||
.grid .grid-small .grid-item-title {
|
||||
display: block;
|
||||
vertical-align: top;
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
text-align:center;
|
||||
width: 100%;
|
||||
}
|
||||
.grid .grid-small .grid-item-title h2 { font-size:10px; border-bottom: none; }
|
||||
.grid .grid-small .grid-item-title span { display: none }
|
||||
|
||||
|
||||
.pagemenu {
|
||||
margin: 0px -30px;
|
||||
padding: 0px 30px;
|
||||
font-size:20px;
|
||||
line-height: 40px;
|
||||
display:none
|
||||
}
|
||||
|
||||
.navpagemenu {
|
||||
padding:0px;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.pagemenu {
|
||||
display: block;
|
||||
margin: 0px -30px;
|
||||
padding: 0px 30px;
|
||||
font-size:20px;
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
.navpagemenu {
|
||||
float: left;
|
||||
list-style: none;
|
||||
margin: 0px 15px 0px 0px;
|
||||
padding:0px;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.navpagemenu li {
|
||||
float: left;
|
||||
list-style: none;
|
||||
margin: 0px;
|
||||
padding:0px 10px;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.navpagemenu li a:hover {
|
||||
text-decoration:none;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.widgetplacehorder {
|
||||
height:50px;
|
||||
border: 2px dotted #3498db;
|
||||
background-color:#cdcdcd;
|
||||
}
|
||||
|
||||
.widgetempty {
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
.widget {
|
||||
margin-top:30px;
|
||||
}
|
||||
|
||||
.widgetmenu {
|
||||
float: right;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.widgetmenu i {
|
||||
font-size :20px;
|
||||
}
|
||||
|
||||
.widgetheader {
|
||||
padding:10px;
|
||||
font-size:20px;
|
||||
font-weight: bold;
|
||||
height:50px;
|
||||
}
|
||||
|
||||
.widgetbody iframe {
|
||||
width:100%;
|
||||
border:0px;
|
||||
height:100%;
|
||||
}
|
||||
|
||||
.frameitem {
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
width:100%;
|
||||
border:0px;
|
||||
height:100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style>
|
||||
|
@ -218,7 +408,8 @@
|
|||
.pagination>.active>span:focus,
|
||||
.pagination>.active>span:hover,
|
||||
.herotitle img,
|
||||
.avatar
|
||||
.avatar,
|
||||
#pagemenu
|
||||
{
|
||||
background-color: #{{ color['main'] }}
|
||||
}
|
||||
|
@ -251,7 +442,10 @@
|
|||
.nav>li>a:focus,
|
||||
.nav>li>a:hover,
|
||||
.nav .open>a, .nav .open>a:focus, .nav .open>a:hover,
|
||||
.sidebar ul li a.active {
|
||||
.sidebar ul li a.active,
|
||||
.navpagemenu li:hover,
|
||||
.navpagemenu li.active
|
||||
{
|
||||
background-color: #{{ color['dark'] }}
|
||||
}
|
||||
|
||||
|
@ -274,14 +468,16 @@
|
|||
.header a,
|
||||
.navbar-default .navbar-brand,
|
||||
.navbar-default a,
|
||||
.sidebar a {
|
||||
.sidebar a,
|
||||
#pagemenu a {
|
||||
color: #{{ color['fontcolorhover'] }}
|
||||
}
|
||||
|
||||
.header a:hover,
|
||||
.navbar-default .navbar-brand:focus,
|
||||
.navbar-default .navbar-brand:hover,
|
||||
.navbar-default a:hover {
|
||||
.navbar-default a:hover,
|
||||
#pagemenu a:hover {
|
||||
color: #{{ color['fontcolorhoverdark'] }}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<!-- Header -->
|
||||
{% set color = app.session.get('color') %}
|
||||
|
||||
{% if useheader %}
|
||||
<div class="header" style="height:{{ app.session.get('heightheader') }}px; background-image: linear-gradient(90deg,rgba({{ color['mainrgb']['r'] }},{{ color['mainrgb']['g'] }},{{ color['mainrgb']['b'] }},1),rgba({{ color['mainrgb']['r'] }},{{ color['mainrgb']['g'] }},{{ color['mainrgb']['b'] }},0.1)),url(/{{ alias }}/{{ app.session.get('header') }});">
|
||||
<a class="title" href="{{ path("cadoles_core_home") }}">
|
||||
<img id="logo" src="/{{ alias }}/{{ app.session.get('logo') }}" style="height:{{ app.session.get('heightheader')-20 }}px;">
|
||||
|
@ -22,16 +23,15 @@
|
|||
{{ include('@CadolesCore/Include/menu.html.twig') }}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- Pour l'instant ne sert pas
|
||||
{% if not usesidebar %}
|
||||
{% endif %}
|
||||
|
||||
{% if usemenu %}
|
||||
<nav class="navbarheader navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
|
||||
<ul class="nav navbar-top-links navbar-left">
|
||||
|
||||
</ul>
|
||||
</nav>
|
||||
{% endif %}
|
||||
-->
|
||||
{% endif %}
|
||||
|
||||
<!-- Navigation -->
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends '@CadolesCore/nosidebar.html.twig' %}
|
||||
{% extends '@CadolesCore/base.html.twig' %}
|
||||
|
||||
{% block pagewrapper %}
|
||||
{{ form_start(form) }}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends '@CadolesCore/nosidebar.html.twig' %}
|
||||
{% extends '@CadolesCore/base.html.twig' %}
|
||||
|
||||
{% block pagewrapper %}
|
||||
<h1 class="page-header">Inscriptions</h1>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends '@CadolesCore/nosidebar.html.twig' %}
|
||||
{% extends '@CadolesCore/base.html.twig' %}
|
||||
|
||||
{% block pagewrapper %}
|
||||
<style>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends '@CadolesCore/simple.html.twig' %}
|
||||
{% extends '@CadolesCore/base.html.twig' %}
|
||||
|
||||
{% block pagewrapper %}
|
||||
|
||||
|
|
|
@ -19,11 +19,6 @@
|
|||
{{ form_widget(form.submit) }}
|
||||
{% if access=="config" %}
|
||||
<a class="btn btn-default" href={{ path('cadoles_core_config_user') }}>Annuler</a>
|
||||
{% else %}
|
||||
<style>
|
||||
.sidebar{display: none}
|
||||
#page-wrapper { max-width: 1000px;}
|
||||
</style>
|
||||
{% endif %}
|
||||
<br><br>
|
||||
|
||||
|
|
|
@ -8,20 +8,24 @@
|
|||
{% endblock %}
|
||||
</style>
|
||||
|
||||
<body class="body">
|
||||
<body class="{% if useheader %}body{% else %}simple{% endif %}">
|
||||
<div id="wrapper">
|
||||
{% set usesidebar = true %}
|
||||
{{ include('@CadolesCore/Include/hero.html.twig') }}
|
||||
|
||||
<div id="page-wrapper" style="min-height: 604px;">
|
||||
{% if useheader %}
|
||||
<div id="page-wrapper" style="min-height:1200px; {% if not usesidebar %} margin:0px; {% endif %}">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
{% endif %}
|
||||
|
||||
{% block pagewrapper %}
|
||||
|
||||
{% endblock %}
|
||||
{% if useheader %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{{ include('@CadolesCore/Include/footer.html.twig') }}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
{% set usesidebar = false %}
|
||||
{{ include('@CadolesCore/Include/hero.html.twig') }}
|
||||
|
||||
<div id="page-wrapper" style="min-height: 604px; margin:0px">
|
||||
<div id="page-wrapper" style="min-height:1200px; margin:0px; ">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
{% block pagewrapper %}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace Cadoles\CronBundle;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
class CadolesCronBundle extends Bundle
|
||||
{
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
|
||||
namespace Cadoles\CronBundle\Command;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
use Cadoles\CronBundle\Entity\Cron;
|
||||
|
||||
class CronCommand extends ContainerAwareCommand
|
||||
{
|
||||
private $output;
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('Cron:Exec')
|
||||
->setDescription('Execution of the cron command')
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$entityManager = $this->getContainer()->get('doctrine')->getEntityManager();
|
||||
$this->output = $output;
|
||||
|
||||
|
||||
$cron_activate = $this->getContainer()->getParameter('cron_activate');
|
||||
if(!$cron_activate)
|
||||
{
|
||||
$this->writelnred('CRON désactivé');
|
||||
return false;
|
||||
}
|
||||
|
||||
$crons = $entityManager->getRepository('CadolesCronBundle:Cron')->toexec();
|
||||
$i=0;
|
||||
|
||||
if($crons) {
|
||||
$now=new \DateTime();
|
||||
$this->writelnred('');
|
||||
$this->writelnred('=====================================================');
|
||||
$this->writelnred('== CRON =============================================');
|
||||
$this->writelnred('=====================================================');
|
||||
$this->writeln ('Date = '.$now->format('Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
foreach($crons as $cron) {
|
||||
$i++;
|
||||
|
||||
// Flag d'execution en cours
|
||||
$now=new \DateTime();
|
||||
$cron->setStartexecdate($now);
|
||||
//$cron->setStatut(1);
|
||||
$entityManager->persist($cron);
|
||||
$entityManager->flush();
|
||||
|
||||
// Récupération de la commande
|
||||
$command = $this->getApplication()->find($cron->getCommand());
|
||||
|
||||
// Réccuépration des parametres
|
||||
$jsonparameter=json_decode($cron->getJsonargument(),true);
|
||||
|
||||
// Parametre id du cron actuel
|
||||
$jsonparameter["cronid"]=$cron->getId();
|
||||
|
||||
// Parametre si dernière execution
|
||||
$lastchance=false;
|
||||
if($cron->getRepeatcall()>0)
|
||||
$lastchance=($cron->getRepeatexec()+1==$cron->getRepeatcall());
|
||||
$jsonparameter["lastchance"]=$lastchance;
|
||||
|
||||
// Formater la chaine de parametre
|
||||
$parameter = new ArrayInput($jsonparameter);
|
||||
|
||||
// Executer la commande
|
||||
$returnCode = $command->run($parameter, $output);
|
||||
|
||||
// Flag de fin d'execution
|
||||
$now=new \DateTime();
|
||||
$cron->setEndexecdate($now);
|
||||
|
||||
// Date prochaine execution
|
||||
if($cron->getrepeatinterval()>=0) {
|
||||
$next=new \DateTime();
|
||||
$next->add(new \DateInterval('PT'.$cron->getRepeatinterval().'S'));
|
||||
$cron->setNextexecdate($next);
|
||||
}
|
||||
|
||||
// Statut OK/KO/Retry
|
||||
if($returnCode!="retry"||!$returnCode) {
|
||||
$cron->setStatut(2);
|
||||
if($returnCode!=1) {
|
||||
$cron->setStatut(3);
|
||||
if($cron->getRepeatcall()>0) $cron->setRepeatexec($cron->getRepeatexec()+1);
|
||||
}
|
||||
}
|
||||
|
||||
$entityManager->persist($cron);
|
||||
$entityManager->flush();
|
||||
}
|
||||
}
|
||||
|
||||
private function writelnred($string) { $this->output->writeln('<fg=red>'.$string.'</>'); }
|
||||
private function writeln($string) { $this->output->writeln($string); }
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
|
||||
namespace Cadoles\CronBundle\Command;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Doctrine\ORM\Id\AssignedGenerator;
|
||||
|
||||
use Cadoles\CronBundle\Entity\Cron;
|
||||
|
||||
class InitDataCommand extends ContainerAwareCommand
|
||||
{
|
||||
private $entityManager;
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('Cron:InitData')
|
||||
->setDescription('Init Data for Cron')
|
||||
->setHelp('This command Init Data for Portal')
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->entityManager = $this->getContainer()->get('doctrine')->getEntityManager();
|
||||
|
||||
|
||||
$cron_activate = $this->getContainer()->getParameter('cron_activate');
|
||||
if(!$cron_activate)
|
||||
return false;
|
||||
|
||||
$output->writeln('CRON = Default Data');
|
||||
|
||||
$this->insertCron();
|
||||
|
||||
$output->writeln('');
|
||||
|
||||
return $this->entityManager->flush();
|
||||
}
|
||||
|
||||
protected function insertCron() {
|
||||
// Job Mail
|
||||
// Toute les minutes
|
||||
$entity = $this->entityManager->getRepository('CadolesCronBundle:Cron')->find(1);
|
||||
if(!$entity) {
|
||||
$entity = new Cron;
|
||||
$entity->setCommand("Cron:Mail");
|
||||
$entity->setDescription("Execution du spool de mail en attente");
|
||||
$entity->setId(1);
|
||||
$entity->setStatut(2);
|
||||
$entity->setRepeatcall(0);
|
||||
$entity->setRepeatexec(0);
|
||||
$entity->setRepeatinterval(60);
|
||||
$entity->setNextexecdate($entity->getSubmitdate());
|
||||
$entity->setJsonargument('{"message-limit":"100","env":"prod"}');
|
||||
$this->entityManager->persist($entity);
|
||||
}
|
||||
|
||||
// Job synchronisation des comptes utilisateur
|
||||
// Toute les 24h à 3h00
|
||||
$entity = $this->entityManager->getRepository('CadolesCronBundle:Cron')->find(100);
|
||||
if(!$entity) {
|
||||
$entity = new Cron;
|
||||
$nextdate=$entity->getSubmitdate();
|
||||
$nextdate->setTime(3,0);
|
||||
$entity->setCommand("Core:Synchro");
|
||||
$entity->setDescription("Synchronisation des Comptes Utilisateurs");
|
||||
$entity->setId(100);
|
||||
$entity->setStatut(2);
|
||||
$entity->setRepeatcall(0);
|
||||
$entity->setRepeatexec(0);
|
||||
$entity->setRepeatinterval(86400);
|
||||
$entity->setNextexecdate($nextdate);
|
||||
$entity->setJsonargument('{"simulate":"false"}');
|
||||
$this->entityManager->persist($entity);
|
||||
}
|
||||
|
||||
// Job purge des registrations obsolètes
|
||||
// Toute les 5mn
|
||||
$entity = $this->entityManager->getRepository('CadolesCronBundle:Cron')->find(110);
|
||||
if(!$entity) {
|
||||
$entity = new Cron;
|
||||
$entity->setCommand("Core:PurgeRegistration");
|
||||
$entity->setDescription("Purge des Inscriptions obsolètes");
|
||||
$entity->setId(110);
|
||||
$entity->setStatut(2);
|
||||
$entity->setRepeatcall(0);
|
||||
$entity->setRepeatexec(0);
|
||||
$entity->setRepeatinterval(300);
|
||||
$entity->setNextexecdate($entity->getSubmitdate());
|
||||
$this->entityManager->persist($entity);
|
||||
}
|
||||
|
||||
// afin de forcer les ID sur certaines entités
|
||||
$metadata = $this->entityManager->getClassMetaData(get_class($entity));
|
||||
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
|
||||
$metadata->setIdGenerator(new AssignedGenerator());
|
||||
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace Cadoles\CronBundle\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
use Cadoles\CronBundle\Entity\Cron;
|
||||
|
||||
class MailCommand extends Command
|
||||
{
|
||||
private $container;
|
||||
private $em;
|
||||
private $output;
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('Cron:Mail')
|
||||
->setDescription('Send Mail')
|
||||
->addArgument('message-limit', InputArgument::OPTIONAL, 'limit message Mail')
|
||||
->addArgument('env', InputArgument::OPTIONAL, 'env Mail')
|
||||
->addArgument('cronid', InputArgument::OPTIONAL, 'ID Cron Job')
|
||||
->addArgument('lastchance', InputArgument::OPTIONAL, 'Lastchance to run the cron')
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
|
||||
$this->container = $this->getApplication()->getKernel()->getContainer();
|
||||
$this->em = $this->container->get('doctrine')->getEntityManager();
|
||||
$this->output = $output;
|
||||
|
||||
$this->writelnred('');
|
||||
$this->writelnred('== Cron:Mail');
|
||||
$this->writelnred('=====================================================');
|
||||
|
||||
$command = $this->getApplication()->find("swiftmailer:spool:send");
|
||||
$tbparameter["--message-limit"]=100;
|
||||
$tbparameter["--env"]="prod";
|
||||
$parameter = new ArrayInput($tbparameter);
|
||||
$returnCode = $command->run($parameter, $output);
|
||||
$output->writeln("");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
private function writelnred($string) { $this->output->writeln('<fg=red>'.$string.'</>'); }
|
||||
private function writeln($string) { $this->output->writeln($string); }
|
||||
}
|
|
@ -0,0 +1,172 @@
|
|||
<?php
|
||||
|
||||
namespace Cadoles\CronBundle\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use Cadoles\CronBundle\Entity\Cron;
|
||||
use Cadoles\CronBundle\Form\CronType;
|
||||
|
||||
class CronController extends Controller
|
||||
{
|
||||
private $labelentity="CadolesCronBundle:Cron";
|
||||
private $routeprimary="cadoles_cron_config";
|
||||
|
||||
public function listAction()
|
||||
{
|
||||
return $this->render($this->labelentity.':list.html.twig',[
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function ajaxlistAction(Request $request)
|
||||
{
|
||||
// S'assurer que c'est un appel ajax
|
||||
if (!$request->isXmlHttpRequest()) {
|
||||
return new JsonResponse(array('message' => 'Interdit'), 400);
|
||||
}
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$start=$request->query->get('start');
|
||||
$length= $request->query->get('length');
|
||||
$search= $request->query->get('search');
|
||||
$draw= $request->query->get('draw');
|
||||
$order= $request->query->get('order');
|
||||
|
||||
// Query de base
|
||||
$qbase=$em->createQueryBuilder()->from($this->labelentity,'table');
|
||||
$qsearch=$qbase->Where('table.id LIKE :value')
|
||||
->orWhere('table.command LIKE :value')
|
||||
->orWhere('table.jsonargument LIKE :value')
|
||||
->andWhere('table.repeatcall=0 OR (table.statut!=2 AND table.repeatcall>0)')
|
||||
->setParameter("value", "%".$search["value"]."%");
|
||||
|
||||
// Nombre total d'enregistrement
|
||||
$total = $qbase->select('COUNT(table)')->getQuery()->getSingleScalarResult();
|
||||
|
||||
// Nombre d'enregistrement filtré
|
||||
if($search["value"]=="")
|
||||
$totalf = $total;
|
||||
else {
|
||||
$totalf= $qsearch->select('COUNT(table)')->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
|
||||
// Parcours des Enregistrement
|
||||
if($search["value"]=="")
|
||||
$qb = $qbase->select('table');
|
||||
else
|
||||
$qb = $qsearch->select('table');
|
||||
|
||||
// Order
|
||||
switch($order[0]["column"]) {
|
||||
case 1 :
|
||||
$qb->orderBy('table.id',$order[0]["dir"]);
|
||||
break;
|
||||
case 2 :
|
||||
$qb->orderBy('table.command',$order[0]["dir"]);
|
||||
break;
|
||||
case 3 :
|
||||
$qb->orderBy('table.description',$order[0]["dir"]);
|
||||
break;
|
||||
case 4 :
|
||||
$qb->orderBy('table.statut',$order[0]["dir"]);
|
||||
break;
|
||||
case 5 :
|
||||
$qb->orderBy('table.nextexecdate',$order[0]["dir"]);
|
||||
break;
|
||||
}
|
||||
|
||||
// Execution de la requete d'affichage
|
||||
$datas=$qb->setFirstResult($start)->setMaxResults($length)->getQuery()->getResult();
|
||||
|
||||
// Construction du tableau de retour
|
||||
$output = array(
|
||||
'draw' => $draw,
|
||||
'recordsFiltered' => $totalf,
|
||||
'recordsTotal' => $total,
|
||||
'data' => array(),
|
||||
);
|
||||
foreach($datas as $data) {
|
||||
$action = "<a href='".$this->generateUrl($this->routeprimary.'_update', array('id'=>$data->getId()))."'><i class='fa fa-file fa-fw'></i></a>";
|
||||
$action.= "<a href='".$this->generateUrl($this->routeprimary.'_exec', array('id'=>$data->getId()))."'><i class='fa fa-play fa-fw'></i></a>";
|
||||
|
||||
$nextexec=($data->getNextexecdate()==null?"":$data->getNextexecdate()->format("d/m/Y H:i:s"));
|
||||
if($data->getRepeatCall()>0 AND $data->getRepeatCall()<=$data->getRepeatExec())
|
||||
$nextexec="Déjà rejoué ".$data->getRepeatExec()." fois";
|
||||
|
||||
array_push($output["data"],array($action,$data->getId(),$data->getCommand(),$data->getDescription(),$data->getStatutLabel(),$nextexec));
|
||||
}
|
||||
|
||||
// Retour
|
||||
return new Response(json_encode($output), 200);
|
||||
}
|
||||
|
||||
public function updateAction(Request $request, $id)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$entity = $em->getRepository($this->labelentity)->find($id);
|
||||
|
||||
if (!$entity) {
|
||||
throw $this->createNotFoundException('Unable to find entity.');
|
||||
}
|
||||
|
||||
$form = $this->createForm(CronType::class, $entity, ['method' => 'POST']);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid()) {
|
||||
$em->persist($entity);
|
||||
$em->flush();
|
||||
|
||||
return $this->redirect($this->generateUrl($this->routeprimary));
|
||||
}
|
||||
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
'entity' => $entity,
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function execAction(Request $request, $id)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$entity = $em->getRepository($this->labelentity)->find($id);
|
||||
|
||||
if (!$entity) {
|
||||
throw $this->createNotFoundException('Unable to find entity.');
|
||||
}
|
||||
|
||||
$kernel = $this->get('kernel');
|
||||
$application = new Application($kernel);
|
||||
$application->setAutoExit(false);
|
||||
$command = $application->find($entity->getCommand());
|
||||
$jsonparameter=json_decode($entity->getJsonargument(),true);
|
||||
$parameter = ($jsonparameter?new ArrayInput($jsonparameter):new ArrayInput([]));
|
||||
|
||||
|
||||
$output = new BufferedOutput(OutputInterface::VERBOSITY_NORMAL,false);
|
||||
$command->run($parameter, $output);
|
||||
$content = $output->fetch();
|
||||
|
||||
return $this->render('CadolesCoreBundle:Core:command.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
"title" => $entity->getDescription(),
|
||||
"return_path" =>"cadoles_cron_config",
|
||||
"content" =>$content
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,382 @@
|
|||
<?php
|
||||
|
||||
namespace Cadoles\CronBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Cron
|
||||
*
|
||||
* @ORM\Table(name="cron")
|
||||
* @ORM\Entity(repositoryClass="Cadoles\CronBundle\Repository\CronRepository")
|
||||
*/
|
||||
class Cron
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="command", type="string", nullable=false)
|
||||
* @Assert\NotBlank()
|
||||
*
|
||||
*/
|
||||
private $command;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", nullable=true)
|
||||
*/
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private $statut;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=false)
|
||||
*/
|
||||
private $submitdate;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true)
|
||||
*/
|
||||
private $startexecdate;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true)
|
||||
*/
|
||||
private $endexecdate;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true)
|
||||
*/
|
||||
private $nextexecdate;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="integer", nullable=true)
|
||||
*/
|
||||
private $repeatcall;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="integer", nullable=true)
|
||||
*/
|
||||
private $repeatexec;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="integer", nullable=true)
|
||||
*/
|
||||
private $repeatinterval;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", nullable=true)
|
||||
*/
|
||||
private $jsonargument;
|
||||
|
||||
|
||||
// A garder pour forcer l'id en init
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
// A garder pour récupérer le label du statut
|
||||
public function getStatutLabel()
|
||||
{
|
||||
switch($this->statut) {
|
||||
case 0: return "A éxécuter";
|
||||
case 1: return "Exécution en cours";
|
||||
case 2: return "OK";
|
||||
case 3: return "KO";
|
||||
}
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->submitdate = new \DateTime();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set command
|
||||
*
|
||||
* @param string $command
|
||||
*
|
||||
* @return Cron
|
||||
*/
|
||||
public function setCommand($command)
|
||||
{
|
||||
$this->command = $command;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get command
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCommand()
|
||||
{
|
||||
return $this->command;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set description
|
||||
*
|
||||
* @param string $description
|
||||
*
|
||||
* @return Cron
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set statut
|
||||
*
|
||||
* @param integer $statut
|
||||
*
|
||||
* @return Cron
|
||||
*/
|
||||
public function setStatut($statut)
|
||||
{
|
||||
$this->statut = $statut;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get statut
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getStatut()
|
||||
{
|
||||
return $this->statut;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set submitdate
|
||||
*
|
||||
* @param \DateTime $submitdate
|
||||
*
|
||||
* @return Cron
|
||||
*/
|
||||
public function setSubmitdate($submitdate)
|
||||
{
|
||||
$this->submitdate = $submitdate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get submitdate
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getSubmitdate()
|
||||
{
|
||||
return $this->submitdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set startexecdate
|
||||
*
|
||||
* @param \DateTime $startexecdate
|
||||
*
|
||||
* @return Cron
|
||||
*/
|
||||
public function setStartexecdate($startexecdate)
|
||||
{
|
||||
$this->startexecdate = $startexecdate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get startexecdate
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getStartexecdate()
|
||||
{
|
||||
return $this->startexecdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set endexecdate
|
||||
*
|
||||
* @param \DateTime $endexecdate
|
||||
*
|
||||
* @return Cron
|
||||
*/
|
||||
public function setEndexecdate($endexecdate)
|
||||
{
|
||||
$this->endexecdate = $endexecdate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get endexecdate
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getEndexecdate()
|
||||
{
|
||||
return $this->endexecdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set nextexecdate
|
||||
*
|
||||
* @param \DateTime $nextexecdate
|
||||
*
|
||||
* @return Cron
|
||||
*/
|
||||
public function setNextexecdate($nextexecdate)
|
||||
{
|
||||
$this->nextexecdate = $nextexecdate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get nextexecdate
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getNextexecdate()
|
||||
{
|
||||
return $this->nextexecdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set repeatcall
|
||||
*
|
||||
* @param integer $repeatcall
|
||||
*
|
||||
* @return Cron
|
||||
*/
|
||||
public function setRepeatcall($repeatcall)
|
||||
{
|
||||
$this->repeatcall = $repeatcall;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get repeatcall
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getRepeatcall()
|
||||
{
|
||||
return $this->repeatcall;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set repeatexec
|
||||
*
|
||||
* @param integer $repeatexec
|
||||
*
|
||||
* @return Cron
|
||||
*/
|
||||
public function setRepeatexec($repeatexec)
|
||||
{
|
||||
$this->repeatexec = $repeatexec;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get repeatexec
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getRepeatexec()
|
||||
{
|
||||
return $this->repeatexec;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set repeatinterval
|
||||
*
|
||||
* @param integer $repeatinterval
|
||||
*
|
||||
* @return Cron
|
||||
*/
|
||||
public function setRepeatinterval($repeatinterval)
|
||||
{
|
||||
$this->repeatinterval = $repeatinterval;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get repeatinterval
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getRepeatinterval()
|
||||
{
|
||||
return $this->repeatinterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set jsonargument
|
||||
*
|
||||
* @param string $jsonargument
|
||||
*
|
||||
* @return Cron
|
||||
*/
|
||||
public function setJsonargument($jsonargument)
|
||||
{
|
||||
$this->jsonargument = $jsonargument;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get jsonargument
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getJsonargument()
|
||||
{
|
||||
return $this->jsonargument;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
namespace Cadoles\CronBundle\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FileType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ColorType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
|
||||
use Trsteel\CkeditorBundle\Form\Type\CkeditorType;
|
||||
|
||||
class CronType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* @param FormBuilderInterface $builder
|
||||
* @param array $options
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('submit', SubmitType::class, [
|
||||
"label" => "Valider",
|
||||
"attr" => array("class" => "btn btn-success")
|
||||
])
|
||||
|
||||
->add('command', TextType::class, [
|
||||
'label' => 'Commande',
|
||||
"disabled" => true,
|
||||
])
|
||||
|
||||
->add('jsonargument', TextType::class, [
|
||||
'label' => 'Argument Commande au format json',
|
||||
"disabled" => true,
|
||||
])
|
||||
|
||||
->add('statut', ChoiceType::class, [
|
||||
'label' => "Statut",
|
||||
'choices' => array("A éxécuter" => "0","Exécution en cours" => "1","OK" => "2","KO" => "3","Désactivé" => "4")
|
||||
])
|
||||
|
||||
->add('repeatcall', IntegerType::class, [
|
||||
'label' => "Nombre d'éxécution en cas d'echec. Si zéro on le répete à l'infini même si OK"
|
||||
])
|
||||
|
||||
->add('repeatinterval', IntegerType::class, [
|
||||
'label' => "Interval en seconde entre deux éxécution"
|
||||
])
|
||||
|
||||
->add('nextexecdate', DatetimeType::class, [
|
||||
'label' => "Prochaine exécution"
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OptionsResolver $resolver
|
||||
*/
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => 'Cadoles\CronBundle\Entity\Cron'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'cadoles_cron_cron';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Cadoles\CronBundle\Repository;
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
class CronRepository extends EntityRepository
|
||||
{
|
||||
public function toExec()
|
||||
{
|
||||
// Les commandes à executer
|
||||
// = statut = 0 (à executer)
|
||||
// = statut = 2 (OK) et derniere execution + interval > now et nombre d'appel = 0
|
||||
// = statut = 3 (KO) et derniere execution + interval > now et nombre d'appel = 0
|
||||
// = statut = 3 (KO) et nombre d'execution < nombre d'appel
|
||||
|
||||
|
||||
$now=new \DateTime();
|
||||
|
||||
$qb = $this->createQueryBuilder('cron')
|
||||
->Where('cron.statut=0')
|
||||
->orWhere('cron.statut=2 AND cron.nextexecdate<:now AND cron.repeatcall=0')
|
||||
->orWhere('cron.statut=3 AND cron.nextexecdate<:now AND cron.repeatcall=0')
|
||||
->orWhere('cron.statut=3 AND cron.nextexecdate<:now AND cron.repeatcall>cron.repeatexec');
|
||||
|
||||
return $qb->getQuery()->setParameter('now',$now->format("Y-m-d H:i:s"))->getResult();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
cadoles_cron_config:
|
||||
path: /config/cron
|
||||
defaults: { _controller: CadolesCronBundle:Cron:list }
|
||||
|
||||
cadoles_cron_config_ajax_list:
|
||||
path: /config/cron/ajax/list
|
||||
defaults: { _controller: CadolesCronBundle:Cron:ajaxlist }
|
||||
|
||||
cadoles_cron_config_update:
|
||||
path: /config/cron/update/{id}
|
||||
defaults: { _controller: CadolesCronBundle:Cron:update }
|
||||
|
||||
cadoles_cron_config_exec:
|
||||
path: /config/cron/exec/{id}
|
||||
defaults: { _controller: CadolesCronBundle:Cron:exec }
|
|
@ -0,0 +1,4 @@
|
|||
services:
|
||||
cadoles.cron.service.mail:
|
||||
class: Cadoles\CronBundle\Service\mailService
|
||||
arguments: ["@mailer", "@twig"]
|
|
@ -0,0 +1,45 @@
|
|||
{% extends '@CadolesCore/base.html.twig' %}
|
||||
|
||||
{% block pagewrapper %}
|
||||
{{ form_start(form) }}
|
||||
<h1 class="page-header">Modification Job</h1>
|
||||
|
||||
<p>
|
||||
{{ form_widget(form.submit) }}
|
||||
<a class="btn btn-default" href="{{ path('cadoles_cron_config') }}">Annuler</a>
|
||||
|
||||
|
||||
{% if app.session.flashbag.has('error') %}
|
||||
<div class='alert alert-danger' style='margin: 5px 0px'>
|
||||
<strong>Erreur</strong><br>
|
||||
{% for flashMessage in app.session.flashbag.get('error') %}
|
||||
{{ flashMessage }}<br>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if app.session.flashbag.has('notice') %}
|
||||
<div class='alert alert-info' style='margin: 5px 0px'>
|
||||
<strong>Information</strong><br>
|
||||
{% for flashMessage in app.session.flashbag.get('notice') %}
|
||||
{{ flashMessage }}<br>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-pencil fa-fw"></i> Informations
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
{{ form_row(form.command) }}
|
||||
{{ form_row(form.jsonargument) }}
|
||||
{{ form_row(form.statut) }}
|
||||
{{ form_row(form.repeatcall) }}
|
||||
{{ form_row(form.repeatinterval) }}
|
||||
</div>
|
||||
</div>
|
||||
{{ form_end(form) }}
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1,46 @@
|
|||
{% extends '@CadolesCore/base.html.twig' %}
|
||||
|
||||
|
||||
{% block pagewrapper %}
|
||||
<h1>
|
||||
Gestion des Jobs
|
||||
</h1>
|
||||
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-table fa-fw"></i> Liste des Utilisateurs
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<div class="dataTable_wrapper">
|
||||
<table class="table table-striped table-bordered table-hover" id="dataTables" style="width:100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="70px" class="no-sort">Action</th>
|
||||
<th>Order</th>
|
||||
<th>Command</th>
|
||||
<th>Description</th>
|
||||
<th>Statut</th>
|
||||
<th>Prochaine exécution</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block localjavascript %}
|
||||
$(document).ready(function() {
|
||||
$('#dataTables').DataTable({
|
||||
columnDefs: [ { "targets": 'no-sort', "orderable": false } ],
|
||||
responsive: true,
|
||||
iDisplayLength: 100,
|
||||
order: [[ 1, "asc" ]],
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: "{{ path('cadoles_cron_config_ajax_list') }}"
|
||||
});
|
||||
});
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace Cnous\CronBundle\Service;
|
||||
|
||||
class mailService
|
||||
{
|
||||
protected $mailer;
|
||||
protected $twig;
|
||||
|
||||
public function __construct(\Swift_Mailer $mailer, \Twig_Environment $twig)
|
||||
{
|
||||
$this->mailer = $mailer;
|
||||
$this->twig = $twig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send email
|
||||
*
|
||||
* @param string $template email template
|
||||
* @param mixed $parameters custom params for template
|
||||
* @param string $to to email address or array of email addresses
|
||||
* @param string $from from email address
|
||||
* @param string $fromName from name
|
||||
*
|
||||
* @return boolean send status
|
||||
*/
|
||||
public function sendEmail($template, $parameters, $to, $from, $fromName = null)
|
||||
{
|
||||
$template = $this->twig->loadTemplate('CnousCronBundle:Mail:' . $template . '.html.twig');
|
||||
|
||||
$subject = $template->renderBlock('subject', $parameters);
|
||||
$bodyHtml = $template->renderBlock('body_html', $parameters);
|
||||
$bodyText = $template->renderBlock('body_text', $parameters);
|
||||
|
||||
try {
|
||||
$message = \Swift_Message::newInstance()
|
||||
->setSubject($subject)
|
||||
->setFrom($from, $fromName)
|
||||
->setTo($to)
|
||||
->setBody($bodyHtml, 'text/html')
|
||||
->addPart($bodyText, 'text/plain')
|
||||
;
|
||||
$response = $this->mailer->send($message);
|
||||
|
||||
} catch (\Exception $ex) {
|
||||
return $ex->getMessage();
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
|
@ -7,23 +7,22 @@ use Symfony\Component\Console\Output\OutputInterface;
|
|||
use Symfony\Component\Finder\Finder;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Doctrine\DBAL\Connection as DBALConnection;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\em;
|
||||
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Doctrine\ORM\Id\AssignedGenerator;
|
||||
|
||||
use Cadoles\PortalBundle\Entity\Icon;
|
||||
use Cadoles\PortalBundle\Entity\Pagecategory;
|
||||
use Cadoles\PortalBundle\Entity\Widget;
|
||||
|
||||
class InitDataCommand extends ContainerAwareCommand
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
// the name of the command (the part after "bin/console")
|
||||
->setName('Portal:InitData')
|
||||
|
||||
// the short description shown while running "php bin/console list"
|
||||
->setDescription('Init Data for Portal')
|
||||
|
||||
// the full command description shown when running the command with
|
||||
// the "--help" option
|
||||
->setHelp('This command Init Data for Portal')
|
||||
;
|
||||
}
|
||||
|
@ -36,7 +35,7 @@ class InitDataCommand extends ContainerAwareCommand
|
|||
$output->writeln('PORTAL = Default Data');
|
||||
|
||||
// Creation des icons
|
||||
$output->writeln(' > Creation icons');
|
||||
$output->writeln(' > Creation Icons');
|
||||
$finder = new Finder();
|
||||
$finder->in('web/uploads/icon/');
|
||||
$finder->name('icon_*');
|
||||
|
@ -49,8 +48,109 @@ class InitDataCommand extends ContainerAwareCommand
|
|||
$em->persist($entityicon);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Creation des pagecategory
|
||||
$output->writeln(' > Creation Pagecategory');
|
||||
$entityPagecategory = $em->getRepository('CadolesPortalBundle:Pagecategory')->find(1);
|
||||
if(!$entityPagecategory) {
|
||||
$entityPagecategory = new Pagecategory();
|
||||
$entityPagecategory->setId(1);
|
||||
$entityPagecategory->setName('URL');
|
||||
$em->persist($entityPagecategory);
|
||||
}
|
||||
$entityPagecategory = $em->getRepository('CadolesPortalBundle:Pagecategory')->find(2);
|
||||
if(!$entityPagecategory) {
|
||||
$entityPagecategory = new Pagecategory();
|
||||
$entityPagecategory->setId(2);
|
||||
$entityPagecategory->setName('Widget');
|
||||
$em->persist($entityPagecategory);
|
||||
}
|
||||
$entityPagecategory = $em->getRepository('CadolesPortalBundle:Pagecategory')->find(3);
|
||||
if(!$entityPagecategory) {
|
||||
$entityPagecategory = new Pagecategory();
|
||||
$entityPagecategory->setId(3);
|
||||
$entityPagecategory->setName('Editeur');
|
||||
$em->persist($entityPagecategory);
|
||||
}
|
||||
|
||||
// Creation des Widgets
|
||||
$output->writeln(' > Creation Widget');
|
||||
$entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-2000);
|
||||
if(!$entityWidget) {
|
||||
$entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>"uploads/icon/icon_ribbon.png"]);
|
||||
|
||||
$entityWidget = new Widget();
|
||||
$entityWidget->setId(-2000);
|
||||
$entityWidget->setRoworder(1);
|
||||
$entityWidget->setIcon($entityicon);
|
||||
$entityWidget->setName('URL');
|
||||
$entityWidget->setDescription("Affiche le contenu d'une url");
|
||||
$entityWidget->setRouteview("cadoles_portal_config_panelwidget_view_url");
|
||||
$entityWidget->setHeight("630");
|
||||
$entityWidget->setAutoajust(false);
|
||||
$entityWidget->setBorder(true);
|
||||
|
||||
$parameter = json_decode('{"fields": [{"id": "url", "loc": "col1", "type": "string", "label": "URL", "value": "", "mandatory": "true"}]}');
|
||||
$entityWidget->setParameter($parameter);
|
||||
|
||||
$em->persist($entityWidget);
|
||||
}
|
||||
|
||||
$entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1990);
|
||||
if(!$entityWidget) {
|
||||
$entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>"uploads/icon/icon_computer.png"]);
|
||||
|
||||
$entityWidget = new Widget();
|
||||
$entityWidget->setId(-1990);
|
||||
$entityWidget->setRoworder(2);
|
||||
$entityWidget->setIcon($entityicon);
|
||||
$entityWidget->setName('Bureau');
|
||||
$entityWidget->setDescription("Affiche vos items de bureau");
|
||||
$entityWidget->setRouteview("cadoles_portal_config_panelwidget_view_item");
|
||||
$entityWidget->setHeight("630");
|
||||
$entityWidget->setAutoajust(true);
|
||||
$entityWidget->setBorder(false);
|
||||
$entityWidget->setColorbodyback("ffffff");
|
||||
|
||||
$parameter = json_decode('{"fields": [{"id": "modedesktop", "loc": "col1", "type": "desktopmode", "label": "Mode Affichage", "value": "0", "mandatory": "true"},{"id": "itemcategory", "loc": "col1", "type": "itemcategory", "label": "Catégorie Affichée", "value": "", "mandatory": "false"}]}');
|
||||
$entityWidget->setParameter($parameter);
|
||||
|
||||
$em->persist($entityWidget);
|
||||
}
|
||||
|
||||
$entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1980);
|
||||
if(!$entityWidget) {
|
||||
$entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>"uploads/icon/icon_megaphone.png"]);
|
||||
|
||||
$entityWidget = new Widget();
|
||||
$entityWidget->setId(-1980);
|
||||
$entityWidget->setRoworder(3);
|
||||
$entityWidget->setIcon($entityicon);
|
||||
$entityWidget->setName('Annonces');
|
||||
$entityWidget->setDescription("Affiche vos annonces");
|
||||
$entityWidget->setRouteview("cadoles_portal_config_panelwidget_view_alert");
|
||||
$entityWidget->setHeight("630");
|
||||
$entityWidget->setAutoajust(true);
|
||||
$entityWidget->setBorder(false);
|
||||
$entityWidget->setColorbodyback("ffffff");
|
||||
|
||||
$parameter = json_decode('{"fields": [{"id": "alertcategory", "loc": "col1", "type": "alertcategory", "label": "Catégorie Affichée", "value": "", "mandatory": "false"}]}');
|
||||
$entityWidget->setParameter($parameter);
|
||||
|
||||
$em->persist($entityWidget);
|
||||
}
|
||||
|
||||
// afin de forcer les ID sur certaines entités
|
||||
$metadata = $em->getClassMetaData(get_class($entityWidget));
|
||||
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
|
||||
$metadata->setIdGenerator(new AssignedGenerator());
|
||||
|
||||
$metadata = $em->getClassMetaData(get_class($entityPagecategory));
|
||||
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
|
||||
$metadata->setIdGenerator(new AssignedGenerator());
|
||||
|
||||
$em->flush();
|
||||
$output->writeln('');
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,9 +26,12 @@ class AlertController extends Controller
|
|||
$groups = $this->getDoctrine()->getRepository('CadolesCoreBundle:Group')->findBy([], ['label' => 'asc']);
|
||||
|
||||
return $this->render($this->labelentity.':list.html.twig', [
|
||||
'alerts' => $alerts,
|
||||
'alertcategorys' => $alertcategorys,
|
||||
'groups' => $groups
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
'alerts' => $alerts,
|
||||
'alertcategorys' => $alertcategorys,
|
||||
'groups' => $groups
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -60,12 +63,15 @@ class AlertController extends Controller
|
|||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'submit',
|
||||
'icons' => $this->getDoctrine()->getRepository("CadolesPortalBundle:Icon")->findAll(),
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateAction($id,Request $request)
|
||||
|
@ -101,11 +107,14 @@ class AlertController extends Controller
|
|||
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function deleteAction($id,Request $request)
|
||||
|
|
|
@ -47,11 +47,14 @@ class AlertcategoryController extends Controller
|
|||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'submit',
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateAction($id,Request $request)
|
||||
|
@ -85,11 +88,14 @@ class AlertcategoryController extends Controller
|
|||
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function deleteAction($id,Request $request)
|
||||
|
|
|
@ -22,7 +22,12 @@ class IconController extends Controller
|
|||
public function listAction()
|
||||
{
|
||||
|
||||
return $this->render($this->labelentity.':list.html.twig',[$this->labeldatas=>$this->getDatas()]);
|
||||
return $this->render($this->labelentity.':list.html.twig',[
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldatas => $this->getDatas()
|
||||
]);
|
||||
}
|
||||
|
||||
public function submitAction(Request $request)
|
||||
|
@ -53,11 +58,14 @@ class IconController extends Controller
|
|||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'submit',
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateAction($id,Request $request)
|
||||
|
@ -91,11 +99,14 @@ class IconController extends Controller
|
|||
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function deleteAction($id,Request $request)
|
||||
|
@ -116,7 +127,11 @@ class IconController extends Controller
|
|||
|
||||
public function iconAction()
|
||||
{
|
||||
return $this->render('CadolesPortalBundle:Icon:icon.html.twig');
|
||||
return $this->render('CadolesPortalBundle:Icon:icon.html.twig',[
|
||||
'useheader' => false,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getDatas()
|
||||
|
|
|
@ -25,8 +25,11 @@ class ItemController extends Controller
|
|||
$groups = $this->getDoctrine()->getRepository('CadolesCoreBundle:Group')->findBy([], ['label' => 'asc']);
|
||||
|
||||
return $this->render($this->labelentity.':list.html.twig', [
|
||||
'itemcategorys' => $itemcategorys,
|
||||
'groups' => $groups
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
'itemcategorys' => $itemcategorys,
|
||||
'groups' => $groups
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -62,12 +65,15 @@ class ItemController extends Controller
|
|||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'submit',
|
||||
'icons' => $this->getDoctrine()->getRepository("CadolesPortalBundle:Icon")->findAll(),
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateAction($id,Request $request)
|
||||
|
@ -108,12 +114,15 @@ class ItemController extends Controller
|
|||
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'update',
|
||||
'icons' => $this->getDoctrine()->getRepository("CadolesPortalBundle:Icon")->findAll(),
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function deleteAction($id,Request $request)
|
||||
|
|
|
@ -47,11 +47,14 @@ class ItemcategoryController extends Controller
|
|||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'submit',
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateAction($id,Request $request)
|
||||
|
@ -85,11 +88,14 @@ class ItemcategoryController extends Controller
|
|||
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->labelentity.':edit.html.twig', array(
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
$this->labeldata => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function deleteAction($id,Request $request)
|
||||
|
|
|
@ -0,0 +1,331 @@
|
|||
<?php
|
||||
|
||||
namespace Cadoles\PortalBundle\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
use Cadoles\PortalBundle\Entity\Page;
|
||||
use Cadoles\PortalBundle\Form\PageSubmitType;
|
||||
use Cadoles\PortalBundle\Form\PageUpdateURLType;
|
||||
use Cadoles\PortalBundle\Form\PageUpdateWidgetType;
|
||||
use Cadoles\PortalBundle\Form\PageUpdateEditorType;
|
||||
|
||||
class PageController extends Controller
|
||||
{
|
||||
private $labelentity="CadolesPortalBundle:Page";
|
||||
private $routeprimary="cadoles_portal_config_page";
|
||||
|
||||
public function listAction()
|
||||
{
|
||||
return $this->render($this->labelentity.':list.html.twig',[
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function ajaxlistAction(Request $request,$access="config")
|
||||
{
|
||||
// S'assurer que c'est un appel ajax
|
||||
if (!$request->isXmlHttpRequest()) {
|
||||
return new JsonResponse(array('message' => 'Interdit'), 400);
|
||||
}
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$start=$request->query->get('start');
|
||||
$length= $request->query->get('length');
|
||||
$search= $request->query->get('search');
|
||||
$draw= $request->query->get('draw');
|
||||
$order= $request->query->get('order');
|
||||
|
||||
// Query de base
|
||||
$qbase=$em->createQueryBuilder()->from($this->labelentity,'table');
|
||||
$qsearch=$qbase->where('table.id LIKE :value')
|
||||
->orWhere('table.name LIKE :value')
|
||||
->setParameter("value", "%".$search["value"]."%");
|
||||
|
||||
// Nombre total d'enregistrement
|
||||
$total = $qbase->select('COUNT(table)')->getQuery()->getSingleScalarResult();
|
||||
|
||||
// Nombre d'enregistrement filtré
|
||||
if($search["value"]=="")
|
||||
$totalf = $total;
|
||||
else {
|
||||
$totalf= $qsearch->select('COUNT(table)')->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
|
||||
// Parcours des Enregistrement
|
||||
if($search["value"]=="")
|
||||
$qb = $qbase->select('table');
|
||||
else
|
||||
$qb = $qsearch->select('table');
|
||||
|
||||
// Order
|
||||
switch($order[0]["column"]) {
|
||||
case 1 :
|
||||
$qb->orderBy('table.roworder',$order[0]["dir"]);
|
||||
break;
|
||||
case 2 :
|
||||
$qb->orderBy('table.name',$order[0]["dir"]);
|
||||
break;
|
||||
}
|
||||
|
||||
// Execution de la requete d'affichage
|
||||
$datas=$qb->setFirstResult($start)->setMaxResults($length)->getQuery()->getResult();
|
||||
|
||||
// Construction du tableau de retour
|
||||
$output = array(
|
||||
'draw' => $draw,
|
||||
'recordsFiltered' => $totalf,
|
||||
'recordsTotal' => $total,
|
||||
'data' => array(),
|
||||
);
|
||||
foreach($datas as $data) {
|
||||
$route=str_replace("_config_","_".$access."_",$this->routeprimary);
|
||||
$action = "";
|
||||
//$action.="<a href='".$this->generateUrl($route.'_update', array('id'=>$data->getId()))."'><i class='fa fa-file fa-fw'></i></a>";
|
||||
$action.="<a href='".$this->generateUrl($route.'_delete', array('id'=>$data->getId()))."' data-method='delete'><i class='fa fa-trash fa-fw'></i></a>";
|
||||
$action.="<a href='".$this->generateUrl($route.'_view', array('id'=>$data->getId()))."'><i class='fa fa-eye'></i></a>";
|
||||
|
||||
array_push($output["data"],array($action,$data->getRoworder(),$data->getName(),$data->getPagecategory()->getName()));
|
||||
}
|
||||
|
||||
// Retour
|
||||
return new Response(json_encode($output), 200);
|
||||
}
|
||||
|
||||
private function entityForm(Page $entity,$access="config")
|
||||
{
|
||||
$route=str_replace("_config_","_".$access."_",$this->routeprimary);
|
||||
|
||||
if ($this->getDoctrine()->getManager()->contains($entity)) {
|
||||
// Type URL
|
||||
if($entity->getPagecategory()->getId()==1 ) {
|
||||
return $this->createForm(PageUpdateURLType::class, $entity, [
|
||||
"mode" => "update",
|
||||
"access" => $access
|
||||
]);
|
||||
}
|
||||
// Type Widget
|
||||
elseif($entity->getPagecategory()->getId()==2 ) {
|
||||
return $this->createForm(PageUpdateWidgetType::class, $entity, [
|
||||
"mode" => "update",
|
||||
"access" => $access
|
||||
]);
|
||||
}
|
||||
// Type Editeur
|
||||
elseif($entity->getPagecategory()->getId()==3 ) {
|
||||
return $this->createForm(PageUpdateEditorType::class, $entity, [
|
||||
"mode" => "update",
|
||||
"access" => $access
|
||||
]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return $this->createForm(PageSubmitType::class, $entity, [
|
||||
"mode" => "update",
|
||||
"access" => $access
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function submitAction(Request $request,$access="config")
|
||||
{
|
||||
$entity = new Page();
|
||||
$form = $this->entityForm($entity,$access);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->persist($entity);
|
||||
$em->flush();
|
||||
|
||||
$route=str_replace("_config_","_".$access."_",$this->routeprimary);
|
||||
return $this->redirect($this->generateUrl($route.'_update',["id"=>$entity->getId()]));
|
||||
}
|
||||
|
||||
return $this->render($this->labelentity.':submit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => ($access=="config"),
|
||||
'entity' => $entity,
|
||||
'mode' => "submit",
|
||||
'access' => $access,
|
||||
'form' => $form->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateAction(Request $request, $id,$access="config")
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$entity = $em->getRepository($this->labelentity)->find($id);
|
||||
|
||||
if (!$entity) {
|
||||
throw $this->createNotFoundException('Unable to find entity.');
|
||||
}
|
||||
|
||||
$form = $this->entityForm($entity,$access);
|
||||
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->persist($entity);
|
||||
$em->flush();
|
||||
|
||||
$route=str_replace("_config_","_".$access."_",$this->routeprimary);
|
||||
return $this->redirect($this->generateUrl($route.'_view',["id"=>$id]));
|
||||
}
|
||||
|
||||
|
||||
// Type URL
|
||||
if($entity->getPagecategory()->getId()==1 ) {
|
||||
return $this->render($this->labelentity.':updateurl.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => ($access=="config"),
|
||||
'entity' => $entity,
|
||||
'access' => $access,
|
||||
'mode' => "update",
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
// Type Widget
|
||||
elseif($entity->getPagecategory()->getId()==2 ) {
|
||||
return $this->render($this->labelentity.':updatewidget.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => ($access=="config"),
|
||||
'entity' => $entity,
|
||||
'access' => $access,
|
||||
'mode' => "update",
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
// Type Editeur
|
||||
elseif($entity->getPagecategory()->getId()==3 ) {
|
||||
return $this->render($this->labelentity.':updateeditor.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => ($access=="config"),
|
||||
'entity' => $entity,
|
||||
'access' => $access,
|
||||
'mode' => "update",
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteAction(Request $request, $id,$access="config")
|
||||
{
|
||||
$entity = $this->getDoctrine()
|
||||
->getRepository($this->labelentity)
|
||||
->find($id);
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->remove($entity);
|
||||
$em->flush();
|
||||
|
||||
$route=str_replace("_config_","_".$access."_",$this->routeprimary);
|
||||
return $this->redirect($this->generateUrl($route));
|
||||
}
|
||||
|
||||
public function viewAction($id,$access=null) {
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$entity = $em->getRepository($this->labelentity)->find($id);
|
||||
|
||||
if (!$entity) {
|
||||
throw $this->createNotFoundException('Unable to find entity.');
|
||||
}
|
||||
|
||||
// Pages profilé
|
||||
if($access=="config") {
|
||||
$pages=new ArrayCollection();
|
||||
$pages->add($entity);
|
||||
}
|
||||
else {
|
||||
// Profilage
|
||||
$user=$this->getUser();
|
||||
$roles=($user?$user->getRoles():["ROLE_ANONYME"]);
|
||||
$groups=($user?$user->getGroups():[]);
|
||||
|
||||
// Initialisation du calcul des pages
|
||||
$pagesnotorder=new ArrayCollection();
|
||||
|
||||
// Récupération des pages par rôles
|
||||
foreach($roles as $role) {
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('page')
|
||||
->from("CadolesPortalBundle:Page", 'page')
|
||||
->where($qb->expr()->like('page.roles', $qb->expr()->literal("%$role%")));
|
||||
|
||||
$pagesroles=$qb->getQuery()->getResult();
|
||||
foreach($pagesroles as $pagerole) {
|
||||
if(!$pagesnotorder->contains($pagerole)) $pagesnotorder->add($pagerole);
|
||||
}
|
||||
}
|
||||
|
||||
// Récupération des pages par group
|
||||
foreach($groups as $group) {
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('page')
|
||||
->from("CadolesPortalBundle:Page", 'page')
|
||||
->where(":group MEMBER OF page.groups")
|
||||
->setParameter("group",$group->getGroup());
|
||||
|
||||
$pagesgroups=$qb->getQuery()->getResult();
|
||||
foreach($pagesgroups as $pagegroup) {
|
||||
if(!$pagesnotorder->contains($pagegroup)) $pagesnotorder->add($pagegroup);
|
||||
}
|
||||
}
|
||||
|
||||
// Trie des pages
|
||||
$pages = $pagesnotorder->getIterator();
|
||||
$pages->uasort(function ($first, $second) {
|
||||
return (int) $first->getRowOrder() > (int) $second->getRowOrder() ? 1 : -1;
|
||||
});
|
||||
}
|
||||
|
||||
// Type URL
|
||||
if($entity->getPageCategory()->getId()==1) {
|
||||
return $this->render($this->labelentity.':viewurl.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => ($access=="config"),
|
||||
'entity' => $entity,
|
||||
'access' => $access,
|
||||
'pages' => $pages
|
||||
]);
|
||||
}
|
||||
// Type Editeur
|
||||
if($entity->getPageCategory()->getId()==2) {
|
||||
return $this->render($this->labelentity.':viewwidget.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => ($access=="config"),
|
||||
'entity' => $entity,
|
||||
'access' => $access,
|
||||
'pages' => $pages,
|
||||
'widgets' => $this->getDoctrine()->getRepository("CadolesPortalBundle:Widget")->findAll()
|
||||
]);
|
||||
}
|
||||
// Type Editeur
|
||||
if($entity->getPageCategory()->getId()==3) {
|
||||
return $this->render($this->labelentity.':vieweditor.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => ($access=="config"),
|
||||
'entity' => $entity,
|
||||
'access' => $access,
|
||||
'pages' => $pages
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,439 @@
|
|||
<?php
|
||||
|
||||
namespace Cadoles\PortalBundle\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
||||
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
use Cadoles\PortalBundle\Entity\Pagewidget;
|
||||
use Cadoles\PortalBundle\Form\PagewidgetType;
|
||||
|
||||
class PagewidgetController extends Controller
|
||||
{
|
||||
private $labelentity="CadolesPortalBundle:Pagewidget";
|
||||
private $routeprimary="cadoles_portal_config_pagewidget";
|
||||
|
||||
private function searchArray($array, $key, $value)
|
||||
{
|
||||
$results = array();
|
||||
|
||||
if (is_array($array))
|
||||
{
|
||||
if (isset($array[$key]) && $array[$key] == $value)
|
||||
$results[] = $array;
|
||||
|
||||
foreach ($array as $subarray)
|
||||
$results = array_merge($results, $this->searchArray($subarray, $key, $value));
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
private function entityForm(Pagewidget $entity,$idpage,$id,$access="config")
|
||||
{
|
||||
if ($this->getDoctrine()->getManager()->contains($entity)) {
|
||||
$widgettype= $this->getDoctrine()->getManager()->getRepository("CadolesPortalBundle:Pagewidget")->find($id)->getWidget();
|
||||
$params = $widgettype->getParameter();
|
||||
$values = $entity->getParameter();
|
||||
|
||||
foreach($params->fields as $key => $param) {
|
||||
$tmp = $this->searchArray($values,"id",$param->id);
|
||||
if(is_array($tmp))
|
||||
$params->fields[$key]->value=$tmp[0]["value"];
|
||||
}
|
||||
|
||||
return $this->createForm(PagewidgetType::class, $entity, [
|
||||
'param' => $params,
|
||||
'mode' => "update",
|
||||
'idicon' => $entity->getIcon()->getId(),
|
||||
'method' => 'POST',
|
||||
]);
|
||||
} else {
|
||||
$widgettype= $this->getDoctrine()->getManager()->getRepository("CadolesPortalBundle:Widget")->find($id);
|
||||
$entity->setName($widgettype->getName());
|
||||
$entity->setHeight($widgettype->getHeight());
|
||||
$entity->setAutoajust($widgettype->getAutoajust());
|
||||
$entity->setBorder($widgettype->getBorder());
|
||||
$entity->setColorheaderback($widgettype->getColorheaderback());
|
||||
$entity->setColorheaderfont($widgettype->getColorheaderfont());
|
||||
$entity->setColorbodyback($widgettype->getColorbodyback());
|
||||
$entity->setColorbodyfont($widgettype->getColorbodyfont());
|
||||
$entity->setIcon($widgettype->getIcon());
|
||||
|
||||
$param = $widgettype->getParameter();
|
||||
return $this->createForm(PagewidgetType::class, $entity, [
|
||||
'param' => $param,
|
||||
'mode' => "submit",
|
||||
'idicon' => $widgettype->getIcon()->getId(),
|
||||
'method' => 'POST',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function submitAction(Request $request,$idpage,$idwidgettype,$access="config")
|
||||
{
|
||||
|
||||
$entity = new Pagewidget();
|
||||
$form = $this->entityForm($entity,$idpage,$idwidgettype,$access);
|
||||
$form->handleRequest($request);
|
||||
|
||||
|
||||
if ($form->isValid()) {
|
||||
$idicon = $form->get('idicon')->getData();
|
||||
$icon=$this->getDoctrine()->getRepository("CadolesPortalBundle:Icon")->findoneby(["id"=>$idicon]);
|
||||
$panel=$this->getDoctrine()->getRepository("CadolesPortalBundle:Page")->findoneby(["id"=>$idpage]);
|
||||
$widgettype=$this->getDoctrine()->getRepository("CadolesPortalBundle:Widget")->findoneby(["id"=>$idwidgettype]);
|
||||
|
||||
// Localisation par défaut en R1C1
|
||||
$entity->setLoc("R1C1");
|
||||
$entity->setRoworder("1");
|
||||
|
||||
// Rattachement icon / panel / widgettype
|
||||
$entity->setIcon($icon);
|
||||
$entity->setPage($panel);
|
||||
$entity->setWidget($widgettype);
|
||||
|
||||
// Récupération des paramétres
|
||||
$jsons=$widgettype->getParameter();
|
||||
$param=array();
|
||||
$param["fields"]=array();
|
||||
foreach($jsons->fields as $field) {
|
||||
$tmp=array();
|
||||
$tmp["id"]=$field->id;
|
||||
$tmp["value"]=$form->get($field->id)->getData();
|
||||
array_push($param["fields"],$tmp);
|
||||
}
|
||||
|
||||
$entity->setParameter($param);
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->persist($entity);
|
||||
$em->flush();
|
||||
|
||||
return $this->redirect($this->generateUrl('cadoles_portal_'.$access.'_page_view',["id"=>$idpage]));
|
||||
}
|
||||
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => ($access=="config"),
|
||||
'entity' => $entity,
|
||||
'icons' => $this->getDoctrine()->getRepository("CadolesPortalBundle:Icon")->findAll(),
|
||||
'mode' => "submit",
|
||||
'access' => $access,
|
||||
'idpage' => $idpage,
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateAction(Request $request,$idpage,$idwidget,$access="config")
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$entity = $em->getRepository($this->labelentity)->find($idwidget);
|
||||
if (!$entity) {
|
||||
throw $this->createNotFoundException('Unable to find entity.');
|
||||
}
|
||||
|
||||
$form = $this->entityForm($entity,$idpage,$idwidget,$access);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$idicon = $form->get('idicon')->getData();
|
||||
$icon=$this->getDoctrine()->getRepository("CadolesPortalBundle:Icon")->findoneby(["id"=>$idicon]);
|
||||
$entity->setIcon($icon);
|
||||
|
||||
// Récupération des paramétres
|
||||
$widgettype= $entity->getWidget();
|
||||
$jsons=$widgettype->getParameter();
|
||||
$param=array();
|
||||
$param["fields"]=array();
|
||||
foreach($jsons->fields as $field) {
|
||||
$tmp=array();
|
||||
$tmp["id"]=$field->id;
|
||||
|
||||
$tmp["value"]=$form->get($field->id)->getData();
|
||||
array_push($param["fields"],$tmp);
|
||||
}
|
||||
|
||||
$entity->setParameter($param);
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->persist($entity);
|
||||
$em->flush();
|
||||
|
||||
return $this->redirect($this->generateUrl('cadoles_portal_'.$access.'_page_view',["id"=>$idpage]));
|
||||
}
|
||||
|
||||
return $this->render($this->labelentity.':edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usemenu' => false,
|
||||
'usesidebar' => ($access=="config"),
|
||||
'entity' => $entity,
|
||||
'icons' => $this->getDoctrine()->getRepository("CadolesPortalBundle:Icon")->findAll(),
|
||||
'mode' => "update",
|
||||
'access' => $access,
|
||||
'idpage' => $idpage,
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function deleteAction(Request $request)
|
||||
{
|
||||
// S'assurer que c'est un appel ajax
|
||||
if (!$request->isXmlHttpRequest()) {
|
||||
return new JsonResponse(array('message' => 'Interdit'), 400);
|
||||
}
|
||||
|
||||
$output=array();
|
||||
$idwidget=$request->request->get('idwidget');
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$entity = $em->getRepository($this->labelentity)->find($idwidget);
|
||||
if (!$entity) {
|
||||
throw $this->createNotFoundException('Unable to find entity.');
|
||||
}
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->remove($entity);
|
||||
$em->flush();
|
||||
|
||||
$response = new Response(json_encode($output));
|
||||
$response->headers->set('Content-Type', 'application/json');
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function orderAction(Request $request)
|
||||
{
|
||||
// S'assurer que c'est un appel ajax
|
||||
if (!$request->isXmlHttpRequest()) {
|
||||
return new JsonResponse(array('message' => 'Interdit'), 400);
|
||||
}
|
||||
|
||||
$output=array();
|
||||
$idwidget=$request->request->get('idwidget');
|
||||
$order=$request->request->get('order');
|
||||
$idloc=$request->request->get('idloc');
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$entity = $em->getRepository($this->labelentity)->find($idwidget);
|
||||
if (!$entity) {
|
||||
throw $this->createNotFoundException('Unable to find entity.');
|
||||
}
|
||||
|
||||
$entity->setRoworder($order);
|
||||
$entity->setLoc($idloc);
|
||||
$em->persist($entity);
|
||||
$em->flush();
|
||||
|
||||
$response = new Response(json_encode($output));
|
||||
$response->headers->set('Content-Type', 'application/json');
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function viewurlAction($id) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$entity = $em->getRepository($this->labelentity)->find($id);
|
||||
if (!$entity) {
|
||||
throw $this->createNotFoundException('Unable to find entity.');
|
||||
}
|
||||
|
||||
$url="";
|
||||
foreach($entity->getParameter()["fields"] as $parameter) {
|
||||
if($parameter["id"]=="url")
|
||||
$url=$parameter["value"];
|
||||
}
|
||||
|
||||
// Gestion des url youtuve
|
||||
$url=str_replace("http://www.youtube.com","https://www.youtube.com",$url);
|
||||
$url=str_replace("https://www.youtube.com/watch?v=","https://www.youtube.com/embed/",$url);
|
||||
|
||||
// Detecter le type de lien
|
||||
$imagemedia=false;
|
||||
$pathinfo = pathinfo($url);
|
||||
|
||||
// Type image
|
||||
if(array_key_exists("extension",$pathinfo)) {
|
||||
if($pathinfo['extension']=="jpg"||$pathinfo['extension']=="gif"||$pathinfo['extension']=="png") {
|
||||
$imagemedia=true;
|
||||
}
|
||||
}
|
||||
|
||||
// Spécifique Deviant Art
|
||||
if(strpos($url, "images-wixmp") !== false) $imagemedia=true;
|
||||
|
||||
|
||||
return $this->render($this->labelentity.':viewurl.html.twig', [
|
||||
'entity' => $entity,
|
||||
'url' => $url,
|
||||
'imagemedia' => $imagemedia
|
||||
]);
|
||||
}
|
||||
|
||||
public function viewitemAction($id) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$entity = $em->getRepository($this->labelentity)->find($id);
|
||||
if (!$entity) {
|
||||
throw $this->createNotFoundException('Unable to find entity.');
|
||||
}
|
||||
|
||||
// Récupération des paramétres du widget
|
||||
$modedesktop=0;
|
||||
$iditemcategory=null;
|
||||
foreach($entity->getParameter()["fields"] as $parameter) {
|
||||
switch($parameter["id"]) {
|
||||
case "modedesktop":
|
||||
$modedesktop=$parameter["value"];
|
||||
break;
|
||||
|
||||
case "itemcategory":
|
||||
$iditemcategory=$parameter["value"];
|
||||
if($iditemcategory) $itemcategoryfilter=$em->getRepository("CadolesPortalBundle:Itemcategory")->find($iditemcategory);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Profilage
|
||||
$user=$this->getUser();
|
||||
$roles=($user?$user->getRoles():["ROLE_ANONYME"]);
|
||||
$groups=($user?$user->getGroups():[]);
|
||||
|
||||
// Initialisation du calcul des items
|
||||
$items=new ArrayCollection();
|
||||
|
||||
// Récupération des items par rôles
|
||||
foreach($roles as $role) {
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('item')
|
||||
->from("CadolesPortalBundle:Item", 'item')
|
||||
->where($qb->expr()->like('item.roles', $qb->expr()->literal("%$role%")));
|
||||
|
||||
if($iditemcategory && $itemcategoryfilter) {
|
||||
$qb->andWhere("item.itemcategory=:itemcategory")
|
||||
->setParameter("itemcategory",$itemcategoryfilter);
|
||||
}
|
||||
$itemsroles=$qb->getQuery()->getResult();
|
||||
foreach($itemsroles as $itemrole) {
|
||||
if(!$items->contains($itemrole)) $items->add($itemrole);
|
||||
}
|
||||
}
|
||||
|
||||
// Récupération des items par group
|
||||
foreach($groups as $group) {
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('item')
|
||||
->from("CadolesPortalBundle:Item", 'item')
|
||||
->where(":group MEMBER OF item.groups")
|
||||
->setParameter("group",$group->getGroup());
|
||||
|
||||
if($iditemcategory && $itemcategoryfilter) {
|
||||
$qb->andWhere("item.itemcategory=:itemcategory")
|
||||
->setParameter("itemcategory",$itemcategoryfilter);
|
||||
}
|
||||
$itemsgroups=$qb->getQuery()->getResult();
|
||||
foreach($itemsgroups as $itemgroup) {
|
||||
if(!$items->contains($itemgroup)) $items->add($itemgroup);
|
||||
}
|
||||
}
|
||||
|
||||
// Trie des items
|
||||
$itemsordered = $items->getIterator();
|
||||
$itemsordered->uasort(function ($first, $second) {
|
||||
return (int) $first->getRowOrder() > (int) $second->getRowOrder() ? 1 : -1;
|
||||
});
|
||||
|
||||
// Catégories affichées
|
||||
$itemcategorys = $this->getDoctrine()->getRepository('CadolesPortalBundle:Itemcategory')->findBy([], ['rowOrder' => 'asc']);
|
||||
if($iditemcategory && $itemcategoryfilter) $itemcategorys = $itemcategoryfilter;
|
||||
|
||||
// Render
|
||||
return $this->render($this->labelentity.':viewitem.html.twig', [
|
||||
'entity' => $entity,
|
||||
'modedesktop' => $modedesktop,
|
||||
'items' => $itemsordered,
|
||||
'itemcategorys' => $itemcategorys
|
||||
]);
|
||||
}
|
||||
|
||||
public function viewalertAction($id) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$entity = $em->getRepository($this->labelentity)->find($id);
|
||||
if (!$entity) {
|
||||
throw $this->createNotFoundException('Unable to find entity.');
|
||||
}
|
||||
|
||||
// Récupération des paramétres du widget
|
||||
$idalertcategory=null;
|
||||
foreach($entity->getParameter()["fields"] as $parameter) {
|
||||
switch($parameter["id"]) {
|
||||
case "alertcategory":
|
||||
$idalertcategory=$parameter["value"];
|
||||
if($idalertcategory) $alertcategoryfilter=$em->getRepository("CadolesPortalBundle:Alertcategory")->find($idalertcategory);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Profilage
|
||||
$user=$this->getUser();
|
||||
$roles=($user?$user->getRoles():["ROLE_ANONYME"]);
|
||||
$groups=($user?$user->getGroups():[]);
|
||||
|
||||
// Initialisation du calcul des alerts
|
||||
$alerts=new ArrayCollection();
|
||||
dump("yo");
|
||||
// Récupération des alerts par rôles
|
||||
foreach($roles as $role) {
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('alert')
|
||||
->from("CadolesPortalBundle:Alert", 'alert')
|
||||
->where($qb->expr()->like('alert.roles', $qb->expr()->literal("%$role%")));
|
||||
|
||||
if($idalertcategory && $alertcategoryfilter) {
|
||||
$qb->andWhere("alert.alertcategory=:alertcategory")
|
||||
->setParameter("alertcategory",$alertcategoryfilter);
|
||||
}
|
||||
$alertsroles=$qb->getQuery()->getResult();
|
||||
foreach($alertsroles as $alertrole) {
|
||||
if(!$alerts->contains($alertrole)) $alerts->add($alertrole);
|
||||
}
|
||||
}
|
||||
|
||||
// Récupération des alerts par group
|
||||
foreach($groups as $group) {
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('alert')
|
||||
->from("CadolesPortalBundle:Alert", 'alert')
|
||||
->where(":group MEMBER OF alert.groups")
|
||||
->setParameter("group",$group->getGroup());
|
||||
|
||||
if($idalertcategory && $alertcategoryfilter) {
|
||||
$qb->andWhere("alert.alertcategory=:alertcategory")
|
||||
->setParameter("alertcategory",$alertcategoryfilter);
|
||||
}
|
||||
$alertsgroups=$qb->getQuery()->getResult();
|
||||
foreach($alertsgroups as $alertgroup) {
|
||||
if(!$alerts->contains($alertgroup)) $alerts->add($alertgroup);
|
||||
}
|
||||
}
|
||||
|
||||
// Trie des alerts
|
||||
$alertsordered = $alerts->getIterator();
|
||||
$alertsordered->uasort(function ($first, $second) {
|
||||
return (int) $first->getRowOrder() > (int) $second->getRowOrder() ? 1 : -1;
|
||||
});
|
||||
|
||||
// Render
|
||||
return $this->render($this->labelentity.':viewalert.html.twig', [
|
||||
'entity' => $entity,
|
||||
'alerts' => $alertsordered
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,348 @@
|
|||
<?php
|
||||
|
||||
namespace Cadoles\PortalBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Page
|
||||
*
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="page")
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*/
|
||||
class Page
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="name", type="string", length=100)
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @ORM\Column(name="roworder", type="integer")
|
||||
*/
|
||||
private $roworder;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="url", type="text", nullable=true)
|
||||
*/
|
||||
private $url;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="html", type="text", nullable=true)
|
||||
*/
|
||||
private $html;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="template", type="array", nullable=true)
|
||||
*/
|
||||
private $template;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="roles", type="array", nullable=true)
|
||||
*/
|
||||
private $roles;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Pagecategory", inversedBy="pages")
|
||||
*/
|
||||
private $pagecategory;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="Cadoles\CoreBundle\Entity\Group", inversedBy="pages", cascade={"persist"})
|
||||
* @ORM\JoinTable(name="pagegroupe",
|
||||
* joinColumns={@ORM\JoinColumn(name="page", referencedColumnName="id")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="groupe", referencedColumnName="id")}
|
||||
* )
|
||||
*/
|
||||
protected $groups;
|
||||
|
||||
/**
|
||||
* @var ArrayCollection $pagewidgets
|
||||
* @var Order
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity="Pagewidget", mappedBy="page", cascade={"persist"}, orphanRemoval=true)
|
||||
* @ORM\OrderBy({"loc" = "ASC", "roworder" = "ASC"})
|
||||
*/
|
||||
private $pagewidgets;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->groups = new \Doctrine\Common\Collections\ArrayCollection();
|
||||
$this->pagewidgets = new \Doctrine\Common\Collections\ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set roworder
|
||||
*
|
||||
* @param integer $roworder
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
public function setRoworder($roworder)
|
||||
{
|
||||
$this->roworder = $roworder;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get roworder
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getRoworder()
|
||||
{
|
||||
return $this->roworder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set url
|
||||
*
|
||||
* @param string $url
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
public function setUrl($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get url
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set html
|
||||
*
|
||||
* @param string $html
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
public function setHtml($html)
|
||||
{
|
||||
$this->html = $html;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get html
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHtml()
|
||||
{
|
||||
return $this->html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set template
|
||||
*
|
||||
* @param array $template
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
public function setTemplate($template)
|
||||
{
|
||||
$this->template = $template;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get template
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTemplate()
|
||||
{
|
||||
return $this->template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set roles
|
||||
*
|
||||
* @param array $roles
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
public function setRoles($roles)
|
||||
{
|
||||
$this->roles = $roles;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get roles
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRoles()
|
||||
{
|
||||
return $this->roles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set pagecategory
|
||||
*
|
||||
* @param \Cadoles\PortalBundle\Entity\Pagecategory $pagecategory
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
public function setPagecategory(\Cadoles\PortalBundle\Entity\Pagecategory $pagecategory = null)
|
||||
{
|
||||
$this->pagecategory = $pagecategory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pagecategory
|
||||
*
|
||||
* @return \Cadoles\PortalBundle\Entity\Pagecategory
|
||||
*/
|
||||
public function getPagecategory()
|
||||
{
|
||||
return $this->pagecategory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add group
|
||||
*
|
||||
* @param \Cadoles\CoreBundle\Entity\Group $group
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
public function addGroup(\Cadoles\CoreBundle\Entity\Group $group)
|
||||
{
|
||||
$this->groups[] = $group;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove group
|
||||
*
|
||||
* @param \Cadoles\CoreBundle\Entity\Group $group
|
||||
*/
|
||||
public function removeGroup(\Cadoles\CoreBundle\Entity\Group $group)
|
||||
{
|
||||
$this->groups->removeElement($group);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get groups
|
||||
*
|
||||
* @return \Doctrine\Common\Collections\Collection
|
||||
*/
|
||||
public function getGroups()
|
||||
{
|
||||
return $this->groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add pagewidget
|
||||
*
|
||||
* @param \Cadoles\PortalBundle\Entity\Pagewidget $pagewidget
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
public function addPagewidget(\Cadoles\PortalBundle\Entity\Pagewidget $pagewidget)
|
||||
{
|
||||
$this->pagewidgets[] = $pagewidget;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove pagewidget
|
||||
*
|
||||
* @param \Cadoles\PortalBundle\Entity\Pagewidget $pagewidget
|
||||
*/
|
||||
public function removePagewidget(\Cadoles\PortalBundle\Entity\Pagewidget $pagewidget)
|
||||
{
|
||||
$this->pagewidgets->removeElement($pagewidget);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pagewidgets
|
||||
*
|
||||
* @return \Doctrine\Common\Collections\Collection
|
||||
*/
|
||||
public function getPagewidgets()
|
||||
{
|
||||
return $this->pagewidgets;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
<?php
|
||||
|
||||
namespace Cadoles\PortalBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Pagetype
|
||||
*
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="pagecategory")
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*/
|
||||
class Pagecategory
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="name", type="string", length=100)
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var ArrayCollection $pages
|
||||
* @var Page
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity="Page", mappedBy="pagecategory", cascade={"persist"}, orphanRemoval=false)
|
||||
*/
|
||||
private $pages;
|
||||
|
||||
|
||||
// A garder pour forcer l'id en init
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->pages = new \Doctrine\Common\Collections\ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return Pagecategory
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add page
|
||||
*
|
||||
* @param \Cadoles\PortalBundle\Entity\Page $page
|
||||
*
|
||||
* @return Pagecategory
|
||||
*/
|
||||
public function addPage(\Cadoles\PortalBundle\Entity\Page $page)
|
||||
{
|
||||
$this->pages[] = $page;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove page
|
||||
*
|
||||
* @param \Cadoles\PortalBundle\Entity\Page $page
|
||||
*/
|
||||
public function removePage(\Cadoles\PortalBundle\Entity\Page $page)
|
||||
{
|
||||
$this->pages->removeElement($page);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pages
|
||||
*
|
||||
* @return \Doctrine\Common\Collections\Collection
|
||||
*/
|
||||
public function getPages()
|
||||
{
|
||||
return $this->pages;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,468 @@
|
|||
<?php
|
||||
|
||||
namespace Cadoles\PortalBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Pagewidget
|
||||
*
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="pagewidget")
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*/
|
||||
class Pagewidget
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="name", type="string", length=100)
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="loc", type="string")
|
||||
*/
|
||||
private $loc;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="roworder", type="integer")
|
||||
*/
|
||||
private $roworder;
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @ORM\Column(name="height", type="integer")
|
||||
*/
|
||||
private $height;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
*
|
||||
* @ORM\Column(name="autoajust", type="boolean", options={"default":false})
|
||||
*/
|
||||
protected $autoajust;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
*
|
||||
* @ORM\Column(name="border", type="boolean", options={"default":true})
|
||||
*/
|
||||
protected $border;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="colorheaderback", type="string", nullable=true)
|
||||
*/
|
||||
protected $colorheaderback;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="colorheaderfont", type="string", nullable=true)
|
||||
*/
|
||||
protected $colorheaderfont;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="colorbodyback", type="string", nullable=true)
|
||||
*/
|
||||
protected $colorbodyback;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="colorbodyfont", type="string", nullable=true)
|
||||
*/
|
||||
protected $colorbodyfont;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="parameter", type="array", nullable=true)
|
||||
*/
|
||||
private $parameter;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Page", inversedBy="pagewidgets")
|
||||
*/
|
||||
private $page;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Widget", inversedBy="pagewidgets")
|
||||
*/
|
||||
private $widget;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Icon", inversedBy="panelwidgets")
|
||||
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
|
||||
*/
|
||||
private $icon;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return Pagewidget
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set loc
|
||||
*
|
||||
* @param string $loc
|
||||
*
|
||||
* @return Pagewidget
|
||||
*/
|
||||
public function setLoc($loc)
|
||||
{
|
||||
$this->loc = $loc;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get loc
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLoc()
|
||||
{
|
||||
return $this->loc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set roworder
|
||||
*
|
||||
* @param integer $roworder
|
||||
*
|
||||
* @return Pagewidget
|
||||
*/
|
||||
public function setRoworder($roworder)
|
||||
{
|
||||
$this->roworder = $roworder;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get roworder
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getRoworder()
|
||||
{
|
||||
return $this->roworder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set height
|
||||
*
|
||||
* @param integer $height
|
||||
*
|
||||
* @return Pagewidget
|
||||
*/
|
||||
public function setHeight($height)
|
||||
{
|
||||
$this->height = $height;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get height
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getHeight()
|
||||
{
|
||||
return $this->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set autoajust
|
||||
*
|
||||
* @param boolean $autoajust
|
||||
*
|
||||
* @return Pagewidget
|
||||
*/
|
||||
public function setAutoajust($autoajust)
|
||||
{
|
||||
$this->autoajust = $autoajust;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get autoajust
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getAutoajust()
|
||||
{
|
||||
return $this->autoajust;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set border
|
||||
*
|
||||
* @param boolean $border
|
||||
*
|
||||
* @return Pagewidget
|
||||
*/
|
||||
public function setBorder($border)
|
||||
{
|
||||
$this->border = $border;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get border
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getBorder()
|
||||
{
|
||||
return $this->border;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set colorheaderback
|
||||
*
|
||||
* @param string $colorheaderback
|
||||
*
|
||||
* @return Pagewidget
|
||||
*/
|
||||
public function setColorheaderback($colorheaderback)
|
||||
{
|
||||
$this->colorheaderback = $colorheaderback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get colorheaderback
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getColorheaderback()
|
||||
{
|
||||
return $this->colorheaderback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set colorheaderfont
|
||||
*
|
||||
* @param string $colorheaderfont
|
||||
*
|
||||
* @return Pagewidget
|
||||
*/
|
||||
public function setColorheaderfont($colorheaderfont)
|
||||
{
|
||||
$this->colorheaderfont = $colorheaderfont;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get colorheaderfont
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getColorheaderfont()
|
||||
{
|
||||
return $this->colorheaderfont;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set colorbodyback
|
||||
*
|
||||
* @param string $colorbodyback
|
||||
*
|
||||
* @return Pagewidget
|
||||
*/
|
||||
public function setColorbodyback($colorbodyback)
|
||||
{
|
||||
$this->colorbodyback = $colorbodyback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get colorbodyback
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getColorbodyback()
|
||||
{
|
||||
return $this->colorbodyback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set colorbodyfont
|
||||
*
|
||||
* @param string $colorbodyfont
|
||||
*
|
||||
* @return Pagewidget
|
||||
*/
|
||||
public function setColorbodyfont($colorbodyfont)
|
||||
{
|
||||
$this->colorbodyfont = $colorbodyfont;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get colorbodyfont
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getColorbodyfont()
|
||||
{
|
||||
return $this->colorbodyfont;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set parameter
|
||||
*
|
||||
* @param array $parameter
|
||||
*
|
||||
* @return Pagewidget
|
||||
*/
|
||||
public function setParameter($parameter)
|
||||
{
|
||||
$this->parameter = $parameter;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parameter
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getParameter()
|
||||
{
|
||||
return $this->parameter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set page
|
||||
*
|
||||
* @param \Cadoles\PortalBundle\Entity\Page $page
|
||||
*
|
||||
* @return Pagewidget
|
||||
*/
|
||||
public function setPage(\Cadoles\PortalBundle\Entity\Page $page = null)
|
||||
{
|
||||
$this->page = $page;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get page
|
||||
*
|
||||
* @return \Cadoles\PortalBundle\Entity\Page
|
||||
*/
|
||||
public function getPage()
|
||||
{
|
||||
return $this->page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set widget
|
||||
*
|
||||
* @param \Cadoles\PortalBundle\Entity\Widget $widget
|
||||
*
|
||||
* @return Pagewidget
|
||||
*/
|
||||
public function setWidget(\Cadoles\PortalBundle\Entity\Widget $widget = null)
|
||||
{
|
||||
$this->widget = $widget;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get widget
|
||||
*
|
||||
* @return \Cadoles\PortalBundle\Entity\Widget
|
||||
*/
|
||||
public function getWidget()
|
||||
{
|
||||
return $this->widget;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set icon
|
||||
*
|
||||
* @param \Cadoles\PortalBundle\Entity\Icon $icon
|
||||
*
|
||||
* @return Pagewidget
|
||||
*/
|
||||
public function setIcon(\Cadoles\PortalBundle\Entity\Icon $icon = null)
|
||||
{
|
||||
$this->icon = $icon;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get icon
|
||||
*
|
||||
* @return \Cadoles\PortalBundle\Entity\Icon
|
||||
*/
|
||||
public function getIcon()
|
||||
{
|
||||
return $this->icon;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,497 @@
|
|||
<?php
|
||||
|
||||
namespace Cadoles\PortalBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Widget
|
||||
*
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="widget")
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*/
|
||||
class Widget
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @ORM\Column(name="roworder", type="integer")
|
||||
*/
|
||||
private $roworder;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="name", type="string", length=100)
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="description", type="text", nullable=true)
|
||||
*/
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="routeview", type="string")
|
||||
*/
|
||||
private $routeview;
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @ORM\Column(name="height", type="integer")
|
||||
*/
|
||||
private $height;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
*
|
||||
* @ORM\Column(name="autoajust", type="boolean", options={"default":false})
|
||||
*/
|
||||
protected $autoajust;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
*
|
||||
* @ORM\Column(name="border", type="boolean", options={"default":true})
|
||||
*/
|
||||
protected $border;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="colorheaderback", type="string", nullable=true)
|
||||
*/
|
||||
protected $colorheaderback;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="colorheaderfont", type="string", nullable=true)
|
||||
*/
|
||||
protected $colorheaderfont;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="colorbodyback", type="string", nullable=true)
|
||||
*/
|
||||
protected $colorbodyback;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="colorbodyfont", type="string", nullable=true)
|
||||
*/
|
||||
protected $colorbodyfont;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="parameter", type="array", nullable=true)
|
||||
*/
|
||||
private $parameter;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Icon", inversedBy="widgets")
|
||||
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
|
||||
*/
|
||||
private $icon;
|
||||
|
||||
/**
|
||||
* @var ArrayCollection $pagewidgets
|
||||
* @var Order
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity="Pagewidget", mappedBy="widget", cascade={"persist"}, orphanRemoval=false)
|
||||
*/
|
||||
private $pageidgets;
|
||||
|
||||
// A garder pour forcer l'id en init
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->pageidgets = new \Doctrine\Common\Collections\ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set roworder
|
||||
*
|
||||
* @param integer $roworder
|
||||
*
|
||||
* @return Widget
|
||||
*/
|
||||
public function setRoworder($roworder)
|
||||
{
|
||||
$this->roworder = $roworder;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get roworder
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getRoworder()
|
||||
{
|
||||
return $this->roworder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return Widget
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set description
|
||||
*
|
||||
* @param string $description
|
||||
*
|
||||
* @return Widget
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set routeview
|
||||
*
|
||||
* @param string $routeview
|
||||
*
|
||||
* @return Widget
|
||||
*/
|
||||
public function setRouteview($routeview)
|
||||
{
|
||||
$this->routeview = $routeview;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get routeview
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRouteview()
|
||||
{
|
||||
return $this->routeview;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set height
|
||||
*
|
||||
* @param integer $height
|
||||
*
|
||||
* @return Widget
|
||||
*/
|
||||
public function setHeight($height)
|
||||
{
|
||||
$this->height = $height;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get height
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getHeight()
|
||||
{
|
||||
return $this->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set autoajust
|
||||
*
|
||||
* @param boolean $autoajust
|
||||
*
|
||||
* @return Widget
|
||||
*/
|
||||
public function setAutoajust($autoajust)
|
||||
{
|
||||
$this->autoajust = $autoajust;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get autoajust
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getAutoajust()
|
||||
{
|
||||
return $this->autoajust;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set border
|
||||
*
|
||||
* @param boolean $border
|
||||
*
|
||||
* @return Widget
|
||||
*/
|
||||
public function setBorder($border)
|
||||
{
|
||||
$this->border = $border;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get border
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getBorder()
|
||||
{
|
||||
return $this->border;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set colorheaderback
|
||||
*
|
||||
* @param string $colorheaderback
|
||||
*
|
||||
* @return Widget
|
||||
*/
|
||||
public function setColorheaderback($colorheaderback)
|
||||
{
|
||||
$this->colorheaderback = $colorheaderback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get colorheaderback
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getColorheaderback()
|
||||
{
|
||||
return $this->colorheaderback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set colorheaderfont
|
||||
*
|
||||
* @param string $colorheaderfont
|
||||
*
|
||||
* @return Widget
|
||||
*/
|
||||
public function setColorheaderfont($colorheaderfont)
|
||||
{
|
||||
$this->colorheaderfont = $colorheaderfont;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get colorheaderfont
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getColorheaderfont()
|
||||
{
|
||||
return $this->colorheaderfont;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set colorbodyback
|
||||
*
|
||||
* @param string $colorbodyback
|
||||
*
|
||||
* @return Widget
|
||||
*/
|
||||
public function setColorbodyback($colorbodyback)
|
||||
{
|
||||
$this->colorbodyback = $colorbodyback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get colorbodyback
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getColorbodyback()
|
||||
{
|
||||
return $this->colorbodyback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set colorbodyfont
|
||||
*
|
||||
* @param string $colorbodyfont
|
||||
*
|
||||
* @return Widget
|
||||
*/
|
||||
public function setColorbodyfont($colorbodyfont)
|
||||
{
|
||||
$this->colorbodyfont = $colorbodyfont;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get colorbodyfont
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getColorbodyfont()
|
||||
{
|
||||
return $this->colorbodyfont;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set parameter
|
||||
*
|
||||
* @param array $parameter
|
||||
*
|
||||
* @return Widget
|
||||
*/
|
||||
public function setParameter($parameter)
|
||||
{
|
||||
$this->parameter = $parameter;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parameter
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getParameter()
|
||||
{
|
||||
return $this->parameter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set icon
|
||||
*
|
||||
* @param \Cadoles\PortalBundle\Entity\Icon $icon
|
||||
*
|
||||
* @return Widget
|
||||
*/
|
||||
public function setIcon(\Cadoles\PortalBundle\Entity\Icon $icon = null)
|
||||
{
|
||||
$this->icon = $icon;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get icon
|
||||
*
|
||||
* @return \Cadoles\PortalBundle\Entity\Icon
|
||||
*/
|
||||
public function getIcon()
|
||||
{
|
||||
return $this->icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add pageidget
|
||||
*
|
||||
* @param \Cadoles\PortalBundle\Entity\Pagewidget $pageidget
|
||||
*
|
||||
* @return Widget
|
||||
*/
|
||||
public function addPageidget(\Cadoles\PortalBundle\Entity\Pagewidget $pageidget)
|
||||
{
|
||||
$this->pageidgets[] = $pageidget;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove pageidget
|
||||
*
|
||||
* @param \Cadoles\PortalBundle\Entity\Pagewidget $pageidget
|
||||
*/
|
||||
public function removePageidget(\Cadoles\PortalBundle\Entity\Pagewidget $pageidget)
|
||||
{
|
||||
$this->pageidgets->removeElement($pageidget);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pageidgets
|
||||
*
|
||||
* @return \Doctrine\Common\Collections\Collection
|
||||
*/
|
||||
public function getPageidgets()
|
||||
{
|
||||
return $this->pageidgets;
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Ivory\CKEditorBundle\Form\Type\CKEditorType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
|
||||
class AlertType extends AbstractType
|
||||
{
|
||||
|
@ -41,6 +42,19 @@ class AlertType extends AbstractType
|
|||
'placeholder' => '-- Sélectionnez une Catégorie --'
|
||||
])
|
||||
|
||||
->add('roles', ChoiceType::class, [
|
||||
"label" => 'Visible pour les Rôles',
|
||||
"choices" => [
|
||||
"Visiteur" => 'ROLE_ANONYME',
|
||||
"Utilisateur" => 'ROLE_USER',
|
||||
"Modérateur" => 'ROLE_MODO',
|
||||
"Administateur" => 'ROLE_ADMIN',
|
||||
],
|
||||
"multiple" => true,
|
||||
"expanded" => true,
|
||||
"disabled" => ($options["mode"]=="delete"?true:false),
|
||||
])
|
||||
|
||||
->add('groups', EntityType::class, [
|
||||
"label" => 'Visible pour les Groupes',
|
||||
"class" => 'CadolesCoreBundle:Group',
|
||||
|
@ -56,7 +70,7 @@ class AlertType extends AbstractType
|
|||
])
|
||||
|
||||
->add('unpublishedat', DateType::class, [
|
||||
'label' => 'jusqu\'au',
|
||||
'label' => 'Jusqu\'au',
|
||||
'input' => 'datetime',
|
||||
'required' => false,
|
||||
'years' => range(date('Y'), date('Y')+10)
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace Cadoles\PortalBundle\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class PageSubmitType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('submit', SubmitType::class, [
|
||||
"label" => ($options["mode"]=="delete"?"Confirmer la Suppression":"Valider"),
|
||||
"attr" => ($options["mode"]=="delete"?array("class" => "btn btn-danger"):array("class" => "btn btn-success"))
|
||||
])
|
||||
|
||||
->add('name', TextType::class, [
|
||||
'label' => 'Nom'
|
||||
])
|
||||
|
||||
->add('roworder', IntegerType::class, [
|
||||
'label' => 'Ordre',
|
||||
])
|
||||
|
||||
->add('pagecategory', EntityType::class, [
|
||||
'label' => 'Catégorie de Page',
|
||||
'class' => 'CadolesPortalBundle:Pagecategory',
|
||||
'choice_label' => 'name',
|
||||
'placeholder' => '-- Sélectionnez une catégorie --'
|
||||
]);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => 'Cadoles\PortalBundle\Entity\Page',
|
||||
'mode' => 'string',
|
||||
'access' => 'string'
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
namespace Cadoles\PortalBundle\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Ivory\CKEditorBundle\Form\Type\CKEditorType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class PageUpdateEditorType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('submit', SubmitType::class, [
|
||||
"label" => ($options["mode"]=="delete"?"Confirmer la Suppression":"Valider"),
|
||||
"attr" => ($options["mode"]=="delete"?array("class" => "btn btn-danger"):array("class" => "btn btn-success"))
|
||||
])
|
||||
|
||||
->add('name', TextType::class, [
|
||||
'label' => 'Nom'
|
||||
])
|
||||
|
||||
->add('roworder', IntegerType::class, [
|
||||
'label' => 'Ordre'
|
||||
])
|
||||
|
||||
->add("html",CKEditorType::class,[
|
||||
"config_name" => 'full_config',
|
||||
"label" => 'Description',
|
||||
"required" => false,
|
||||
"disabled" => ($options["mode"]=="delete"?true:false),
|
||||
"config" => array("height" => "500px")
|
||||
])
|
||||
|
||||
->add('roles', ChoiceType::class, [
|
||||
"label" => 'Visible pour les Rôles',
|
||||
"choices" => [
|
||||
"Visiteur" => 'ROLE_ANONYME',
|
||||
"Utilisateur" => 'ROLE_USER',
|
||||
"Modérateur" => 'ROLE_MODO',
|
||||
"Administateur" => 'ROLE_ADMIN',
|
||||
],
|
||||
"multiple" => true,
|
||||
"expanded" => true,
|
||||
"disabled" => ($options["mode"]=="delete"?true:false),
|
||||
])
|
||||
|
||||
->add('groups', EntityType::class, [
|
||||
'label' => 'Visible pour les Groupes',
|
||||
'class' => 'CadolesCoreBundle:Group',
|
||||
'choice_label' => 'label',
|
||||
'multiple' => true,
|
||||
'expanded' => true
|
||||
]);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => 'Cadoles\PortalBundle\Entity\Page',
|
||||
'mode' => 'string',
|
||||
'access' => 'string'
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
namespace Cadoles\PortalBundle\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class PageUpdateURLType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('submit',SubmitType::class, [
|
||||
"label" => ($options["mode"]=="delete"?"Confirmer la Suppression":"Valider"),
|
||||
"attr" => ($options["mode"]=="delete"?array("class" => "btn btn-danger"):array("class" => "btn btn-success"))
|
||||
])
|
||||
|
||||
->add('name', TextType::class, [
|
||||
'label' => 'Nom'
|
||||
])
|
||||
|
||||
->add('roworder', IntegerType::class, [
|
||||
'label' => 'Ordre',
|
||||
])
|
||||
|
||||
->add('url', TextType::class, [
|
||||
'label' => 'URL'
|
||||
])
|
||||
|
||||
->add('roles', ChoiceType::class, [
|
||||
"label" => 'Visible pour les Rôles',
|
||||
"choices" => [
|
||||
"Visiteur" => 'ROLE_ANONYME',
|
||||
"Utilisateur" => 'ROLE_USER',
|
||||
"Modérateur" => 'ROLE_MODO',
|
||||
"Administateur" => 'ROLE_ADMIN',
|
||||
],
|
||||
"multiple" => true,
|
||||
"expanded" => true,
|
||||
"disabled" => ($options["mode"]=="delete"?true:false),
|
||||
])
|
||||
|
||||
->add('groups', EntityType::class, [
|
||||
'label' => 'Visible pour les Groupes',
|
||||
'class' => 'CadolesCoreBundle:Group',
|
||||
'choice_label' => 'label',
|
||||
'multiple' => true,
|
||||
'expanded' => true
|
||||
]);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => 'Cadoles\PortalBundle\Entity\Page',
|
||||
'access' => 'string',
|
||||
'mode' => 'string'
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
namespace Cadoles\PortalBundle\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class PageUpdateWidgetType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('submit',SubmitType::class, [
|
||||
"label" => ($options["mode"]=="delete"?"Confirmer la Suppression":"Valider"),
|
||||
"attr" => ($options["mode"]=="delete"?array("class" => "btn btn-danger"):array("class" => "btn btn-success"))
|
||||
])
|
||||
|
||||
->add('name', TextType::class, [
|
||||
'label' => 'Nom'
|
||||
])
|
||||
|
||||
->add('roworder', IntegerType::class, [
|
||||
'label' => 'Ordre',
|
||||
])
|
||||
|
||||
->add('template', HiddenType::class, [
|
||||
'label' => 'Template',
|
||||
'required' => false
|
||||
])
|
||||
|
||||
->add('roles', ChoiceType::class, [
|
||||
"label" => 'Visible pour les Rôles',
|
||||
"choices" => [
|
||||
"Visiteur" => 'ROLE_ANONYME',
|
||||
"Utilisateur" => 'ROLE_USER',
|
||||
"Modérateur" => 'ROLE_MODO',
|
||||
"Administateur" => 'ROLE_ADMIN',
|
||||
],
|
||||
"multiple" => true,
|
||||
"expanded" => true,
|
||||
"disabled" => ($options["mode"]=="delete"?true:false),
|
||||
])
|
||||
|
||||
->add('groups', EntityType::class, [
|
||||
'label' => 'Visible pour les Groupes',
|
||||
'class' => 'CadolesCoreBundle:Group',
|
||||
'choice_label' => 'label',
|
||||
'multiple' => true,
|
||||
'expanded' => true
|
||||
]);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => 'Cadoles\PortalBundle\Entity\Page',
|
||||
'access' => 'string',
|
||||
'mode' => 'string'
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,160 @@
|
|||
<?php
|
||||
|
||||
namespace Cadoles\PortalBundle\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FileType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ColorType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
use Trsteel\CkeditorBundle\Form\Type\CkeditorType;
|
||||
|
||||
use Cadoles\PortalBundle\Entity\Itemcategory;
|
||||
|
||||
class PagewidgetType extends AbstractType
|
||||
{
|
||||
public $container;
|
||||
|
||||
public function __construct($container) {
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
// Ajout des champs commun à tout les widgets
|
||||
$builder
|
||||
->add('submit',SubmitType::class, [
|
||||
"label" => ($options["mode"]=="delete"?"Confirmer la Suppression":"Valider"),
|
||||
"attr" => ($options["mode"]=="delete"?array("class" => "btn btn-danger"):array("class" => "btn btn-success"))
|
||||
])
|
||||
|
||||
->add('name', TextType::class, [
|
||||
'label' => 'Nom'
|
||||
])
|
||||
->add('height', IntegerType::class, [
|
||||
'label' => "Hauteur du Widget",
|
||||
])
|
||||
->add('border', ChoiceType::class, [
|
||||
'label' => "Afficher les Bords",
|
||||
'choices' => array("oui" => "1","non" => "0")
|
||||
])
|
||||
->add('autoajust', ChoiceType::class, [
|
||||
'label' => "Ajuster la Hauteur au Contenu",
|
||||
'choices' => array("oui" => "1","non" => "0")
|
||||
])
|
||||
->add('colorheaderback', TextType::class, [
|
||||
'label' => "Couleur de Fond de l'Entête",
|
||||
'required' => false,
|
||||
'attr' => array("class" => "pick-a-color")
|
||||
])
|
||||
->add('colorheaderfont', TextType::class, [
|
||||
'label' => "Couleur du Texte de l'Entête",
|
||||
'required' => false,
|
||||
'attr' => array("class" => "pick-a-color")
|
||||
])
|
||||
->add('colorbodyback', TextType::class, [
|
||||
'label' => "Couleur de Fond du Corps",
|
||||
'required' => false,
|
||||
'attr' => array("class" => "pick-a-color")
|
||||
])
|
||||
->add('colorbodyfont', TextType::class, [
|
||||
'label' => "Couleur du Texte du Corps",
|
||||
'required' => false,
|
||||
'attr' => array("class" => "pick-a-color")
|
||||
])
|
||||
|
||||
->add('idicon', HiddenType::class,['mapped'=> false,'data' => $options["idicon"]]);
|
||||
|
||||
foreach($options["param"]->fields as $field) {
|
||||
if($field->type=="string") {
|
||||
$builder
|
||||
->add($field->id, TextType::class, [
|
||||
'label' => $field->label,
|
||||
'mapped'=> false,
|
||||
'label_attr' => ['loc' => $field->loc],
|
||||
'data' => $field->value,
|
||||
'required' => ($field->mandatory=="true"),
|
||||
]);
|
||||
}
|
||||
|
||||
elseif($field->type=="integer") {
|
||||
$builder
|
||||
->add($field->id, IntegerType::class, [
|
||||
'label' => $field->label,
|
||||
'mapped'=> false,
|
||||
'label_attr' => ['loc' => $field->loc],
|
||||
'data' => $field->value,
|
||||
'required' => ($field->mandatory=="true"),
|
||||
]);
|
||||
}
|
||||
|
||||
elseif($field->type=="desktopmode") {
|
||||
$builder
|
||||
->add($field->id, ChoiceType::class, [
|
||||
'label' => $field->label,
|
||||
'mapped'=> false,
|
||||
'label_attr' => ['loc' => $field->loc],
|
||||
'data' => $field->value,
|
||||
'required' => ($field->mandatory=="true"),
|
||||
'choices' => array("Grand" => "0","Moyen" => "1", "Petit" => "2")
|
||||
]) ;
|
||||
}
|
||||
|
||||
elseif($field->type=="itemcategory") {
|
||||
$id = $field->value;
|
||||
$categorys= $this->container->get('doctrine.orm.entity_manager')->getRepository("CadolesPortalBundle:Itemcategory")->findAll();
|
||||
$choices=array();
|
||||
foreach($categorys as $category) {
|
||||
$choices[$category->getLabel()]=$category->getId();
|
||||
}
|
||||
|
||||
$builder
|
||||
->add($field->id, ChoiceType::class, [
|
||||
'label' => $field->label,
|
||||
'mapped'=> false,
|
||||
'label_attr' => ['loc' => $field->loc],
|
||||
'data' => $id,
|
||||
'required' => ($field->mandatory=="true"),
|
||||
'choices' => $choices,
|
||||
'placeholder' => '-- Sélectionnez une catégorie --',
|
||||
]) ;
|
||||
}
|
||||
|
||||
elseif($field->type=="alertcategory") {
|
||||
$id = $field->value;
|
||||
$categorys= $this->container->get('doctrine.orm.entity_manager')->getRepository("CadolesPortalBundle:Alertcategory")->findAll();
|
||||
$choices=array();
|
||||
foreach($categorys as $category) {
|
||||
$choices[$category->getLabel()]=$category->getId();
|
||||
}
|
||||
|
||||
$builder
|
||||
->add($field->id, ChoiceType::class, [
|
||||
'label' => $field->label,
|
||||
'mapped'=> false,
|
||||
'label_attr' => ['loc' => $field->loc],
|
||||
'data' => $id,
|
||||
'required' => ($field->mandatory=="true"),
|
||||
'choices' => $choices,
|
||||
'placeholder' => '-- Sélectionnez une catégorie --',
|
||||
]) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => 'Cadoles\PortalBundle\Entity\Pagewidget',
|
||||
'param' => 'string',
|
||||
'mode' => 'string',
|
||||
'idicon' => 'string'
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -92,3 +92,105 @@ cadoles_portal_config_alertcategory_delete:
|
|||
defaults: { _controller: CadolesPortalBundle:Alertcategory:delete }
|
||||
|
||||
|
||||
#== Config Page
|
||||
#-- Access config
|
||||
cadoles_portal_config_page:
|
||||
path: /config/page
|
||||
defaults: { _controller: CadolesPortalBundle:Page:list }
|
||||
|
||||
cadoles_portal_config_page_ajax_list:
|
||||
path: /config/page/ajax/list
|
||||
defaults: { _controller: CadolesPortalBundle:Page:ajaxlist, access: config }
|
||||
|
||||
cadoles_portal_config_page_submit:
|
||||
path: /config/page/submit
|
||||
defaults: { _controller: CadolesPortalBundle:Page:submit, access: config }
|
||||
|
||||
cadoles_portal_config_page_update:
|
||||
path: /config/page/update/{id}
|
||||
defaults: { _controller: CadolesPortalBundle:Page:update, access: config }
|
||||
|
||||
cadoles_portal_config_page_delete:
|
||||
path: /config/page/delete/{id}
|
||||
defaults: { _controller: CadolesPortalBundle:Page:delete, access: config }
|
||||
|
||||
cadoles_portal_config_page_view:
|
||||
path: /config/page/view/{id}
|
||||
defaults: { _controller: CadolesPortalBundle:Page:view, access: config }
|
||||
|
||||
#-- Access user
|
||||
cadoles_portal_user_page_submit:
|
||||
path: /user/page/submit
|
||||
defaults: { _controller: CadolesPortalBundle:Page:submit, access: user }
|
||||
|
||||
cadoles_portal_user_page_update:
|
||||
path: /user/page/update/{id}
|
||||
defaults: { _controller: CadolesPortalBundle:Page:update, access: user }
|
||||
|
||||
cadoles_portal_user_page_delete:
|
||||
path: /user/page/delete/{id}
|
||||
defaults: { _controller: CadolesPortalBundle:Page:delete, access: user }
|
||||
|
||||
cadoles_portal_user_page_view:
|
||||
path: /page/view/{id}
|
||||
defaults: { _controller: CadolesPortalBundle:Page:view, access: user }
|
||||
|
||||
|
||||
#== Config Pagewidget
|
||||
#-- Access config
|
||||
cadoles_portal_config_pagewidget_widget_sumbit:
|
||||
path: /config/pagewidget/submit/{idpage}/{idwidgettype}
|
||||
defaults: { _controller: CadolesPortalBundle:Pagewidget:submit, access: config }
|
||||
|
||||
cadoles_portal_config_pagewidget_widget_update:
|
||||
path: /config/pagewidget/update/{idpage}/{idwidget}
|
||||
defaults: { _controller: CadolesPortalBundle:Pagewidget:update, access: config }
|
||||
|
||||
cadoles_portal_config_pagewidget_delete:
|
||||
path: /config/pagewidget/delete
|
||||
defaults: { _controller: CadolesPortalBundle:Pagewidget:delete, access: config }
|
||||
|
||||
cadoles_portal_config_pagewidget_order:
|
||||
path: /config/pagewidget/order
|
||||
defaults: { _controller: CadolesPortalBundle:Pagewidget:order, access: config }
|
||||
|
||||
cadoles_portal_config_panelwidget_view_url:
|
||||
path: /config/pagewidget/view/url/{id}
|
||||
defaults: { _controller: CadolesPortalBundle:Pagewidget:viewurl, access: config }
|
||||
|
||||
cadoles_portal_config_panelwidget_view_item:
|
||||
path: /config/pagewidget/view/item/{id}
|
||||
defaults: { _controller: CadolesPortalBundle:Pagewidget:viewitem, access: config }
|
||||
|
||||
cadoles_portal_config_panelwidget_view_alert:
|
||||
path: /config/pagewidget/view/alert/{id}
|
||||
defaults: { _controller: CadolesPortalBundle:Pagewidget:viewalert, access: config }
|
||||
|
||||
#-- Access user
|
||||
cadoles_portal_user_pagewidget_widget_sumbit:
|
||||
path: /user/pagewidget/submit/{idpage}/{idwidgettype}
|
||||
defaults: { _controller: CadolesPortalBundle:Pagewidget:submit, access: user }
|
||||
|
||||
cadoles_portal_user_pagewidget_widget_update:
|
||||
path: /user/pagewidget/update/{idpage}/{idwidget}
|
||||
defaults: { _controller: CadolesPortalBundle:Pagewidget:update, access: user }
|
||||
|
||||
cadoles_portal_user_pagewidget_delete:
|
||||
path: /user/pagewidget/delete
|
||||
defaults: { _controller: CadolesPortalBundle:Pagewidget:delete, access: user }
|
||||
|
||||
cadoles_portal_user_pagewidget_order:
|
||||
path: /user/pagewidget/order
|
||||
defaults: { _controller: CadolesPortalBundle:Pagewidget:order, access: user }
|
||||
|
||||
cadoles_portal_user_panelwidget_view_url:
|
||||
path: /pagewidget/view/url/{id}
|
||||
defaults: { _controller: CadolesPortalBundle:Pagewidget:viewurl, access: user }
|
||||
|
||||
cadoles_portal_user_panelwidget_view_item:
|
||||
path: /pagewidget/view/item/{id}
|
||||
defaults: { _controller: CadolesPortalBundle:Pagewidget:viewitem, access: user }
|
||||
|
||||
cadoles_portal_user_panelwidget_view_alert:
|
||||
path: /pagewidget/view/alert/{id}
|
||||
defaults: { _controller: CadolesPortalBundle:Pagewidget:viewalert, access: user }
|
|
@ -0,0 +1,5 @@
|
|||
services:
|
||||
Cadoles\PortalBundle\Form\PagewidgetType:
|
||||
arguments: ['@service_container']
|
||||
tags:
|
||||
- { name: form.type }
|
|
@ -54,21 +54,16 @@
|
|||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
{{ form_row(form.publishedat) }}
|
||||
{{ form_row(form.unpublishedat) }}
|
||||
{{ form_row(form.content) }}
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
{{ form_row(form.roles) }}
|
||||
{{ form_row(form.groups) }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{{ form_row(form.publishedat) }}
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
{{ form_row(form.unpublishedat) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{{ form_end(form) }}
|
||||
|
|
|
@ -1,16 +1,5 @@
|
|||
{% extends '@CadolesCore/base.html.twig' %}
|
||||
|
||||
{% block localstyle %}
|
||||
.portalalert {
|
||||
color:#ffffff;
|
||||
}
|
||||
|
||||
.portalalert .panel-heading a{
|
||||
color:#ffffff;
|
||||
font-size: 22px;
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
{% block pagewrapper %}
|
||||
<h1>
|
||||
Gestion des Annonces
|
||||
|
@ -31,12 +20,13 @@
|
|||
alert-list-item
|
||||
portalalert
|
||||
alert-{{ alert.alertcategory.id }}
|
||||
{{ alert.isOnline ? "alert-online" : ""}}
|
||||
{{ alert.isPending ? "alert-pending" : ""}}
|
||||
{{ alert.isArchived ? "alert-archived" : ""}}
|
||||
{{ alert.isOnline ? "alertstatut-online" : ""}}
|
||||
{{ alert.isPending ? "alertstatut-pending" : ""}}
|
||||
{{ alert.isArchived ? "alertstatut-archived" : ""}}
|
||||
{% for group in alert.groups %}{{ ' group-' ~ group.id }}{% endfor %}
|
||||
data-alert-category-id="{{ alert.alertcategory.id }}"
|
||||
data-alert-id="{{ alert.id }}"
|
||||
"
|
||||
data-alert-category-id="{{ alert.alertcategory.id }}"
|
||||
data-alert-id="{{ alert.id }}"
|
||||
style="background: {{ alert.alertcategory.color }};"
|
||||
>
|
||||
<div class="panel-heading" role="tab">
|
||||
|
@ -72,14 +62,14 @@
|
|||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<div id="alert-category-filter" class="list-group">
|
||||
<div id="category-filter" class="list-group">
|
||||
{% for alertcategory in alertcategorys %}
|
||||
<div class="clearfix">
|
||||
<a class="btn btn-primary pull-right" href="{{ path('cadoles_portal_config_alertcategory_update', { id: alertcategory.id }) }}" style="margin:4px">
|
||||
<i class="fa fa-edit"></i>
|
||||
</a>
|
||||
|
||||
<a href="#" class="list-group-item active alert-category-item" data-category="{{ alertcategory.id }}" style="border-left: 15px solid {{ alertcategory.color }}; position: inherit;">
|
||||
<a href="#" class="list-group-item active category-alert-item" data-category="{{ alertcategory.id }}" style="border-left: 15px solid {{ alertcategory.color }}; position: inherit;">
|
||||
<i class="fa fa-fw {{ alertcategory.icon }}"></i>
|
||||
{{ alertcategory.label }}
|
||||
</a>
|
||||
|
@ -96,8 +86,8 @@
|
|||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<div id="role-filter" class="list-group">
|
||||
<a href="#" class="active list-group-item">
|
||||
<div id="group-filter" class="list-group">
|
||||
<a href="#" class="active list-group-item filterfgall">
|
||||
<i class="fa fa-users"></i>
|
||||
Tout les profils
|
||||
<span class="badge">{{ alerts|length }}</span>
|
||||
|
@ -121,8 +111,8 @@
|
|||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<div class="alert-statut-item list-group">
|
||||
<a class="list-group-item active" data-statut="all" href="#">
|
||||
<div id="statut-filter" class="list-group">
|
||||
<a class="list-group-item active filterfgall" data-statut="all" href="#">
|
||||
<i class="fa fa-eye-slash"></i>
|
||||
Toutes
|
||||
</a>
|
||||
|
@ -154,7 +144,6 @@
|
|||
|
||||
function updateItems() {
|
||||
changes = true;
|
||||
console.log("updateItems");
|
||||
$('.alert-list-item:not(.alert-list-item-placeholder').each(function(i) {
|
||||
var itemid = $(this).data('alert-id');
|
||||
$(this).find('input[name="alert_item[rowOrder][]"]').val(i);
|
||||
|
@ -178,55 +167,73 @@
|
|||
update: updateItems
|
||||
});
|
||||
|
||||
$(".alert-category-item").click(function(){
|
||||
var $alerts = $('.mse-alert-'+$(this).data('category'));
|
||||
if($(this).hasClass('active')){
|
||||
$alerts.hide();
|
||||
} else {
|
||||
$alerts.show();
|
||||
}
|
||||
$(this).toggleClass('active');
|
||||
return false;
|
||||
});
|
||||
$("#category-filter a").click(function(){
|
||||
// On réactive les auters filtres à tout
|
||||
$('#group-filter a').removeClass('active');
|
||||
$('#statut-filter a').removeClass('active');
|
||||
$(".filterfgall").addClass('active');
|
||||
$(this).toggleClass('active');
|
||||
|
||||
$(".alert-statut-item a").click(function(){
|
||||
var activeItem = $(".alert-statut-item a.active");
|
||||
var statut = $(this).data('statut');
|
||||
var $alerts = $('[class*="mse-alert-"]:not(.mse-alert-'+$(this).data('statut')+')');
|
||||
var $alertsToShow = $('.mse-alert-'+$(this).data('statut'));
|
||||
$('.category-alert-item').each(function(i) {
|
||||
var $alerts = $('.alert-'+$(this).data('category'));
|
||||
if($(this).hasClass('active')){
|
||||
$alerts.show();
|
||||
} else {
|
||||
$alerts.hide();
|
||||
}
|
||||
});
|
||||
|
||||
if ( activeItem != $(this) ) {
|
||||
activeItem.toggleClass('active');
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if( statut != "all"){
|
||||
if($(this).hasClass('active')){
|
||||
$alerts.hide();
|
||||
} else {
|
||||
$alerts.hide();
|
||||
$alertsToShow.show();
|
||||
}
|
||||
} else {
|
||||
$alerts.show();
|
||||
}
|
||||
$('#group-filter a').click(function(){
|
||||
// On réactive les auters filtres à tout
|
||||
$(".category-alert-item").addClass('active');
|
||||
$('#statut-filter a').removeClass('active');
|
||||
$("#statut-filter .filterfgall").addClass('active');
|
||||
|
||||
// On rend actif la zone cliquée
|
||||
$('#group-filter a').removeClass('active');
|
||||
$(this).addClass('active');
|
||||
|
||||
$(this).toggleClass('active');
|
||||
return false;
|
||||
// On cache l'ensemble des elements
|
||||
$(".portalalert").hide();
|
||||
|
||||
});
|
||||
// On affiche les elements filtrés
|
||||
if($(this).hasClass('filterfgall'))
|
||||
var $alerts = $('.alert-list-item');
|
||||
else
|
||||
var $alerts = $('.group-'+$(this).data('role'));
|
||||
|
||||
$alerts.show();
|
||||
|
||||
$('#role-filter a.list-group-item').click(function(){
|
||||
$('#role-filter a.list-group-item').removeClass('active');
|
||||
$(this).addClass('active');
|
||||
if($(this).data('role')){
|
||||
$('[class*="mse-alert-"]:not([class*="role-'+$(this).data('role')+'"])').hide();
|
||||
$('.role-'+$(this).data('role')).show();
|
||||
} else {
|
||||
$('[class*="mse-alert-"]').show();
|
||||
}
|
||||
return false;
|
||||
});
|
||||
} );
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#statut-filter a").click(function(){
|
||||
// On réactive les auters filtres à tout
|
||||
$(".category-alert-item").addClass('active');
|
||||
$('#group-filter a').removeClass('active');
|
||||
$("#group-filter .filterfgall").addClass('active');
|
||||
|
||||
// On rend actif la zone cliquée
|
||||
$('#statut-filter a').removeClass('active');
|
||||
$(this).addClass('active');
|
||||
|
||||
// On cache l'ensemble des elements
|
||||
$(".portalalert").hide();
|
||||
|
||||
// On affiche les elements filtrés
|
||||
if($(this).hasClass('filterfgall'))
|
||||
var $alerts = $('.alert-list-item');
|
||||
else
|
||||
var $alerts = $('.alertstatut-'+$(this).data('statut'));
|
||||
|
||||
$alerts.show();
|
||||
return false;
|
||||
});
|
||||
|
||||
} );
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends '@CadolesCore/simple.html.twig' %}
|
||||
{% extends '@CadolesCore/base.html.twig' %}
|
||||
|
||||
{% block pagewrapper %}
|
||||
<h3 class="page-header">Téléchargez votre Logo</h3>
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-pencil fa-fw"></i> Informations
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
{% extends '@CadolesCore/base.html.twig' %}
|
||||
|
||||
|
||||
{% block pagewrapper %}
|
||||
<h1>
|
||||
Gestion des Pages
|
||||
</h1>
|
||||
|
||||
<p>
|
||||
<a href="{{ path('cadoles_portal_config_page_submit') }}" class="btn btn-success">Ajouter une Page</a>
|
||||
</p>
|
||||
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-table fa-fw"></i> Liste des Utilisateurs
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<div class="dataTable_wrapper">
|
||||
<table class="table table-striped table-bordered table-hover" id="dataTables" style="width:100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="100px" class="no-sort">Action</th>
|
||||
<th>Ordre</th>
|
||||
<th>Nom</th>
|
||||
<th>Catégorie</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block localjavascript %}
|
||||
$(document).ready(function() {
|
||||
$('#dataTables').DataTable({
|
||||
columnDefs: [ { "targets": 'no-sort', "orderable": false } ],
|
||||
responsive: true,
|
||||
iDisplayLength: 100,
|
||||
order: [[ 1, "asc" ]],
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: "{{ path('cadoles_portal_config_page_ajax_list') }}",
|
||||
drawCallback: function(settings) {
|
||||
$("a[data-method='delete']").click(function(){
|
||||
if( !confirm('Êtes-vous sûr de vouloir supprimer cette page ?')) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1,44 @@
|
|||
{% extends '@CadolesCore/base.html.twig' %}
|
||||
|
||||
{% block pagewrapper %}
|
||||
{{ form_start(form) }}
|
||||
<h1>
|
||||
Nouvelle Page
|
||||
</h1>
|
||||
|
||||
<p>
|
||||
{{ form_widget(form.submit) }}
|
||||
<a class="btn btn-default" href="{{ path('cadoles_portal_'~access~'_page') }}">Annuler</a>
|
||||
</p>
|
||||
|
||||
{% if app.session.flashbag.has('error') %}
|
||||
<div class='alert alert-danger' style='margin: 5px 0px'>
|
||||
<strong>Erreur</strong><br>
|
||||
{% for flashMessage in app.session.flashbag.get('error') %}
|
||||
{{ flashMessage }}<br>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if app.session.flashbag.has('notice') %}
|
||||
<div class='alert alert-info' style='margin: 5px 0px'>
|
||||
<strong>Information</strong><br>
|
||||
{% for flashMessage in app.session.flashbag.get('notice') %}
|
||||
{{ flashMessage }}<br>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-pencil fa-fw"></i> Informations
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
{{ form_row(form.name) }}
|
||||
{{ form_row(form.roworder) }}
|
||||
{{ form_row(form.pagecategory) }}
|
||||
</div>
|
||||
</div>
|
||||
{{ form_end(form) }}
|
||||
{% endblock %}
|
|
@ -0,0 +1,58 @@
|
|||
{% extends '@CadolesCore/base.html.twig' %}
|
||||
|
||||
{% block pagewrapper %}
|
||||
{{ form_start(form) }}
|
||||
<h1 class="page-header">
|
||||
{% if mode=="update" %}
|
||||
Modification Page Editeur
|
||||
{% elseif mode=="submit" %}
|
||||
Création Page Editeur
|
||||
{% endif %}
|
||||
</h1>
|
||||
|
||||
<p>
|
||||
{{ form_widget(form.submit) }}
|
||||
<a class="btn btn-default" href="{{ path('cadoles_portal_'~access~'_page_view',{id:entity.id}) }}">Annuler</a>
|
||||
|
||||
{% if mode=="update" %}
|
||||
<a href={{ path('cadoles_portal_'~access~'_page_delete',{'id':entity.id}) }}
|
||||
class="btn btn-danger pull-right"
|
||||
data-method="delete" data-csrf="_token:{{ 'csrf' }}"
|
||||
data-confirm="Êtes-vous sûr de vouloir supprimer cette page ?">
|
||||
Supprimer
|
||||
</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
|
||||
{% if app.session.flashbag.has('error') %}
|
||||
<div class='alert alert-danger' style='margin: 5px 0px'>
|
||||
<strong>Erreur</strong><br>
|
||||
{% for flashMessage in app.session.flashbag.get('error') %}
|
||||
{{ flashMessage }}<br>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if app.session.flashbag.has('notice') %}
|
||||
<div class='alert alert-info' style='margin: 5px 0px'>
|
||||
<strong>Information</strong><br>
|
||||
{% for flashMessage in app.session.flashbag.get('notice') %}
|
||||
{{ flashMessage }}<br>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="form-group row clearfix">
|
||||
<div class="col-md-8">
|
||||
{{ form_row(form.name) }}
|
||||
{{ form_row(form.roworder) }}
|
||||
{{ form_row(form.html) }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ form_row(form.roles) }}
|
||||
{{ form_row(form.groups) }}
|
||||
</div>
|
||||
</div>
|
||||
{{ form_end(form) }}
|
||||
{% endblock %}
|
|
@ -0,0 +1,58 @@
|
|||
{% extends '@CadolesCore/base.html.twig' %}
|
||||
|
||||
{% block pagewrapper %}
|
||||
{{ form_start(form) }}
|
||||
<h1 class="page-header">
|
||||
{% if mode=="update" %}
|
||||
Modification Page URL
|
||||
{% elseif mode=="submit" %}
|
||||
Création Page URL
|
||||
{% endif %}
|
||||
</h1>
|
||||
|
||||
<p>
|
||||
{{ form_widget(form.submit) }}
|
||||
<a class="btn btn-default" href="{{ path('cadoles_portal_'~access~'_page_view',{id:entity.id}) }}">Annuler</a>
|
||||
|
||||
{% if mode=="update" %}
|
||||
<a href={{ path('cadoles_portal_'~access~'_page_delete',{'id':entity.id}) }}
|
||||
class="btn btn-danger pull-right"
|
||||
data-method="delete" data-csrf="_token:{{ 'csrf' }}"
|
||||
data-confirm="Êtes-vous sûr de vouloir supprimer cette page ?">
|
||||
Supprimer
|
||||
</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
|
||||
{% if app.session.flashbag.has('error') %}
|
||||
<div class='alert alert-danger' style='margin: 5px 0px'>
|
||||
<strong>Erreur</strong><br>
|
||||
{% for flashMessage in app.session.flashbag.get('error') %}
|
||||
{{ flashMessage }}<br>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if app.session.flashbag.has('notice') %}
|
||||
<div class='alert alert-info' style='margin: 5px 0px'>
|
||||
<strong>Information</strong><br>
|
||||
{% for flashMessage in app.session.flashbag.get('notice') %}
|
||||
{{ flashMessage }}<br>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="form-group row clearfix">
|
||||
<div class="col-md-8">
|
||||
{{ form_row(form.name) }}
|
||||
{{ form_row(form.roworder) }}
|
||||
{{ form_row(form.url) }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ form_row(form.roles) }}
|
||||
{{ form_row(form.groups) }}
|
||||
</div>
|
||||
</div>
|
||||
{{ form_end(form) }}
|
||||
{% endblock %}
|
|
@ -0,0 +1,502 @@
|
|||
{% extends '@CadolesCore/base.html.twig' %}
|
||||
|
||||
{% block localstyle %}
|
||||
#gridtemplate {
|
||||
border: 1px solid #cdcdcd;
|
||||
padding:20px;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
#gridtemplate .row {
|
||||
height: 500px;
|
||||
border: 1px solid #cdcdcd;
|
||||
margin: 0px 0px 20px 0px;
|
||||
background-color: #c8f7c5;
|
||||
}
|
||||
|
||||
#gridtemplate .addRow {
|
||||
width: 100%;
|
||||
height: 10%;
|
||||
padding: 2px;
|
||||
max-height: 30px
|
||||
}
|
||||
|
||||
#gridtemplate .delRow {
|
||||
height:100%;
|
||||
width: 5%;
|
||||
background-color: #e74c3c;
|
||||
color: #fff;
|
||||
text-align:center;
|
||||
float: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#gridtemplate .delRow i {
|
||||
position: relative;
|
||||
top: 50%;
|
||||
-webkit-transform: translateY(-50%);
|
||||
-ms-transform: translateY(-50%);
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
|
||||
#gridtemplate .colcontainer {
|
||||
width:90%;
|
||||
height:100%;
|
||||
float:left;
|
||||
padding:15px;
|
||||
}
|
||||
|
||||
#gridtemplate .colcontainer .col {
|
||||
border: 1px solid #cdcdcd;
|
||||
height:100%;
|
||||
padding: 0px;
|
||||
background-color:#fff;
|
||||
}
|
||||
|
||||
#gridtemplate .addCol {
|
||||
height:100%;
|
||||
width: 5%;
|
||||
background-color: #2c3e50;
|
||||
color: #fff;
|
||||
text-align:center;
|
||||
float: right;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#gridtemplate .addCol i {
|
||||
position: relative;
|
||||
top: 50%;
|
||||
-webkit-transform: translateY(-50%);
|
||||
-ms-transform: translateY(-50%);
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
|
||||
#gridtemplate .colcontainer .col .delCol {
|
||||
height:10%;
|
||||
width: 100%;
|
||||
background-color: #e74c3c;
|
||||
color: #fff;
|
||||
text-align:center;
|
||||
float: right;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#gridtemplate .colcontainer .col .delCol i {
|
||||
position: relative;
|
||||
top: 50%;
|
||||
-webkit-transform: translateY(-50%);
|
||||
-ms-transform: translateY(-50%);
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
|
||||
#gridtemplate .colcontainer .col .maxleft {
|
||||
height:80%;
|
||||
width: 5%;
|
||||
background-color: #2c3e50;
|
||||
color: #fff;
|
||||
text-align:center;
|
||||
float: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#gridtemplate .colcontainer .col .maxleft i {
|
||||
position: relative;
|
||||
top: 50%;
|
||||
-webkit-transform: translateY(-50%);
|
||||
-ms-transform: translateY(-50%);
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
|
||||
#gridtemplate .colcontainer .col .maxright {
|
||||
height:80%;
|
||||
width: 5%;
|
||||
background-color: #2c3e50;
|
||||
color: #fff;
|
||||
text-align:center;
|
||||
float: right;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#gridtemplate .colcontainer .col .maxright i {
|
||||
position: relative;
|
||||
top: 50%;
|
||||
-webkit-transform: translateY(-50%);
|
||||
-ms-transform: translateY(-50%);
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
|
||||
#gridtemplate .rowcontainer {
|
||||
float:left;
|
||||
width:90%;
|
||||
height:80%;
|
||||
}
|
||||
|
||||
#gridtemplate .rowcontainer .row {height:50%; margin:0px}
|
||||
#gridtemplate .rowcontainer .maxright, #gridtemplate .rowcontainer .maxleft {height:90% !important; width:20% !important; }
|
||||
#gridtemplate .rowcontainer .rowcontainer {width:60% !important;}
|
||||
#gridtemplate .rowcontainer .addRow {display:none;}
|
||||
#gridtemplate .rowcontainer .colcontainer {padding:5px;}
|
||||
|
||||
{% endblock %}
|
||||
{% block pagewrapper %}
|
||||
{{ form_start(form) }}
|
||||
<h1 class="page-header">
|
||||
{% if mode=="update" %}
|
||||
Modification Page Widget
|
||||
{% elseif mode=="submit" %}
|
||||
Création Page Widget
|
||||
{% endif %}
|
||||
</h1>
|
||||
|
||||
<p>
|
||||
{{ form_widget(form.submit) }}
|
||||
<a class="btn btn-default" href="{{ path('cadoles_portal_'~access~'_page_view',{id:entity.id}) }}">Annuler</a>
|
||||
|
||||
{% if mode=="update" %}
|
||||
<a href={{ path('cadoles_portal_'~access~'_page_delete',{'id':entity.id}) }}
|
||||
class="btn btn-danger pull-right"
|
||||
data-method="delete" data-csrf="_token:{{ 'csrf' }}"
|
||||
data-confirm="Êtes-vous sûr de vouloir supprimer cette page ?">
|
||||
Supprimer
|
||||
</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
|
||||
{% if app.session.flashbag.has('error') %}
|
||||
<div class='alert alert-danger' style='margin: 5px 0px'>
|
||||
<strong>Erreur</strong><br>
|
||||
{% for flashMessage in app.session.flashbag.get('error') %}
|
||||
{{ flashMessage }}<br>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if app.session.flashbag.has('notice') %}
|
||||
<div class='alert alert-info' style='margin: 5px 0px'>
|
||||
<strong>Information</strong><br>
|
||||
{% for flashMessage in app.session.flashbag.get('notice') %}
|
||||
{{ flashMessage }}<br>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="form-group row clearfix">
|
||||
<div class="col-md-8">
|
||||
{{ form_row(form.name) }}
|
||||
{{ form_row(form.roworder) }}
|
||||
{{ form_row(form.template) }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ form_row(form.roles) }}
|
||||
{{ form_row(form.groups) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3>Template de Mise en Page</h3>
|
||||
<div id="gridtemplate" class="row">
|
||||
</div>
|
||||
{{ form_end(form) }}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block localjavascript %}
|
||||
var defcol = [];
|
||||
defcol[1] = ["col-xs-12"];
|
||||
defcol[2] = ["col-xs-6","col-xs-6"];
|
||||
defcol[3] = ["col-xs-4","col-xs-4","col-xs-4"];
|
||||
defcol[4] = ["col-xs-3","col-xs-3","col-xs-3","col-xs-3"];
|
||||
defcol[5] = ["col-xs-4","col-xs-2","col-xs-2","col-xs-2","col-xs-2"];
|
||||
defcol[6] = ["col-xs-2","col-xs-2","col-xs-2","col-xs-2","col-xs-2","col-xs-2"];
|
||||
|
||||
var defaultcol = ""
|
||||
defaultcol+="<div class='delCol'>";
|
||||
defaultcol+="<i class='fa fa-trash'></i>";
|
||||
defaultcol+="</div>";
|
||||
defaultcol+="<div class='maxleft'>";
|
||||
defaultcol+="<i class='fa fa-chevron-left'></i>";
|
||||
defaultcol+="</div>";
|
||||
defaultcol+="<div class='rowcontainer'>";
|
||||
defaultcol+="</div>";
|
||||
defaultcol+="<div class='maxright'>";
|
||||
defaultcol+="<i class='fa fa-chevron-right'></i>";
|
||||
defaultcol+="</div>";
|
||||
defaultcol+="<a class='addRow btn btn-info'>Ajouter une Ligne</a>";
|
||||
|
||||
$('document').ready(function(){
|
||||
// Template de base
|
||||
if($(page_update_widget_template).val()=="") {
|
||||
myrow ="<div class='row'>";
|
||||
myrow+="<div class='delRow'><i class='fa fa-trash'></i></div>";
|
||||
|
||||
myrow+="<div class='colcontainer'>";
|
||||
myrow+="<div class='col col-xs-4'>"+defaultcol+"</div>"
|
||||
myrow+="<div class='col col-xs-4'>"+defaultcol+"</div>"
|
||||
myrow+="<div class='col col-xs-4'>"+defaultcol+"</div>"
|
||||
myrow+="</div>"
|
||||
|
||||
myrow+="<div class='addCol'><i class='fa fa-plus'></i></div>";
|
||||
myrow+="</div>"
|
||||
|
||||
$("#gridtemplate").append(myrow);
|
||||
}
|
||||
// Interprétation du template sauvegardé
|
||||
else {
|
||||
var json = jQuery.parseJSON($(page_update_widget_template).val());
|
||||
var mygrid="";
|
||||
$.each(json.rows, function( index, rownv01 ) {
|
||||
mygrid+="<div class='row'>";
|
||||
mygrid+="<div class='delRow'><i class='fa fa-trash'></i></div>";
|
||||
mygrid+="<div class='colcontainer'>";
|
||||
|
||||
$.each(rownv01.cols, function( index, colnv01 ) {
|
||||
mygrid+="<div class='col col-xs-"+colnv01.size+"'>";
|
||||
mygrid+="<div class='delCol'>";
|
||||
mygrid+="<i class='fa fa-trash'></i>";
|
||||
mygrid+="</div>";
|
||||
mygrid+="<div class='maxleft'>";
|
||||
mygrid+="<i class='fa fa-chevron-left'></i>";
|
||||
mygrid+="</div>";
|
||||
mygrid+="<div class='rowcontainer'>";
|
||||
|
||||
$.each(colnv01.rows, function( index, rownv02 ) {
|
||||
mygrid+="<div class='row'>";
|
||||
mygrid+="<div class='delRow'><i class='fa fa-trash'></i></div>";
|
||||
mygrid+="<div class='colcontainer'>";
|
||||
$.each(rownv02.cols, function( index, colnv02 ) {
|
||||
mygrid+="<div class='col col-xs-"+colnv02.size+"'>"+defaultcol+"</div>";
|
||||
});
|
||||
mygrid+="</div>";
|
||||
mygrid+="<div class='addCol'><i class='fa fa-plus'></i></div>";
|
||||
mygrid+="</div>";
|
||||
});
|
||||
|
||||
mygrid+="</div>";
|
||||
mygrid+="<div class='maxright'>";
|
||||
mygrid+="<i class='fa fa-chevron-right'></i>";
|
||||
mygrid+="</div>";
|
||||
mygrid+="<a class='addRow btn btn-info'>Ajouter une Ligne</a>";
|
||||
mygrid+="</div>";
|
||||
});
|
||||
|
||||
mygrid+="</div>";
|
||||
mygrid+="<div class='addCol'><i class='fa fa-plus'></i></div>";
|
||||
mygrid+="</div>";
|
||||
});
|
||||
|
||||
$("#gridtemplate").append(mygrid);
|
||||
}
|
||||
|
||||
$("#gridtemplate").append("<a class='addRow btn btn-info'>Ajouter une Ligne</a>");
|
||||
|
||||
// Ajout d'une ligne
|
||||
$(document).on('click','.addRow', function(event){
|
||||
lastrow=$(this).parent().children('.row').last();
|
||||
parentid=$(this).parent().attr("id");
|
||||
|
||||
if(parentid=="gridtemplate") {
|
||||
nbrow=$(this).parent().children('.row').length;
|
||||
nbmax=5;
|
||||
}
|
||||
else {
|
||||
nbrow=$(this).parent().children(".rowcontainer").children('.row').length;
|
||||
nbmax=3;
|
||||
}
|
||||
|
||||
nbrow++;
|
||||
if(nbrow==nbmax)
|
||||
alert("Vous ne pouvez pas insérer plus de "+(nbmax-1)+" lignes");
|
||||
else {
|
||||
myrow ="<div class='row'>";
|
||||
myrow+="<div class='delRow'><i class='fa fa-trash'></i></div>";
|
||||
|
||||
myrow+="<div class='colcontainer'>";
|
||||
myrow+="<div class='col col-xs-4'>"+defaultcol+"</div>"
|
||||
myrow+="<div class='col col-xs-4'>"+defaultcol+"</div>"
|
||||
myrow+="<div class='col col-xs-4'>"+defaultcol+"</div>"
|
||||
myrow+="</div>"
|
||||
|
||||
myrow+="<div class='addCol'><i class='fa fa-plus'></i></div>";
|
||||
myrow+="</div>"
|
||||
|
||||
if(lastrow.length)
|
||||
lastrow.after(myrow);
|
||||
else
|
||||
$(this).parent().children(".rowcontainer").append(myrow);
|
||||
}
|
||||
});
|
||||
|
||||
// Suppression d'une ligne
|
||||
$(document).on('click','.delRow', function(event){
|
||||
// On compte le nombre de row de ce niveau et on bloque s'il en reste plus qu'une et que l'on est sur le premier niveau de ligne
|
||||
if($( this ).parent().parent().children(".row").length==1 && $( this ).parent().parent().attr("id")=="gridtemplate")
|
||||
{
|
||||
alert("Votre page doit avoir au minimum une ligne");
|
||||
}
|
||||
// Si ce n'est pas le cas on la supprime
|
||||
else {
|
||||
$( this ).parent().remove();
|
||||
}
|
||||
});
|
||||
|
||||
// Ajout d'une Colonne
|
||||
$(document).on('click','.addCol', function(event){
|
||||
// On récupère la ligne
|
||||
row=$( this ).parent();
|
||||
colcontainer=row.children(".colcontainer");
|
||||
|
||||
// On compte le nombre de colonne
|
||||
nbcol=colcontainer.children(".col").length;
|
||||
nbcol++;
|
||||
if(nbcol>6) {
|
||||
alert("Votre page ne peut avoir plus de 6 colonnes");
|
||||
}
|
||||
else {
|
||||
// Pour chaque colonne on applique la répartition de taille en fonction du nombre de colonne total
|
||||
colcontainer.children('.col').each(function( index ) {
|
||||
$(this).removeClass();
|
||||
$(this).attr("class","col "+defcol[nbcol][index]);
|
||||
});
|
||||
|
||||
// On ajoute une colonne après la derniere colonne de la ligne
|
||||
lastcol=colcontainer.children('.col').last();
|
||||
lastcol.after("<div class='col "+defcol[nbcol][nbcol-1]+"'>"+defaultcol+"</div>");
|
||||
}
|
||||
});
|
||||
|
||||
// Suppression d'une Colonne
|
||||
$(document).on('click','.delCol', function(event){
|
||||
// On récupère la colonne
|
||||
col=$( this ).parent();
|
||||
colcontainer=col.parent();
|
||||
|
||||
// On compte le nombre de colonne
|
||||
nbcol=colcontainer.children(".col").length;
|
||||
nbcol--;
|
||||
if(nbcol<1) {
|
||||
alert("Au minimum 1 colonne");
|
||||
}
|
||||
else {
|
||||
// On détruit la colonne
|
||||
col.remove();
|
||||
|
||||
// Pour chaque colonne on applique la répartition de taille en fonction du nombre de colonne total
|
||||
colcontainer.children('.col').each(function( index ) {
|
||||
$(this).removeClass();
|
||||
$(this).attr("class","col "+defcol[nbcol][index]);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Agrandissement colonne sur la droite
|
||||
$(document).on('click','.maxright', function(event){
|
||||
// On récupère la colonne
|
||||
col=$( this ).parent();
|
||||
colcontainer=col.parent();
|
||||
|
||||
// On recherche la colonne suivante
|
||||
colnext=col.next();
|
||||
if(colnext.length) {
|
||||
// uniquement si taille de la colonne suivant n'est pas col-xs-1
|
||||
if(colnext.attr("class")!="col col-xs-1") {
|
||||
// On récupére la taille de la colonne suivante et en cours
|
||||
taillenext=parseInt(colnext.attr("class").replace("col-xs-","").replace("col ",""));
|
||||
taille=parseInt(col.attr("class").replace("col-xs-","").replace("col ",""));
|
||||
|
||||
// On applique la nouvelle taille à la colonne en cours
|
||||
col.removeClass();
|
||||
col.attr("class","col col-xs-"+(taille+1));
|
||||
|
||||
// On applique la nouvelle taille à la colonne suivante
|
||||
colnext.removeClass();
|
||||
colnext.attr("class","col col-xs-"+(taillenext-1));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Agrandissement colonne sur la gauche
|
||||
$(document).on('click','.maxleft', function(event){
|
||||
// On récupère la colonne
|
||||
col=$( this ).parent();
|
||||
colcontainer=col.parent();
|
||||
|
||||
// On recherche la colonne suivante
|
||||
colprev=col.prev();
|
||||
if(colprev.length) {
|
||||
// uniquement si taille de la colonne précédente n'est pas col-xs-1
|
||||
if(colprev.attr("class")!="col col-xs-1") {
|
||||
// On récupére la taille de la colonne précédente et en cours
|
||||
tailleprev=parseInt(colprev.attr("class").replace("col-xs-","").replace("col ",""));
|
||||
taille=parseInt(col.attr("class").replace("col-xs-","").replace("col ",""));
|
||||
|
||||
// On applique la nouvelle taille à la colonne en cours
|
||||
col.removeClass();
|
||||
col.attr("class","col col-xs-"+(taille+1));
|
||||
|
||||
// On applique la nouvelle taille à la colonne suivante
|
||||
colprev.removeClass();
|
||||
colprev.attr("class","col col-xs-"+(tailleprev-1));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Sur validation formulaire
|
||||
$( "form" ).submit(function( event ) {
|
||||
//event.preventDefault();
|
||||
|
||||
template='{"rows":[';
|
||||
|
||||
// Pour chaque ligne de niveau 01 de la grille
|
||||
nbrownv01=$("#gridtemplate").children('.row').length;
|
||||
$("#gridtemplate").children('.row').each(function( index ) {
|
||||
template+='{';
|
||||
template+='"id":'+index+',';
|
||||
|
||||
// Pour chaque colonne de la ligne de niveau 01
|
||||
nbcolnv01=$(this).children('.colcontainer').children('.col').length;
|
||||
template+='"cols":[';
|
||||
$(this).children('.colcontainer').children('.col').each(function( index ) {
|
||||
template+='{';
|
||||
template+='"id":'+index+',';
|
||||
template+='"size": '+parseInt($(this).attr("class").replace("col-xs-","").replace("col ",""))+',';
|
||||
|
||||
// Pour chaque ligne de niveau 02
|
||||
template+='"rows":[';
|
||||
nbrownv02=$(this).children('.rowcontainer').children('.row').length;
|
||||
$(this).children('.rowcontainer').children('.row').each(function( index ) {
|
||||
template+='{';
|
||||
template+='"id":'+index+',';
|
||||
|
||||
nbcolnv02=$(this).children('.colcontainer').children('.col').length;
|
||||
template+='"cols":[';
|
||||
$(this).children('.colcontainer').children('.col').each(function( index ) {
|
||||
template+='{';
|
||||
template+='"id":'+index+',';
|
||||
template+='"size": '+parseInt($(this).attr("class").replace("col-xs-","").replace("col ",""));
|
||||
template+='}';
|
||||
if(index+1<nbcolnv02) template+=',';
|
||||
});
|
||||
template+=']';
|
||||
template+='}';
|
||||
|
||||
if(index+1<nbrownv02) template+=',';
|
||||
});
|
||||
template+=']';
|
||||
|
||||
|
||||
template+='}';
|
||||
if(index+1<nbcolnv01) template+=',';
|
||||
|
||||
});
|
||||
template+=']';
|
||||
template+='}';
|
||||
if(index+1<nbrownv01) template+=',';
|
||||
});
|
||||
template+=']}';
|
||||
|
||||
$("#page_update_widget_template").val(template);
|
||||
});
|
||||
|
||||
});
|
||||
{% endblock %}
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
{% extends '@CadolesCore/base.html.twig' %}
|
||||
|
||||
{% block pagewrapper %}
|
||||
<div class="pagemenu navbar-default navbar-collapse" role="navigation">
|
||||
<ul class="navpagemenu">
|
||||
{% for page in pages %}
|
||||
{% if page.id==entity.id %}
|
||||
<li class="active"><a href="{{ path('cadoles_portal_'~access~'_page_view', {id:page.id})}}">{{ page.name }}</a></li>
|
||||
{% else %}
|
||||
<li><a href="{{ path('cadoles_portal_'~access~'_page_view', {id:page.id})}}">{{ page.name }}</a></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div style="margin: 30px 0px">
|
||||
{{ entity.html | raw }}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block localjavascript %}
|
||||
$('document').ready(function(){
|
||||
$(".pagemenu").append("<a href='{{ path('cadoles_portal_'~access~'_page_update', {id:entity.id}) }}' title='Modifier le panel'><i class='fa fa-file fa-fw'></i></a>");
|
||||
$(".pagemenu").append("<a href='{{ path('cadoles_portal_'~access~'_page_delete', { id: entity.id }) }}' data-method='delete' data-confirm='Êtes-vous sûr de vouloir supprimer ?' title='Supprimer le panel'><i class='fa fa-trash fa-fw'></i></a>");
|
||||
});
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1,61 @@
|
|||
|
||||
{% extends '@CadolesCore/base.html.twig' %}
|
||||
|
||||
{% block localstyle %}
|
||||
#pageiframe { margin: 0px -30px;}
|
||||
{% endblock %}
|
||||
|
||||
{% block pagewrapper %}
|
||||
<nav>
|
||||
<div class="pagemenu navbar-default navbar-collapse" role="navigation">
|
||||
<ul class="navpagemenu">
|
||||
{% for page in pages %}
|
||||
{% if page.id==entity.id %}
|
||||
<li class="active"><a href="{{ path('cadoles_portal_'~access~'_page_view', {id:page.id})}}">{{ page.name }}</a></li>
|
||||
{% else %}
|
||||
<li><a href="{{ path('cadoles_portal_'~access~'_page_view', {id:page.id})}}">{{ page.name }}</a></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div id="pageiframe">
|
||||
<iframe src="{{entity.url}}" id="frameContent" style="border:none;" width="100%" height="100%"></iframe>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block localjavascript %}
|
||||
$(window).resize(function() {
|
||||
resizeFrame();
|
||||
});
|
||||
|
||||
$('document').ready(function(){
|
||||
$(".pagemenu").append("<a href='{{ path('cadoles_portal_'~access~'_page_update', {id:entity.id}) }}' title='Modifier le panel'><i class='fa fa-file fa-fw'></i></a>");
|
||||
$(".pagemenu").append("<a href='{{ path('cadoles_portal_'~access~'_page_delete', { id: entity.id }) }}' data-method='delete' data-confirm='Êtes-vous sûr de vouloir supprimer ?' title='Supprimer le panel'><i class='fa fa-trash fa-fw'></i></a>");
|
||||
|
||||
resizeFrame();
|
||||
});
|
||||
|
||||
function resizeFrame() {
|
||||
$("body").css("overflow-y","hidden");
|
||||
$(".col-md-10").css("padding","0");
|
||||
|
||||
var iFrame = document.getElementById('frameContent');
|
||||
|
||||
var heightbody = $('html').height();
|
||||
var heightheader = $('.header').height();
|
||||
if($('.pagemenu').css("display")=="none")
|
||||
var heightmenu = 0;
|
||||
else
|
||||
var heightmenu = $('.pagemenu').height();
|
||||
|
||||
|
||||
var heightframe = heightbody-heightheader-heightmenu;
|
||||
|
||||
if($("#frameContent").length>0) {
|
||||
$("#frameContent").height(heightframe);
|
||||
}
|
||||
|
||||
}
|
||||
{% endblock %}
|
|
@ -0,0 +1,324 @@
|
|||
|
||||
{% extends '@CadolesCore/base.html.twig' %}
|
||||
|
||||
|
||||
{% block pagewrapper %}
|
||||
<nav>
|
||||
<div class="pagemenu navbar-default navbar-collapse" role="navigation">
|
||||
<ul class="navpagemenu">
|
||||
{% for page in pages %}
|
||||
{% if page.id==entity.id %}
|
||||
<li class="active"><a href="{{ path('cadoles_portal_'~access~'_page_view', {id:page.id})}}">{{ page.name }}</a></li>
|
||||
{% else %}
|
||||
<li><a href="{{ path('cadoles_portal_'~access~'_page_view', {id:page.id})}}">{{ page.name }}</a></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div id="gridtemplate" style="margin-bottom:30px">
|
||||
|
||||
</div>
|
||||
|
||||
<div id="tolocalize" style="display:none">
|
||||
{% for pagewidget in entity.pagewidgets %}
|
||||
{{ render(url(pagewidget.widget.routeview|replace({'_config_':'_'~access~'_'}),{id:pagewidget.id})) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<div id="selwidget" class="modal fade bs-item-modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title">SELECTIONNER UN WIDGET</h4>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<div class="form-group row clearfix">
|
||||
<div class="col-md-12" style="margin-bottom:15px">
|
||||
<a onclick="$('#selwidget').modal('hide');" class="btn btn-default">
|
||||
Annuler
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="dataTable_wrapper col-md-12">
|
||||
<table id="dataTables" class="table table-bordered table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="100px">#</th>
|
||||
<th>Nom</th>
|
||||
<th class="no-sort">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{% for widget in widgets %}
|
||||
<tr>
|
||||
<td>
|
||||
<a onClick="selWidget({{ widget.id }})" style="cursor:pointer;">
|
||||
<img id="widgettype-{{ widget.id }}" class="grid-item-img" height="40" src="/{{ alias }}/{{ widget.icon.label }}" style="padding:2px">
|
||||
</a>
|
||||
</td>
|
||||
<td>{{ widget.name }}</td>
|
||||
<td>{{ widget.description }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block localjavascript %}
|
||||
$('document').ready(function(){
|
||||
// Ajustement des frames
|
||||
$(window).resize(function() {
|
||||
AjustFrame();
|
||||
});
|
||||
|
||||
// Initialisation du tableau des widgets selectionnable à la création
|
||||
$('#dataTables').DataTable({
|
||||
columnDefs: [ { "targets": 'no-sort', "orderable": false }, { "targets": 0, "className": "text-center" } ],
|
||||
responsive: true,
|
||||
iDisplayLength: 10,
|
||||
order: [[ 1, "asc" ]],
|
||||
});
|
||||
|
||||
// Création du menu
|
||||
$(".pagemenu").append("<a href='{{ path('cadoles_portal_'~access~'_page_update', {id:entity.id}) }}' title='Modifier le panel'><i class='fa fa-file fa-fw'></i></a>");
|
||||
$(".pagemenu").append("<a href='{{ path('cadoles_portal_'~access~'_page_delete', { id: entity.id }) }}' data-method='delete' data-confirm='Êtes-vous sûr de vouloir supprimer ?' title='Supprimer le panel'><i class='fa fa-trash fa-fw'></i></a>");
|
||||
$(".pagemenu").append("<a href='' style='cursor:pointer' data-toggle='modal' data-target='#selwidget' title='Ajouter un widget'><i class='fa fa-cubes fa-fw'></i></a>");
|
||||
|
||||
// Création de la grille des widgets
|
||||
var template = '{{ entity.template | raw }}';
|
||||
|
||||
// Template de base
|
||||
if(template=="") {
|
||||
myrow ="<div class='row'>";
|
||||
myrow+="<div class='colcontainer'>";
|
||||
myrow+="<div id='R1C1' class='col col-md-4'></div>"
|
||||
myrow+="<div id='R1C2' class='col col-md-4'></div>"
|
||||
myrow+="<div id='R1C3' class='col col-md-4'></div>"
|
||||
myrow+="</div>"
|
||||
|
||||
$("#gridtemplate").append(myrow);
|
||||
}
|
||||
// Interprétation du template sauvegardé
|
||||
else {
|
||||
var json = jQuery.parseJSON(template);
|
||||
var mygrid="";
|
||||
var row01=0;
|
||||
|
||||
$.each(json.rows, function( index, rownv01 ) {
|
||||
row01++;
|
||||
col01=0;
|
||||
mygrid+="<div class='row'>";
|
||||
mygrid+="<div class='colcontainer'>";
|
||||
|
||||
$.each(rownv01.cols, function( index, colnv01 ) {
|
||||
col01++;
|
||||
var row02=0;
|
||||
|
||||
mygrid+="<div id='R"+row01+"C"+col01+"' class='col col-md-"+colnv01.size+"'>";
|
||||
mygrid+="<div class='rowcontainer'>";
|
||||
|
||||
$.each(colnv01.rows, function( index, rownv02 ) {
|
||||
row02++;
|
||||
col02=0;
|
||||
|
||||
mygrid+="<div class='row'>";
|
||||
mygrid+="<div class='colcontainer'>";
|
||||
$.each(rownv02.cols, function( index, colnv02 ) {
|
||||
col02++;
|
||||
mygrid+="<div id='R"+row01+"C"+col01+"R"+row02+"C"+col02+"' class='col col-md-"+colnv02.size+"'></div>";
|
||||
});
|
||||
mygrid+="</div>";
|
||||
mygrid+="</div>";
|
||||
});
|
||||
|
||||
mygrid+="</div>";
|
||||
mygrid+="</div>";
|
||||
});
|
||||
|
||||
mygrid+="</div>";
|
||||
mygrid+="</div>";
|
||||
});
|
||||
|
||||
$("#gridtemplate").append(mygrid);
|
||||
}
|
||||
|
||||
// On déplace les widgets à leur emplacement
|
||||
$("#tolocalize").children(".widget").each(function( element ) {
|
||||
if($('#'+$(this).attr("loc")).length)
|
||||
$(this).appendTo('#'+$(this).attr("loc"));
|
||||
else
|
||||
$(this).appendTo('#R1C1');
|
||||
});
|
||||
|
||||
// On ajoute un widget vide à chaque colonne
|
||||
$("#gridtemplate .col").each(function(element) {
|
||||
$("<div class='widgetempty'> </div>").appendTo($(this));
|
||||
});
|
||||
|
||||
// Mettre une taille mini de colonne sinon on ne pourra pas déplacer le widget dans la colonne
|
||||
//$(".widgetbody").hide();
|
||||
$(".colcontainer .col").css("min-height","100px");
|
||||
$("#gridtemplate .col").sortable({
|
||||
connectWith: "#gridtemplate .col",
|
||||
handle: '.widgetheader',
|
||||
placeholder: "widget widgetplacehorder",
|
||||
tolerance: "pointer",
|
||||
cursor: "move",
|
||||
opacity: 0.6,
|
||||
start: function( event, ui ) {
|
||||
ui.placeholder.css("height",ui.item.height());
|
||||
$(".widgetbody").hide();
|
||||
$(".colcontainer .col").css("border","1px solid #cdcdcd");
|
||||
$(".colcontainer .col").css("padding-bottom","15px");
|
||||
},
|
||||
stop: function( event, ui ) {
|
||||
$(".widgetbody").show();
|
||||
$(".colcontainer .col").css("border","none");
|
||||
$(".colcontainer .col").css("padding-bottom","none");
|
||||
|
||||
// Création des grilles d'items
|
||||
var optiongrid={columnWidth: '.grid-sizer',itemSelector: '.grid-item'};
|
||||
var grid = $('.grid').masonry(optiongrid);
|
||||
},
|
||||
update: updateLocalisation
|
||||
|
||||
});
|
||||
|
||||
// Création des grilles d'items
|
||||
var optiongrid={columnWidth: '.grid-sizer',itemSelector: '.grid-item'};
|
||||
var grid = $('.grid').masonry(optiongrid);
|
||||
|
||||
// Preview item
|
||||
$( ".grid .item-preview" ).click(function() {
|
||||
if($(this).parent().children(".grid-item-body").css('display') == 'none') {
|
||||
$(this).html('<i style="color: #FFF" class="fa fa-minus" title="Informations sur ce service"></i>');
|
||||
heightbody=$(this).parent().children(".grid-item-body").height()+30;
|
||||
heightitem=$(this).parent().parent().height();
|
||||
|
||||
|
||||
$(this).parent().children(".grid-item-body").show();
|
||||
$(this).parent().parent().css("width","100%");
|
||||
|
||||
$(this).parent().parent().css("height",heightitem+heightbody);
|
||||
$(this).parent().children(".grid-item-content").css("height",heightitem+heightbody);
|
||||
$(this).parent().children(".item-preview").css("height",heightitem+heightbody);
|
||||
|
||||
var grid = $('.grid').masonry(optiongrid);
|
||||
}
|
||||
else {
|
||||
$(this).html('<i style="color: #FFF" class="fa fa-plus" title="Informations sur ce service"></i>');
|
||||
|
||||
$(this).parent().children(".grid-item-body").hide();
|
||||
$(this).parent().parent().css("width","");
|
||||
$(this).parent().parent().css("height","");
|
||||
$(this).parent().children(".grid-item-content").css("height","");
|
||||
$(this).parent().children(".item-preview").css("height","");
|
||||
|
||||
var grid = $('.grid').masonry(optiongrid);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// Modification de la localisation d'un widget
|
||||
function updateLocalisation() {
|
||||
$('.colcontainer .col').each(function(index) {
|
||||
var idloc=$(this).attr('id');
|
||||
$(this).children(".widget").each(function(order){
|
||||
var idwidget=$(this).attr('dataid');
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "{{ path('cadoles_portal_'~access~'_pagewidget_order') }}",
|
||||
data: {
|
||||
idwidget:idwidget,
|
||||
order:order,
|
||||
idloc:idloc
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Création d'un widget selectionné
|
||||
function selWidget(idwidgettype) {
|
||||
var url="{{ path('cadoles_portal_'~access~'_pagewidget_widget_sumbit',{idpage:entity.id,idwidgettype:'xx'})}}";
|
||||
url=url.replace('xx',idwidgettype);
|
||||
|
||||
$(location).attr('href', url);
|
||||
};
|
||||
|
||||
// Modifciation d'un widget
|
||||
function modWidget(idwidget) {
|
||||
$('#modwidget').modal('show');
|
||||
|
||||
var url="{{ path('cadoles_portal_'~access~'_pagewidget_widget_update',{idpage:entity.id,idwidget:'xx'})}}";
|
||||
|
||||
url=url.replace('xx',idwidget);
|
||||
$(location).attr('href', url);
|
||||
}
|
||||
|
||||
// Suppression d'un widget
|
||||
function delWidget(idwidget) {
|
||||
var txt;
|
||||
var r = confirm("Confirmez-vous la suppression de ce widget ?");
|
||||
if (r == true) {
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "{{ path('cadoles_portal_'~access~'_pagewidget_delete') }}",
|
||||
data: {
|
||||
idwidget:idwidget
|
||||
}
|
||||
});
|
||||
|
||||
$(".widget[dataid="+idwidget+"]").remove();
|
||||
}
|
||||
}
|
||||
|
||||
// Ajustement des frames
|
||||
function AjustFrame() {
|
||||
$('.frameajust').iframeAutoHeight({
|
||||
minHeight: 500, // Sets the iframe height to this value if the calculated value is less
|
||||
heightOffset: 0, // Optionally add some buffer to the bottom
|
||||
callback: function(callbackObject) { $(this).parent().css("height",callbackObject.newFrameHeight) ;}
|
||||
});
|
||||
|
||||
if($(".frameitem").length>0) {
|
||||
var heightbody = $('html').height();
|
||||
var heightheader = $('.header').height();
|
||||
if($('.pagemenu').css("display")=="none")
|
||||
var heightmenu = 0;
|
||||
else
|
||||
var heightmenu = $('.pagemenu').height();
|
||||
|
||||
var heightframe = heightbody-heightheader-heightmenu;
|
||||
|
||||
$(".frameitem").height(heightframe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Affichage des frames associés aux items de bureau
|
||||
function showFrameitem(id,url) {
|
||||
$("#gridtemplate").hide();
|
||||
$("body").css("overflow-y","hidden");
|
||||
|
||||
if($("#frameitem-"+id).length) {
|
||||
$("#frameitem-"+id).show();
|
||||
}
|
||||
else {
|
||||
$(".pagemenu").after("<iframe id='frameitem-"+id+"' class='frameitem' src='"+url+"'></iframe>");
|
||||
}
|
||||
}
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1,209 @@
|
|||
{% macro mystylewidget(entity) %}
|
||||
{% set color = app.session.get('color') %}
|
||||
|
||||
{% set colorheaderback = entity.colorheaderback %}
|
||||
{% if colorheaderback is null %}
|
||||
{% set colorheaderback = color['main'] %}
|
||||
{% endif %}
|
||||
|
||||
{% set colorheaderfont = entity.colorheaderfont %}
|
||||
{% if colorheaderfont is null %}
|
||||
{% set colorheaderfont = color['fontcolorhover'] %}
|
||||
{% endif %}
|
||||
|
||||
{% set colorbodyback = entity.colorbodyback %}
|
||||
{% if colorbodyback is null %}
|
||||
{% set colorbodyback = color['main'] %}
|
||||
{% endif %}
|
||||
|
||||
{% set colorbodyfont = entity.colorbodyfont %}
|
||||
{% if colorbodyfont is null %}
|
||||
{% set colorbodyfont = color['fontcolorhover'] %}
|
||||
{% endif %}
|
||||
|
||||
{% set stylewidget = "" %}
|
||||
{% if not entity.autoajust %}
|
||||
{% set stylewidget = stylewidget ~ "height: " ~ entity.height ~ "px; " %}
|
||||
{% endif %}
|
||||
|
||||
{% if entity.border %}
|
||||
{% set stylewidget = stylewidget ~ "border:1px solid #" ~ colorheaderback ~ "; " %}
|
||||
{% endif %}
|
||||
|
||||
{{ stylewidget }}
|
||||
{% endmacro %}`
|
||||
|
||||
|
||||
{% macro mystylewidgetmenu(entity) %}
|
||||
{% set color = app.session.get('color') %}
|
||||
|
||||
{% set colorheaderback = entity.colorheaderback %}
|
||||
{% if colorheaderback is null %}
|
||||
{% set colorheaderback = color['main'] %}
|
||||
{% endif %}
|
||||
|
||||
{% set colorheaderfont = entity.colorheaderfont %}
|
||||
{% if colorheaderfont is null %}
|
||||
{% set colorheaderfont = color['fontcolorhover'] %}
|
||||
{% endif %}
|
||||
|
||||
{% set colorbodyback = entity.colorbodyback %}
|
||||
{% if colorbodyback is null %}
|
||||
{% set colorbodyback = color['main'] %}
|
||||
{% endif %}
|
||||
|
||||
{% set colorbodyfont = entity.colorbodyfont %}
|
||||
{% if colorbodyfont is null %}
|
||||
{% set colorbodyfont = color['fontcolorhover'] %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% set stylewidgetmenu = "" %}
|
||||
{% set stylewidgetmenu = stylewidgetmenu ~ "color: #" ~ colorheaderfont ~ "; " %}
|
||||
{% set stylewidgetmenu = stylewidgetmenu ~ "cursor: pointer; " %}
|
||||
|
||||
{{ stylewidgetmenu }}
|
||||
{% endmacro %}`
|
||||
|
||||
|
||||
|
||||
{% macro mystylewidgetheader(entity) %}
|
||||
{% set color = app.session.get('color') %}
|
||||
|
||||
{% set colorheaderback = entity.colorheaderback %}
|
||||
{% if colorheaderback is null %}
|
||||
{% set colorheaderback = color['main'] %}
|
||||
{% endif %}
|
||||
|
||||
{% set colorheaderfont = entity.colorheaderfont %}
|
||||
{% if colorheaderfont is null %}
|
||||
{% set colorheaderfont = color['fontcolorhover'] %}
|
||||
{% endif %}
|
||||
|
||||
{% set colorbodyback = entity.colorbodyback %}
|
||||
{% if colorbodyback is null %}
|
||||
{% set colorbodyback = color['main'] %}
|
||||
{% endif %}
|
||||
|
||||
{% set colorbodyfont = entity.colorbodyfont %}
|
||||
{% if colorbodyfont is null %}
|
||||
{% set colorbodyfont = color['fontcolorhover'] %}
|
||||
{% endif %}
|
||||
|
||||
{% set stylewidgetheader = "" %}
|
||||
{% set stylewidgetheader = stylewidgetheader ~ "background-color: #" ~ colorheaderback ~ "; " %}
|
||||
{% set stylewidgetheader = stylewidgetheader ~ "color: #" ~ colorheaderfont ~ "; " %}
|
||||
|
||||
{{ stylewidgetheader }}
|
||||
{% endmacro %}`
|
||||
|
||||
|
||||
|
||||
|
||||
{% macro mystylewidgetbody(entity) %}
|
||||
{% set color = app.session.get('color') %}
|
||||
|
||||
{% set colorheaderback = entity.colorheaderback %}
|
||||
{% if colorheaderback is null %}
|
||||
{% set colorheaderback = color['main'] %}
|
||||
{% endif %}
|
||||
|
||||
{% set colorheaderfont = entity.colorheaderfont %}
|
||||
{% if colorheaderfont is null %}
|
||||
{% set colorheaderfont = color['fontcolorhover'] %}
|
||||
{% endif %}
|
||||
|
||||
{% set colorbodyback = entity.colorbodyback %}
|
||||
{% if colorbodyback is null %}
|
||||
{% set colorbodyback = color['main'] %}
|
||||
{% endif %}
|
||||
|
||||
{% set colorbodyfont = entity.colorbodyfont %}
|
||||
{% if colorbodyfont is null %}
|
||||
{% set colorbodyfont = color['fontcolorhover'] %}
|
||||
{% endif %}
|
||||
|
||||
{% set stylewidgetbody = "" %}
|
||||
{% set stylewidgetbody = stylewidgetbody ~ "background-color: #" ~ colorbodyback ~ "; " %}
|
||||
{% set stylewidgetbody = stylewidgetbody ~ "color: #" ~ colorbodyfont ~ "; " %}
|
||||
{% if not entity.autoajust %}
|
||||
{% set stylewidgetbody = stylewidgetbody ~ "height: " ~ (entity.height-50-2) ~ "px; overflow-y: auto" %}
|
||||
{% endif %}
|
||||
|
||||
{{ stylewidgetbody }}
|
||||
|
||||
{% endmacro %}`
|
||||
|
||||
|
||||
|
||||
|
||||
{% macro mystylewidgetbodyframe(entity) %}
|
||||
{% set color = app.session.get('color') %}
|
||||
|
||||
{% set colorheaderback = entity.colorheaderback %}
|
||||
{% if colorheaderback is null %}
|
||||
{% set colorheaderback = color['main'] %}
|
||||
{% endif %}
|
||||
|
||||
{% set colorheaderfont = entity.colorheaderfont %}
|
||||
{% if colorheaderfont is null %}
|
||||
{% set colorheaderfont = color['fontcolorhover'] %}
|
||||
{% endif %}
|
||||
|
||||
{% set colorbodyback = entity.colorbodyback %}
|
||||
{% if colorbodyback is null %}
|
||||
{% set colorbodyback = color['main'] %}
|
||||
{% endif %}
|
||||
|
||||
{% set colorbodyfont = entity.colorbodyfont %}
|
||||
{% if colorbodyfont is null %}
|
||||
{% set colorbodyfont = color['fontcolorhover'] %}
|
||||
{% endif %}
|
||||
|
||||
{% set stylewidgetbodyframe = "" %}
|
||||
{% set stylewidgetbodyframe = stylewidgetbodyframe ~ "background-color: #" ~ colorbodyback ~ "; " %}
|
||||
{% set stylewidgetbodyframe = stylewidgetbodyframe ~ "color: #" ~ colorbodyfont ~ "; " %}
|
||||
{% if not entity.autoajust %}
|
||||
{% set stylewidgetbodyframe = stylewidgetbodyframe ~ "height: " ~ (entity.height-50-2) ~ "px;" %}
|
||||
{% endif %}
|
||||
|
||||
{{ stylewidgetbodyframe }}
|
||||
|
||||
{% endmacro %}`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{% macro mystylewidgetbodyimage(entity) %}
|
||||
{% set color = app.session.get('color') %}
|
||||
|
||||
{% set colorheaderback = entity.colorheaderback %}
|
||||
{% if colorheaderback is null %}
|
||||
{% set colorheaderback = color['main'] %}
|
||||
{% endif %}
|
||||
|
||||
{% set colorheaderfont = entity.colorheaderfont %}
|
||||
{% if colorheaderfont is null %}
|
||||
{% set colorheaderfont = color['fontcolorhover'] %}
|
||||
{% endif %}
|
||||
|
||||
{% set colorbodyback = entity.colorbodyback %}
|
||||
{% if colorbodyback is null %}
|
||||
{% set colorbodyback = color['main'] %}
|
||||
{% endif %}
|
||||
|
||||
{% set colorbodyfont = entity.colorbodyfont %}
|
||||
{% if colorbodyfont is null %}
|
||||
{% set colorbodyfont = color['fontcolorhover'] %}
|
||||
{% endif %}
|
||||
|
||||
{% set stylewidgetbodyimage = "" %}
|
||||
{% set stylewidgetbodyimage = stylewidgetbodyimage ~ "background-color: #" ~ colorbodyback ~ "; " %}
|
||||
{% set stylewidgetbodyimage = stylewidgetbodyimage ~ "color: #" ~ colorbodyfont ~ "; " %}
|
||||
{% if not entity.autoajust %}
|
||||
{% set stylewidgetbodyimage = stylewidgetbodyimage ~ "height: " ~ (entity.height-2) ~ "px; " %}
|
||||
{% endif %}
|
||||
|
||||
{{ stylewidgetbodyimage }}
|
||||
{% endmacro %}`
|
|
@ -0,0 +1,141 @@
|
|||
{% extends '@CadolesCore/base.html.twig' %}
|
||||
|
||||
{% block pagewrapper %}
|
||||
{{ form_start(form) }}
|
||||
<h1 class="page-header">
|
||||
{% if mode=="update" %}
|
||||
Modification Widget
|
||||
{% elseif mode=="submit" %}
|
||||
Création Widget
|
||||
{% endif %}
|
||||
</h1>
|
||||
|
||||
<p>
|
||||
{{ form_widget(form.submit) }}
|
||||
<a class="btn btn-default" href={{ path('cadoles_portal_config_page_view'|replace({'_config_':'_'~access~'_'}),{'id':idpage}) }}>Annuler</a>
|
||||
|
||||
</p>
|
||||
|
||||
{% if app.session.flashbag.has('error') %}
|
||||
<div class='alert alert-danger' style='margin: 5px 0px'>
|
||||
<strong>Erreur</strong><br>
|
||||
{% for flashMessage in app.session.flashbag.get('error') %}
|
||||
{{ flashMessage }}<br>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if app.session.flashbag.has('notice') %}
|
||||
<div class='alert alert-info' style='margin: 5px 0px'>
|
||||
<strong>Information</strong><br>
|
||||
{% for flashMessage in app.session.flashbag.get('notice') %}
|
||||
{{ flashMessage }}<br>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="row" style="margin:0px 0px 15px 0px">
|
||||
<div id="col1" class="col-xs-8">
|
||||
{{ form_row(form.name) }}
|
||||
</div>
|
||||
|
||||
<div class="col-xs-4">
|
||||
<div id="diviconsel" class="col-md-12 text-left" style="height:140px; padding:20px; text-align:center; background-color: {{ entity.colorheaderback ? entity.colorheaderback : '#000000' }};">
|
||||
{% if entity.icon %}
|
||||
<img src="/{{ alias }}/{{ entity.icon.label }}" height="100" />
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="col-md-12" style="text-align:center;padding:0px">
|
||||
{{ form_row(form.idicon) }}
|
||||
<a class="btn btn-success" data-toggle="modal" data-target="#selicon" title='Ajouter' style="width:100%">Selectionner un Icône</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="col2" class="col-xs-4">
|
||||
{{ form_row(form.height) }}
|
||||
{{ form_row(form.autoajust) }}
|
||||
{{ form_row(form.border) }}
|
||||
</div>
|
||||
|
||||
<div id="col3" class="col-xs-4">
|
||||
{{ form_row(form.colorheaderback) }}
|
||||
{{ form_row(form.colorheaderfont) }}
|
||||
{{ form_row(form.colorbodyback) }}
|
||||
{{ form_row(form.colorbodyfont) }}
|
||||
</div>
|
||||
|
||||
<div id="col4" class="col-xs-4">
|
||||
|
||||
</div>
|
||||
|
||||
<div id="col5" class="col-md-12" style="clear:both">
|
||||
{{ form_widget(form) }}
|
||||
</div>
|
||||
|
||||
<div id="selicon" class="modal fade bs-item-modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title">SELECTIONNER UN ICONE</h4>
|
||||
</div>
|
||||
|
||||
<div class="modal-body" style="height: 480px; overflow-y: scroll;">
|
||||
<div class="form-group row clearfix">
|
||||
<div class="col-md-12" style="margin-bottom:15px">
|
||||
<a onclick="$('#selicon').modal('hide');" class="btn btn-info">
|
||||
<i class="fa fa-chevron-left"></i>
|
||||
Annuler
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12">
|
||||
{% for icon in icons %}
|
||||
<a href="#" onClick="selIcon({{ icon.id }})">
|
||||
<img id="icon-{{ icon.id }}" class="grid-item-img" height="40" src="/{{ alias }}/{{ icon.label }}" style="padding:2px">
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{ form_end(form) }}
|
||||
{% endblock %}
|
||||
|
||||
{% block localjavascript %}
|
||||
|
||||
$(document).ready(function() {
|
||||
$(".control-label").each(function( element ) {
|
||||
var loc = $(this).attr('loc');
|
||||
if (typeof loc !== typeof undefined && loc !== false) {
|
||||
$(this).parent().appendTo("#"+loc);
|
||||
}
|
||||
});
|
||||
|
||||
$("#col2").children(".form-group").each(function( element ) {
|
||||
$(this).css("zoom","80%");
|
||||
});
|
||||
|
||||
$("#col3").children(".form-group").each(function( element ) {
|
||||
$(this).css("zoom","80%");
|
||||
});
|
||||
|
||||
$("#col4").children(".form-group").each(function( element ) {
|
||||
$(this).css("zoom","80%");
|
||||
});
|
||||
});
|
||||
|
||||
function selIcon(idicon) {
|
||||
$("#pagewidget_idicon").val(idicon);
|
||||
$("#diviconsel img").remove();
|
||||
|
||||
$("#icon-"+idicon).clone().appendTo($("#diviconsel"));
|
||||
$("#diviconsel img").attr("height","100px");
|
||||
$('#selicon').modal('hide');
|
||||
}
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1,41 @@
|
|||
{% import "@CadolesPortal/Pagewidget/constants.twig" as constants %}
|
||||
|
||||
{% set stylewidget = constants.mystylewidget(entity) %}
|
||||
{% set stylewidgetmenu = constants.mystylewidgetmenu(entity) %}
|
||||
{% set stylewidgetheader = constants.mystylewidgetheader(entity) %}
|
||||
{% set stylewidgetbody = constants.mystylewidgetbody(entity) %}
|
||||
|
||||
|
||||
|
||||
<div class="widget" dataid="{{ entity.id }}" loc="{{ entity.loc }}" style="{{ stylewidget }}" height="{{ entity.height }}px">
|
||||
<div class="widgetmenu">
|
||||
<i class="fa fa-trash fa-fw" onClick="delWidget({{ entity.id }})" style="{{ stylewidgetmenu }}"></i>
|
||||
<i class="fa fa-file fa-fw" onClick="modWidget({{ entity.id }})" style="{{ stylewidgetmenu }}"></i>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="widgetheader" style="{{ stylewidgetheader }}">
|
||||
<img src="/{{ alias }}/{{ entity.icon.label }}" height="40" width="40" style="cursor: move; border-radius: 100%; margin-top:-5px; margin-right:10px; "/>
|
||||
{{ entity.name }}
|
||||
</div>
|
||||
|
||||
<div class="widgetbody" style="{{ stylewidgetbody }}">
|
||||
{% for alert in alerts %}
|
||||
<div class="panel portalalert alert-list-item" style="background: {{ alert.alertcategory.color }};">
|
||||
<div class="panel-heading" role="tab">
|
||||
<i class="fa fa-fw {{ alert.alertcategory.icon }}"></i>
|
||||
{{ alert.title }}
|
||||
</div>
|
||||
|
||||
<div id="alert-{{ alert.id }}" class="panel-body">
|
||||
{{ alert.content|raw }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
{% import "@CadolesPortal/Pagewidget/constants.twig" as constants %}
|
||||
|
||||
{% set stylewidget = constants.mystylewidget(entity) %}
|
||||
{% set stylewidgetmenu = constants.mystylewidgetmenu(entity) %}
|
||||
{% set stylewidgetheader = constants.mystylewidgetheader(entity) %}
|
||||
{% set stylewidgetbody = constants.mystylewidgetbody(entity) %}
|
||||
|
||||
{% if modedesktop==0 %}
|
||||
{% set stylegrid="" %}
|
||||
{% elseif modedesktop==1 %}
|
||||
{% set stylegrid="grid-medium" %}
|
||||
{% elseif modedesktop==2 %}
|
||||
{% set stylegrid="grid-small" %}
|
||||
{% endif %}
|
||||
|
||||
<div class="widget" dataid="{{ entity.id }}" loc="{{ entity.loc }}" style="{{ stylewidget }}" height="{{ entity.height }}px">
|
||||
<div class="widgetmenu">
|
||||
<i class="fa fa-trash fa-fw" onClick="delWidget({{ entity.id }})" style="{{ stylewidgetmenu }}"></i>
|
||||
<i class="fa fa-file fa-fw" onClick="modWidget({{ entity.id }})" style="{{ stylewidgetmenu }}"></i>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="widgetheader" style="{{ stylewidgetheader }}">
|
||||
<img src="/{{ alias }}/{{ entity.icon.label }}" height="40" width="40" style="cursor: move; border-radius: 100%; margin-top:-5px; margin-right:10px; "/>
|
||||
{{ entity.name }}
|
||||
</div>
|
||||
|
||||
<div class="widgetbody" style="{{ stylewidgetbody }}">
|
||||
|
||||
{% for itemcategory in itemcategorys %}
|
||||
{% set haveitem=false %}
|
||||
|
||||
{% for item in items if item.itemcategory==itemcategory %}
|
||||
|
||||
{% if loop.index ==1 %}
|
||||
{% set haveitem=true %}
|
||||
<h2 class="grid-title">{{ itemcategory.label }}</h2>
|
||||
|
||||
<div class="grid clearfix">
|
||||
<div class="grid-sizer {{ stylegrid }}"></div>
|
||||
{% endif %}
|
||||
|
||||
<div class="grid-item {{ stylegrid }}">
|
||||
<div class="grid-item-content" style="background-color: {{ item.color ? item.color : '#FFF' }};">
|
||||
{% if item.content %}
|
||||
<a style="cursor:pointer" class="item-preview"><i style="color: #FFF" class="fa fa-plus" title="Informations sur ce service"></i></a>
|
||||
{% endif %}
|
||||
|
||||
{% if item.protected and not app.user %}
|
||||
{% if app_login_mode == "SAML" %}
|
||||
<a href="{{ path('lightsaml_sp.login') }}">
|
||||
{% elseif app_login_mode == "CAS" %}
|
||||
<a href="{{ path('cas_sp.login') }}">
|
||||
{% elseif app_login_mode == "MYSQL" %}
|
||||
<a href="{{ path('cnous_portal_user_login') }}">
|
||||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
{% if item.target == 'frame' %}
|
||||
<a onClick="showFrameitem({{ item.id }},'{{ item.url }}')">
|
||||
{% else %}
|
||||
<a href="{{ item.url }}" target="{{ item.target }}">
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<div class="item-link clearfix">
|
||||
<div class="grid-item-logo">
|
||||
{% if item.icon %}
|
||||
<img class="grid-item-img" height="110" src="/{{ alias }}/{{ item.icon.label }}">
|
||||
{% else %}
|
||||
<img class="grid-item-img" height="110" src="/{{ alias }}/uploads/icon/icon_pin.png">
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="grid-item-title">
|
||||
<h2>{{ item.title }}</h2>
|
||||
<span>{{ item.subtitle|nl2br }}</<span>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<div class="grid-item-body" style="display:none">
|
||||
{{ item.content|raw }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% if haveitem %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
{% import "@CadolesPortal/Pagewidget/constants.twig" as constants %}
|
||||
|
||||
{% set stylewidget = constants.mystylewidget(entity) %}
|
||||
{% set stylewidgetmenu = constants.mystylewidgetmenu(entity) %}
|
||||
{% set stylewidgetheader = constants.mystylewidgetheader(entity) %}
|
||||
{% set stylewidgetbodyframe = constants.mystylewidgetbodyframe(entity) %}
|
||||
{% set stylewidgetbodyimage = constants.mystylewidgetbodyimage(entity) %}
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="widget" dataid="{{ entity.id }}" loc="{{ entity.loc }}" style="{{ stylewidget }}" height="{{ entity.height }}px">
|
||||
<div class="widgetmenu">
|
||||
<i class="fa fa-trash fa-fw" onClick="delWidget({{ entity.id }})" style="{{ stylewidgetmenu }}"></i>
|
||||
<i class="fa fa-file fa-fw" onClick="modWidget({{ entity.id }})" style="{{ stylewidgetmenu }}"></i>
|
||||
</div>
|
||||
|
||||
{% if imagemedia %}
|
||||
{% if entity.autoajust %}
|
||||
<div class="widgetheader" style="{{ stylewidgetheader }}">
|
||||
<img src="/{{ alias }}/{{ entity.icon.label }}" height="40" width="40" style="cursor: move; border-radius: 100%; margin-top:-5px; margin-right:10px; "/>
|
||||
{{ entity.name }}
|
||||
</div>
|
||||
<div class="widgetbody" style="{{ stylewidgetbodyframe }}">
|
||||
<img src="{{ url }}" width="100%" >
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="widgetheader" style="{{ stylewidgetbodyimage }} width:100%; background-image: url({{url}}); background-size:cover; background-position:center;")></div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<div class="widgetheader" style="{{ stylewidgetheader }}">
|
||||
<img src="/{{ alias }}/{{ entity.icon.label }}" height="40" width="40" style="cursor: move; border-radius: 100%; margin-top:-5px; margin-right:10px; "/>
|
||||
{{ entity.name }}
|
||||
</div>
|
||||
|
||||
<div class="widgetbody" style="{{ stylewidgetbodyframe }}">
|
||||
<iframe src="{{ url }}" class="{% if entity.autoajust %}frameajust {% endif %}"></iframe>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
</script>
|
||||
|
|
@ -23,23 +23,27 @@ INSERT IGNORE INTO `user` (`id`, `niveau01_id`, `username`, `firstname`, `lastna
|
|||
|
||||
|
||||
TRUNCATE TABLE sidebar;
|
||||
INSERT IGNORE INTO `sidebar` (`id`, `parent_id`, `roworder`, `label`, `path`, `fonticon`, `permission`) VALUES
|
||||
(1000, NULL, 1000, 'CONFIGIRATION', '', 'fa-gear', 'ROLE_ADMIN,ROLE_MODO'),
|
||||
(1010, 1000, 1010, 'Générale', 'cadoles_core_config_commun', 'fa-table', 'ROLE_ADMIN'),
|
||||
(1200, 1000, 1200, 'Organisations', NULL, 'fa-sitemap', 'ROLE_ADMIN,ROLE_MODO'),
|
||||
(1210, 1200, 1210, 'Listes Blanche', 'cadoles_core_config_whitelist', 'fa-tasks', 'ROLE_ADMIN'),
|
||||
(1220, 1200, 1220, 'Niveau 01', 'cadoles_core_config_niveau01', 'fa-building', 'ROLE_ADMIN'),
|
||||
INSERT IGNORE INTO `sidebar` (`id`, `parent_id`, `roworder`, `label`, `path`, `fonticon`, `permission`, `appactivate`) VALUES
|
||||
(1000, NULL, 1000, 'CONFIGIRATION', '', 'fa-gear', 'ROLE_ADMIN,ROLE_MODO', ''),
|
||||
(1010, 1000, 1010, 'Générale', 'cadoles_core_config_commun', 'fa-table', 'ROLE_ADMIN', ''),
|
||||
(1200, NULL, 1200, 'ORGANISATION', NULL, 'fa-sitemap', 'ROLE_ADMIN,ROLE_MODO', ''),
|
||||
(1210, 1200, 1210, 'Listes Blanche', 'cadoles_core_config_whitelist', 'fa-tasks', 'ROLE_ADMIN', ''),
|
||||
(1220, 1200, 1220, 'Niveau 01', 'cadoles_core_config_niveau01', 'fa-building', 'ROLE_ADMIN', ''),
|
||||
%if %%getVar("cadolesuser_niveau02view", 'non') == "oui"
|
||||
(1230, 1200, 1230, 'Niveau 02', 'cadoles_core_config_niveau02', 'fa-sitemap', 'ROLE_ADMIN,ROLE_MODO'),
|
||||
(1230, 1200, 1230, 'Niveau 02', 'cadoles_core_config_niveau02', 'fa-sitemap', 'ROLE_ADMIN,ROLE_MODO', ''),
|
||||
%end if
|
||||
(1240, 1200, 1240, 'Groupes', 'cadoles_core_config_group', 'fa-users', 'ROLE_ADMIN,ROLE_MODO'),
|
||||
(1250, 1200, 1250, 'Inscriptions', 'cadoles_core_config_registration', 'fa-pencil-square-o', 'ROLE_ADMIN,ROLE_MODO'),
|
||||
(1260, 1200, 1260, 'Utilisateurs', 'cadoles_core_config_user', 'fa-child', 'ROLE_ADMIN,ROLE_MODO'),
|
||||
(1240, 1200, 1240, 'Groupes', 'cadoles_core_config_group', 'fa-users', 'ROLE_ADMIN,ROLE_MODO', ''),
|
||||
(1250, 1200, 1250, 'Inscriptions', 'cadoles_core_config_registration', 'fa-pencil-square-o', 'ROLE_ADMIN,ROLE_MODO', ''),
|
||||
(1260, 1200, 1260, 'Utilisateurs', 'cadoles_core_config_user', 'fa-child', 'ROLE_ADMIN,ROLE_MODO', ''),
|
||||
|
||||
(1500, NULL, 1500, 'PORTAIL', NULL, 'fa-cubes', 'ROLE_ADMIN,ROLE_MODO'),
|
||||
(1510, 1500, 1510, 'Icônes', 'cadoles_portal_config_icon', 'fa-bug', 'ROLE_ADMIN,ROLE_MODO'),
|
||||
(1520, 1500, 1520, 'Items', 'cadoles_portal_config_item', 'fa-desktop', 'ROLE_ADMIN,ROLE_MODO'),
|
||||
(1530, 1500, 1530, 'Annonces', 'cadoles_portal_config_alert', 'fa-warning', 'ROLE_ADMIN,ROLE_MODO');
|
||||
(1500, NULL, 1500, 'PORTAIL', NULL, 'fa-cubes', 'ROLE_ADMIN,ROLE_MODO', 'portal_activate'),
|
||||
(1510, 1500, 1510, 'Icônes', 'cadoles_portal_config_icon', 'fa-bug', 'ROLE_ADMIN,ROLE_MODO', 'portal_activate'),
|
||||
(1520, 1500, 1520, 'Items', 'cadoles_portal_config_item', 'fa-desktop', 'ROLE_ADMIN,ROLE_MODO', 'portal_activate'),
|
||||
(1530, 1500, 1530, 'Annonces', 'cadoles_portal_config_alert', 'fa-bell', 'ROLE_ADMIN,ROLE_MODO', 'portal_activate'),
|
||||
(1540, 1500, 1540, 'Pages', 'cadoles_portal_config_page', 'fa-file', 'ROLE_ADMIN,ROLE_MODO', 'portal_activate'),
|
||||
|
||||
(7000, NULL, 7000, 'CRON', NULL, 'fa-bolt', 'ROLE_ADMIN,ROLE_MODO', 'cron_activate'),
|
||||
(7010, 7000, 7010, 'Jobs', 'cadoles_cron_config', 'fa-bullseye', 'ROLE_ADMIN,ROLE_MODO', 'cron_activate');
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -23,6 +23,10 @@ parameters:
|
|||
moderegistration: none
|
||||
%end if
|
||||
|
||||
# Activation module
|
||||
cron_activate: true
|
||||
portal_activate: true
|
||||
|
||||
# Information de base de l'annuaire
|
||||
ldap_host: %%adresse_ip_ldap
|
||||
ldap_port: %%ldap_port
|
||||
|
@ -165,11 +169,15 @@ doctrine:
|
|||
connection: default
|
||||
mappings:
|
||||
CadolesCoreBundle: ~
|
||||
CadolesCronBundle: ~
|
||||
CadolesPortalBundle: ~
|
||||
%if %%getVar("cadolesuser_synceportail", 'non') == "oui"
|
||||
eportail:
|
||||
connection: eportail
|
||||
mappings:
|
||||
CadolesCoreBundle: ~
|
||||
CadolesCronBundle: ~
|
||||
CadolesPortalBundle: ~
|
||||
%end if
|
||||
|
||||
|
|
@ -1,5 +1 @@
|
|||
# Regular cron jobs for the cadolesuser package
|
||||
*/10 * * * * root /var/www/html/cadolesuser/scripts/cadolesuser-cron.sh > /dev/null
|
||||
%if not %%is_empty(%%cadolesuser_smtpport)
|
||||
*/1 * * * * root /var/www/html/cadolesuser/scripts/cadolesuser-mail.sh > /dev/null
|
||||
%end if
|
||||
* * * * * root /var/www/html/cadolesuser/scripts/cadolesuser-cron.sh >> /var/www/html/cadolesuser/var/logs/cron.log
|
Loading…
Reference in New Issue