Crear un panel de administración con layout personalizado con CakePHP

¿Quieres un panel de administración separado en tu aplicación CakePHP? Para crear uno necesitaremos editar algunos ficheros y crear algunos nuevos. También crearemos un theme para el panel de administración, y lo utilizaremos cuando entremos como administradores.

Usaremos CakePHP 2.x para este tutorial.

1. Edita /app/Config/core.php

Configure::write('Routing.prefixes', array('admin'));
Añadimos el prefijo admin y lo descomentamos.

2.  Crea un layout para admin

– ve a /app/View/Layouts
– haz una copia de default.ctp y renómbrala como admin.ctp

3. Edita el layout admin.ctp

– haz las modificaciones necesarias al layout

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
    <?php echo $this->Html->charset(); ?>
    <title>Administrator | <?php echo $title_for_layout; ?></title>
        echo $this->fetch('meta');
        echo $this->Html->css(array('admin'));
        echo $this->fetch('css');
        echo $this->fetch('script');
    <div id="container">
        <div id="header">
            <div class="logo"></div>
            <div class="clear"></div>
        <div id="content-wrapper">
            <?php echo $this->fetch('content'); ?>
        <div id="footer">
            © <?php echo date("Y");?> - All rights         
             <?php echo $this->element('sql_dump'); ?>   

4. Crea la hoja de estilos admin.css

– /app/webroot/css/admin.css
– añade los estilos que desees

5. Edita AppController.php

– Añade la comprobación de prefijo en tu función beforeFilter para cargar tu layout admin

