diff --git a/src/cadolesuser-1.0/app/AppKernel.php b/src/cadolesuser-1.0/app/AppKernel.php index 9f6e7420..8abbb972 100644 --- a/src/cadolesuser-1.0/app/AppKernel.php +++ b/src/cadolesuser-1.0/app/AppKernel.php @@ -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() ]; diff --git a/src/cadolesuser-1.0/app/config/config.yml b/src/cadolesuser-1.0/app/config/config.yml index e2db424b..d7fffc0c 100644 --- a/src/cadolesuser-1.0/app/config/config.yml +++ b/src/cadolesuser-1.0/app/config/config.yml @@ -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 diff --git a/src/cadolesuser-1.0/app/config/routing.yml b/src/cadolesuser-1.0/app/config/routing.yml index 478ff958..8493b3d8 100644 --- a/src/cadolesuser-1.0/app/config/routing.yml +++ b/src/cadolesuser-1.0/app/config/routing.yml @@ -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: / diff --git a/src/cadolesuser-1.0/app/config/security.yml b/src/cadolesuser-1.0/app/config/security.yml index 15f3ce00..f42fe80c 100644 --- a/src/cadolesuser-1.0/app/config/security.yml +++ b/src/cadolesuser-1.0/app/config/security.yml @@ -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] } diff --git a/src/cadolesuser-1.0/app/config/template.yml b/src/cadolesuser-1.0/app/config/template.yml index cce0b12e..9bc6920c 100644 --- a/src/cadolesuser-1.0/app/config/template.yml +++ b/src/cadolesuser-1.0/app/config/template.yml @@ -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: ~ \ No newline at end of file diff --git a/src/cadolesuser-1.0/composer.json b/src/cadolesuser-1.0/composer.json index 91542a74..6b6531d8 100644 --- a/src/cadolesuser-1.0/composer.json +++ b/src/cadolesuser-1.0/composer.json @@ -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", diff --git a/src/cadolesuser-1.0/composer.lock b/src/cadolesuser-1.0/composer.lock index 73f1f22a..475a9b28 100644 --- a/src/cadolesuser-1.0/composer.lock +++ b/src/cadolesuser-1.0/composer.lock @@ -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", diff --git a/src/cadolesuser-1.0/scripts/cadolesuser-cron.sh b/src/cadolesuser-1.0/scripts/cadolesuser-cron.sh index f97ebce8..af1959ab 100755 --- a/src/cadolesuser-1.0/scripts/cadolesuser-cron.sh +++ b/src/cadolesuser-1.0/scripts/cadolesuser-cron.sh @@ -1,4 +1,4 @@ #!/bin/bash cd /var/www/html/cadolesuser -php bin/console Core:Cron \ No newline at end of file +php bin/console Cron:Exec \ No newline at end of file diff --git a/src/cadolesuser-1.0/scripts/cadolesuser-postservice-01.sh b/src/cadolesuser-1.0/scripts/cadolesuser-postservice-01.sh index f8729cf8..cfd728a1 100755 --- a/src/cadolesuser-1.0/scripts/cadolesuser-postservice-01.sh +++ b/src/cadolesuser-1.0/scripts/cadolesuser-postservice-01.sh @@ -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 diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Command/CronCommand.php b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Command/CronCommand.php deleted file mode 100644 index a12c2c7b..00000000 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Command/CronCommand.php +++ /dev/null @@ -1,72 +0,0 @@ -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'], '/'); - } -} diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Command/PurgeRegistrationCommand.php b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Command/PurgeRegistrationCommand.php new file mode 100644 index 00000000..8036b2dc --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Command/PurgeRegistrationCommand.php @@ -0,0 +1,68 @@ +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(''.$string.''); } + private function writeln($string) { $this->output->writeln($string); } +} diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Command/SynchroCommand.php b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Command/SynchroCommand.php index c63201f0..66617845 100644 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Command/SynchroCommand.php +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Command/SynchroCommand.php @@ -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(''.$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(); } } diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Command/data/core-init-01.sql b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Command/data/core-init-01.sql index ddada894..865d2972 100644 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Command/data/core-init-01.sql +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Command/data/core-init-01.sql @@ -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'); \ No newline at end of file +('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'); diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/ConfigController.php b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/ConfigController.php index 17f4ba7b..3decd372 100755 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/ConfigController.php +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/ConfigController.php @@ -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) diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/CoreController.php b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/CoreController.php index 36ff69ad..060d4e36 100644 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/CoreController.php +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/CoreController.php @@ -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, + ]); } } diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/CropController.php b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/CropController.php index bb0b829e..e169ef1b 100644 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/CropController.php +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/CropController.php @@ -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 diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/GroupController.php b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/GroupController.php index db0cdda9..3e29228a 100644 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/GroupController.php +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/GroupController.php @@ -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() diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/Niveau01Controller.php b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/Niveau01Controller.php index 1afc2113..a769e30f 100644 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/Niveau01Controller.php +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/Niveau01Controller.php @@ -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() diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/Niveau02Controller.php b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/Niveau02Controller.php index a8836a57..069e57fb 100644 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/Niveau02Controller.php +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/Niveau02Controller.php @@ -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() diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/RegistrationController.php b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/RegistrationController.php index 59c2a5a0..94db3eb5 100755 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/RegistrationController.php +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/RegistrationController.php @@ -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() - )); + ]); } } diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/SecurityController.php b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/SecurityController.php index 72691168..73762b09 100644 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/SecurityController.php +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/SecurityController.php @@ -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; } diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/UserController.php b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/UserController.php index bee34a62..b7a3b481 100644 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/UserController.php +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/UserController.php @@ -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() diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/WhitelistController.php b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/WhitelistController.php index b8498839..01d4e715 100644 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/WhitelistController.php +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Controller/WhitelistController.php @@ -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() diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Entity/Sidebar.php b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Entity/Sidebar.php index de2c406f..de6ab87b 100644 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Entity/Sidebar.php +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Entity/Sidebar.php @@ -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 diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/EventListener/sessionListener.php b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/EventListener/sessionListener.php index f836ade7..99cd48f8 100644 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/EventListener/sessionListener.php +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/EventListener/sessionListener.php @@ -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())) { diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml index 123e63a6..e9e43fbe 100644 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml @@ -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 } diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/public/js/local.js b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/public/js/local.js index 516b655a..a303a7c5 100644 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/public/js/local.js +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/public/js/local.js @@ -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); diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/public/js/masonry.pkgd.js b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/public/js/masonry.pkgd.js new file mode 100644 index 00000000..6803cb5c --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/public/js/masonry.pkgd.js @@ -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; + +})); + diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/public/js/sb-admin-2.js b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/public/js/sb-admin-2.js index ae76899d..4e38b268 100644 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/public/js/sb-admin-2.js +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/public/js/sb-admin-2.js @@ -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; diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Config/header.html.twig b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Config/header.html.twig index c02a0edb..f16e1187 100755 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Config/header.html.twig +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Config/header.html.twig @@ -1,4 +1,4 @@ -{% extends '@CadolesCore/simple.html.twig' %} +{% extends '@CadolesCore/base.html.twig' %} {% block pagewrapper %} diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Config/logo.html.twig b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Config/logo.html.twig index f9650801..0e90ed28 100755 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Config/logo.html.twig +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Config/logo.html.twig @@ -1,4 +1,4 @@ -{% extends '@CadolesCore/simple.html.twig' %} +{% extends '@CadolesCore/base.html.twig' %} {% block pagewrapper %} diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Core/home.html.twig b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Core/home.html.twig index 7e0d30a8..416befe1 100644 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Core/home.html.twig +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Core/home.html.twig @@ -1,4 +1,4 @@ -{% extends '@CadolesCore/nosidebar.html.twig' %} +{% extends '@CadolesCore/base.html.twig' %} {% block pagewrapper %}
diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Core/refresh.html.twig b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Core/refresh.html.twig deleted file mode 100644 index 1407c447..00000000 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Core/refresh.html.twig +++ /dev/null @@ -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 %} diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Crop/crop01.html.twig b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Crop/crop01.html.twig index 437601f1..f7c8d25c 100644 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Crop/crop01.html.twig +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Crop/crop01.html.twig @@ -1,4 +1,4 @@ -{% extends '@CadolesCore/simple.html.twig' %} +{% extends '@CadolesCore/base.html.twig' %} {% block pagewrapper %} diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Crop/crop02.html.twig b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Crop/crop02.html.twig index 8902946f..434062b0 100644 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Crop/crop02.html.twig +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Crop/crop02.html.twig @@ -1,4 +1,4 @@ -{% extends '@CadolesCore/simple.html.twig' %} +{% extends '@CadolesCore/base.html.twig' %} {% block pagewrapper %} diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Form/fields.html.twig b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Form/fields.html.twig index 1c9f28ff..431d53eb 100644 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Form/fields.html.twig +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Form/fields.html.twig @@ -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 }}
{% 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 %} +
+ + {{ time_pattern|replace({ + '{{ hour }}': self.date_form_widget(form.hour), + '{{ minute }}': self.date_form_widget(form.minute), + })|raw }} +
+ {% endif %} + {% endspaceless %} +{% endblock time_widget %} +#} {% block file_widget %} {% spaceless %} diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Include/footer.html.twig b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Include/footer.html.twig index a12ac05b..42b5abd6 100644 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Include/footer.html.twig +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Include/footer.html.twig @@ -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' diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Include/head.html.twig b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Include/head.html.twig index 84293e8b..c7611886 100644 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Include/head.html.twig +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/Include/head.html.twig @@ -39,7 +39,10 @@ {% endif %}

diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/base.html.twig b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/base.html.twig index 69efed71..ac2d6c7d 100644 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/base.html.twig +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/base.html.twig @@ -8,20 +8,24 @@ {% endblock %} - +
- {% set usesidebar = true %} {{ include('@CadolesCore/Include/hero.html.twig') }} -
+ {% if useheader %} +
+ {% endif %} + {% block pagewrapper %} {% endblock %} + {% if useheader %}
+ {% endif %}
{{ include('@CadolesCore/Include/footer.html.twig') }} diff --git a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/nosidebar.html.twig b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/nosidebar.html.twig index fc846986..0fb3fa9f 100644 --- a/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/nosidebar.html.twig +++ b/src/cadolesuser-1.0/src/Cadoles/CoreBundle/Resources/views/nosidebar.html.twig @@ -14,7 +14,7 @@ {% set usesidebar = false %} {{ include('@CadolesCore/Include/hero.html.twig') }} -
+
{% block pagewrapper %} diff --git a/src/cadolesuser-1.0/src/Cadoles/CronBundle/CadolesCronBundle.php b/src/cadolesuser-1.0/src/Cadoles/CronBundle/CadolesCronBundle.php new file mode 100644 index 00000000..fcaa1ca8 --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/CronBundle/CadolesCronBundle.php @@ -0,0 +1,9 @@ +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(''.$string.''); } + private function writeln($string) { $this->output->writeln($string); } +} diff --git a/src/cadolesuser-1.0/src/Cadoles/CronBundle/Command/InitDataCommand.php b/src/cadolesuser-1.0/src/Cadoles/CronBundle/Command/InitDataCommand.php new file mode 100644 index 00000000..d95f8f22 --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/CronBundle/Command/InitDataCommand.php @@ -0,0 +1,104 @@ +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(); + } +} diff --git a/src/cadolesuser-1.0/src/Cadoles/CronBundle/Command/MailCommand.php b/src/cadolesuser-1.0/src/Cadoles/CronBundle/Command/MailCommand.php new file mode 100644 index 00000000..e89021c3 --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/CronBundle/Command/MailCommand.php @@ -0,0 +1,55 @@ +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(''.$string.''); } + private function writeln($string) { $this->output->writeln($string); } +} diff --git a/src/cadolesuser-1.0/src/Cadoles/CronBundle/Controller/CronController.php b/src/cadolesuser-1.0/src/Cadoles/CronBundle/Controller/CronController.php new file mode 100644 index 00000000..93693a2d --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/CronBundle/Controller/CronController.php @@ -0,0 +1,172 @@ +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 = "$data->getId()))."'>"; + $action.= "$data->getId()))."'>"; + + $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 + ]); + } +} diff --git a/src/cadolesuser-1.0/src/Cadoles/CronBundle/Entity/Cron.php b/src/cadolesuser-1.0/src/Cadoles/CronBundle/Entity/Cron.php new file mode 100644 index 00000000..2e12fca1 --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/CronBundle/Entity/Cron.php @@ -0,0 +1,382 @@ +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; + } +} diff --git a/src/cadolesuser-1.0/src/Cadoles/CronBundle/Form/CronType.php b/src/cadolesuser-1.0/src/Cadoles/CronBundle/Form/CronType.php new file mode 100644 index 00000000..a8c321aa --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/CronBundle/Form/CronType.php @@ -0,0 +1,78 @@ +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'; + } +} diff --git a/src/cadolesuser-1.0/src/Cadoles/CronBundle/Repository/CronRepository.php b/src/cadolesuser-1.0/src/Cadoles/CronBundle/Repository/CronRepository.php new file mode 100644 index 00000000..aee50f12 --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/CronBundle/Repository/CronRepository.php @@ -0,0 +1,28 @@ + 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(); + } +} diff --git a/src/cadolesuser-1.0/src/Cadoles/CronBundle/Resources/config/routing.yml b/src/cadolesuser-1.0/src/Cadoles/CronBundle/Resources/config/routing.yml new file mode 100644 index 00000000..ffce066a --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/CronBundle/Resources/config/routing.yml @@ -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 } \ No newline at end of file diff --git a/src/cadolesuser-1.0/src/Cadoles/CronBundle/Resources/config/services.yml b/src/cadolesuser-1.0/src/Cadoles/CronBundle/Resources/config/services.yml new file mode 100644 index 00000000..3d9b22dd --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/CronBundle/Resources/config/services.yml @@ -0,0 +1,4 @@ +services: + cadoles.cron.service.mail: + class: Cadoles\CronBundle\Service\mailService + arguments: ["@mailer", "@twig"] diff --git a/src/cadolesuser-1.0/src/Cadoles/CronBundle/Resources/views/Cron/edit.html.twig b/src/cadolesuser-1.0/src/Cadoles/CronBundle/Resources/views/Cron/edit.html.twig new file mode 100644 index 00000000..ae2aaf85 --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/CronBundle/Resources/views/Cron/edit.html.twig @@ -0,0 +1,45 @@ +{% extends '@CadolesCore/base.html.twig' %} + +{% block pagewrapper %} +{{ form_start(form) }} +

