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 $this->timer->setMarker(__CLASS__ . '::outputBody - start');
61 $ff = HTML_FlexyFramework::get();
65 // DB_DataObject::debugLevel(1);
66 $m = DB_DAtaObject::factory('Builder_modules');
67 $m->get('name', $proj );
69 //var_dump($m->path);exit;
70 // needs to modify the template directory??
71 // use the builder_module == app name
72 // look for part with same name.
73 if (empty($ff->Pman_Builder['from_filesystem'])) {
75 $template_engine = new HTML_Template_Flexy(array(
76 'templateDir' => $m->path
79 $template_engine = new HTML_Template_Flexy();
82 $template_engine->debug = 1;
83 //print_R($template_engine);
85 $template_engine->compile($this->template);
86 if ($this->elements) { /* BC crap! */
87 $this->elements = HTML_Template_Flexy_Factory::setErrors($this->elements,$this->errors);
89 $template_engine->elements = $this->elements;
91 $this->timer->setMarker(__CLASS__ . '::outputBody - render template');
93 //DB_DataObject::debugLevel(1);
94 $template_engine->outputObject($this,$this->elements);
97 $this->timer->setMarker(__CLASS__ . '::outputBody - end');