log =& LoggerManager::getLogger(__CLASS__); } /* rewrite adress */ public static function computeUrl($tableId, $columnId, $inputValues) { if (empty($inputValues[$columnId])) { return ''; } $url = $inputValues[$columnId]; if (substr($url, 0, 4) <> 'http') { $url = 'http://www.exemple.com/view.asp?DocId=' . $url; } return sprintf('%s', $url, $url); } /* create a recenter url */ public static function computeRecenterUrl($tableId, $inputValues) { $url = self::$baseUrl; $url .= "?layer=$tableId&id=" . $inputValues['row_id']; return array('recenter_url' => $url); } /* rewrite adress */ public static function computeAdress ($tableId, $columnId, $inputValues) { list($name, $street) = explode(',', $inputValues[$columnId]); $strName = ucfirst(trim($street)); if ($strName != '' && $strName[strlen($strName) - 1] != '-') { $strName .= ' '; } $strName .= $name; $num = $inputValues['hnr']; $newAdress = $strName.' '.$num; return $newAdress; } public static function emptyNum ($tableId, $columnId, $inputValues) { return ''; } public function initialize() { self::$baseUrl = $this->getConfig()->recenterBaseUrl; $tablesPlugin = $this->cartoclient->getPluginManager()->tables; $registry = $tablesPlugin->getTableRulesRegistry(); $outputType = $this->cartoclient->getOutputType(); // Following rules are only applied in the HTML viewer frame (i.e. not in PDF) if ($outputType == Cartoclient::OUTPUT_HTML_VIEWER) { /* call filter to add an url */ $registry->addCellFilter('query', '*', 'url*', NULL, array('ClientExempleTableRules', 'computeUrl')); /* call filter to add an url in a new column */ $registry->addColumnAdder('query', '*', new ColumnPosition(ColumnPosition::TYPE_ABSOLUTE, -1), array('recenter_url'), NULL, array('ClientExempleTableRules', 'computeRecenterUrl')); } /* call filter to reorder the adress element */ $registry->addCellFilter('query', 'adresses_postales', 'str_name', array('str_name', 'hnr'), array('ClientExempleTableRules', 'computeAdress')); /* call filter to display nothing for elements 'hnr' */ $registry->addCellFilter('query', 'adresses_postales', 'hnr', array(), array('ClientExempleTableRules', 'emptyNum')); /* unselect the 'row_id' column */ $registry->addColumnUnselector('*', '*', array('row_id')); } } ?>