ini_set('display_errors','off');
header("Content-Type: text/html;charset=utf-8");
$TemplatePath = "template/";
$ClassPath = "class/";
$LibPath = 'ClassLib/';
include($LibPath . 'Config.php');
include($LibPath . 'DataAccess.php');
include($LibPath . 'Template.php');
include($ClassPath . 'Information.php');
include($ClassPath . 'Pages.php');
session_start();
##############################################################
$ConfigObj = new Config();
$DataObj = new DataAccess($ConfigObj);
$template = new Template($TemplatePath);
##############################################################
##############################################################
$template -> set_file('header_handle','header.html');
if(!$_GET['page'])
$template -> set_file('page_handle', 'index.html');
else
$template -> set_file('page_handle', 'index_page.html');
$template -> set_file('footer_handle','footer.html');
##############################################################
if($_GET['search'])
{
$template->set_var(Array('SEARCH' => $_GET['search']));
}
else
$template->set_var(Array('SEARCH' => 'criteria ...'));
##############################################################
if(!$_GET['page'])
{
$template->set_block('page_handle','autori_articol_block','autori_articol_result');
$template->set_block('page_handle','editorial_autori_articol_block','editorial_autori_articol_result');
//$template->set_block('page_handle','line_block','line_result');
//$template->set_block('page_handle','continut_block','continut_result');
$template->set_block('page_handle','e_more_block','e_more_result');
$template->set_block('page_handle','e_download_block','e_download_result');
$template->set_block('page_handle','nr_revista_block','nr_revista_result');
$template->set_block('page_handle','keywords_block','keywords_result');
$template->set_block('page_handle','jel_block','jel_result');
$template->set_block('page_handle','e_keywords_block','e_keywords_result');
$template->set_block('page_handle','e_jel_block','e_jel_result');
$template->set_block('page_handle','more_block','more_result');
$template->set_block('page_handle','download_block','download_result');
$template->set_block('page_handle','editorial_block','editorial_result');
$template->set_block('page_handle','abstract_block','abstract_result');
//$template->set_block('page_handle','aline_block','aline_result');
##############################################################
##############################################################
}
$template->set_var(Array('STITLU' => '', 'NR_AN' => '','AUTOR_NAME' => ''));
list (,,$Sectiuni) = Information::GetSectiuni($DataObj);
list (,,$Revista) = Information::GetDefaults($DataObj, 'NR_CURENT');
if(!$_SESSION['revista'])
{
$_SESSION['revista'] = $Revista;
}
else
{
if($_GET['revista'] != '')
{
$_SESSION['revista'] = $_GET['revista'];
}
}
$Sql = "select * from revista where Id = ?";
$SqlResult = $DataObj->DbObj->getRow($Sql, Array($_SESSION['revista']));
$NrRevista = $SqlResult['numar'];
$AnRevista = $SqlResult['an'];
$Volum = $SqlResult['volum'];
$Luna = $SqlResult['luna'];
$NrCurrent = explode("/", $Revista);
$template->set_var(Array(
'NUMAR_CURENT' => $Revista,
'AN' => $AnRevista,
'NUMAR' => $NrRevista,
'AN_CURRENT' => $NrCurrent[1],
'NR_CURRENT' => $NrCurrent[0]
));
list (,,$Headline, $Ids) = Information::GetHeadlineArticles($DataObj, $_SESSION['revista'], $_GET['filter'], $_GET['search'], $_GET['author']);
//list (,,$Articole, $Ids) = Information::GetAllAbstract($DataObj, $_SESSION['revista'],$_GET['filter'],$_GET['search'],$_GET['author']);
list (,,$Autori) = Information::GetAutoriFromArticole($DataObj, $Ids);
//list (,,$Autori) = Information::GetAutoriOrderByRAND($DataObj, $NrRevista, $AnRevista);
list (,,$Numere) = Information::GetReviste($DataObj);
##############################################################
$RegExp = "/[^a-zA-ZăîâşţĂÎÂŞŢ+0-9-_?!.,<>\s\/\"=&;:%@(){}]/";
$LowerCharacters = "abcdefghijklmnopqrstuvwxyzăîşţâ";
$UpperCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZĂÎŞŢÂ";
$PreparedArticole = Array();
if(is_array($Headline) && count($Headline) > 0)
{
foreach($Headline as $Key => $Value)
{
$PreparedArticole[$Value['sectiune']][] = $Value;
}
}
$Total = 0;
$template->set_block('page_handle','sectiuni_block','sectiuni_result');
$template->set_block('page_handle','autori_block','autori_result');
$template->set_block('page_handle','numar_block','numar_result');
$template->set_var(Array('autori_articol_result'=>''));
if(is_array($Sectiuni) && count($Sectiuni) > 0)
{
foreach($Sectiuni as $Key => $Value)
{
$template->set_var(Array(
'STITLU' => $Value['cd_name'],
'COLOR' => $Value['cd_color'],
'SID' => $Value['cd_id'],
'PADDING_TOP' => (floor(strlen($Value['cd_name']) / 24) * 15 + 35) . 'px'
));
$template->parse('sectiuni_result','sectiuni_block',true);
}
}
else
{
$template->set_var('sectiuni_result','');
}
if(is_array($Autori) && count($Autori) > 0)
{
$Count = 0;
$ArrayAutori = array();
foreach($Autori as $Key => $Val)
{
foreach($Val as $Key1 => $Value)
{
$ArrayAutori[$Value['id']] = $Value;
}
}
foreach($ArrayAutori as $Key1 => $Value)
{
$template->set_var(Array(
'AUTOR_NAME' => $Value['firstname'] . ' ' . strtr($Value['lastname'], $LowerCharacters, $UpperCharacters),
'AUTOR_DESCRIPTION' => $Value['description'],
));
$template->parse('autori_result','autori_block', true);
$Count++;
}
}
else
$template->set_var('autori_result','');
if(is_array($Numere) && count($Numere) > 0)
{
foreach($Numere as $Key => $Value)
{
$template->set_var(Array(
'NR' => $Value['id'],
'NR_SEL' => $Value['id'] == $_SESSION['revista'] ? 'selected' : '',
'NR_AN' => 'Vol. ' . $Value['volum'] . ' Issue ' . $Value['numar'] .' - ' . $Value['luna'] .'/'.$Value['an'],
));
$template->parse('numar_result','numar_block', true);
}
}
$HasAbstract = false;
$HasEditorial = false;
if (!$_GET['id']) // index or other page
{
if($_GET['page']) // website pages
{
list (,, $PageInfo) = Pages::GetArticle($DataObj, $_GET['page']);
if($_GET['page'] == 8) // autori
{
list(,, $AllAutori) = Information::LoadAllAutori($DataObj);
foreach($AllAutori as $Key => $Value)
{
$file = '';
if(@is_file('autori/' . $Value['id'] . '.gif'))
$file = '/autori/' . $Value['id'] . '.gif';
if(@is_file('autori/' . $Value['id'] . '.jpg'))
$file = '/autori/' . $Value['id'] . '.jpg';
if(@is_file('autori/' . $Value['id'] . '.png'))
$file = '/autori/' . $Value['id'] . '.png';
$PageInfo['lung'] .= '
'. ($file ? '

' : '') . '
' . $Value['firstname'] . '
' . strtr($Value['lastname'],$LowerCharacters, $UpperCharacters) . '' . $Value['description'] . '
';
}
}
$template->set_var(Array(
'TITLU' => $PageInfo['titlu'],
'CONTENT' => stripslashes($PageInfo['lung']),
'CATEGORY' => $Value['cd_name'] ? $Value['cd_name'] : 'Uncategorized',
'MIDDLE_COLOR' => $Value['cd_color'],
'IMG' => '',
'AUTOR' => '',
'DESCRIERE' => '',
'NR_REVISTA' => '',
'KEYWORDS' => '',
'JEL' => '',
'ID' => '',
'WIDTH' => 'width: 90% !important',
'DISPLAY' => 'style="display:none"'
));
$template->set_var(Array(
'PADDING_TOP' => (floor(strlen($Value['titlu']) / 47) * 15 + 32) . 'px'
));
$template->set_var(Array(
'more_result' => '',
'keywords_result' => '',
'jel_result' => '',
'nr_revista_result' => '',
'download_result' => '',
'autori_articol_result' => '',
));
// $template->parse('abstract_result','abstract_block', true);
$HasAbstract = true;
}
else // abstract list or search list
{
//var_dump($Headline);
if(is_array($Headline) && count($Headline) > 0)
{
foreach($Headline as $Key => $Value)
{
$ArticoleIds[] = $Value['id'];
}
}
if(count($ArticoleIds))
{
list (,, $Keywords) = Information::GetKeywords($DataObj, $ArticoleIds);
list (,, $JEL) = Information::GetJEL($DataObj, $ArticoleIds);
}
if(is_array($Headline) && count($Headline) > 0)
{
foreach($Headline as $Key => $Value)
{
// var_dump($Value['cd_color']);
$template->set_var(Array(
'TITLU' => $Value['titlu'],
'CONTENT' => ($_GET['filter'] || $_GET['search'] ? '' : $Value['scurt']),
// 'AUTOR' => $Value['firstname'] .' ' . strtr($Value['lastname'], $LowerCharacters, $UpperCharacters),
// 'DESCRIERE' => $Value['description'],
'NR_REVISTA' => 'Vol. ' . $Value['volum']. ' Issue ' . $Value['nr_revista'] .' - ' . $Value['luna'] . '/'.$Value['an'],
'KEYWORDS' => $_GET['filter'] || $_GET['search'] ? '' : 'Keywords:
' . @implode(", ", $Keywords[$Value['id']]),
'CATEGORY' => $Value['cd_name'] ? $Value['cd_name'] : 'Uncategorized',
'MIDDLE_COLOR' => $Value['cd_color'],
'JEL' => $_GET['filter'] || $_GET['search'] ? '' : 'JEL:
' . @implode(", ", $JEL[$Value['id']]),
'ID' => $Value['id'],
));
$Titlu = explode(" ", $Value['titlu']);
$i = 0;
$NiceTitlu = Array();
$End = false;
$Count = 0;
while(!$End)
{
if($Titlu[$i])
$NiceTitlu[] = $Titlu[$i];
$Count += strlen($Titlu[$i]);
$i++;
if($Count > 60 || ($i > count($Titlu)))
{
$End = true;
}
}
$template->set_var(Array(
'LINK' => '/abstract/' . $Value['id'] .'/' . @preg_replace("/[^a-zA-Z0-9ăîşţâĂÎÂŢŞ-]/", "", @implode("-", $NiceTitlu)) . '.html',
));
if($Value['editorial'] == 1)
{
if($Autori[$Value['id']])
{
$first = true;
foreach($Autori[$Value['id']] as $K => $V)
{
$file = '';
if(@is_file('autori/' . $V['id'] . '.gif'))
$file = '/autori/' . $V['id'] . '.gif';
if(@is_file('autori/' . $V['id'] . '.jpg'))
$file = '/autori/' . $V['id'] . '.jpg';
if(@is_file('autori/' . $V['id'] . '.png'))
$file = '/autori/' . $V['id'] . '.png';
$template->set_var(Array(
'AUTOR' => $first ? $V['firstname'] . ' ' . strtr($V['lastname'], $LowerCharacters, $UpperCharacters) : $V['firstname'] . ' ' . strtr($V['lastname'], $LowerCharacters, $UpperCharacters),
'DESCRIERE' => $first ? $V['description'] : '',
'IMG' => ($file && $first ? '
' : ''),
));
$template->parse('editorial_autori_articol_result','editorial_autori_articol_block',!$first);
$first = false;
}
}
$template->set_var(Array(
'PADDING_TOP' => (floor(strlen($Value['titlu']) / 47) * 15 + 55) . 'px'
));
if(count($Keywords[$Value['id']]) > 0)
$template->parse('e_keywords_result','e_keywords_block', false);
else
$template->set_var('e_keywords_result','');
if(count($JEL[$Value['id']]) > 0)
$template->parse('e_jel_result','e_jel_block', false);
else
$template->set_var('e_jel_result','');
$template->parse('nr_revista_result','nr_revista_block', false);
$template->parse('e_more_result','e_more_block', false);
if(is_file('files/pdf/' . $Value['id'] . '.pdf'))
{
$template->set_var('DOWNLOAD_LINK', '/files/pdf/' . $Value['id'] . '.pdf');
$template->parse('e_download_result','e_download_block',false);
}
else
{
$template->set_var('e_download_result', '');
}
$template->parse('editorial_result','editorial_block', true);
$HasEditorial = true;
}
else
{
if($Autori[$Value['id']])
{
$first = true;
foreach($Autori[$Value['id']] as $K => $V)
{
$file = '';
if(@is_file('autori/' . $V['id'] . '.gif'))
$file = '/autori/' . $V['id'] . '.gif';
if(@is_file('autori/' . $V['id'] . '.jpg'))
$file = '/autori/' . $V['id'] . '.jpg';
if(@is_file('autori/' . $V['id'] . '.png'))
$file = '/autori/' . $V['id'] . '.png';
$template->set_var(Array(
'AUTOR' => $first ? $V['firstname'] . ' ' . strtr($V['lastname'], $LowerCharacters, $UpperCharacters) : $V['firstname'] . ' ' . strtr($V['lastname'], $LowerCharacters, $UpperCharacters),
'AID' => $V['id'],
'DESCRIERE' => $first ? $V['description'] : '',
'IMG' => ($file && $first ? '
' : ''),
));
$template->parse('autori_articol_result','autori_articol_block',!$first);
$first = false;
}
}
$template->set_var(Array(
'PADDING_TOP' => (floor(strlen($Value['titlu']) / 47) * 15 + 32) . 'px'
));
if(count($Keywords[$Value['id']]))
$template->parse('keywords_result','keywords_block', false);
else
$template->set_var('keywords_result','');
if(count($JEL[$Value['id']]))
$template->parse('jel_result','jel_block', false);
else
$template->set_var('jel_result','');
$template->parse('nr_revista_result','nr_revista_block', false);
$template->parse('more_result','more_block', false);
if(is_file('files/pdf/' . $Value['id'] . '.pdf'))
{
$template->set_var('DOWNLOAD_LINK', '/files/pdf/' . $Value['id'] . '.pdf');
$template->parse('download_result','download_block',false);
}
else
{
$template->set_var('download_result', '');
}
$template->parse('abstract_result','abstract_block', true);
$HasAbstract = true;
}
}
}
}
}
else // abstract details
{
list (,,$Value, $Keywords, $JEL) = Information::GetArticol($DataObj, intval($_GET['id']));
if($Autori[$Value['id']])
{
$first = true;
foreach($Autori[$Value['id']] as $K => $V)
{
$file = '';
if(@is_file('autori/' . $V['id'] . '.gif'))
$file = '/autori/' . $V['id'] . '.gif';
if(@is_file('autori/' . $V['id'] . '.jpg'))
$file = '/autori/' . $V['id'] . '.jpg';
if(@is_file('autori/' . $V['id'] . '.png'))
$file = '/autori/' . $V['id'] . '.png';
$template->set_var(Array(
'AUTOR' => $V['firstname'] . ' ' . strtr($V['lastname'], $LowerCharacters, $UpperCharacters),
'AID' => $V['id'],
'DESCRIERE' => stripslashes($V['description']),
'IMG' => ($file ? '
' : ''),
));
if($Value['editorial'] == 1)
$template->parse('editorial_autori_articol_result','editorial_autori_articol_block',!$first);
else
$template->parse('autori_articol_result','autori_articol_block',!$first);
$first = false;
}
}
if(is_array($Keywords) && count($Keywords) > 0)
{
foreach($Keywords as $Key => $Val)
$Words[] = $Val['keyword'];
}
if(is_array($JEL) && count($JEL) > 0)
{
foreach($JEL as $Key => $Val)
$JWords[] = $Val['name'];
}
$template->set_var(Array(
'TITLU' => $Value['titlu'],
'CONTENT' => $Value['lung'] ? stripslashes($Value['lung']) : stripslashes(stripslashes($Value['scurt'])),
'IMG' => ($file ? '
' : ''),
'AUTOR' => $Value['firstname'] .' ' . strtr($Value['lastname'], $LowerCharacters, $UpperCharacters),
'DESCRIERE' => stripslashes($Value['description']),
'CATEGORY' => $Value['cd_name'] ? $Value['cd_name'] : 'Editorial',
'MIDDLE_COLOR' => $Value['cd_color'],
'NR_REVISTA' => $NrRevista . '/'. $AnRevista,
'KEYWORDS' => @implode(", ", $Words),
'JEL' => @implode(", ", $JWords),
'ID' => $Value['id'],
));
if($Value['editorial'] == 1)
{
$template->set_var(Array(
'PADDING_TOP' => (floor(strlen($Value['titlu']) / 47) * 15 + 55) . 'px'
));
$template->set_var('e_more_result','');
if(is_file('files/pdf/' . $Value['id'] . '.pdf'))
{
$template->set_var('DOWNLOAD_LINK', '/files/pdf/' . $Value['id'] . '.pdf');
$template->parse('e_download_result','download_block',false);
}
else
{
$template->set_var('e_download_result', '');
}
if(count($Words) > 0)
$template->parse('e_keywords_result','e_keywords_block', false);
else
$template->set_var('e_keywords_result','');
if(count($JWords) > 0)
$template->parse('e_jel_result','e_jel_block', false);
else
$template->set_var('e_jel_result','');
$template->parse('editorial_result','editorial_block', true);
$HasEditorial = true;
}
else
{
$template->set_var(Array(
'PADDING_TOP' => (floor(strlen($Value['titlu']) / 47) * 15 + 32) . 'px'
));
if($Words)
$template->parse('keywords_result','keywords_block', false);
else
$template->set_var('keywords_result','');
if($JWords)
$template->parse('jel_result','jel_block', false);
else
$template->set_var('jel_result','');
$template->parse('nr_revista_result','nr_revista_block', false);
if(is_file('files/pdf/' . $Value['id'] . '.pdf'))
{
$template->set_var('DOWNLOAD_LINK', '/files/pdf/' . $Value['id'] . '.pdf');
$template->parse('download_result','download_block',false);
}
else
{
$template->set_var('download_result', '');
}
$template->set_var('more_result','');
$template->parse('abstract_result','abstract_block', true);
$HasAbstract = true;
}
}
if(!$HasEditorial)
$template->set_var('editorial_result','');
if(!$HasAbstract)
$template->set_var('abstract_result','');
$template->pparse('page_output', 'header_handle');
$template->pparse('page_output', 'page_handle');
$template->pparse('page_output', 'footer_handle');
?>