Menu

#1 scan vars in template

open
nobody
5
2008-11-26
2008-11-26
orouk
No

You could add this method to your class.
It can avoid to have errors with setVars()

class myOdfClass extends Odf
{

public function scanTemplate()
{
$subject = $this->__toString();

$pattern = '/.*\\'.parent::DELIMITER_LEFT.'(.*)\\'.parent::DELIMITER_RIGHT.'.*/mU';

preg_match_all($pattern, $subject, $matches);

return $matches[1];
}

}

// object instanciation
$odf = new myOdfClass ("tpl/myTemplate.odt");

// Get marks included in template
$marks = $odf->scanTemplate();

// Replace Vars/marks by values or NULL values
foreach ($marks as $val) {

if (isset($defaultVal[$val])) {

$odf->setVars($val, $defaultVal[$val]);

} else {
$odf->setVars($val, '');
}

} // end foreach ($marks ...

Discussion


Log in to post a comment.

MongoDB Logo MongoDB