function buildCFGFile($cacic_config)
 {
     $oTmpl = new patTemplate();
     $oTmpl->setNamespace('cacicInstall');
     $oTmpl->setRoot('templates');
     $oTmpl->readTemplatesFromInput('install_navbar.tmpl');
     $oTmpl->addVar('tmplCFGFile', 'cacic_path', addslashes(CACIC_PATH));
     $oTmpl->addVar('tmplCFGFile', 'CACIC_URL', CACIC_URL);
     $oTmpl->addVar('tmplCFGFile', 'DB_SERVER', $cacic_config['db_host']);
     $oTmpl->addVar('tmplCFGFile', 'DB_PORT', $cacic_config['db_port']);
     $oTmpl->addVar('tmplCFGFile', 'DB_NAME', $cacic_config['db_name']);
     $oTmpl->addVar('tmplCFGFile', 'DB_USER', $cacic_config['db_user']);
     $oTmpl->addVar('tmplCFGFile', 'DB_USER_PASS', $cacic_config['db_pass']);
     $oTmpl->addVar('tmplCFGFile', 'CACIC_KEY', CACIC_KEY);
     $oTmpl->addVar('tmplCFGFile', 'CACIC_IV', CACIC_IV);
     $oTmpl->addVar('tmplCFGFile', 'CACIC_LANGUAGE', $_SESSION['cacic_language']);
     $oTmpl->addVar('tmplCFGFileCab', 'show_path', CACIC_PATH);
     $oTmpl->addVar('tmplCFGFileCab', 'cacic_ds', CACIC_DS);
     $oTmpl->displayParsedTemplate('tmplCFGFile');
 }
示例#2
0
 /**
  * @param array An array of additional files to include from the root folder
  * @return object
  */
 function &createTemplate($files = null)
 {
     global $mainframe;
     $tmpl = new patTemplate();
     // patTemplate
     if ($GLOBALS['mosConfig_caching']) {
         $tmpl->useTemplateCache('File', array('cacheFolder' => $GLOBALS['mosConfig_cachepath'], 'lifetime' => 20));
     }
     $tmpl->setNamespace('mos');
     // load the wrapper and common templates
     $tmpl->setRoot(dirname(__FILE__) . '/tmpl');
     $tmpl->readTemplatesFromFile('page.html');
     $tmpl->applyInputFilter('ShortModifiers');
     if (is_array($files)) {
         foreach ($files as $file) {
             $tmpl->readTemplatesFromInput($file);
         }
     }
     //echo $this->basePath() . '/components/' . $option . '/tmpl';
     $tmpl->addGlobalVar('option', $GLOBALS['option']);
     $tmpl->addGlobalVar('self', $_SERVER['PHP_SELF']);
     $tmpl->addGlobalVar('itemid', $GLOBALS['Itemid']);
     $tmpl->addGlobalVar('siteurl', $GLOBALS['mosConfig_live_site']);
     $tmpl->addGlobalVar('adminurl', $GLOBALS['mosConfig_live_site'] . '/administrator');
     $tmpl->addGlobalVar('templateurl', $GLOBALS['mosConfig_live_site'] . '/templates/' . $mainframe->getTemplate());
     $tmpl->addGlobalVar('admintemplateurl', $GLOBALS['mosConfig_live_site'] . '/administrator/templates/' . $mainframe->getTemplate());
     $tmpl->addGlobalVar('sitename', $GLOBALS['mosConfig_sitename']);
     $tmpl->addGlobalVar('treecss', 'dtree.css');
     $tmpl->addGlobalVar('treeimgfolder', 'img');
     $iso = split('=', _ISO);
     $tmpl->addGlobalVar('page_encoding', $iso[1]);
     $tmpl->addGlobalVar('version_copyright', $GLOBALS['_VERSION']->COPYRIGHT);
     $tmpl->addGlobalVar('version_url', $GLOBALS['_VERSION']->URL);
     $tmpl->addVar('form', 'formAction', $_SERVER['PHP_SELF']);
     $tmpl->addVar('form', 'formName', 'adminForm');
     // tabs
     $turl = $GLOBALS['mosConfig_live_site'] . '/includes/js/tabs/';
     $tmpl->addVar('includeTabs', 'taburl', $turl);
     return $tmpl;
 }
// create a form definition
$definition = patForms_Definition_Propel::create(array('name' => $classname, 'filename' => $path . '/form.' . $classname . '.xml'));
// create a storage
$storage = patForms::createStorage('Propel');
$storage->setStorageLocation($classname . 'peer');
// create a form
$form =& patForms::createCreator('Definition')->create($definition);
$form->setRenderer(patForms::createRenderer('Array'));
$form->setStorage($storage);
if (isset($pk)) {
    $form->setValues($pk);
}
// render it to a patTemplate (could be done by other template engines)
$tpl = new patTemplate();
$tpl->setRoot($path);
$tpl->readTemplatesFromInput('form.dynamic.tpl');
$tpl->addVar('page', 'title', 'Bookstore party');
$tpl->addVar('form', 'start', $form->serializeStart());
$tpl->addVar('form', 'end', $form->serializeEnd());
$tpl->addRows('elements', $form->renderForm());
// this should be possible to be done in a more elegant way
if ($errors = $form->getValidationErrors()) {
    foreach ($errors as $field => $error) {
        $tpl->addVar('error', 'field', $field);
        foreach ($error as $line) {
            $tpl->addVar('error', 'message', $line['message']);
            $tpl->addVar('error', 'code', $line['code']);
            $tpl->parseTemplate('error', 'a');
        }
    }
    $tpl->setAttribute('errors', 'visibility', 'visible');