$doc->load('template.xml'); $head = $doc->getElementsByTagName('head')->item(0); $body = $doc->getElementsByTagName('body')->item(0); $ma = array('base' => new BaseModule('./base'), 'company' => new CompanyModule('./company'), 'service' => new ServiceModule('./service'), 'connect' => new ConnectModule('./connect'), 'bill' => new BillModule('./bill'), 'contact' => new ContactModule('./contact')); # -- make module selection accordinly to user option -- if (isset($_GET['op']) && isset($ma[$_GET['op']])) { $option = $_GET['op']; } else { $option = 'company'; } $ma[$option]->select(); # -- Include CSS files into $doc from required modules -- foreach ($ma as $mod) { if ($mod->required()) { foreach ($mod->cssFiles as $file) { $link = $head->appendChild($doc->createElement('link')); $link->setAttribute('type', 'text/css'); $link->setAttribute('rel', 'stylesheet'); $link->setAttribute('href', $file); } } } # -- Include JS files into $doc from required modules -- foreach ($ma as $mod) { if ($mod->required()) { foreach ($mod->jsFiles as $file) { $link = $head->appendChild($doc->createElement('script')); $link->setAttribute('type', 'text/javascript'); $link->setAttribute('src', $file); } }
<?php require_once '../config.php'; require_once CLASS_PATH . '/Session.php'; require_once CLASS_PATH . '/DOMDoc.php'; $ss = Session::getInstance(); $doc = new DOMDoc('1.0', 'UTF-8'); $doc->load('voip.html'); $planList = $doc->getElementById('PlanList'); foreach ($ss->user->plan as $plan) { $option = $planList->appendChild($doc->createElement('option')); $option->setAttribute('value', $plan['plan_id']); $option->nodeValue = $plan['name']; } echo $doc->saveHTML();