Modification Job

+ +

+ {{ form_widget(form.submit) }} + Annuler + + + {% if app.session.flashbag.has('error') %} +

+ Erreur
+ {% for flashMessage in app.session.flashbag.get('error') %} + {{ flashMessage }}
+ {% endfor %} +
+ {% endif %} + + {% if app.session.flashbag.has('notice') %} +
+ Information
+ {% for flashMessage in app.session.flashbag.get('notice') %} + {{ flashMessage }}
+ {% endfor %} +
+ {% endif %} + +
+
+ Informations +
+ +
+ {{ form_row(form.command) }} + {{ form_row(form.jsonargument) }} + {{ form_row(form.statut) }} + {{ form_row(form.repeatcall) }} + {{ form_row(form.repeatinterval) }} +
+
+{{ form_end(form) }} + +{% endblock %} diff --git a/src/cadolesuser-1.0/src/Cadoles/CronBundle/Resources/views/Cron/list.html.twig b/src/cadolesuser-1.0/src/Cadoles/CronBundle/Resources/views/Cron/list.html.twig new file mode 100644 index 00000000..cc4977fe --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/CronBundle/Resources/views/Cron/list.html.twig @@ -0,0 +1,46 @@ +{% extends '@CadolesCore/base.html.twig' %} + + +{% block pagewrapper %} +

