Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
0
<?php

include "../includes/structure.php";
include "../includes/mysql.php";
include "../includes/patTemplate.php";
// Read some database information about the current user... cookies anyone?
db_connect();
$sql = sprintf("SELECT * FROM users WHERE id=1 LIMIT 1");
$result = db_query($sql);
$user = mysql_fetch_assoc($result);
// Setup the template...
$template = new patTemplate();
$template->setBasedir("templates");
$template->readTemplatesFromFile("basic.tmpl.html");
// Add the default variables to the template (header section):
$variables = array();
foreach ($user as $var => $val) {
    $variables[strtoupper($var)] = $val;
    $template->addGlobalVar(strtoupper($var), $val);
}
$template->addGlobalVar("FULLNAME", $user['fullname']);
//$template->addVars ("header", $variables);
if (!empty($user['website'])) {
    $template->setAttributes("websitev", array('visibility' => 'visible'));
}
$template->displayParsedTemplate();