Aller au contenu | Aller au menu | Aller à la recherche

Display lastest dotclear posts in symfony

Here is a little tip to display the latest posts of your dotclear blog in your symfony website.

Create a connection

If your blog database is in an other database than symfony's one, you need to create a connection in the /config/databases.yml. Otherwise, skip this step Mine looks like this :

      classname:  DebugPDO

      classname:  DebugPDO

    class:        sfDoctrineDatabase
      classname:  DoctrinePDO
      dsn:        mysql:dbname=mysymfonydbanem;host=localhost
      username:   mysymfonyusername
      password:   mysymfonypassword
      encoding:   utf8
      persistent: true
      pooling:    true
    class:        sfDoctrineDatabase
      classname:  DoctrinePDO
      dsn:        mysql:dbname=myblogdbname;host=localhost
      username:   myblogusername
      password:   myblogpassword
      encoding:   utf8
      persistent: true
      pooling:    true

Read more about connections.

Create Dotclear models from the database

You must create models from the database to be able to retrieve the posts

$ ./symfony doctrine:build-schema --env=blog
$ ./symfony doctrine:build-model

As you can see, some Dc*.class.php are now created in the /lib/model/doctrine/ folder.

Fetching latests posts

In your controller (actions.class.php), use and customize this request :

public function executeIndex(sfWebRequest $request)
    $this->posts = Doctrine_Query::create()
        ->from('DcPost p')
        ->where('p.post_status = 1')
        ->orderBy('p.post_creadt DESC')

Displaying posts

<?php foreach($posts as $post) : ?>
  <div class="blog_box">
    <h5><a href="#"><?php echo $post->getPostTitle() ?></a></h5>
    <?php echo __('Posted by') ?> <a href="<?php echo $post->getPostUrl() ?>"><span><?php echo $post->getDcUser()->getUserDisplayname () ?></span></a> <?php echo __('in') ?> <a href="#"><span><?php echo $post->getDcCategory()->getCatTitle() ?></span></a><br />
    <?php echo substr(strip_tags($post->getRawValue()->getPostContentXhtml()), 0, 40).'...' ?><br />
    <div class="datetime"><?php echo $post->getPostCreadt() ?></div>
<?php endforeach; ?>

and that's it, you made it ! :)

PS: This howto is maybe somehow wrong, I made those steps few times before making this working. Feel free to correct.

Update 1 : Added a where clause to select only posts where post_status = 1. Added the link to the post

Protect your .svn files in your website

If you are using like me svn to manage your website, you certainly notified that all the .svn files are fully readable by everyone in plain text. So here is a fix to deny the acces to those files :

<Directory ~ "\.svn">
    Order allow,deny
    Deny from all

Solution found at

Howto reveal an input type="password" with simple tools

When your browser is configured to save password fields, it's very easy to reveal that field without knowing the master password (because *of course* you have a master password).

Just use firebug. Load the page, and change change <input type="password" /> by <input type="text" />

HADOPI - Le Net en France : black-out

HADOPI - Le Net en France : black-out

Decibel audio player and MP3

I recently installed a fresh debian lenny. To play some music I decided to keep decibel audio player that I already have on my personal pc.

But when I wanted to play some MP3's it kept saying:

** Message: don't know how to handle audio/mpeg, mpegversion=(int)1, layer=(int)3
** Message: don't know how to handle audio/mpeg, mpegversion=(int)1, layer=(int)3
** Message: don't know how to handle audio/mpeg, mpegversion=(int)1, layer=(int)3
** Message: don't know how to handle audio/mpeg, mpegversion=(int)1, layer=(int)3

I finally found why. You just have to install gstreamer0.10-fluendo-mp3

Hope this help

Toussa toussa

Notify plugin for aMSN updated (1.4)

Here is a new version of my plugin.

  • Don't show the event if the user is blocked (and the "don't show blocked user notification" config is set
  • Added OS Check
  • Code cleaning
  • Bumped to version 1.4

Thanks to KaKaRoTo for the blocked system.

MPD Remote control script v0.2

Here is a new version of my console mpd remote script.

Lire la suite

Recomposer un HTML valide après l'avoir tronqué.

Récemment, je me suis occupé de la création d'un site web tout joli tout beau, dans lequel les webmasters peuvent composer certaines parties de leur site web via un éditeur online wysiwyg. Mais à certains endroits, j'avais besoin de mettre juste le début du texte suivi des traditionnels 3 petits points.

Lire la suite

Notify plugin for aMSN updated (1.3)

New version of my notify plugin for aMSN


Download the pugin: notify-plugin-by-Yoda-BZH_2008-10-19.tar.bz2

See my previous post for more information on this plugin.

Augigy SE/LS: Alsa vs OSS4

I finally bought a new sound card: A Sound Blaster Audigy SE (Sound Blaster Audigy SE - Sound Blaster Audigy SE), but lspci says :

