public function LoginForm()
 {
     $username = new Input(array('type' => 'text', 'name' => 'username', 'label' => 'Nom d\'utilisateur :', 'attributes' => 'class="form-control"'));
     $password = new Input(array('type' => 'password', 'name' => 'password', 'label' => 'Mot de passe :', 'attributes' => 'class="form-control"'));
     $submit = new Input(array('type' => 'submit', 'name' => 'submit', 'value' => 'Se connecter', 'attributes' => 'class="btn btn-primary"'));
     $form = new FormType(array('action' => '/admin/', 'method' => 'post', 'attributes' => 'class="well" id="login"'));
     $form->addField($username);
     $form->addField($password);
     $form->addField($submit);
     $content = '<h3 class="text-center">Connexion :</h3>' . $form->createView();
     return $this->getPage($content);
 }
 public function userForm($user = null)
 {
     $username = new Input(array('type' => 'text', 'name' => 'username', 'label' => 'Nom d\'utilisateur :', 'attributes' => 'class="form-control" required'));
     $password1 = new Input(array('type' => 'password', 'name' => 'password', 'label' => 'Mot de passe :', 'attributes' => 'class="form-control" required'));
     $password2 = new Input(array('type' => 'password', 'name' => 'password2', 'label' => 'Répetez le mot de passe :', 'attributes' => 'class="form-control" required'));
     $role0 = new Radio(array('type' => 'radio', 'name' => 'role', 'value' => '0', 'label' => 'Aucun role', 'attributes' => 'required'));
     $role1 = new Radio(array('type' => 'radio', 'name' => 'role', 'value' => '1', 'label' => 'Auteur', 'attributes' => 'required'));
     $role2 = new Radio(array('type' => 'radio', 'name' => 'role', 'value' => '2', 'label' => 'Admin', 'attributes' => 'required'));
     $submit = new Input(array('type' => 'submit', 'name' => 'submit', 'value' => 'Enregistrer', 'attributes' => 'class="btn btn-primary"'));
     $form = new FormType(array('action' => '/admin/user/save', 'method' => 'post', 'attributes' => 'class="well" id="userForm"'));
     $form->addField($username);
     $form->addField($password1);
     $form->addField($password2);
     $form->addField($role0);
     $form->addField($role1);
     $form->addField($role2);
     $form->addField($submit);
     if (!empty($user)) {
         $username->setValue($user->getUsername());
         $password1->setValue($user->getPassword());
         $password2->setValue($user->getPassword());
         $id = new Input(array('type' => 'hidden', 'name' => 'id', 'value' => $user->getId()));
         $form->addField($id);
     }
     if (isset($_POST['username'])) {
         $username->setValue($_POST['username']);
     }
     $content = '<h3 class="text-center">';
     if (!empty($user)) {
         $content .= 'Editer un utilisateur</h3>';
     } else {
         $content .= 'Ajouter un utilisateur</h3>';
     }
     $content .= $form->createView();
     return $this->getPage($content);
 }
 public function commentForm($id)
 {
     $postId = new Input(array('type' => 'hidden', 'name' => 'postId', 'value' => $id));
     $pseudo = new Input(array('type' => 'text', 'name' => 'pseudo', 'label' => 'Nom ou pseudo :', 'labelAttributes' => 'class="col-sm-4"', 'attributes' => 'placeholder="Votre nom" class="form-control col-sm-8"'));
     $mail = new Input(array('type' => 'email', 'name' => 'email', 'label' => 'Adresse mail :', 'labelAttributes' => 'class="col-sm-4"', 'attributes' => 'placeholder="*****@*****.**" class="form-control col-sm-8"'));
     $comment = new Textarea(array('name' => 'comment', 'label' => 'Commentaire :*', 'labelAttributes' => 'class="col-sm-4"', 'attributes' => 'class="form-control col-sm-8" required'));
     $submit = new Input(array('type' => 'submit', 'name' => 'submit', 'value' => 'Commenter', 'attributes' => 'class="btn btn-primary col-sm-6"'));
     $form = new FormType(array('action' => '/view/' . $id, 'method' => 'post', 'attributes' => 'class="well form-horizontal" id="commentForm"'));
     $form->addField($postId);
     $form->addField($pseudo);
     $form->addField($mail);
     $form->addField($comment);
     $form->addField($submit);
     return $form->createView();
 }
 public function configForm()
 {
     $config = $this->config;
     $adminPosts = new Input(array('type' => 'text', 'name' => 'postsAdmin', 'label' => 'Nombre de posts/utilisateurs sur l\'index de l\'Administration :', 'value' => strval($config->postsperpage->admin), 'attributes' => 'class="form-control" required'));
     $blogPosts = new Input(array('type' => 'text', 'name' => 'postsBlog', 'label' => 'Nombre de posts/utilisateurs sur l\'index du Blog :', 'value' => strval($config->postsperpage->blog), 'attributes' => 'class="form-control" required'));
     $modComs = new Input(array('type' => 'checkbox', 'name' => 'moderateComs', 'value' => '1', 'label' => 'Modérer les commentaires Avant publication :'));
     if ($config->moderate_comments == true) {
         $modComs->setAttributes('class="form-control" checked');
     } else {
         $modComs->setAttributes('class="form-control"');
     }
     $submit = new Input(array('type' => 'submit', 'name' => 'submit', 'value' => 'Sauvegarder', 'attributes' => 'class="btn btn-primary"'));
     $form = new FormType(array('action' => '/admin/config/save', 'method' => 'post', 'attributes' => 'class="well" id="configForm"'));
     $form->addField($adminPosts);
     $form->addField($blogPosts);
     $form->addField($modComs);
     $form->addField($submit);
     $content = '<h3>Page de configuration</h3>';
     $content .= $form->createView();
     return $this->getPage($content);
 }
 public function postForm($post = null)
 {
     $title = new Input(array('type' => 'text', 'name' => 'title', 'label' => 'Titre de l\'article :', 'attributes' => 'class="form-control" required'));
     $author = new Input(array('type' => 'text', 'name' => 'author', 'label' => 'Auteur :', 'attributes' => 'class="form-control"', 'value' => $_SESSION['username']));
     $content = new Textarea(array('name' => 'content', 'label' => 'Contenu :', 'attributes' => 'rows="10" class="form-control" id="content" required'));
     $submit = new Input(array('type' => 'submit', 'name' => 'submit', 'value' => 'Enregistrer', 'attributes' => 'class="btn btn-primary"'));
     if (!is_null($post)) {
         $title->setValue($post[0]->getTitle());
         $author->setValue($post[0]->getAuthor());
         $content->setPlaceholder($post[0]->getContent());
     }
     $form = new FormType(array('action' => '/admin/post/save', 'method' => 'post', 'attributes' => 'class="well"'));
     $form->addField($title);
     $form->addField($author);
     $form->addField($content);
     $form->addField($submit);
     if (!is_null($post)) {
         $content = '<h3>Editer un post :</h3>';
     } else {
         $content = '<h3>Nouveau post :</h3>';
     }
     $content .= $form->createView();
     return $this->getPage($content);
 }