+ Gestion des Jobs +

+ +
+
+ Liste des Utilisateurs +
+ +
+
+ + + + + + + + + + + +
ActionOrderCommandDescriptionStatutProchaine exécution
+
+
+
+{% 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 %} diff --git a/src/cadolesuser-1.0/src/Cadoles/CronBundle/Service/mailService.php b/src/cadolesuser-1.0/src/Cadoles/CronBundle/Service/mailService.php new file mode 100644 index 00000000..698bd967 --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/CronBundle/Service/mailService.php @@ -0,0 +1,51 @@ +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; + } +} \ No newline at end of file diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Command/InitDataCommand.php b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Command/InitDataCommand.php index 42a41a19..1cd913cf 100644 --- a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Command/InitDataCommand.php +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Command/InitDataCommand.php @@ -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(''); - } } diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Controller/AlertController.php b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Controller/AlertController.php index bc77b0a8..af4c2977 100644 --- a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Controller/AlertController.php +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Controller/AlertController.php @@ -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) diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Controller/AlertcategoryController.php b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Controller/AlertcategoryController.php index 36f46f58..d50e7180 100644 --- a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Controller/AlertcategoryController.php +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Controller/AlertcategoryController.php @@ -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) diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Controller/IconController.php b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Controller/IconController.php index 47c1003b..45f9e862 100644 --- a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Controller/IconController.php +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Controller/IconController.php @@ -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() diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Controller/ItemController.php b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Controller/ItemController.php index 04520fc8..2084de95 100644 --- a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Controller/ItemController.php +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Controller/ItemController.php @@ -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) diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Controller/ItemcategoryController.php b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Controller/ItemcategoryController.php index ee438fdd..cdf1f581 100644 --- a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Controller/ItemcategoryController.php +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Controller/ItemcategoryController.php @@ -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) diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Controller/PageController.php b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Controller/PageController.php new file mode 100644 index 00000000..2726a109 --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Controller/PageController.php @@ -0,0 +1,331 @@ +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.="$data->getId()))."'>"; + $action.="$data->getId()))."' data-method='delete'>"; + $action.="$data->getId()))."'>"; + + 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 + ]); + } + + } +} diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Controller/PagewidgetController.php b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Controller/PagewidgetController.php new file mode 100644 index 00000000..1e362f1d --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Controller/PagewidgetController.php @@ -0,0 +1,439 @@ +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 + ]); + } +} diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Entity/Page.php b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Entity/Page.php new file mode 100644 index 00000000..54cce136 --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Entity/Page.php @@ -0,0 +1,348 @@ +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; + } +} diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Entity/Pagecategory.php b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Entity/Pagecategory.php new file mode 100644 index 00000000..aa0aaf51 --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Entity/Pagecategory.php @@ -0,0 +1,126 @@ +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; + } +} diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Entity/Pagewidget.php b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Entity/Pagewidget.php new file mode 100644 index 00000000..1daa889b --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Entity/Pagewidget.php @@ -0,0 +1,468 @@ +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; + } +} diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Entity/Widget.php b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Entity/Widget.php new file mode 100644 index 00000000..b6e3055f --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Entity/Widget.php @@ -0,0 +1,497 @@ +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; + } +} diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Form/AlertType.php b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Form/AlertType.php index d247ff04..d1614eb7 100644 --- a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Form/AlertType.php +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Form/AlertType.php @@ -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) diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Form/PageSubmitType.php b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Form/PageSubmitType.php new file mode 100644 index 00000000..95456b05 --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Form/PageSubmitType.php @@ -0,0 +1,47 @@ +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' + ]); + } +} diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Form/PageUpdateEditorType.php b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Form/PageUpdateEditorType.php new file mode 100644 index 00000000..0963c736 --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Form/PageUpdateEditorType.php @@ -0,0 +1,71 @@ +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' + ]); + } +} diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Form/PageUpdateURLType.php b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Form/PageUpdateURLType.php new file mode 100644 index 00000000..aec791e8 --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Form/PageUpdateURLType.php @@ -0,0 +1,66 @@ +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' + ]); + } +} diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Form/PageUpdateWidgetType.php b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Form/PageUpdateWidgetType.php new file mode 100644 index 00000000..8eb67a6d --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Form/PageUpdateWidgetType.php @@ -0,0 +1,68 @@ +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' + ]); + } +} diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Form/PagewidgetType.php b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Form/PagewidgetType.php new file mode 100644 index 00000000..3c8e3ae2 --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Form/PagewidgetType.php @@ -0,0 +1,160 @@ +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' + ]); + } +} diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/config/routing.yml b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/config/routing.yml index e2070f10..17fea767 100644 --- a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/config/routing.yml +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/config/routing.yml @@ -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 } \ No newline at end of file diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/config/services.yml b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/config/services.yml new file mode 100644 index 00000000..39998476 --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/config/services.yml @@ -0,0 +1,5 @@ +services: + Cadoles\PortalBundle\Form\PagewidgetType: + arguments: ['@service_container'] + tags: + - { name: form.type } \ No newline at end of file diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Alert/edit.html.twig b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Alert/edit.html.twig index 7ba39585..28b40742 100755 --- a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Alert/edit.html.twig +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Alert/edit.html.twig @@ -54,21 +54,16 @@
+ {{ form_row(form.publishedat) }} + {{ form_row(form.unpublishedat) }} {{ form_row(form.content) }}
+ {{ form_row(form.roles) }} {{ form_row(form.groups) }}
-
-
- {{ form_row(form.publishedat) }} -
-
- {{ form_row(form.unpublishedat) }} -
-
{{ form_end(form) }} diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Alert/list.html.twig b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Alert/list.html.twig index 17e4b6f5..f3c30eee 100644 --- a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Alert/list.html.twig +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Alert/list.html.twig @@ -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 %}

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 }};" >
-
+
{% for alertcategory in alertcategorys %}
-
- +
-
- +
+ Toutes @@ -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 %} diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Icon/icon.html.twig b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Icon/icon.html.twig index 5ebc63a5..88f3781b 100755 --- a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Icon/icon.html.twig +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Icon/icon.html.twig @@ -1,4 +1,4 @@ -{% extends '@CadolesCore/simple.html.twig' %} +{% extends '@CadolesCore/base.html.twig' %} {% block pagewrapper %} diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Itemcategory/edit.html.twig b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Itemcategory/edit.html.twig index 526e535e..3f555418 100755 --- a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Itemcategory/edit.html.twig +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Itemcategory/edit.html.twig @@ -40,6 +40,7 @@ {% endfor %}
{% endif %} +
Informations diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Page/list.html.twig b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Page/list.html.twig new file mode 100644 index 00000000..c673182d --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Page/list.html.twig @@ -0,0 +1,57 @@ +{% extends '@CadolesCore/base.html.twig' %} + + +{% block pagewrapper %} +