└─(~)-> lspci -vv -s 04:09.0
04:09.0 Multimedia audio controller: Creative Labs SB Audigy LS
	Subsystem: Creative Labs Device 100a
	Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 64 (500ns min, 5000ns max)
	Interrupt: pin A routed to IRQ 18
	Region 0: I/O ports at cc00 [size=32]
	Capabilities: <access denied>
	Kernel driver in use: audigyls

Ok, it's an Audigy LS.


Let's configure this card with Alsa. It suggests me to use the ca0106 module. Once detected and the module loaded, I have now hw:0,0, hw:0,1 and hw:0,2. Which are respectively front, rear and center. Apparently I can't have a native 5.1 surround system. I have 3 different cards. But Alsa let's the possibilty to mix differents things with the /etc/asound.conf file.

I tried differentthings. I've been able to set up a correct dmix system, nor a valid surround system, but NOT both. And no one seemed to manage to make that working. I asked for a little help on #alsa@freenode :

<Yoda-BZH>      hi ppl
<Yoda-BZH>      is it possible to have dmix AND surround (5.1) at the same time ? (with ca0106 module)
<wishie>        no
<Yoda-BZH>      seriously ?!
<Zider> hey wishie :)
<wishie>        Yoda-BZH: seriously
<Yoda-BZH>      :(
<Yoda-BZH>      why isn't that possible ?
<Zider> wishie: shouldn't it be possible to hack up an .asoundrc to do that?
<wishie>        because the ca0106 is used as 3 x 2ch devices
<wishie>        and the ca0106 has to use all 3 at once to get 6ch sound
<wishie>        so basically..
<wishie>        you have to mix all 3 streams to get 6ch, then dmix the result
<wishie>        thats where the problem lies.
<wishie>        dmix only accepts a hw device as a slave
<Zider> aha
<wishie>        and which one do you give it ? the 1st, 2nd, or 3rd hw device (each 2ch)
<Zider> none of the above!
<Zider> ;)
<wishie>        exactly
<Zider> didn't know dmix required a hardware device
<wishie>        the ca0106 can also be used in a 1x6ch device mode, but its not implemented
<Zider> ah
<wishie>        i believe this is due to the fact, the buffer becomes insanely small if its used in that mode.
<wishie>        but!
<Zider> so the answer is "no, not yet"
<Zider> :)
<Yoda-BZH>      hmmmm
<Yoda-BZH>      ok
<wishie>        you CAN get it working, IF you want to get compilcated and use PulseAudio aswell
<--     hiptobecubic has quit (No route to host)
<wishie>        i did get it working at one stage, for someone.. cant remember how, though.
<wishie>        i think it involved doing the upmixing, then passing the resulting stream to PA, then back to ALSA..heh
<wishie>        it was nasty, in any event.
<jeeger`>       are the in-kernel drivers in 2.6.27 newer than alsa-1.0.17?
<jeeger`>       because then I could try out the out-of-kernel drivers

So, without external mixing software (pulseaudio, arts, esd ...) it's not possible to have both dmix and surround5.1.


I often read posts on OSS, in particular this one that make me thinking a lot. With this Alsa problem, I decided to try OSS4. They proposes different packages, event a .deb file. I downloaded it and installed.

└─(/home/yoda/usr/share/oss)-> dpkg -i oss-linux-4.0-1016_i386.deb

The package stopped Alsa proprely, detected correctly my sound card and compiled some drivers. Once loaded the audigyls module, I checked my /dev/dsp* devices. And here is the result :

└─(~)-> ls -l /dev/dsp*
lrwxrwxrwx 1 root root 23 sep 26 09:17 /dev/dsp -> /dev/oss/audigyls0/pcm0
lrwxrwxrwx 1 root root 23 sep 26 09:17 /dev/dsp0 -> /dev/oss/audigyls0/pcm0
lrwxrwxrwx 1 root root 23 sep 26 09:17 /dev/dsp1 -> /dev/oss/audigyls0/pcm1
lrwxrwxrwx 1 root root 23 sep 26 09:17 /dev/dsp2 -> /dev/oss/audigyls0/pcm2
lrwxrwxrwx 1 root root 23 sep 26 09:17 /dev/dsp3 -> /dev/oss/audigyls0/pcm3
lrwxrwxrwx 1 root root 23 sep 26 09:17 /dev/dsp_ac3 -> /dev/oss/audigyls0/pcm0
lrwxrwxrwx 1 root root  8 sep 26 09:17 /dev/dsp_in -> /dev/dsp
lrwxrwxrwx 1 root root 23 sep 26 09:17 /dev/dsp_mmap -> /dev/oss/audigyls0/pcm0
lrwxrwxrwx 1 root root 23 sep 26 09:17 /dev/dsp_multich -> /dev/oss/audigyls0/pcm3
lrwxrwxrwx 1 root root 23 sep 26 09:17 /dev/dsp_out -> /dev/oss/audigyls0/pcm0

