The class has no specific methods from the start. Each information request is passed through formatInfoResults method and search requests are passed through formatSearchResults method.
Extended methods displayed in the code below will first call it's parent method and then perform additional modifications on the results.
<?php
class Giscuit_Db_Table_Layer_Worldboundaries extends Giscuit_Db_Table_Layer_Abstract
{
/**
* Format information results
*
* @param stdClass $itemField - field descriptor
* @param string $name - field name
* @param mixed $value - field value
* @param Zend_Form $form - layer form
* @return void
*/
public function formatInfoResults($itemField, $name, $value, $form)
{
//Call parent class method
parent::formatInfoResults($itemField, $name, $value, $form);
$translate = Zend_Registry::get('Zend_Translate');
//Check for "name" field which is to be modified
if ($name == 'name') {
//Create link to wikipedia and overwrite the element's html
$link = 'http://en.wikipedia.org/wiki/' . $value;
$itemField->html = $translate->_($name) . ": <a target=\"_blank\" href=\"{$link}\" title=\"{$value}\">{$value}</a>";
}}
/**
* Format search results
*
* @param Zend_Db_Table_Rowset $rows - resulting rows
* @param Zend_Form $form - layer form
* @return Zend_Db_Table_Rowset
*/
public function formatSearchResults($rows, $form)
{
//Call parent class method and get results
$rows = parent::formatSearchResults($rows, $form);
$translate = Zend_Registry::get('Zend_Translate');
//Iterate through results
foreach ($rows as $key => $value) {
//Create link to wikipedia and assign it to each "name" field
$link = 'http://en.wikipedia.org/wiki/' . $rows[$key]['name'];
$rows[$key]['name'] = "<a target=\"_blank\" href=\"{$link}\" title=\"{$rows[$key]['name']}\">{$rows[$key]['name']}</a>";
}
return $rows;
}}
Put the code above into "library/Giscuit/Db/Table/Layer/Worldboundaries.php" file and check the results by using Information and Search tool on World boundaries layer.
Upon displaying results the country's name should be a link which will open a new web page with a link to the it's wikipedia page.
You can extend the default functionality for any layer by overwriting their existing methods.