Ejemplo n.º 1
0
/**
 * Search annotations by record id
 * returns JSON array
 */
function getAnnotationsById($recid)
{
    $result = array();
    if (defined('DT_ANNOTATION_RANGE') && defined('DT_ANNOTATION_RESOURCE')) {
        $params = array("q" => "f:" . DT_ANNOTATION_RESOURCE . "=" . $recid, "w" => BOTH);
        $result = loadSearch($params);
        //from search/getSearchResults.php - loads array of records based og GET request
        if (!array_key_exists('records', $result) || $result['resultCount'] == 0) {
        }
    }
    return $result;
}
}
$fuzziness = intval($_REQUEST['fuzziness']);
if (!$fuzziness) {
    $fuzziness = 20;
}
$bibs = array();
$dupes = array();
$dupekeys = array();
$recsGivenNames = array();
$dupeDifferences = array();
$recIDs = null;
$result = null;
if (@$_REQUEST['q']) {
    $_REQUEST['l'] = -1;
    // tell the loader we want all the ids
    $result = loadSearch($_REQUEST, false, true);
    //get recIDs for the search
    if ($result['resultCount'] > 0 && $result['recordCount'] > 0) {
        $recIDs = $result['recIDs'];
    }
}
// error output
if (!@$_REQUEST['q'] || array_key_exists("error", @$result) || @$result['resultCount'] != @$result['recordCount']) {
    //error has occured tell the user and stop
    ?>

	<html>
		<head>
			<title>Heurist duplicate records for search results set</title>
            <meta http-equiv="content-type" content="text/html; charset=utf-8">
			<link rel=stylesheet type=text/css href='<?php 
Ejemplo n.º 3
0
* @link        http://HeuristNetwork.org
* @version     3.1.0
* @license     http://www.gnu.org/licenses/gpl-3.0.txt GNU License 3.0
* @package     Heurist academic knowledge management system
* @subpackage  !!!subpackagename for file such as Administration, Search, Edit, Application, Library
*/
/**
* filename, brief description, date of creation, by whom
* @copyright (C) 2005-2010 University of Sydney Digital Innovation Unit.
* @link: http://HeuristNetwork.org
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @package Heurist academic knowledge management system
* @todo
**/
header("Cache-Control: no-cache, must-revalidate");
// HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// Date in the past
session_cache_limiter('no-cache');
define('SAVE_URI', 'disabled');
define('SEARCH_VERSION', 1);
require_once dirname(__FILE__) . "/../../search/getSearchResults.php";
$args = json_decode(@$_POST["data"] ? $_POST["data"] : base64_decode(@$_GET["data"]), true);
$result = loadSearch($args);
if (array_key_exists("records", $result)) {
    // turn the associative array into the non-associative one HAPI expects
    foreach ($result["records"] as $i => $record) {
        $result["records"][$i] = array(@$record["rec_ID"], null, @$record["rec_RecTypeID"], @$record["rec_Title"], @$record["details"], @$record["rec_URL"], @$record["rec_ScratchPad"], @$record["rec_OwnerUGrpID"], @$record["rec_NonOwnerVisibility"], @$record["rec_URLLastVerified"], @$record["rec_URLErrorMessage"], @$record["rec_Added"], @$record["rec_Modified"], @$record["rec_AddedByUGrpID"], @$record["rec_Hash"], @$record["bkm_ID"], null, @$record["bkm_Rating"], null, null, @$record["tags"], @$record["wgTags"], @$record["notifies"], @$record["comments"]);
    }
}
print json_format($result);
Ejemplo n.º 4
0
//----------------------------------------------------------------------------//
//  Turn off output buffering
//----------------------------------------------------------------------------//
if (!@$ARGV) {
    @apache_setenv('no-gzip', 1);
}
@ini_set('zlib.output_compression', 0);
@ini_set('implicit_flush', 1);
for ($i = 0; $i < ob_get_level(); $i++) {
    ob_end_flush();
}
ob_implicit_flush(1);
//----------------------------------------------------------------------------//
//  Output
//----------------------------------------------------------------------------//
$result = loadSearch($_REQUEST);
openTag('hml');
/*
openTag('hml', array(
	'xmlns' => 'http://heuristscholar.org/heurist/hml',
	'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
	'xsi:schemaLocation' => 'http://heuristscholar.org/heurist/hml http://heuristscholar.org/heurist/schemas/hml.xsd')
);
*/
$query_attrs = array_intersect_key($_REQUEST, array('q' => 1, 'w' => 1, 'depth' => 1, 'f' => 1, 'limit' => 1, 'offset' => 1, 'db' => 1, 'stub' => 1, 'woot' => 1, 'fc' => 1, 'slb' => 1, 'filters' => 1));
if ($pub_id) {
    $query_attrs['pubID'] = $pub_id;
}
makeTag('query', $query_attrs);
makeTag('dateStamp', null, date('c'));
if (array_key_exists('error', $result)) {
Ejemplo n.º 5
0
function expandCollections($recIDs, $publicOnly = false)
{
    $colRT = defined('RT_COLLECTION') ? RT_COLLECTION : 0;
    $qStrDT = defined('DT_QUERY_STRING') ? DT_QUERY_STRING : 0;
    $resrcDT = defined('DT_RESOURCE') ? DT_RESOURCE : 0;
    $expRecIDs = array();
    foreach ($recIDs as $recID) {
        $rectype = mysql__select_array("Records", "rec_RecTypeID", "rec_ID = {$recID}");
        $rectype = intval($rectype[0]);
        if ($rectype == $colRT) {
            // collection rec so get query string and expand it and list all ptr recIDs
            $qryStr = mysql__select_array("recDetails", "dtl_Value", "dtl_DetailTypeID = {$qStrDT} and dtl_RecID = {$recID}");
            if (count($qryStr) > 0) {
                // get recIDs only for query. and add them to expanded recs
                $loadResult = loadSearch(array("q" => $qryStr[0]), true, true, $publicOnly);
                if (array_key_exists("recordCount", $loadResult) && $loadResult["recordCount"] > 0) {
                    foreach (explode(",", $loadResult["recIDs"]) as $resRecID) {
                        if (!in_array($resRecID, $expRecIDs)) {
                            array_push($expRecIDs, $resRecID);
                        }
                    }
                }
            }
            //add any colected record pointers
            $collRecIDs = mysql__select_array("recDetails", "dtl_Value", "dtl_DetailTypeID = {$resrcDT} and dtl_RecID = {$recID}");
            foreach ($collRecIDs as $collRecID) {
                if (!in_array($collRecID, $expRecIDs)) {
                    array_push($expRecIDs, $collRecID);
                }
            }
        } else {
            if (!in_array($recID, $expRecIDs)) {
                array_push($expRecIDs, $recID);
            }
        }
    }
    return $expRecIDs;
}
Ejemplo n.º 6
0
//----------------------------------------------------------------------------//
$hmlAttrs = array();
$hmlAttrs['xmlns'] = 'http://heuristnetwork.org';
$hmlAttrs['xmlns:xsi'] = 'http://www.w3.org/2001/XMLSchema-instance';
$hmlAttrs['xsi:schemaLocation'] = 'http://heuristnetwork.org/reference/scheme_hml.xsd';
if ($USEXINCLUDE) {
    $hmlAttrs['xmlns:xi'] = 'http://www.w3.org/2001/XInclude';
}
if (@$_REQUEST['filename']) {
    $hmlAttrs['filename'] = $_REQUEST['filename'];
}
if (@$_REQUEST['pathfilename']) {
    $hmlAttrs['pathfilename'] = $_REQUEST['pathfilename'];
}
if (@$_REQUEST['filename']) {
    $result = loadSearch($_REQUEST, false, true, $PUBONLY);
    //load IDS only
} else {
    // true || @$_REQUEST['rules']){ //search with h4 search engine
    $url = HEURIST_BASE_URL . "hserver/controller/record_search.php";
    $url = $url . '?' . $_SERVER["QUERY_STRING"] . "&detail=ids&vo=h3&needall=1";
    //call h4
    if ($PUBONLY) {
        $url = $url . "&publiconly=1";
    }
    /*
    $result = loadRemoteURLContent($url);
    $result = json_decode($result, true);
    */
    $result = loadRemoteURLviaSocket($url);
    //because of issue with curl/proxy on heurist server loadRemoteURLContent($url, false);
Ejemplo n.º 7
0
/**
* Main function
*
* @param mixed $_REQUEST
*/
function executeSmartyTemplate($params)
{
    global $smarty, $outputfile, $isJSout, $rtStructs, $dtStructs, $dtTerms, $gparams, $max_allowed_depth, $publishmode, $execution_counter, $execution_total_counter, $session_id, $mysqli;
    set_time_limit(0);
    //no script execution time limit
    mysql_connection_overwrite(DATABASE);
    //AO: mysql_connection_select - does not work since there is no access to stored procedures(getTemporalDateString)
    //    which Steve used in some queries
    //TODO SAW  grant ROuser EXECUTE on getTemporalDate and any other readonly procs
    //load definitions (USE CACHE)
    //$rtStructs = getAllRectypeStructures(true);
    //$dtStructs = getAllDetailTypeStructures(true);
    //$dtTerms = getTerms(true);
    $params["f"] = 1;
    //always search (do not use cache)
    $isJSout = array_key_exists("mode", $params) && $params["mode"] == "js";
    //use javascript wrap
    $outputfile = array_key_exists("output", $params) ? $params["output"] : null;
    $publishmode = array_key_exists("publish", $params) ? intval($params['publish']) : 0;
    $emptysetmessage = array_key_exists("emptysetmessage", $params) ? $params['emptysetmessage'] : null;
    $gparams = $params;
    //keep to use in other functions
    if (!array_key_exists("limit", $params)) {
        //not defined
        if ($publishmode == 0) {
            $limit_for_interface = intval(@$_SESSION[HEURIST_SESSION_DB_PREFIX . 'heurist']["display-preferences"]['smarty-output-limit']);
            if (!$limit_for_interface || $limit_for_interface < 1) {
                $limit_for_interface = 50;
                //default limit in dispPreferences
            }
            $params["limit"] = $limit_for_interface;
            //force limit
        } else {
            $params["limit"] = PHP_INT_MAX;
        }
    }
    if (@$params['recordset']) {
        //we already have the list of record ids
        if (is_array($params['recordset'])) {
            $qresult = $params['recordset'];
        } else {
            $qresult = json_decode($params['recordset'], true);
        }
        //truncate recordset  - limit does not work for publish mode
        if ($publishmode == 0 && $qresult && array_key_exists('recIDs', $qresult)) {
            $recIDs = explode(',', $qresult['recIDs']);
            if ($params["limit"] < count($recIDs)) {
                $qresult['recIDs'] = implode(',', array_slice($recIDs, 0, $params["limit"]));
            }
        }
    } else {
        if (@$params['h4'] == 1) {
            //search with h4 search engine and got list of ids
            /*    for future use
                  $params['detail']='ids';
                  $params['vo']='h3';
                  $qresult = recordSearch($system, $params);
                  */
            $url = "";
            foreach ($params as $key => $value) {
                $url = $url . $key . "=" . urlencode($value) . "&";
            }
            $url = HEURIST_BASE_URL . "hserver/controller/record_search.php?" . $url . "&detail=ids&vo=h3";
            $result = loadRemoteURLviaSocket($url);
            // loadRemoteURLContent($url);
            $qresult = json_decode($result, true);
        } else {
            $qresult = loadSearch($params);
            //from search/getSearchResults.php - loads array of records based og GET request
        }
    }
    // EMPTY RESULT SET - EXIT
    if (!$qresult || !array_key_exists('recIDs', $qresult) && !array_key_exists('records', $qresult) || $qresult['resultCount'] == 0) {
        if ($emptysetmessage) {
            $error = $emptysetmessage;
            // allows publisher of URL to customise the message if no records retrieved
        } else {
            if ($publishmode > 0) {
                $error = "<b><font color='#ff0000'>Note: There are no records in this view. The URL will only show records to which the viewer has access. Unless you are logged in to the database, you can only see records which are marked as Public visibility</font></b>";
            } else {
                $error = "<b><font color='#ff0000'>Search or Select records to see template output</font></b>";
            }
        }
        if ($isJSout) {
            $error = add_javascript_wrap4($error, null);
        }
        if ($publishmode > 0 && $outputfile != null) {
            //save empty output into file
            save_report_output2($error . "<div style=\"padding:20px;font-size:110%\">Currently there are no results</div>");
        } else {
            echo $error;
        }
        exit;
    }
    //get name of template file
    $template_file = array_key_exists('template', $params) ? $params['template'] : null;
    //get template body from request (for execution from editor)
    $template_body = array_key_exists('template_body', $params) ? $params['template_body'] : null;
    if (null != $template_file) {
        if (substr($template_file, -4) != ".tpl") {
            $template_file = $template_file . ".tpl";
        }
        if (file_exists(HEURIST_SMARTY_TEMPLATES_DIR . $template_file)) {
            $content = file_get_contents(HEURIST_SMARTY_TEMPLATES_DIR . $template_file);
        } else {
            $error = "<b><font color='#ff0000'>Template file {$template_file} does not exist</font></b>";
            echo $error;
            if ($publishmode > 0 && $outputfile != null) {
                //save empty output into file
                save_report_output2($error);
            }
            exit;
        }
    } else {
        $content = $template_body;
    }
    //verify that template has new features
    //need to detect $heurist->getRecord - if it is not found this is old version - show error message
    if (strpos($content, '$heurist->getRecord(') === false) {
        $error = '<p>To improve performance we have made some small changes to the report template specifications (July 2016).</p>' . '<p>You will need to add  {$r = $heurist->getRecord($r)}  immediately after the start of the main record loop, like this:<p/>' . '{*------------------------------------------------------------*}' . '<br/>{foreach $results as $r}' . '<br/><b>{$r = $heurist->getRecord($r)}</b>' . '<br/>{*------------------------------------------------------------*}' . '<p>and similar expressions for record pointer loops - example: {$r.f103 = $heurist->getRecord($r.f103)}</p>' . '<p>Please generate a new report to obtain an example of the syntax, or simply send your report template to ' . '<br/>support at HeuristNetwork dot org and we will adjust the template for you.</p>';
        if ($publishmode > 0 && $outputfile != null) {
            save_report_output2($error);
        } else {
            echo $error;
        }
        exit;
    }
    $k = strpos($content, "{*depth");
    $kp = 8;
    if (is_bool($k) && !$k) {
        $k = strpos($content, "{* depth");
        $kp = 9;
    }
    if (is_numeric($k) && $k >= 0) {
        $nd = substr($content, $k + $kp, 1);
        //strpos($content,"*}",$k)-$k-8);
        if (is_numeric($nd) && $nd < 3) {
            $max_allowed_depth = $nd;
        }
    }
    //end pre-parsing of template
    $mysqli = mysqli_connection_overwrite(DATABASE);
    if ($publishmode == 0 && $session_id != null) {
        updateProgress($mysqli, $session_id, true, '0,0');
    }
    //convert to array that will assigned to smarty variable
    if (array_key_exists('recIDs', $qresult)) {
        $results = explode(",", $qresult["recIDs"]);
        $execution_total_counter = count($results);
        /* OLD WAY
                $records =  explode(",", $qresult["recIDs"]);
                $results = array();
                $k = 0;
                $execution_total_counter = count($records); //'tot_count'=>$tot_count,
        
                foreach ($records as $recordID){
        
                    if(smarty_function_progress(array('done'=>$k), $smarty)){
                        echo 'Execution was terminated';
                        return;
                    }
        
                    $rec = loadRecord($recordID, false, true); //from search/getSearchResults.php
        
                    $res1 = getRecordForSmarty($rec, 0, $k);
                    $res1["recOrder"]  = $k;
                    $k++;
                    array_push($results, $res1);
                }
        */
    } else {
        $records = $qresult["records"];
        $execution_total_counter = count($records);
        //'tot_count'=>$tot_count,
        //v5.5+ $results =  array_column($records, 'recID');
        $results = array_map(function ($value) {
            return @$value['recID'] ? $value['recID'] : array();
        }, $records);
        /*  OLD WAY        
                $records =  $qresult["records"];
                $execution_total_counter = count($records); //'tot_count'=>$tot_count,
                $results = array();
                $k = 0;
                foreach ($records as $rec){
        
                    if(smarty_function_progress(array('done'=>$k), $smarty)){
                        echo 'Execution was terminated';
                        return;
                    }
        
                    $res1 = getRecordForSmarty($rec, 0, $k);
                    $res1["recOrder"]  = $k;
                    $k++;
                    array_push($results, $res1);
                }
        */
    }
    //activate default template - generic list of records
    //we have access to 2 methods getRecord and getRelatedRecords
    $heuristRec = new ReportRecord();
    //$smarty->registerObject('heurist', $heuristRec, array('getRecord'), false);
    $smarty->assignByRef('heurist', $heuristRec);
    $smarty->assign('results', $results);
    //assign
    //$smarty->getvar()
    ini_set('display_errors', 'false');
    // 'stdout' );
    $smarty->error_reporting = 0;
    if ($template_body) {
        //execute template from string - modified template in editor
        //error report level: 1 notices, 2 all, 3 debug mode
        $replevel = array_key_exists('replevel', $params) ? $params['replevel'] : 0;
        if ($replevel == "1" || $replevel == "2") {
            ini_set('display_errors', 'true');
            // 'stdout' );
            $smarty->debugging = false;
            if ($replevel == "2") {
                $smarty->error_reporting = E_ALL & ~E_STRICT & ~E_NOTICE;
            } else {
                $smarty->error_reporting = E_NOTICE;
            }
        } else {
            $smarty->debugging = $replevel == "3";
        }
        $smarty->debug_tpl = dirname(__FILE__) . '/debug_html.tpl';
        //save temporary template
        //this is user name $template_file = "_temp.tpl";
        $template_file = "_" . get_user_username() . ".tpl";
        $file = fopen($smarty->template_dir . $template_file, "w");
        fwrite($file, $template_body);
        fclose($file);
        //$smarty->display('string:'.$template_body);
    } else {
        // usual way - from file
        if (!$template_file) {
            $template_file = 'test01.tpl';
        }
        $smarty->debugging = false;
        $smarty->error_reporting = 0;
        if ($outputfile != null) {
            $smarty->registerFilter('output', 'smarty_output_filter');
        } else {
            if ($isJSout) {
                $smarty->registerFilter('output', 'add_javascript_wrap5');
            }
        }
    }
    //DEBUG
    $smarty->registerFilter('post', 'smarty_post_filter');
    if ($publishmode == 0 && $session_id != null) {
        updateProgress($mysqli, $session_id, true, '0,' . count($results));
        /*session_start();
          $_SESSION[HEURIST_SESSION_DB_PREFIX.'heurist']['smarty_progress2'] = '0,'.count($results);
          session_write_close();*/
    }
    $execution_counter = -1;
    $execution_total_counter = count($results);
    try {
        $smarty->display($template_file);
    } catch (Exception $e) {
        echo 'Exception on execution: ', $e->getMessage(), "\n";
    }
    if ($publishmode == 0 && $session_id != null) {
        updateProgress($mysqli, $session_id, false, 'REMOVE');
    }
    $mysqli->close();
}
function createQueryRecSet()
{
    //echo "request = ".print_r($_REQUEST,true)."\n";
    $qresult = loadSearch($_REQUEST);
    //echo "query result = ".print_r($qresult,true)."\n";
    $recSet = array('count' => 0, 'recSet' => array(), 'params' => array_intersect_key($_REQUEST, array('q' => 1, 'w' => 1, 'depth' => 1, 'f' => 1, 'limit' => 1, 'offset' => 1, 'rev' => 1, 'revexpand' => 1, 'db' => 1, 'sid' => 1, 'slb' => 1, 'rtfilters' => 1, 'relfilters' => 1, 'ptrfilters' => 1)), 'infoByDepth' => array(array('recIDs' => array(), 'rectypes' => array())));
    //echo "query reults = ".json_format($result,true);
    $rec_ids = array();
    foreach ($qresult['records'] as $record) {
        array_push($rec_ids, $record['rec_ID']);
        $recSet['recSet'][$record['rec_ID']] = array('depth' => 0, 'record' => array(null, null, $record['rec_ID'], $record['rec_URL'], $record['rec_RecTypeID'], $record['rec_Title'], $record['rec_OwnerUGrpID'], $record['rec_NonOwnerVisibility'], null, null, null, getThumbnailURL($record['rec_ID'])));
        array_push($recSet['infoByDepth'][0]['recIDs'], $record['rec_ID']);
        // add recID to it's rectype array for this depth
        if (!@$recSet['infoByDepth'][0]['rectypes'][$record['rec_RecTypeID']]) {
            $recSet['infoByDepth'][0]['rectypes'][$record['rec_RecTypeID']] = array($record['rec_ID']);
        } else {
            if (!in_array($record['rec_ID'], $recSet['infoByDepth'][0]['rectypes'][$record['rec_RecTypeID']])) {
                array_push($recSet['infoByDepth'][0]['rectypes'][$record['rec_RecTypeID']], $record['rec_ID']);
            }
        }
    }
    return $recSet;
}
Ejemplo n.º 9
0
/**
* Main function
*
* @param mixed $_REQUEST
*/
function executeSmartyTemplate($params)
{
    global $smarty, $outputfile, $isJSout, $rtStructs, $dtStructs, $dtTerms, $gparams;
    mysql_connection_overwrite(DATABASE);
    //AO: mysql_connection_select - does not work since there is no access to stored procedures(getTemporalDateString) Steve uses in some query
    //TODO SAW  grant ROuser EXECUTE on getTemporalDate and any other readonly procs
    //load definitions (USE CACHE)
    $rtStructs = getAllRectypeStructures(true);
    $dtStructs = getAllDetailTypeStructures(true);
    $dtTerms = getTerms(true);
    $params["f"] = 1;
    //always search (do not use cache)
    $isJSout = array_key_exists("mode", $params) && $params["mode"] == "js";
    //use javascript wrap
    $outputfile = array_key_exists("output", $params) ? $params["output"] : null;
    $publishmode = array_key_exists("publish", $params) ? intval($params['publish']) : 0;
    $gparams = $params;
    //keep to use in other functions
    if (!array_key_exists("limit", $params)) {
        //not defined
        $limit = intval(@$_SESSION[HEURIST_SESSION_DB_PREFIX . 'heurist']["display-preferences"]['report-output-limit']);
        if (!$limit || $limit < 1) {
            $limit = 1000;
            //default limit in dispPreferences
        }
        $params["limit"] = $limit;
        //force limit
    }
    $qresult = loadSearch($params);
    //from search/getSearchResults.php - loads array of records based og GET request
    /*****DEBUG****/
    //error_log(print_r($qresult,true));
    if (!array_key_exists('records', $qresult) || $qresult['resultCount'] == 0) {
        if ($publishmode > 0) {
            $error = "<b><font color='#ff0000'>Note: There are no records in this view. The URL will only show records to which the viewer has access. Unless you are logged in to the database, you can only see records which are marked as Public visibility</font></b>";
        } else {
            $error = "<b><font color='#ff0000'>Search or Select records to see template output</font></b>";
        }
        if ($isJSout) {
            $error = add_javascript_wrap4($error, null);
        }
        echo $error;
        if ($publishmode > 0 && $outputfile != null) {
            //save empty outpurt inot file
            save_report_output2("<div style=\"padding:20px;font-size:110%\">Currently there are no results</div>");
        }
        exit;
    }
    //get name of template file
    $template_file = array_key_exists('template', $params) ? $params['template'] : null;
    //get template body from request (for execution from editor)
    $template_body = array_key_exists('template_body', $params) ? $params['template_body'] : null;
    //convert to array that will assigned to smarty variable
    $records = $qresult["records"];
    $results = array();
    $k = 0;
    foreach ($records as $rec) {
        $res1 = getRecordForSmarty($rec, 0, $k);
        $k++;
        array_push($results, $res1);
    }
    //activate default template - generic list of records
    $smarty->assign('results', $results);
    ini_set('display_errors', 'false');
    // 'stdout' );
    $smarty->error_reporting = 0;
    if ($template_body) {
        //execute template from string - modified temoplate in editor
        /*****DEBUG****/
        //error_log(">>>".$template_body."<<<");
        /*****DEBUG****/
        //error_log(">>>>>>>".$replevel."<<<<<<");
        //error report level: 1 notices, 2 all, 3 debug mode
        $replevel = array_key_exists('replevel', $params) ? $params['replevel'] : 0;
        if ($replevel == "1" || $replevel == "2") {
            ini_set('display_errors', 'true');
            // 'stdout' );
            $smarty->debugging = false;
            if ($replevel == "2") {
                $smarty->error_reporting = E_ALL & ~E_STRICT & ~E_NOTICE;
            } else {
                $smarty->error_reporting = E_NOTICE;
            }
        } else {
            $smarty->debugging = $replevel == "3";
        }
        $smarty->debug_tpl = dirname(__FILE__) . '/debug_html.tpl';
        //save temporary template
        //this is user name $template_file = "_temp.tpl";
        $template_file = "_" . get_user_username() . ".tpl";
        $file = fopen($smarty->template_dir . $template_file, "w");
        fwrite($file, $template_body);
        fclose($file);
        //$smarty->display('string:'.$template_body);
    } else {
        // usual way - from file
        if (!$template_file) {
            $template_file = 'test01.tpl';
        }
        $smarty->debugging = false;
        $smarty->error_reporting = 0;
        if ($outputfile != null) {
            $smarty->registerFilter('output', 'save_report_output');
        } else {
            if ($isJSout) {
                $smarty->registerFilter('output', 'add_javascript_wrap5');
            }
        }
        //$smarty->unregisterFilter('post','add_javascript_wrap');
    }
    try {
        $smarty->display($template_file);
    } catch (Exception $e) {
        echo 'Exception on execution: ', $e->getMessage(), "\n";
    }
    //$tpl_vars = $smarty->get_template_vars();
    //var_dump($tpl_vars);
    //DEBUG stuff
    //@todo - return the list of record types - to obtain the applicable templates
    //echo "query result = ".print_r($qresult,true)."\n";
    //header("Content-type: text/javascript");
    //header('Content-type: text/html; charset=utf-8');
    //echo json_format( $qresult, true);
    //echo "<br/>***<br/>";
    //echo json_format( $results, true);
    //END DEBUG stuff
}