<?php
/* +----------------------------------------------------------------------+
| Netautor Professional Application Server |
+----------------------------------------------------------------------+
| Copyright (C) 1998-2005 digiconcept GmbH. <www.digiconcept.net> |
+----------------------------------------------------------------------+
| This file is subject to license, that is bundled with this package |
| in the file LICENSE.TXT, and is available at through the |
| world-wide-web at http://www.netautor.com/license/ |
| |
| If you did not receive a copy of the license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| hide@address.com so we can mail you a copy. |
+----------------------------------------------------------------------+
| Authors: Stefan Rottensteiner <hide@address.com> |
| Marek Kadziela <hide@address.com> |
| Gregor Wollner |
| Christian Unger |
| Helli Kleinhans |
+----------------------------------------------------------------------+
| @version $Revision: 1.33 $ |
+----------------------------------------------------------------------+*/
/**
* ????
*/
require_once('../../include/init.inc');
if(!$GLOBALS['USER']->check_feature('Admin') && !$GLOBALS['USER']->check_feature('ac_layout'))
{
$GLOBALS['USER']->login_call();
}
includeNaPro('queu,mlay,nal_compiler,string,array,mdb');
$GLOBALS['LOCALE']->textdomain('layout');
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>/digiconcept/netautor/layoutmanager/layout modification</title>
<meta http-equiv="pragma" content="no-cache" >
<meta http-equiv="cache-control" content="no-cache" >
<meta name ="robots" content="noindex" >
<link href="../../include/netautor.css" rel="stylesheet" type="text/css">
</head>
<script language="JavaScript">
/**
* Opens new window with Netautor docu
*/
function openDocu(functionName)
{
var windowWidth = 600;
var windowHeight= 600;
var new_window= window.open('../docu/docu_show.php?function_name='+escape(functionName),'NA_DOCU','resizable=yes,scrollbars=yes,locationbar=yes,menubar=yes,status=yes,dependent=yes,width='+windowWidth+',height='+windowHeight+',screenX=100,screenY=100');
if (new_window && new_window.focus) new_window.focus();
}
</script>
<body class="brown" bgproperties="FIXED">
<table width="780" border="0" cellspacing="0" cellpadding="4">
<form>
<tr>
<td width="180" align="left" valign="top" class="text">
<img src="../../grafik/pixel.gif" width="180" height="1"><br>
</td>
<td width="600" align="left" valign="top" class="text">
<?php
$map_language = array ( 'de' => array ('showlayout' => 'Zeige Layout '),
'en' => array ('showlayout' => 'Show layout'),
'pl' => array ('showlayout' => 'Pokaz layout'),
'fr' => array ('showlayout' => 'Montrez le layout')
);
$result = false; /* Result of a ToDo */
$mlay_name = trim($mlay_name);
if(!empty($todo))
{
if (empty($mlay_mn_naid))
{
$GLOBALS['DC_ENV']->message[] = $GLOBALS['LOCALE']->gettext('msg_invalid_mlay_id');
$todo='';
}
elseif (empty($mlay_name))
{
$GLOBALS['DC_ENV']->message[] = $GLOBALS['LOCALE']->gettext('msg_invalid_layoutname');
$todo='';
}
}
else
{
$todo='';
}
if (empty($mlay_remark)) $mlay_remark=$mlay_name;
if (!empty($todo)) {
/* Prepare data array if check's okay*/
$invalues['mlay_name'] = $mlay_name; // Name
$invalues['mlay_remark'] = $mlay_remark; // Bemerkungen
$invalues['mlay_definition']= $mlay_definition; // Der eigentliche Inhalt
$invalues['mlay_mn_naid'] = $mlay_mn_naid; // NA-Database ID
$invalues['mlay_typ'] = 'FUNCTION'; // Funktionlayout
$invalues['mlay_default'] = (empty($mlay_default)?0:1);
}
/* create a new layout object */
$lay = new layout($sql_world);
$QUEU = queu_getDefaultQueu(); /* Create one netautor wide QUEU-object, similiar to $sql_world */
$lay->setQueu($QUEU);
/* Set a default saveToPath */
$lay->setSaveTo($GLOBALS['DC_ENV']->layoutspath.$mlay_id.'.lay');
if($path = $USER->get_feature_value('layout_source_path'))
{
$lay->setSourcePath($path);
}
//------------------------------------------------------------------ CREATE
if($todo=='create')
{
$lay->setFromArray($invalues);
$result = $lay->create();
if ($result){
/* If saved withour error */
$lay->setSaveTo($GLOBALS['DC_ENV']->layoutspath.$result.'.lay');
$compile_success = $lay->compileIntoFile('',7);
$GLOBALS['DC_ENV']->message[] = $GLOBALS['LOCALE']->gettext('layout_saved');
$GLOBALS['DC_ENV']->errnr = '130';
$mlay_id = $result;
}
else {
/* Not saved without errors */
$GLOBALS['DC_ENV']->message[] = $sql_world->errstr;
}
}
//------------------------------------------------------------------ SPECIAL CREATE
if($todo=='specialcreate')
{
$mlay_id = '';
$invalues['mlay_id'] = $mlay_id2;
$lay->setFromArray($invalues);
$result = $lay->create(null,true);
if ($result){
/* If saved withour error */
$lay->setSaveTo($GLOBALS['DC_ENV']->layoutspath.$result.'.lay');
$compile_success = $lay->compileIntoFile('',7);
$GLOBALS['DC_ENV']->message[] = $GLOBALS['LOCALE']->gettext('layout_saved');
$mlay_id = $result;
}
else {
/* Not saved without errors */
$GLOBALS['DC_ENV']->message[] = $sql_world->errstr;
}
}
/* If CREATE or SPECIAL CREATE were successull*/
if ($result){
?>
<script language="JavaScript">
<!--
if(window.opener)
{
window.opener.document.location.href = './layoutmgr.php?mlay_id=<?php echo $result;?>&resize=no';
}
else
{
parent.frames['layoutmain'].document.location.href = './layoutmgr.php?mlay_id=<?php echo $result;?>&resize=no';
}
//-->
</script>
<?php
}
//------------------------------------------------------------------ UPDATE
if($todo=='update')
{
// versions
if(!empty($DC_ENV->vers_control_count))
{
includeNaPro('log');
$event_content = $sql_world->select('SELECT mlay_definition FROM mlayouts WHERE mlay_id='.$mlay_id,0,1,2);
$event_content = (!empty($event_content[0]['mlay_definition']) ? addslashes($event_content[0]['mlay_definition']) : '');
$log_params = array(
'event_id' => $mlay_id,
'event_type' => 'layout',
'event_action' => 'update',
'event_content' => $event_content,
'event_user_id' => '100',
'event_ses_id' => ''
);
write_event_log($log_params,$DC_ENV,$sql_world);
}
$lay->read($mlay_id);
$lay->setFromArray($invalues);
$result = $lay->update();
if ($result){
/* If saved without error */
$compile_success = $lay->compileIntoFile('',7);
$GLOBALS['DC_ENV']->message[] = $GLOBALS['LOCALE']->gettext('layout_renew'); //"Das Layout wurde erneuert !";
includeNaPro('npf_cache',false,'npf_lib');
$cache_params = array( 'mode' => ( empty($GLOBALS['DC_ENV']->cache_server_mode) ? 'instant' : 'queu' ) ,
'mlay_id.value' => $mlay_id
);
npf_cache_delete($cache_params,$values,$elements,$npf_runtime,$GLOBALS['DC_ENV'],$sql_world);
}
else {
/* Not saved without errors */
$GLOBALS['DC_ENV']->message[] = $sql_world->errstr;
}
}
//------------------------------------------------------------------ DELETE
if($todo == 'delete')
{
// versions
if(!empty($DC_ENV->vers_control_count))
{
includeNaPro('log');
$event_content = $sql_world->select('SELECT mlay_definition FROM mlayouts WHERE mlay_id='.$mlay_id,0,1,2);
$event_content = (!empty($event_content[0]['mlay_definition']) ? addslashes($event_content[0]['mlay_definition']) : '');
$log_params = array(
'event_id' => $mlay_id,
'event_type' => 'layout',
'event_action' => 'delete',
'event_content' => $event_content,
'event_user_id' => '100',
'event_ses_id' => ''
);
write_event_log($log_params,$DC_ENV,$sql_world);
}
$result = $lay->delete($mlay_id);
if($result) {
$GLOBALS['DC_ENV']->message[] = $GLOBALS['LOCALE']->gettext('layout_deleted'); //"Das Layout wurde gelöscht !";
includeNaPro('npf_cache',false,'npf_lib');
$cache_params = array( 'mode' => ( empty($GLOBALS['DC_ENV']->cache_server_mode) ? 'instant' : 'queu' ) ,
'mlay_id.value' => $mlay_id
);
npf_cache_delete($cache_params,$values,$elements,$npf_runtime,$GLOBALS['DC_ENV'],$sql_world);
}
else {
$GLOBALS['DC_ENV']->message[] = $sql_world->errstr.$sql_world->statement;
}
}
//------------------------------------------------------------------ SEND MAIL
if($todo=='sendmail')
{
$mail_text = "------------- START META INFO --------------------\n";
$mail_text.= "mlay_id = {$mlay_id}\n";
$mail_text.= "mlay_name = {$mlay_name}\n";
$mail_text.= "mlay_remark = {$mlay_remark}\n";
$mail_text.= "mlay_mn_naid = {$mlay_mn_naid}\n";
$mail_text.= "mlay_default = {$mlay_default}\n";
$mail_text.= "------------- END META INFO ----------------------\n";
$mail_text.= $mlay_definition;
$mail_text.= "\n------------- END OF LAYOUT ----------------------\n";
$result = mail($mlay_email,'NAPRO LAYOUT MAIL',$mail_text);
$GLOBALS['DC_ENV']->message[] = ($result ? "Layout send to $mlay_email" : "Layout not send !" );
}
echo ('<center><span class="head">'.show_message($GLOBALS['DC_ENV']->message).'</span></center><br>');
?>
<center><input type="button" value="Close Window" class="clear" onClick="javascript:top.main.document.getElementById('f_editor').rows='*,0,24,24,24';top.scrollFrames('layoutsearch,layoutdb');"><br></center>
<br>
<?php
if (!empty($lay->analysis['ERROR']) || !empty($lay->analysis['WARNING']))
{
$analyse_options = array ('error_mask' => 65535);
echo(analyse_report($lay->analysis,$analyse_options));
}
else
{
echo(analyse_report($lay->analysis));
}
if(count($lay->analysis['ERROR']) > 1 || count($lay->analysis['WARNING']) > 1)
{
?>
<br>
<center><input type="button" value="Close Window" class="clear" onClick="javascript:top.main.document.getElementById('f_editor').rows='*,0,24,24,24';top.scrollFrames('layoutsearch,layoutdb');"><br></center>
<br>
<?php
}
/**
* Simple function to prepare a string with gathered messages
*/
function show_message($messages,$pre='',$post=''){
if (empty($messages)) return '';
$result = '';
$messages = array_unique($messages);
foreach ($messages as $i => $d) {
$result.=$pre.$d.$post.'<br>';
}
return $result;
}
/**
* Prepare a html-analyse report based on given data
*
*/
function analyse_report(&$analyse,$options='')
{
$error_mask = (empty($options['error_mask'])?PARSER_ERROR_ALL:intval($options['error_mask']));
$text='';
/* Statistik-Infos*/
$text.= '<center>'.($GLOBALS['LOCALE']->gettext('functions_used',array(count($analyse['USED_FUNCTIONS'])))).'<br><br></center>';
//$text.='<center><input type="button" value="Close Window" class="clear" onClick="javascript:top.main.document.getElementById(\'f_editor\').rows=\'*,0,24,24,24\';"><br></center>';
if (empty($analyse['ERROR']) && empty($analyse['WARNING'])) return $text;
$text.='<img src="../../grafik/pixel.gif" width="1" height="7"><br>
<img src="../../grafik/spacer_grey.gif" width="592" height="15"><br>
<img src="../../grafik/pixel.gif" width="1" height="5"><br>
';
/* Show errors if given */
$line_index= 0;
if (!empty($analyse['ERROR']))
foreach ($analyse['ERROR'] as $error_index => $error_def )
{
$err_nr = $error_def['ERROR_CODE'];
if (!($error_mask & $err_nr)) continue;
$line_index ++; /* Should be line number some day ..*/
$error_message = ''; /* Specific error message */
$show_docu_link = false; /* Show function name as link into the docu or not */
switch ($err_nr){
case PARSER_ERROR_UNKNOWN: $error_head = $GLOBALS['LOCALE']->gettext('unknown_tag');
break;
case PARSER_ERROR_UNCLOSED: $error_head = $GLOBALS['LOCALE']->gettext('tag_unclosed');
break;
case PARSER_ERROR_UNOPENED: $error_head = $GLOBALS['LOCALE']->gettext('no_open_tag');
break;
case PARSER_ERROR_FUNC_DEP: $error_head = $GLOBALS['LOCALE']->gettext('function_unknown');
break;
case PARSER_ERROR_PARAM_DEP: $error_head = $GLOBALS['LOCALE']->gettext('old_param');
$error_message = implode (',',$error_def['ERROR_OPTIONS']['BAD_PARAM']);
$show_docu_link = true;
break;
case PARSER_ERROR_UNKNOWN_PARAM: $error_head = $GLOBALS['LOCALE']->gettext('param_unknown');
$error_message = implode (',',$error_def['ERROR_OPTIONS']['BAD_PARAM']);
$show_docu_link = true;
break;
case PARSER_ERROR_MISSING_EXPLIZIT: $error_head =$GLOBALS['LOCALE']->gettext('param_not_found');
$error_message = implode (',',$error_def['ERROR_OPTIONS']['BAD_PARAM']);
$show_docu_link = true;
break;
}
$func_name = $error_def['TAG']['NAME'];
$func_name = ($show_docu_link? '<a class="link" href="javascript:openDocu(\''.$func_name.'\');" >'.$func_name.'</a>': $func_name);
$text.= '<span class="textred">'.$error_head.'</span><br>';
$text.= $line_index.'. '.$func_name.'<br>';
if (!empty($error_message)) $text.= $error_message.'<br>';
$text.='<br>';
}
$line_index= 0;
/* Show warnings if given*/
if (!empty($analyse['WARNING']))
{
foreach ($analyse['WARNING'] as $error_index => $error_def )
{
$err_nr = $error_def['ERROR_CODE'];
if (!($error_mask & $err_nr)) continue;
$error_message = '';
$show_docu_link = false;
switch ($err_nr){
case PARSER_ERROR_UNKNOWN:
$error_head =$GLOBALS['LOCALE']->gettext('unknown_tag');
break;
case PARSER_ERROR_PARAM_DEP:
$error_head =$GLOBALS['LOCALE']->gettext('old_param');
$error_message = implode (',',$error_def['ERROR_OPTIONS']['BAD_PARAM']);
$show_docu_link = true;
break;
case PARSER_ERROR_MISSING_EXPLIZIT:
$error_head =$GLOBALS['LOCALE']->gettext('param_not_found');
$error_message = implode (',',$error_def['ERROR_OPTIONS']['BAD_PARAM']);
$show_docu_link = true;
break;
case PARSER_ERROR_FIELD_PARAM_DEP:
$error_head =$GLOBALS['LOCALE']->gettext('old_param_db');
$error_message = implode (',',$error_def['ERROR_OPTIONS']['BAD_PARAM']);
$show_docu_link = false;
break;
/*case PARSER_ERROR_UNKNOWN_PARAM: $error_head =$GLOBALS['LOCALE']->gettext('param_unknown');
$error_message = implode (',',$error_def['ERROR_OPTIONS']['BAD_PARAM']);
$show_docu_link = true;
break;*/
}
if(empty($error_message)) continue;
$line_index ++;
$func_name = $error_def['TAG']['NAME'];
$func_name = ($show_docu_link? '<a class="link" href="javascript:openDocu(\''.$func_name.'\');" >'.$func_name.'</a>': $func_name);
$text.="<b>{$error_head}</b><br>";
$text.= $line_index.'. '.$func_name.'<br>';
$text.= $error_message.'<br><br>';
}
}
return $text;
}
?>
<img src="../../grafik/pixel.gif" width="592" height="1"><br>
</td>
</tr>
</table>
<br>
</form>
<!-- <?php echo time(); ?> -->
<?php if(!empty($todo)) echo("<script>top.main.document.getElementById('f_editor').rows='*,250,24,24,24';</script>"); ?>
</body>
</html>