+ Gestion des Pages +

+ +

+ Ajouter une Page +

+ +
+
+ Liste des Utilisateurs +
+ +
+
+ + + + + + + + + +
ActionOrdreNomCatégorie
+
+
+
+{% 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 %} diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Page/submit.html.twig b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Page/submit.html.twig new file mode 100644 index 00000000..97f58b07 --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Page/submit.html.twig @@ -0,0 +1,44 @@ +{% extends '@CadolesCore/base.html.twig' %} + +{% block pagewrapper %} +{{ form_start(form) }} +

+ Nouvelle Page +

+ +

+ {{ form_widget(form.submit) }} + Annuler +

+ + {% if app.session.flashbag.has('error') %} +
+ Erreur
+ {% for flashMessage in app.session.flashbag.get('error') %} + {{ flashMessage }}
+ {% endfor %} +
+ {% endif %} + + {% if app.session.flashbag.has('notice') %} +
+ Information
+ {% for flashMessage in app.session.flashbag.get('notice') %} + {{ flashMessage }}
+ {% endfor %} +
+ {% endif %} + +
+
+ Informations +
+ +
+ {{ form_row(form.name) }} + {{ form_row(form.roworder) }} + {{ form_row(form.pagecategory) }} +
+
+{{ form_end(form) }} +{% endblock %} diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Page/updateeditor.html.twig b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Page/updateeditor.html.twig new file mode 100644 index 00000000..2ba48c66 --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Page/updateeditor.html.twig @@ -0,0 +1,58 @@ +{% extends '@CadolesCore/base.html.twig' %} + +{% block pagewrapper %} +{{ form_start(form) }} +