Well, I admit that that's really cool to have different /dev/dsp? devices for a single sound card. Software mixing is working on a single device, and if you have an old style OSS software (like teamspeak), you can set it to use a different device ... for the same sound card. Really cool !

Oss is bundled with two mixer software, a command line (ossmix) and a graphical tool (ossxmix). Here's a screenshoft of the graphical one : ossxmix_window.jpg

Pretty cool huh ?

Well, I don't understand what everything means ... but I managed quite easily to make a surround system working with software mixing. I just have to enable spread.

All applications has the oss plugin, so every one is happy, and can send all their crappy sound to a valid device without conflict.

The final word

This post is not intented to make the glory of OSS4, but the fact is that OSS4 make the point with it system for this sound card. I really like Alsa, but I can't use it on my system. Sorry Alsa.



Sinon j'ai acheté une Augigy SE, qui est en fait une Audigy LS (cherchez pas...). D'après la doc d'Alsa, il faut que j'utilise le module ca0106. Tout content de pouvoir enfin brancher mon kit 5.1 de logitech, je configure Alsa pour avoir le 5.1. Dans cette configuration, pas de dmix. J'essaye de faire marcher dmix, pas de 5.1. D'après les gens de chez #alsa@Freenode, il N'EST PAS POSSIBLE d'avoir les deux en même temps ! En effet, le module ca0106 émule en quelque sorte le 5.1, en faisant du 3 x 2 canaux. Pour mélanger tous les canaux, il faut créer un machin dans la conf. Sauf que le machin pour dmix, il faut lui filer un nom de périphérique en dur, genre hw:0,0, donc pas moyen de filer le machin de 5.1 qu'on vient de créer. Ok dommage.

Je suis donc passé à OSS4. Et je dois dire que c'est pas mal du tout ! J'ai juste installé le .deb, ça a compilé tout comme il faut. Il y a ossxmix pour configurer tout ça, et j'ai le mixage software ET le surround 5.1 qui ont l'air de marcher comme il faut. Franchement OSS a un lourd passé de Closed Source, mais là il faut dire que ça marche, et ça marche même plutôt bien ! Leur interface graphique me parle pas trop, on sait pas trop à quoi correspondent les boutons ou les titres (genre vmix-in0, lineout-sel, rec-srcmix-mix, ...), mais une fois qu'on a trouvé les bons réglages, ça ne bouge pas.

Je pense que je ferai un billet un peu plus long là-dessus.


MPD Remote control script

Hey, i'm still looking for my best audio player. At the moment i'm testing MPD with Sonata as Front-end.

Unfortunately, mpd doesn't come with a remote controle system that can be used with my Logitech keyboard. So I managed to write mine.

You'll need Audio::MPD, which is aviable in Debian with libaudio-mpd-perl

# Script by Yoda-BZH
# v0.1
#use strict;
use warnings;
use Audio::MPD;
use Getopt::Long;
my($mpdIp, $mpdPort, $mpdPass, $mpd);
$mpdIp = "localhost";
$mpdPort = 6600;
$mpdPass = "";
my %opt;
        "h|help"                => \&usage,
        "i|ip=s"                => \$mpdIp,
        "p|port=i"              => \$mpdPort,
        "q|pass|password=s"     => \$mpdPass,
        "play"                  => \&play,
        "pause"                 => \&pause,
        "fastforward|next"      => \&fastforward,
        "rewind|previous"       => \&rewind,
sub usage() {
        print "Usage: $0 [-h|--help] [-i|--ip ip] [-p|--port port] [-q|--pass|--password password] action\n";
        print "Action can be :\n";
        print " [--play]\n";
        print " [--pause]\n";
        print " [--stop]\n";
        print " [--fastforward|--next]\n";
        print " [--rewind|--previous]\n";
        print "";
sub mpdConnect() {
        if($mpd) {
        $mpd = Audio::MPD->new(hostname => $mpdIp,
                                  port     => $mpdPort,
                                  password => $mpdPass);
sub play() {
sub pause() {
sub fastforward() {
sub rewind() {
exit 1;


Imperial March (Vader's theme, piano)

Imperial March (Vader's theme)

Photos: Feu d'artifice

Nouvelle série de photo sur le feu d'artifice. Cette fois c'est pour le 14 juillet 2006.

Lire la suite

Photos: Feu d'artifice

Voici une série de photo de Juillet 2004. C'était le feu d'artifice du 14 juillet.

Lire la suite

Photos: À la plage (5/5)

Enfin, quelques photos de traces de pas dans le sable.







Photos: À la plage (4/5)

Quelques nuages ...



... et une vue sur la mer.


- page 2 de 6 -