Example #1
0
 public static function add($tab)
 {
     //Recherce URL dispo pour l'évent
     $compte = 0;
     $buffer = FoxFWKernel::URLencode($tab['titre']);
     while (!empty(R::find('evenement', 'url=?', [$buffer]))) {
         $compte++;
         $buffer = FoxFWKernel::URLencode($tab['titre'] . '-' . $compte);
     }
     //Création événement
     $event = R::dispense('evenement');
     $event->url = $buffer;
     $event->date = $tab['date'];
     $event->date_end = $tab['dateEnd'];
     $event->titre = $tab['titre'];
     $event->body = $tab['body'];
     $event->lieu = $tab['lieu'];
     $event->tag = $tab['tag'];
     R::store($event);
     return $event->url;
 }
Example #2
0
 public static function add($data)
 {
     //verification de l'id dispo
     $compte = 0;
     $buffer = FoxFWKernel::URLencode($data['titre']);
     while (!empty(R::find('page', 'url=?', [$buffer]))) {
         $compte++;
         $buffer = FoxFWKernel::URLencode($data['titre'] . '-' . $compte);
     }
     //preparation de l'article
     $article = R::dispense('page');
     $article->url = $buffer;
     $article->titre = $data['titre'];
     $article->tag = $data['tag'];
     $article->auteur = $data['auteur'];
     $article->filename = $buffer;
     $article->type = $data['type'];
     $article->twig = $data['twig'];
     $article->img = '';
     $article->date = time();
     if (isset($data['date'])) {
         $article->date = $data['date'];
     }
     //création du fichier qui recevra le body
     $filename = _WEB . Page::$buffer_dir . $buffer . '.html';
     file_put_contents($filename, $data['body']);
     if (!file_exists($filename)) {
         //si le fichier existe pas
         die('Erreur Création fichier BODY !: ' . $filename);
     }
     //telechargement de l'image
     $buffer = FoxFWFile::uploadFile($data['path']);
     if (isset($buffer[0])) {
         $article->img = $buffer[0];
     }
     R::store($article);
     return $article->url;
 }