+ {% if mode=="update" %} + Modification Page Editeur + {% elseif mode=="submit" %} + Création Page Editeur + {% endif %} +

+ +

+ {{ form_widget(form.submit) }} + Annuler + + {% if mode=="update" %} + + Supprimer + + {% endif %} +

+ + {% if app.session.flashbag.has('error') %} +
+ Erreur
+ {% for flashMessage in app.session.flashbag.get('error') %} + {{ flashMessage }}
+ {% endfor %} +
+ {% endif %} + + {% if app.session.flashbag.has('notice') %} +
+ Information
+ {% for flashMessage in app.session.flashbag.get('notice') %} + {{ flashMessage }}
+ {% endfor %} +
+ {% endif %} + +
+
+ {{ form_row(form.name) }} + {{ form_row(form.roworder) }} + {{ form_row(form.html) }} +
+ +
+ {{ form_row(form.roles) }} + {{ form_row(form.groups) }} +
+
+{{ form_end(form) }} +{% endblock %} \ No newline at end of file diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Page/updateurl.html.twig b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Page/updateurl.html.twig new file mode 100644 index 00000000..b94013e7 --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Page/updateurl.html.twig @@ -0,0 +1,58 @@ +{% extends '@CadolesCore/base.html.twig' %} + +{% block pagewrapper %} +{{ form_start(form) }} +

+ {% if mode=="update" %} + Modification Page URL + {% elseif mode=="submit" %} + Création Page URL + {% endif %} +

+ +

+ {{ form_widget(form.submit) }} + Annuler + + {% if mode=="update" %} + + Supprimer + + {% endif %} +

+ + {% if app.session.flashbag.has('error') %} +
+ Erreur
+ {% for flashMessage in app.session.flashbag.get('error') %} + {{ flashMessage }}
+ {% endfor %} +
+ {% endif %} + + {% if app.session.flashbag.has('notice') %} +
+ Information
+ {% for flashMessage in app.session.flashbag.get('notice') %} + {{ flashMessage }}
+ {% endfor %} +
+ {% endif %} + +
+
+ {{ form_row(form.name) }} + {{ form_row(form.roworder) }} + {{ form_row(form.url) }} +
+ +
+ {{ form_row(form.roles) }} + {{ form_row(form.groups) }} +
+
+{{ form_end(form) }} +{% endblock %} \ No newline at end of file diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Page/updatewidget.html.twig b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Page/updatewidget.html.twig new file mode 100644 index 00000000..e8771299 --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Page/updatewidget.html.twig @@ -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) }} +

+ {% if mode=="update" %} + Modification Page Widget + {% elseif mode=="submit" %} + Création Page Widget + {% endif %} +

+ +

+ {{ form_widget(form.submit) }} + Annuler + + {% if mode=="update" %} + + Supprimer + + {% endif %} +

