Archive for the ‘Related Links’ Category

Public API now available!

July 31st, 2010 Comments off

Finally, the code of the open source social web gallery phTagr has now an API page available at The API is extracted from source using the API generator plugin for CakePHP which makes the documentation pretty easy. Futher the plugin provides a nice web interface for all classes.

The phTagr API contains the API of cakePHP and the API of phTagr classes. So if you need a code documentation of a class, controller, view, component, helper, theme, etc have a look at, make use of the search function, and get things quicker done.

Categories: Related Links, source Tags: ,

Theme Your CakePHP Application – Make it Mobile Device Aware

July 26th, 2010 4 comments

This post shows how easy your CakePHP applications becomes mobile device aware by using CakePHP theming feature. At the end of this post the mobile theme is selected automatically on requests of mobile devices.

Theming in CakePHP is really a piece of cake! Since CakePHP is a Model-View-Control framework, the data, the data logic and the view is well separated. For theming you just need to replace your view templates without changing the logic or data handling. Theming is quite easy and you don’t need to be a professional software programmer. While a nice theme needs some knowledge of HTML and CSS theming CakePHP requires just basic PHP skills.

CakePHP’s Layout and Views

In standard cases all view templates are located in ./app/views and CakePHP selects by its magic the correct page layout and the view for the current logic. So you have your layouts (the basic document structure) in ./app/views/layouts and your view templates (the specific view of one action) of your current action in ./app/views/[controller]/[action].ctp. For detailed information please have a look at

The CSS and JS files have a little different place. The style sheets are located in ./app/webroot/css and the javascript files are located in ./app/webroot/js.

The important structure of CakePHP’s view templates is shown below:

        layouts/           <-- Location of page layouts
        helpers/           <-- View template helpers
        elements/          <-- Little view templates
            index.ctp      <-- Specific view template of the index action in the home controller
        /themed            <-- Directory of CakePHP themes
    webroot/               <-- Application's webroot (like htdocs for apache)
        css/               <-- Style sheets
        js/                <-- Javascript directory

Now the cool part: You can theme all your views with a very similar view structure. But you don’t have to theme all layouts and views. If your theme does not have a required view CakePHP uses the original one. So you can just theme required layouts and/or views.

The Birth of a New Theme

Now we want to create a mobile version of our application. As example application I use the open source social photo gallery phTagr from I assume that your phTagr gallery is installed and accessible at http://localhost/phtagr. But you can easily adapt these steps to any other CakePHP application.

Basic Folder Structure of a CakePHP Theme

First we need to create a theme folder with its basic theme structure. Goto theme directory ./app/views/themed and create your own theme, I call it “mobile”. Further some required directories are also required. We theme the default layout and some basic actions, for phTagr it is the home, the photo explorer and the image view.

cd app/views/
mkdir -d themed/mobile
cd themed/mobile
mkdir -p layouts elements webroot/css home explorer images

Now we have following folder structure

        layouts/           <-- Default theme layouts
        elements/          <-- Folder for element templates
            css/           <-- Folder for mobile CSS
        home/              <-- Your themed views of home controller
        explorer/          <-- Your themed views of explorer controller
        images/            <-- Your themed views of images controller

Note: ./app/views/themed/mobile is now referred as ./mobile.

Activate Your Theme

