This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
khosb/modules/email/classes/Model/Email/Template/Translate.php

41 lines
962 B
PHP
Raw Normal View History

2010-11-29 22:41:08 +00:00
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
2013-03-19 22:35:19 +00:00
* @package Email
2010-11-29 22:41:08 +00:00
* @category Models
* @author Deon George
2013-03-19 22:35:19 +00:00
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
2010-11-29 22:41:08 +00:00
*/
class Model_Email_Template_Translate extends ORM_OSB {
2010-11-29 22:41:08 +00:00
// This module doesnt keep track of column updates automatically
protected $_created_column = FALSE;
protected $_updated_column = FALSE;
public function variables($field) {
$results = array();
$matches = array();
preg_match_all('/%([A-Z0-9_]+)%/U',$this->$field,$matches,PREG_OFFSET_CAPTURE);
foreach ($matches[1] as $k => $v)
$results[$v[1]] = $v[0];
$results = array_unique($results);
asort($results);
return $results;
}
public function resolve($data,$column) {
$output = $this->display($column);
foreach ($this->variables($column) as $k => $v)
$output = str_replace('%'.$v.'%',$data[$v],$output);
return $output;
}
2010-11-29 22:41:08 +00:00
}
?>