예제 #1
0
 function __register_template()
 {
     global $conf;
     if (!empty($_REQUEST['q'])) {
         require_once DOKU_INC . 'inc/JSON.php';
         $json = new JSON();
         $tempREQUEST = (array) $json->dec(stripslashes($_REQUEST['q']));
     } else {
         if (!empty($_REQUEST['template'])) {
             $tempREQUEST = $_REQUEST;
         } else {
             if (preg_match("/(js|css)\\.php\$/", $_SERVER['SCRIPT_NAME']) && isset($_SERVER['HTTP_REFERER'])) {
                 // this is a css or script, nothing before matched and we have a referrer.
                 // lets asume we came from the dokuwiki page.
                 // Parse the Referrer URL
                 $url = parse_url($_SERVER['HTTP_REFERER']);
                 parse_str($url['query'], $tempREQUEST);
             } else {
                 return;
             }
         }
     }
     // define Template baseURL
     if (empty($tempREQUEST['template'])) {
         return;
     }
     $tplDir = DOKU_INC . 'lib/tpl/' . $tempREQUEST['template'] . '/';
     if (!file_exists($tplDir)) {
         return;
     }
     // Set hint for Dokuwiki_Started event
     if (!defined('SITEEXPORT_TPL')) {
         define('SITEEXPORT_TPL', $tempREQUEST['template']);
     }
     // define baseURL
     // This should be DEPRECATED - as it is in init.php which suggest tpl_basedir and tpl_incdir
     /* **************************************************************************************** */
     if (!defined('DOKU_REL')) {
         define('DOKU_REL', getBaseURL(false));
     }
     if (!defined('DOKU_URL')) {
         define('DOKU_URL', getBaseURL(true));
     }
     if (!defined('DOKU_BASE')) {
         if (isset($conf['canonical'])) {
             define('DOKU_BASE', DOKU_URL);
         } else {
             define('DOKU_BASE', DOKU_REL);
         }
     }
     // This should be DEPRECATED - as it is in init.php which suggest tpl_basedir and tpl_incdir
     if (!defined('DOKU_TPL')) {
         define('DOKU_TPL', (empty($tempREQUEST['base']) ? DOKU_BASE : $tempREQUEST['base']) . 'lib/tpl/' . $tempREQUEST['template'] . '/');
     }
     if (!defined('DOKU_TPLINC')) {
         define('DOKU_TPLINC', $tplDir);
     }
     /* **************************************************************************************** */
 }