*/ /** * patTemplate modfifier: Dictionary * * Use dictionary record * * @version 0.2.1 * @package Wombat * @subpackage patTemplate */ class patTemplate_Modifier_Dictionary extends patTemplate_Modifier { /** * dictionary * @var WBDictionary */ private $dict; /** * modify the value * * @access public * @param string value * @return string modified value */ public function modify($value, $params = array()) { $params = array_merge(array( 'data' => '', 'dict' => 'URL' ), $params); if (empty($value)) { return ''; } // start dictionary $this->dict = WBClass::create('WBDictionary_' . ucfirst($params['dict'])); try { $this->dict->load($value); } catch (Exception $e) { return ''; } if (empty($params['data'])) { return $this->dict->getWord(); } $data = $this->dict->get(); if (empty($data[$params['data']])) { return ''; } return $data[$params['data']]; } }