<?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.14 $ |
+----------------------------------------------------------------------+*/
/**
* A really short and smart script to recompile all layouts of a given netautor db
* Call it with :
* db = Name or id of Netautor database
* copy = If given, old layouts will be saved to old_name.lay
*
* @author Stefan Rottensteiner
*/
require_once ('../../include/init.inc');
if(!$GLOBALS['USER']->check_feature('Admin') && !$GLOBALS['USER']->check_feature('ac_layout'))
{
$GLOBALS['USER']->login_call();
}
includeNaPro('mdb,array');
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>/digiconcept/netautor/layout recompiler</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
<meta name="robots" content="nofollow">
</head>
<link href="../../include/netautor.css" rel="stylesheet" type="text/css" media="screen">
<body>
<form method="post">
<table border="0" cellspacing="0" cellpadding="1" >
<tr>
<td class="text" >Select schema</td>
<td>
<select class="select319" name="db" onchange="submit()" >
<option value="">--- select ---</option>
<?php
$db_avail = mdb_list_dbs($sql_world);
foreach ($db_avail as $index => $db_def){
$opt_val = $db_def['mn_name'];
$opt_text = strtoupper($db_def['mn_name']).' ';
$opt_select = ($db_def['mn_name']== $db? 'selected':'');
echo("<option value='$opt_val' $opt_select>$opt_text</option>");
}
?>
</select>
</td>
</tr>
<tr>
<td class="text">Select template</td>
<td>
<select name="mlay_id" class="select319">
<option value="">--- all ---</option>
<?php
if(!empty($db))
{
$db_id = mdb_get_db_id($sql_world,$db);
$erg = $sql_world->select("select mlay_id,mlay_name from mlayouts where mlay_mn_naid = {$db_id} order by mlay_id",0,0,2);
foreach ($erg as $index => $werte)
{
$opt_select = ($werte['mlay_id']== $mlay_id ? 'selected':'');
echo("<option value='{$werte['mlay_id']}' {$opt_select}>{$werte['mlay_id']} - {$werte['mlay_name']}</option>");
}
}
?>
</select>
</td>
</tr>
<tr>
<td colspan="2" class="text" ><b>Options</b></td>
</tr>
<tr>
<td align="right" class="text">
copy old layouts
</td>
<td>
<input type="checkbox" name="copy" value="1" <?php if (!empty($copy)) echo('checked');?>>
</td>
</tr>
<tr>
<td colspan="2" align="center" >
<hr width="100%" size="1" color="#000000" noshade>
</td>
</tr>
<tr>
<td colspan="2" align="center" >
<input type="submit" name="recompile" value="Recompile selected templates" class="create">
</td>
</tr>
</table>
</form>
<?php
if(!empty($recompile))
{
if (function_exists('ob_end_flush')){ ob_end_flush();}
if (empty($GLOBALS['db'])){
$recompile_state = FALSE;
echo('<span class="textred">No database given</span>');
return;
}
error_reporting(65535);
if ($db_id <=0 ){
$recompile_state = FALSE;
echo('<span class="textred">Unknown database "'.$db.'" given</span>');
return;
}
$elements= mdb_list_elements($sql_world,$db_id);
if(!empty($mlay_id))
{
$ext_query = " and mlay_id = $mlay_id ";
}
@$layouts = $sql_world->select('SELECT mlay_name,mlay_id,mlay_definition FROM mlayouts WHERE mlay_mn_naid='.$db_id.$ext_query.' ORDER BY mlay_mn_naid ASC, mlay_id ASC',0,0,2);
if (!empty($sql_world->errnr) || empty($layouts))
{
$recompile_state = FALSE;
echo('<span class="textred">No layouts found for "'.$db.'" ('.$db_id.')</span>');
return;
}
else
{
echo('<span class="textgreen">'.count($layouts).' layouts found for "'.$db.'" ('.$db_id.')</span><br>');
}
$save_path = (empty($save_path)? $GLOBALS['DC_ENV']->layoutspath : $save_path);
include_once('../../include/functions/nal_compiler.fnc');
$layout_db = $db_id;
foreach ($layouts as $i => $layout)
{
set_time_limit(60);
$layout_def = array();
$message = array ('<br><span class="text"> '.date('d.m.Y H:i:s').' ['.($i+1).'] Recompiling layout <b>"'.$layout['mlay_name'].'" ('.$layout['mlay_id'].')</b></span>');
$layout_def['mlay_mn_naid'] = $db_id;
$layout_def['mlay_id'] = $layout['mlay_id'];
$layout_def['mlay_definition'] = $layout['mlay_definition'];
if (!empty($copy) && file_exists($save_path.$layout['mlay_id'].'.lay')) copy ($save_path.$layout['mlay_id'].'.lay',$save_path.'cp_'.$layout['mlay_id'].'.lay');
$analyse = array();
$success = nal_create_file($layout_def,$analyse,$elements,$save_path);
if (!$success){
switch ($success){
case NAL_NO_FUNCTIONS_DEF : $message[] = ' <span class="textred">No functions-definion found (phase 0)</span>'; break;
case NAL_PARSING_FAILED : $message[] = ' <span class="textred">Parsing failed (phase 1)</span>';break;
case NAL_COMPILING_FAILED : $message[] = ' <span class="textred">Compiling failed (phase 2)</span>'; break;
case NAL_FILE_ERROR : $message[] = ' <span class="textred">File-error (phase 3)</span>'; break;
default : $message[] = ' <span class="textred">Unknown error ('.$success.')</span>';break;
}
}
else
{
$message[] = ' <span class="textgreen">Layout sucessfully compiled and saved</span>';
}
$message = implode('<br>',$message);
echo($message);
flush();
}
}
?>
</body>
</html>