Skip to content

Commit

Permalink
utilisation de app.request.basepath pour trouver la racine du site Th…
Browse files Browse the repository at this point in the history
…u Sep 27 06:34:45 GMT 2012
  • Loading branch information
mparaiso committed Sep 27, 2012
1 parent 4f7ae8b commit df70819
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 2 deletions.
25 changes: 25 additions & 0 deletions App/Form/CaptchaType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
namespace App\Form{

use Symfony\Component\Form\FormBuilderInterface;

class CaptchaType extends AbstractType
{

public function buildForm(FormBuilderInterface $builder,array $options){
$builder->add(array("image","image"));
}

function getDefaultOptions(array $options){
return array();
}

function getName(){
return "captcha";
}

function getParent(array $options){
return "form";
}
}
}
32 changes: 32 additions & 0 deletions App/Form/ImageType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
namespace App\Form{

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use App\Form\DataTransformer\TagsToArrayTransformer;
use App\Form\DataTransformer\MetadataTransformer;

class ImageType extends AbstractType{


function buildForm(FormBuilderInterface $builder,array $options){

}

function getDefaultOptions(array $options){
return array(
"src"=>"/img/image.png",
);
}

function getName(){
return "image";
}

function getParent(){
return "field";
}

}

}
12 changes: 12 additions & 0 deletions App/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,15 @@
$app->mount('/admin/user', new App\Controller\Admin\UserAdminController());
$app->mount('/admin/article',new App\Controller\Admin\ArticleAdminController($app['article_manager']));
$app->mount('/admin/option',new App\Controller\Admin\OptionAdminController($app['options']));


use Silex\Application;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use App\Form\CaptchaType;
use App\Form\ImageType;
$app->match('/captcha',function(Application $app,Request $request){
/** @var $image Symfony\Component\Form\Form **/
$image = $app['form.factory']->create(new ImageType());
return $app['twig']->render('form/captcha.twig',array('form'=>$image->createView()));
});
11 changes: 11 additions & 0 deletions App/view/form/captcha.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<form action="">
<legend>Image</legend>
<div>
{{ form_label(form)}}
{{ form_errors(form)}}
{{ form_widget(form)}}
{% block image_widget %}
{% endblock image_widget %}
</div>
<input type="submit" value="submit">
</form>
6 changes: 6 additions & 0 deletions App/view/form/image.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% block image_widget %}
{% spaceless %}
{{ block('widget_container_attributes')}}
{{ block('field_widget')}}
{% endspaceless %}
{% endblock %}
6 changes: 4 additions & 2 deletions App/view/head.twig
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{# Head #}
{# @note @silex FR : obtenir l'url racine du site avec app.request.basepath #}
{# @note @silex FR : get site base url with app.request.basepath #}
<meta charset="UTF-8">
<title>{{app.options.get('site_title')}}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="{{url('index.index')}}vendor/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="{{url('index.index')}}vendor/bootstrap/css/bootstrap-responsive.min.css">
<link rel="stylesheet" href="{{ app.request.basepath}}vendor/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="{{app.request.basepath}}vendor/bootstrap/css/bootstrap-responsive.min.css">
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
Expand Down
Binary file added public/img/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit df70819

Please sign in to comment.