To activate the new theme you set it in before_render() at ./app/app_controller.php. Later we automate this theme selection but for now the hard coded version is just fine. Important is, that the views are theme aware by this->view = 'Theme'; and of cause your theme name.

  function beforeRender() {
    // ... other code
    $this->view = "Theme";
    $this->theme = "mobile";

Your Themed Page Layout

If we call now our side http://localhost/phtagr nothing is changed. Thats fine, than CakePHP did not find any themed layouts or views to use and uses the standard one. Therefore we want to change the default layout in ./mobile/layouts/default.ctp to see some differences.

Edit ./mobile/layouts/default.ctp

<?php echo $html->docType('xhtml-strict'); ?>
<html xmlns="">

<title><?php echo $title_for_layout; ?></title>
  echo $html->charset('UTF-8');
  echo $html->meta('icon');

<?php echo $content_for_layout; ?>

Now we see some changes http://localhost/phtagr with a plain layout.

Layout Your Views

My profession is not quite a web designer but here I show you howto style your mobile version.

You create your css in ./mobile/webroot/css/mobile.css and add it to your default theme in the <head> section.

  echo $html->charset('UTF-8');
  echo $html->meta('icon');
  echo $html->css('mobile');
* {
  margin: 0;
  padding: 0;

body {
  width: 100%;
  color: black;
  font-family: Druid, Verdana, Sans;
  font-size: 10pt;
  background: white;

h1,h2,h3 { font-weight: bold; }
h1 { font-size: 130%; }
h2 { font-size: 120%; }
h3 { font-size: 110%; }

a { text-decoration: none; }
a img { border: 1px black solid; }

Add Header and Footer

Now we want to add some containers for header and footer. These parts could be rendered in special containers, CakePHP calls them elements template. Header and footer are perfect candidates for such elements.

Adapt your default HTML body layout in ./mobile/layouts/default.ctp

<div><?php echo View::element('header'); ?></div>
<div><?php echo $content_for_layout; ?></div>
<div><?php echo View::element('header'); ?></div>

Now create the elements ./mobile/elements/header.ctp and ./mobile/elements/footer.ctp.




<p>Social Web Gallery <a href="">phTagr</a> - mobile version.</p>

And we add new styles to ./mobile/webroot/css/mobile.css:

.header * {
  display: inline;
.header {
  display: block;
  background: #3d3;
  padding: 2px 5px;
.header h1 span.subheader {
  color: white;
  font-size: 80%;
  font-style: italic;
.footer {
  display: block;
  background: #888;

Adapt Views

Now some views will be adapted from the original ones. The original versions are located in ./app/views/[controller]/. In the theme they are located in ./app/themed/[theme]/[controller], in ./mobile/[controller].

For a theme view of the index action of the home controller CakePHP will look first in ./mobile/home/index.ctp. If it does not exists CakePHP take the standard one. So I copied the original version index.php to the theme folder ./mobile/home and made some changes.

Further I copied and adapt ./app/views/explorer/index.ctp and ./app/views/images/index.ctp. All other themes are not very important to adapt. The same with the view action of images controller.

For the forms I added some basic form style definitions to ./mobile/webroot/css/mobile.css:

fieldset {
  margin: 5pt;
  border: none;
fieldset legend {
  font-weight: bold;
fieldset div label {
  display: block;
  width: 100%;
fieldset div input[type=textfield],
fieldset div input[type=text] {
  width: 100%;
  font-size: 150%;
input[type=checkbox] + label {
  display: inline;
form * input[type=submit] {
  font-size: 150%;
  border: 2px solid black;
  background: #3d3;
  -moz-border-radius: 3px;
  -webkit-border-radius: 3px;

And styled the flag message:

.message {
  display: block;
  font-size: 120%;
  margin: 5pt;
  padding: 5pt;
  border: 1px solid black;
  background: #fd3;
  -moz-border-radius: 3px;
  -webkit-border-radius: 3px;

Fix iPhone

The iPhone (and iPod Touch) requires a special viewport meta information to render without any scaling. This is added to the default layout in the head section:

<title><?php echo $title_for_layout; ?></title>
<meta name="viewport" content="initial-scale=1.0">

Automatic Theme Selection

After adjusting the views and improving the style sheets the automatic theme switch is build in. For this we need the RequestHandler component in our basic app_controller.php which is added to the $components variable:

  var $components = array('RequestHandler');

We use the isMobile() function of RequestHandler component to evaluate the client device type and select the mobile theme for mobile devices

  function beforeRender() {
    // ... other code
    if ($this->RequestHandler->isMobile()) {
      $this->view = "Theme";
      $this->theme = "mobile";


The theme feature of CakePHP is straight forward and easy to use. You can customize your CakePHP application easily by changing the page layout or partial theming by writing single view templates of specific controller actions. The example showed how easy your application becomes mobile device aware.

You can see the full mobile theme of phTagr at

Categories: tools, user Tags: ,

phTagr 2.1.2 released!

July 11th, 2010 Comments off

2.1.1 phTagr is released! It has a simplified upload function which is enabled by default and replaces the advance file browser. Users have now an upload menu entry where uploaded files are stored in a daily upload directory. ZIP archives are extracted automatically. Uploaded and extracted files are imported and are shown immediately. Therefore, users can upload their media within three clicks and the upload form has now five upload field instead of one.

The next big improvement is the quick search which covers sub word. The quick search of ‘ice‘ returns also media with tags of ‘slice‘ or ‘rice‘.

phTagr is build on top of the MVC framework CakePHP and uses now CakePHP 1.3 instead of CakePHP 1.2. You have to upgrade your CakePHP if you use SVN trunk. See How To Migrate Phtagr for more details.

An admin user can now see the access level of other users and can change these. This feature was requested to handle private or malicious media.

phTagr supports now Dutch as new language – Thanks to Remy Wetzels. See also How To Translate.

Following Tickets where closed since 2.1.1

  • #14 – Automatic media import on upload
  • #63 – Multiple inputs for HTML upload
  • #90 – Wish: search on part of a tag
  • #110 – Admin rights: Change access level of others
  • #89 – Wish: change “Welcome to phTagr” via system preferences
  • #83 – Wrong import of files with UTF-8 multi-byte characters
  • #86 – PEAR path is missing in include_path variable
  • #85 – User with 0 quota, file uploaded shows up in “My Files” even it said “Could not upload”
  • #87 – User can see root of filesystem in “My Files”
  • #91 – Search on unknown string returns “Array” as search key
  • #93 – Shorten the user authentication keys
  • #112 – Broken Unzip functionality

Simplified Upload Function

July 9th, 2010 Comments off

Recently the upload function of phTagr was simplified and is enabled as default by now. The older but more advanced file browser could be enabled in the general settings of the user.

By the default the user has an upload button in the menu where he can upload files and ZIP archives. These files are uploaded to a daily created upload directory and are imported automatically. After the successful upload process some of the new imported photos or videos are shown directly in the upload form and gives a great feedback to the user.

This awesome improvement simplifies the technical modeled behavior of the file browser where two separate steps of uploading and importing are necessary to show your media in the gallery. Now new photos could be uploaded and shown in the gallery with only three simple clicks.


Have fun while using phTagr!

phTagr 2.1.1 released!

May 8th, 2010 Comments off

I’m happy to announce phTagr 2.1.1 which simplifies the setup and adds multi-language support. As first language German was submitted. You can submit your language to translation [AT] See How To Translate for further information.

Further, the geo tagging was improved and some minor bugs were fixed.

You can download it from SourceForge (ca. 2.9 MB). Please do not hesitate to report any success story, bugs or feature request. See How To Help for further details.

Following Tickets where solved since 2.1

Setup and Requirements:

  • Fix #6 (Minimum setup requirements)
  • Fix #74 (Automatic setup redirection)
  • Fix #13 (Customizable gallery title)
  • Fix #64 (Add multi-language support (internationalization))
  • Fix #66 (Fallback of getId3 at ImageFilter if exiftool is not available)
  • Fix #67 (Fallback of getId3 at VideoFilter if ffmpeg is not available)
  • Fix #68 (Include required PEAR files to vendor directory)

Explorer: Geotagging

  • Fix #78 (Resizeable Google Map)
  • Fix #79 (Goto address input for geo map)
  • Fix #25 (Current media selection in map)


  • Fix #80 (Show user of random media at home)
  • Fix #81 (User information is droped on date links)
  • Fix #69 (Incorrect import of south and west geo location in ImageFilter)
  • Fix #82 (Place cakeDebug output into html layout)
Categories: announce, Related Links, user Tags:

phTagr spricht Deutsch!

May 8th, 2010 Comments off

Since r523 phTagr supports multi-languages and supports initially German besides English. A new wikipage describes how to create translations for your language. Please do not hesitate to contribute to this great project and send your language files to translation [AT]

Thanks to cakePHP which has a build in language detector. If phTagr supports the language of your browser, phTagr will answer in your language.

Categories: info, Related Links, user Tags:

Resize Control PResizeControl for Google Maps

March 20th, 2010 4 comments

This Google map control adds a dynamic resize function to Google’s map API: You can enlarge or shrink the size of your google map via the resize handle in the right lower corner of the map.

The map control PResizeControl is based on map-in-a-box from Wolfgang Pichler (which bases on Dynamically Resize Google Maps With Mouse). Compared to Wolfgang Pichler’s version it is completed as standalone Google Map control. It also embeds the resize handle image and does not need an external image file (only older IE’s below version 8 could not handle embedded data (But IMHO this is a feature – not a bug!). Further you can resize only the height or widht depending on your configuration. Minimum and maximum of height and/or width is also suppored.

<script type="text/javascript" src=""></script>
<!-- Include resize control PResizeControl -->
<script type="text/javascript" src="./presizecontrol.js"></script>
function initialize() {
  if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("map"));
    map.setCenter(new GLatLng(52.521653, 13.41091), 14);
    // Add resize control PResizeControl with default settings.
    map.addControl(new PResizeControl());
<body onload="initialize">
<div id="map" style="width: 450px; height: 250px;"></div>

Note: The PResizeControl is used in the open-source project phTagr – a social photo gallery for its Geo coding and map display. The javascript file ./presizecontrol.js is extracted from the source of pmap.js of the photo gallery phtagr. Updates of PResizeControl will be commited to the phtagr source.

Variables of PResizeControl

Resize modes. Possible values are PResizeControl.RESIZE_BOTH, PResizeControl.RESIZE_WIDTH or PResizeControl.RESIZE_HEIGHT. Default is PResizeControl.RESIZE_BOTH
Minimal width of the map. 0 disables the minimum width. Default is 150.
Minimal height of the map. 0 disables the minimum height. Default is 150.
Maximal width of the map. 0 disables the minimum width. Default is 0 (disabled).
Maximal height of the map. 0 disables the minimum height. Default is 0 (disabled).

More PResizeControl examples

PResizeControl: Resize Width Only

var resizeControl2 = new PResizeControl();
map2.addControl(new resizeControl2);
resizeControl2.mode = PResizeControl.RESIZE_WIDTH;

PResizeControl: Resize Height Only

var resizeControl3 = new PResizeControl();
map3.addControl(new resizeControl3);
resizeControl3.mode = PResizeControl.RESIZE_HEIGHT;

PResizeControl: Minimal Size

var resizeControl4 = new PResizeControl();
resizeControl4.minWidth = 450;
resizeControl4.minHeight = 250;

PResizeControl: Maximum Size

var resizeControl5 = new PResizeControl();
resizeControl5.maxWidth = 450;
resizeControl5.maxHeight = 250;
Categories: Related Links, source, tools Tags: , , ,

phTagr supports OpenShare Network

January 9th, 2010 Comments off

phTagr joined the OpenShare network which is the first free banner exchange service targeted at open and free source project. The idea is great but simple: You advertise other open source projects – the others advertise your project.

phTagr needs reputation and/or publicity – OpenShare seems to be a fair and great opertunity. Thank you OpenShare and good luck for your idea!

PS: If you know another way how to promote this great project, please speak up!

Categories: Related Links Tags:

phTagr runs on free web hoster!

January 9th, 2010 Comments off

I was just curious if phtagr runs fine on a free web hoster. And yes – it does and does a great job! This entry shows how you can setup your own photo web gallery – totally for free!

I chose the free hoster which comes with

  • Spam and ads free
  • 1,6 GB free storage
  • PHP
  • MySql database

… so all I need for running the gallery.

I signup at for the free account, entered my new domain (of cause I choose the name phtagr), entered my name, email, and address. Then a captcha – success, I am human. After a few seconds I received an confirmation email with my new web space, username, password for the cPanel, and FTP.

Signup for a free web space at

So login to cPanel  for creating a mysql database – called phtagr, which becomes phtagrme_phtagr.

cPanel of

Successfull creation of a MySQL database

Successfull creation of a MySQL database

In the meanwhile I downloaded the latest phtagr source (r505) and extracted it locally. After doing that I was uploading it via FTP (FileZilla) the provided www directory of my new webspace.

Upload phtagr via FTP with FileZilla

Upload phtagr via FTP with FileZilla

Now its time to setup the new gallery! I opend the setup page of and followed the instructions. Everything worked fine. The connection to the database and the admin user creation had no problems.

Setup welcome screen

Setup welcome screen

Setup of database connection

Setup of database connection

Setup of admin account

Setup of admin account

I skipped these optional step

I skipped these optional step

As test images I used the screenshots which I did so far. I zipped them, uploaded the zip archive and imported the files after successful upload. Now it was time for some tagging.

Successful upload and extraction of the zip archive

Successful upload and extraction of the zip archive

Some tagging within the photo explorer

Some tagging within the photo explorer

The home page of phtagr

The startup page of phtagr

I wanted also to geo tag some images so I created a new google maps key (you need a google account for it) for the gallery URL The key was entered in the System -> Commands and now I was able to geo tag, too!

Entering the new key for google maps

Entering the new key for google maps

Geotagging with google maps

Geotagging with google maps

And as last test I did a WebDAV connection with cadaver to That worked, too!

WebDAV connection to gallery

WebDAV connection to my gallery files

So all in all it made lots of fun seeing this great gallery running on a free web hoster. You can upload your photos, tag them – also with geo location, see your images in the build-in slideshow, add other users with there upload quota, etc.

When do you install your own phTagr?

You can see all screenshots at the demo page or some screenhost at

PS: What does not worked well was an initial setup at where the database connection was not working for some reasons. Also the sending of email did not work out of the box at

Eliminated Software Requirements

January 5th, 2010 Comments off

I am happy to announce with revision r505 that the software requirements are finally reduced to a minimum! phTagr requires now only a basic LAMP:

  • Webserver (tested with Apache)
  • PHP (tested with PHP5)
  • GD or ImageMagick
  • database engine (tested with mysql)

This change improves and simplifies the initial steps to run this great gallery! Further, the installation documentation was updated and improved.

exiftool and ffmpeg are no longer required to run the basic operations. Further the dependend PEAR libraries are now included into the software. The new version could be downloaded as  ZIP archive or TAR ball – happy  testing.

Without exiftool the meta data like tags, categories or geo location are imported from photos but not be written back to them. Without ffmpeg only flash movies could be imported. If you have ffmpeg other video formats are supported and the videos are automatically converted from AVI, MPEG or MOV to the flash file format. ffmpeg also creates the a video preview. If now preview exists a default image is shown.