+ + {% if app.session.flashbag.has('error') %} +
+ Erreur
+ {% for flashMessage in app.session.flashbag.get('error') %} + {{ flashMessage }}
+ {% endfor %} +
+ {% endif %} + + {% if app.session.flashbag.has('notice') %} +
+ Information
+ {% for flashMessage in app.session.flashbag.get('notice') %} + {{ flashMessage }}
+ {% endfor %} +
+ {% endif %} + +
+
+ {{ form_row(form.name) }} + {{ form_row(form.roworder) }} + {{ form_row(form.template) }} +
+ +
+ {{ form_row(form.roles) }} + {{ form_row(form.groups) }} +
+
+ +

Template de Mise en Page

+
+
+{{ 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+="
"; + defaultcol+=""; + defaultcol+="
"; + defaultcol+="
"; + defaultcol+=""; + defaultcol+="
"; + defaultcol+="
"; + defaultcol+="
"; + defaultcol+="
"; + defaultcol+=""; + defaultcol+="
"; + defaultcol+="Ajouter une Ligne"; + + $('document').ready(function(){ + // Template de base + if($(page_update_widget_template).val()=="") { + myrow ="
"; + myrow+="
"; + + myrow+="
"; + myrow+="
"+defaultcol+"
" + myrow+="
"+defaultcol+"
" + myrow+="
"+defaultcol+"
" + myrow+="
" + + myrow+="
"; + myrow+="
" + + $("#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+="
"; + mygrid+="
"; + mygrid+="
"; + + $.each(rownv01.cols, function( index, colnv01 ) { + mygrid+="
"; + mygrid+="
"; + mygrid+=""; + mygrid+="
"; + mygrid+="
"; + mygrid+=""; + mygrid+="
"; + mygrid+="
"; + + $.each(colnv01.rows, function( index, rownv02 ) { + mygrid+="
"; + mygrid+="
"; + mygrid+="
"; + $.each(rownv02.cols, function( index, colnv02 ) { + mygrid+="
"+defaultcol+"
"; + }); + mygrid+="
"; + mygrid+="
"; + mygrid+="
"; + }); + + mygrid+="
"; + mygrid+="
"; + mygrid+=""; + mygrid+="
"; + mygrid+="Ajouter une Ligne"; + mygrid+="
"; + }); + + mygrid+="
"; + mygrid+="
"; + mygrid+="
"; + }); + + $("#gridtemplate").append(mygrid); + } + + $("#gridtemplate").append("Ajouter une Ligne"); + + // 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 ="
"; + myrow+="
"; + + myrow+="
"; + myrow+="
"+defaultcol+"
" + myrow+="
"+defaultcol+"
" + myrow+="
"+defaultcol+"
" + myrow+="
" + + myrow+="
"; + myrow+="
" + + 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("
"+defaultcol+"
"); + } + }); + + // 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 + +
+ +
+ {{ entity.html | raw }} +
+{% endblock %} + +{% block localjavascript %} + $('document').ready(function(){ + $(".pagemenu").append(""); + $(".pagemenu").append(""); + }); + +{% endblock %} diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Page/viewurl.html.twig b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Page/viewurl.html.twig new file mode 100644 index 00000000..d0c27d65 --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Page/viewurl.html.twig @@ -0,0 +1,61 @@ + +{% extends '@CadolesCore/base.html.twig' %} + +{% block localstyle %} + #pageiframe { margin: 0px -30px;} +{% endblock %} + +{% block pagewrapper %} + + +
+ +
+{% endblock %} + +{% block localjavascript %} + $(window).resize(function() { + resizeFrame(); + }); + + $('document').ready(function(){ + $(".pagemenu").append(""); + $(".pagemenu").append(""); + + 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 %} diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Page/viewwidget.html.twig b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Page/viewwidget.html.twig new file mode 100644 index 00000000..bab89b81 --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Page/viewwidget.html.twig @@ -0,0 +1,324 @@ + +{% extends '@CadolesCore/base.html.twig' %} + + +{% block pagewrapper %} + + +
+ +
+ + + + +{% 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(""); + $(".pagemenu").append(""); + $(".pagemenu").append(""); + + // Création de la grille des widgets + var template = '{{ entity.template | raw }}'; + + // Template de base + if(template=="") { + myrow ="
"; + myrow+="
"; + myrow+="
" + myrow+="
" + myrow+="
" + myrow+="
" + + $("#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+="
"; + mygrid+="
"; + + $.each(rownv01.cols, function( index, colnv01 ) { + col01++; + var row02=0; + + mygrid+="
"; + mygrid+="
"; + + $.each(colnv01.rows, function( index, rownv02 ) { + row02++; + col02=0; + + mygrid+="
"; + mygrid+="
"; + $.each(rownv02.cols, function( index, colnv02 ) { + col02++; + mygrid+="
"; + }); + mygrid+="
"; + mygrid+="
"; + }); + + mygrid+="
"; + mygrid+="
"; + }); + + mygrid+="
"; + mygrid+="
"; + }); + + $("#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) { + $("
 
").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(''); + 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(''); + + $(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(""); + } + } + +{% endblock %} diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/constants.twig b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/constants.twig new file mode 100644 index 00000000..6d600749 --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/constants.twig @@ -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 %}` \ No newline at end of file diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/edit.html.twig b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/edit.html.twig new file mode 100644 index 00000000..2b8e788d --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/edit.html.twig @@ -0,0 +1,141 @@ +{% extends '@CadolesCore/base.html.twig' %} + +{% block pagewrapper %} +{{ form_start(form) }} +

+ {% if mode=="update" %} + Modification Widget + {% elseif mode=="submit" %} + Création Widget + {% endif %} +

+ +

+ {{ form_widget(form.submit) }} + Annuler + +

+ + {% if app.session.flashbag.has('error') %} +
+ Erreur
+ {% for flashMessage in app.session.flashbag.get('error') %} + {{ flashMessage }}
+ {% endfor %} +
+ {% endif %} + + {% if app.session.flashbag.has('notice') %} +
+ Information
+ {% for flashMessage in app.session.flashbag.get('notice') %} + {{ flashMessage }}
+ {% endfor %} +
+ {% endif %} + +
+
+ {{ form_row(form.name) }} +
+ +
+
+ {% if entity.icon %} + + {% endif %} +
+
+ {{ form_row(form.idicon) }} + Selectionner un Icône +
+
+
+ +
+ {{ form_row(form.height) }} + {{ form_row(form.autoajust) }} + {{ form_row(form.border) }} +
+ +
+ {{ form_row(form.colorheaderback) }} + {{ form_row(form.colorheaderfont) }} + {{ form_row(form.colorbodyback) }} + {{ form_row(form.colorbodyfont) }} +
+ +
+ +
+ +
+ {{ form_widget(form) }} +
+ + + +{{ 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 %} \ No newline at end of file diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewalert.html.twig b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewalert.html.twig new file mode 100644 index 00000000..b363854e --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewalert.html.twig @@ -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) %} + + + +
+
+ + +
+ + +
+ + {{ entity.name }} +
+ +
+ {% for alert in alerts %} +
+ + +
+ {{ alert.content|raw }} +
+ +
+ + {% endfor %} +
+
+ + + diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewitem.html.twig b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewitem.html.twig new file mode 100644 index 00000000..20c6b6a5 --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewitem.html.twig @@ -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 %} + +
+
+ + +
+ + +
+ + {{ entity.name }} +
+ +
+ + {% for itemcategory in itemcategorys %} + {% set haveitem=false %} + + {% for item in items if item.itemcategory==itemcategory %} + + {% if loop.index ==1 %} + {% set haveitem=true %} +

{{ itemcategory.label }}

+ +
+
+ {% endif %} + + + {% endfor %} + {% if haveitem %} +
+ {% endif %} + {% endfor %} +
+
+ + + diff --git a/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewurl.html.twig b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewurl.html.twig new file mode 100644 index 00000000..f1ac33ec --- /dev/null +++ b/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewurl.html.twig @@ -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) %} + + + + +
+
+ + +
+ + {% if imagemedia %} + {% if entity.autoajust %} +
+ + {{ entity.name }} +
+
+ +
+ {% else %} +
+ {% endif %} + {% else %} +
+ + {{ entity.name }} +
+ +
+ +
+ {% endif %} +
+ + + diff --git a/tmpl/cadolesuser-init-01.sql b/tmpl/cadolesuser-init-01.sql index 57bfa2c5..0e905656 100644 --- a/tmpl/cadolesuser-init-01.sql +++ b/tmpl/cadolesuser-init-01.sql @@ -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'); diff --git a/tmpl/cadolesuser-template.yml b/tmpl/cadolesuser-template.yml index 0903b208..255ba460 100644 --- a/tmpl/cadolesuser-template.yml +++ b/tmpl/cadolesuser-template.yml @@ -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 \ No newline at end of file diff --git a/tmpl/cadolesuser.cron b/tmpl/cadolesuser.cron index f21765af..8d2a9d1c 100644 --- a/tmpl/cadolesuser.cron +++ b/tmpl/cadolesuser.cron @@ -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 \ No newline at end of file +* * * * * root /var/www/html/cadolesuser/scripts/cadolesuser-cron.sh >> /var/www/html/cadolesuser/var/logs/cron.log \ No newline at end of file