If you manage :focus CSS styles for certain input controls you may have noticed that Safari attempts against your pretty innovative design adding a blurry blue outline effect.

You can avoid this adding this:

input:focus {
  outline-width:0;
  ...
}

And that’s all.


I’m going to show a way that I’ve found to easily edit N1 relationships with the admin generator of symfony 1.2 Surely it can be polished, and maybe it could be done better another way, if you know how please let me know.

We are going to use the next model schema:

# config/schema.yml
propel:
  lista:
    id:      ~
    name:    varchar(255)
    type:    varchar(255)

  lista_item:
    id:      ~
    lista_id: {type: integer, foreignTable: lista, foreignReference: id, required: true }
    name:    varchar(255)

There is a table of lists, and a table of list items related with the lists, so a list can contain n list items. The problem is to achieve the edition of the list properties and related list items on the same form.

Keep reading…


Today I needed to access a webserver with phpMyAdmin configured as default page if no virtual host matched the requested one. It was configured to deny access from outside so my solution was to use a SSH tunnel:

carlos$ ssh -L 10080:192.168.1.3:80 user@host

So I can access phpMyAdmin writting this in my browser address bar:

localhost:10080

That’s all!


Recently I discovered that Firefox lets you override alert and confirm window object methods. I tried this with prototype and surprisingly it just worked! (Note that it is not tested in IE or Opera and others yet, but it also works in Safari).

<div id="test" style="background:red;color:white;display:none;"></div>
<script type="text/javascript">
window.confirm = function (s) { alert(s); };
window.alert = function (s) { $('test').update(s).show(); }
confirm('Ok?');
</script>


I hope the title is self-explanatory …

Several times, in a symfony project or a project which runs with the help of the prototype library, some problems arise regarding the scope of certain javascripts variables declared inside ajax request (that can be theyselves declared within other ajax request).

Usually , you need to access certain javascript varible or function that is declared on a place which can be outside the scope of the ajax request you’re calling that variable / function from.

This example: (written in symfony) will not work, because it’s written on an ajax request response already

echo javascript_tag("
 var pageOkCodigoAcceso='".url_for('corbatas/compra')."';
".remote_function(array(
 'update'=>'div_formulario_codigo_acceso',
 'url'   => 'forms/codigoAcceso',
 'script'=> 'true',
 'with' => "'complete_callback=garbageDisposal'",
 'complete' => "garbageDisposal()",
 'method'=>'get'))."
function garbageDisposal()
 {
 $('codigoAcceso_submitButton').value='activar oferta';
 }
 ");

in this case, pageOkCodigoAcceso is a javascript variable which the ajax-generated content at div_formulario_codigo_acceso will need to access.
garbageDisposal() is a simple javascript function that will be executed upon completeness of the ajax request described inside the remote_function tag.

Keep reading…


dWhen executing this code:

$this->items = $object->getItens();
...
foreach($this->items as $item)
{
...yadda yadda $item->getId() yadda yadada
}

within a symfony action, the php engine throws:

Notice: Indirect modification of overloaded property  xxxActions::$items has no effect in xxxactions.class.php

That’s related to a php bug , whose implications in symfony are described here. It looks like it’s related to php 5.2. I can see it appears on version 5.2.0  . It looks like the bug is gone in version 5.2.4.

Anyway, the simple workaround: insted of iterate through $this->items, we do:

$items = $object->getItems();
...
foreach($items as $item)
{
...yadda yadda $item->getId() yadda yadda
}
$this->items = $items;

and that’s it.


You can see regular expression examples at this site. Very useful.

This is the content:

  • Examples
  • Numeric Ranges
  • Floating Point Numbers
  • Email Addresses
  • Valid Dates
  • Credit Card Numbers
  • Matching Complete Lines
  • Deleting Duplicate Lines
  • Programming
  • Two Near Words

I was looking for some actions sharing methods weird solution (since I was trying to apply a per-action classes model, and I needed to use methods from one action onto another), and I had no luck at all.

However, what I did find out was fabien saying repeteadly that actions code should not be messy, hard or “thick”, if the code inside your “actions” file is getting fatter, put it away on the model layer or using more helpers.

End of the reminder.


The concept around this is to serve a 1px image through a PHP script. This allows you to insert a new record or update an existing one about read mails.

In your mail you only have to insert an image tag like this at the end of the template:

<img src="<?php echo url_for('stats/image?bulletin='.$id, 'absolute=true') ?>" alt="px.gif" />

And inside your actions.class.php:

public function executeImage()
{
  if ($bulletin = BulletinPeer::retrieveByPk($this->getRequestParameter('bulletin')))
  {
    // We do database stuff here
  }
  // And serve our image
  $this->redirect('http://'.$_SERVER['SERVER_NAME'].'/images/px.gif');
}

Update:
You can specify a routing rule to match /px.gif?bulletin=id (I don’t remember if you have to modify .htaccess in /web)


Nuestros queridos amigos de Joomla / Joomla Spanish, ni sé ni quiero echar las culpas a nadie, se han olvidado un trozo de código en una query para borrar imágenes y saltaba el mensajito de:

No tiene permiso para acceder a esta sección

o algo similar.

Lo que hay que hacer es, en la línea 251 del fichero /path/to/my/joomla/administrator/components/com_media/admin.media.html.php, añadir &amp;<?php josSpoofValue() ?>=1 justo detrás de listdir=<?php echo $listdir; ?>.

La línea al completo (Joomla Spanish version, claro) quedaría así (L251):

<a href="index2.php?option=com_media&amp;task=delete&amp;delFile=<?php echo $file; ?>&amp;
  listdir=<?php echo $listdir; ?>&amp;<?php josSpoofValue() ?>=1" target="_top"
  onclick="return deleteImage('<?php echo $file; ?>');" title="Borrar item">

En fin, eso es todo, amigos.