3 * extends the CMS preview - but should take the template from the builder..
4 * intended use is with the bootstrap code HTML generated..
7 require_once 'Pman/Cms/Preview.php';
9 class Pman_Builder_Preview extends Pman_Cms_Preview
13 function loadPage($prefix, $name, $default = false)
16 if (preg_match('/^BuilderJS/', $name)) {
17 $this->outputJS(preg_replace('#^BuilderJS/#','', $name));
20 //var_dump($name, $default);
21 //DB_DataObject::debugLevel(5);
22 parent::loadPage($prefix, $name, $default );
32 function outputJS($name)
34 $proj = HTML_FlexyFramework::get()->project;
35 // DB_DataObject::debugLevel(1);
36 $m = DB_DAtaObject::factory('Builder_modules');
37 $m->get('name', $proj );
38 $p = DB_DAtaObject::factory('Builder_part');
39 $p->module_id = $m->pid();
40 if (!$p->get('name', $name )) {
43 header('Content-type: text/javascript');
44 // this should outpt the file if it's found.
45 if (file_exists($m->path . '/'. $p->name .'.js')) {
46 $fh = fopen($m->path . '/'. $p->name .'.js', 'r');
59 $proj = HTML_FlexyFramework::get()->project;
60 // DB_DataObject::debugLevel(1);
61 $m = DB_DAtaObject::factory('Builder_modules');
62 $m->get('name', $proj );
64 //var_dump($m->path);exit;
65 // needs to modify the template directory??
66 // use the builder_module == app name
67 // look for part with same name.
68 $template_engine = new HTML_Template_Flexy(array(
69 'templateDir' => $m->path
71 $template_engine->compile($this->template);
72 if ($this->elements) { /* BC crap! */
73 $this->elements = HTML_Template_Flexy_Factory::setErrors($this->elements,$this->errors);
75 $template_engine->elements = $this->elements;
76 $template_engine->outputObject($this,$this->elements);