The administration themes were a request from a customer. He does own
development with developer, stage and production servers and wanted a
subtle way to see which server he was currently changing.
A theme consists of a color set, background images, the icon and a
progress animation. At the moment 7 colors are available in trunk. Because of the favorite icons it is easier to spot the right tabs, too.
2011-07-22
2011-07-21
Strida MAS Upgrade II

Bend handle bars and new grips

Brake cables

Front light
I replaced the Sigma PowerLed (90 lux) with a B&M Ixon IQ Speed (50 lux). In numbers it has less light but in real it is more. It throws a trapezoid of light on the street. Because of the bend handle bars I got problems with the brake cables. A small spacer bar fixed the problem and I really like the look.
Rear Light

The reflector stripe is in the middle, the light is at the top and the battery case at the bottom. The light uses two LEDs that are broken up to a bright line of light. They provide great visibility. Here is no blinking mode (Which is illegal in Germany anyway). I don't like blinking lights because they make it really difficult to recognize distance changes. The light uses the convenient AA battery format.
The light is available in two versions. A basic version "Permanent" and the "Senso" version featuring a light/movement sensor. I know from my previous rear light (IX Back Senso) that the sensor is too sensitive. So I got the "Toplight Line Permanent".
Strida MAS upgraded (Number One)
2011-07-13
Papaya Callbacks
papaya CMS got a new class PapayaObjectCallbacks recently. The class can be used to define and handle callbacks for other classes and relies heavily on the magic methods. It addresses several problems.
PapayaObjectCallbacks is defined as a sub object with lazy initialization. An array is used to define the callbacks functions and the default return value. If you have a complex/large list of callback functions, I suggest to define a new class that extends PapayaObjectCallbacks. With a special class you can define the dynamic properties/methods using PHPDoc comments.
To call the function is really simple. Just do it!
If no function was assigned to the callback the defined default will be returned. Otherwise the assigned function is called and its return value will be used. So no validation of the assignment is needed.
The user (of your class with the callbacks) can assign the callback function, now.
In PHP equal or greater 5.3 an anonymous function is possible:
The first argument of the callback is always a context object. The reason for this is, that we still have to be PHP 5.2 compatible, so we can not use the PHP syntax for it. In addition you can edit the context without a local variable. By default this is an instance of stdClass but you can assign any object.
If you like to see the implementation, you can find it in the papaya SVN.
- Code duplication if you have several callbacks in one class
- Validation before you can use the callback
- Easy to use, self speaking API for callbacks
PapayaObjectCallbacks is defined as a sub object with lazy initialization. An array is used to define the callbacks functions and the default return value. If you have a complex/large list of callback functions, I suggest to define a new class that extends PapayaObjectCallbacks. With a special class you can define the dynamic properties/methods using PHPDoc comments.
public function callbacks(PapayaObjectCallbacks $callbacks = NULL) {
if (isset($callbacks)) {
$this->_callbacks = $callbacks;
} elseif (is_null($this->_callbacks)) {
$this->_callbacks = new PapayaObjectCallbacks(
array(
'onEventOne' => TRUE,
'onEventTwo' => 'default'
)
);
}
return $this->_callbacks;
}
To call the function is really simple. Just do it!
$result = $this->callbacks()->onEventOne($argument);
If no function was assigned to the callback the defined default will be returned. Otherwise the assigned function is called and its return value will be used. So no validation of the assignment is needed.
The user (of your class with the callbacks) can assign the callback function, now.
$someObject->callbacks()->onEventOne = array($this, 'someCallbackHandler');
In PHP equal or greater 5.3 an anonymous function is possible:
$someObject->callbacks()->onEventOne = function($context, $argumentOne) { ... };
The first argument of the callback is always a context object. The reason for this is, that we still have to be PHP 5.2 compatible, so we can not use the PHP syntax for it. In addition you can edit the context without a local variable. By default this is an instance of stdClass but you can assign any object.
$someObject->callbacks()->onEventOne->context->someProperty = 'some value';
If you like to see the implementation, you can find it in the papaya SVN.
Subscribe to:
Posts (Atom)