Example #1
0
function _showTemplateTree()
{
    global $Logs;
    $aTemps = admin_getAllTemps();
    //$Logs->addLog($aTemps,"aPages");
    ?>
	<h3>Templates</h3>
	<table border="1">
		<thead>
		<tr>
			<td>Name</td>
			<td>Parent Template</td>
			<td>Time created / last modified</td>
			<td>Javascript files</td>
			<td>CSS files</td>
			<td>&nbsp;</td>
		</tr>
		</thead>
<?php 
    foreach ($aTemps as $temp) {
        if (!is_null($temp['parentid'])) {
            $parent = admin_getTempData($temp['parentid']);
            $parent_name = $parent['name'];
        } else {
            $parent_name = '---';
        }
        //var_dump($temp);
        ?>
		<tr>
			<th><?php 
        print $temp['name'];
        ?>
</th>
			<td><?php 
        print $parent_name;
        ?>
</td>
			<td>
				<?php 
        print getDateToPrintFromDb($temp['timecreated']);
        print "/<br />" . getDateToPrintFromDb($temp['timemodified']);
        ?>
			</td>
			<td><?php 
        print str_replace(',', '<br />', $temp['js']);
        ?>
</td>
			<td><?php 
        print str_replace(',', '<br />', $temp['css']);
        ?>
</td>
			<td>
				<a href="<?php 
        getUrl('admin');
        ?>
?action=edittemplate&id=<?php 
        print $temp['id'];
        ?>
">edit</a>
			</td>
		</tr>
<?php 
    }
    ?>
	</table>
<?php 
}
            if (!$DB->update('core_templates', $aVals, array('id', '=', $tempid))) {
                throw new cException("Some error during update operation!");
            }
            $aAlerts[] = "Template was updated.";
        } catch (cException $e) {
            $msg = $e->getDbMessageError(__METHOD__ . '(line:' . __LINE__ . ')', $query);
            $aErrors[] = $msg;
            cLogsDb::addFileLog($msg);
        }
    }
}
$allTemps = admin_getAllTemps();
//$Logs->addLog($allTemps, "allTemps");
//$allPages = admin_getAllPages();//add_getAllPages();
//$Logs->addLog($allPages, "allPages");
$aTempData = admin_getTempData($_GET['id']);
$Logs->addLog($aTempData, "data");
###########################################################################################
##################################### code to print #######################################
foreach ($aErrors as $error) {
    print "<div class='error'>{$error}</div>";
}
foreach ($aAlerts as $alert) {
    print "<div class='alert'>{$alert}</div>";
}
?>
<form action="" name="form_edit" method="post">
<input type="hidden" name="tempid" value="<?php 
print $_GET['id'];
?>
" />