public function beforeFilter() {
    if ((isset($this->params['prefix']) && ($this->params['prefix'] == 'admin'))) {
        $this->layout = 'admin';

6. Edit UsersController.php

– We need to tell UsersController that it needs to run the beforeFilter from AppController (remember to put this in all your controllers).

public function beforeFilter() {   
    // Controller spesific beforeFilter

– Crea una función de administración:

public function admin_dashboard() {
        $title_for_layout = 'Dashbord';

– Crea la vista para la función (/app/Views/Users/admin_dashboard.ctp)

<p>Bienvenido al Panel de Administración</p>

7. Apunta el navegador a la localización de tu admin
– Si tienes funciones de login y Auth en juego, intenta establecer los permisos de autentificación a * en UsersController.php


– Ve a:
– Tu nuevo layout de administración debería renderizarse ahora, y deberías ver el mensaje “Bienvenido al Panel de Administración”.

8. Crea más funciones + Controllers + Views + Models
– Recuerda poner admin_ en todas las funciones/views de administración
– Cuando se usa el prefijo “admin_”, se renderizará el layout admin.

Borrar directorios .svn recursivamente

Habiéndo cambiado a git ya no eran necesarios los directorios .svn que plagaban mis proyectos. Así que me puse a de buscar una forma de borrarlos rápidamente:

rm -rf `find . -type d -name .svn`

La primera parte del comando [ rm – rf ] es para borrar, la segunda [ find . -type d -name .svn ] es el predicado a eliminar: todos los archivos/directorios de nombre .svn dentro del directorio actual.

Otras formas de hacerlo:

find . -type d -name '.svn' -print0 | xargs -0 rm -rdf 
find . -name .svn -print0 | xargs -0 rm -rf
find . -name .svn -exec 'rm -rf {};'


Recursively delete .svn directories
Unix Command To Remove Subversion .svn Directories
Recursively remove all .svn directories

02. Instalar Zend Server CE 5.6.0 en Ubuntu 12.10

En el momento de la redacción de este artículo (27/11/2012), la versión actual descargable de Zend Server es la 5.6.0 SP4 (válida para PHP 5.2 y 5.3).

Para instalarso seguiremos los siguientes pasos:

1. Descargamos el script de instalación (disponible en RPM/DEB) desde el sitio oficial de Zend.

2. Accedemos al directorio creado tras descomprimirlo. Dependiendo de si queremos instalar Zend Server con soporte para PHP 5.2 o 5.3 ejecutaremos:

– Para PHP 5.2: # sudo ./ 5.2 ce
– Para PHP 5.3: # sudo ./ 5.3 ce

Una vez finalice la instalación podemos ingresar vía web al panel de administración de Zend Server, desde las siguientes URLs:

– Modo seguro: https://localhost:10082/ZendServer/
– Modo normal: http://localhost:10081/ZendServer/

01. Comenzando a desarrollar con Android

If you are interested in developing applications for Android, then the first thing you’ll need to know is what tools will be required to create your applications and publish them on the Android Market. Below is a quick list with links to getting you started. Best of all, they are all free…

  • Android SDK

You’ll need to start by downloading the Android SDK (Software Development Kit):

Download the Android SDK

  • Eclipse IDE

The Eclipse IDE (Integrated Development Environment) is the preferred environment as the tools needed to create, build, test, and deploy are easily invoked from within the IDE. The Eclipse Classic version is the recommended IDE (Eclipse IDE for Java Developers):

Eclipse Downloads

  • ADT Plugin for Eclipse

The ADT plugin extends the capabilities of Eclipse. It provides an integrated environment from which to build Android application:

Installing the Android ADT plugin for Eclipse

  • SQLite Database Browser

If your application requires a data storage mechanism, Android includes support for SQLite. If you need to create, edit, or view the contents of the database, the SQLite database browser is for you:

Download SQLite Data Browser from

  • Graphics Editor

For graphics development such as icons, buttons, backgrounds, etc., try Inkscape, a free vector graphics editor.

Download InkscapeOfficial Release Packages

A good place to start: Inkscape Tutorial -Shiny Button

  • Version Control System (VCS)

As you develop your application, you will no doubt need to keep track of the changes that you make in the code. One VCS to consider is EGit, an Eclipse Team provider for the Git version control system. EGit is installed through the Eclipse IDE, see the following links for details:

Install the Latest Version of EGit

[FFMPEG] Conversión de AVCHD a MP4/H264/AAC con FFMPEG

I have a Canon HF200 HD video camera, which records to AVCHD format. AVCHD is H.264 encoded video and AC-3 encoded audio in a MPEG-2 Transport Stream (m2ts, mts) container. This format is not supported by Aperture 3, which I use to store my video.

With Blizzard’s help, I figured out an ffmpeg command-line to convert to H.264 encoded video and AAC encoded audio in an MPEG-4 (mp4) container. This is supported by Aperture 3 and other Quicktime apps.

$ ffmpeg -sameq -ab 256k -i input-file.m2ts -s hd1080 output-file.mp4 -acodec aac

Command-line order is important, which is infuriating. If you move the -s or -ab arguments, they may not work. Add -deinterlace if the source videos are interlaced, which mine were originally until I turned it off. The only downside to this is that it generates huge output files, on the order of 4-5x greater than the input file.

Update, 28 April 2010: Alexander Wauck emailed me to say that re-encoding the video isn’t necessary, and that the existing H.264 video could be moved from the m2ts container to the mp4 container with a command-line like this:

$ ffmpeg -i input-file.m2ts -ab 256k -vcodec copy -acodec aac output-file.mp4

And he’s right… as long as you don’t need to deinterlace the video. With the whatever-random-ffmpeg-trunk checkout I have, adding -deinterlace to the command-line segfaults. I actually had tried -vcodec copy early in my experiments but abandoned it after I found that it didn’t deinterlace. I had forgotten to try it again after I moved past my older interlaced videos. Thanks Alex!

[PHP] Librerías de Manipulación de Imágenes para PHP

Librerías de Manipulación de Imágenes para PHP

Otras librerías de manipulación de imágenes (y lenguajes que soportan directamente):

Ver también:

I’m designing a website and I need to:

  • Upload the image
  • Validate that it’s an image (and not, oh I don’t know…. a virus 🙂 )
  • Resize the Image
  • convert to jpg

Essentially basic image upload

Instead of writing my own I’m trying to find a php class that let’s me do all this, because as Jeff Atwood said, “never design what you can steal”

Now before you go ahead and downvote because I didn’t do my research, I did:

Googling this brings up a huge amount of results, which is the problem, I don’t know which results are useful and which are trash!

So far, Ive found:

Does anyone have any experience with these classes? Can you recommend an outstanding image upload class?

If you want to make the uploader a tiny bit better than just an input type=file, try:

: Python