Permalink
Browse files

new menu to delete logs

  • Loading branch information...
nlescure committed Jul 28, 2011
1 parent dbaa5c9 commit 0883a0f13ce29b298763d449b9294d43000ff1a0
@@ -107,7 +107,21 @@ public function setErrorFile($file) {
$this->errorFile = $file;
}
-
+ /**
+ * Clear the output file
+ */
+ public function cleanOutputFile() {
+ file_put_contents($this->outputFile, '');
+ }
+
+ /**
+ * Clear the error file
+ */
+ public function cleanErrorFile() {
+ file_put_contents($this->errorFile, '');
+ }
+
+
private $executable;
private $root;
private $scripts = array();
@@ -34,6 +34,14 @@
border:1px solid grey;
}
+.cronjobs-list label {
+ display:inline;
+}
+
+.cronjobs-list .button {
+ margin-top:15px;
+}
+
.cronjobs-list .clear {
clear:both;
}
@@ -46,3 +54,8 @@
width:50%;
float:right;
}
+
+.cronjobs-list .message-feedback ul {
+ padding-bottom:0px;
+ color:#3e8d29;
+}
@@ -9,5 +9,6 @@
<ul>
<li><div><a href={'/cronjobs/list/'|ezurl}>{'Cronjobs list'|i18n( 'extension/nlcronjobs' )}</a></div></li>
<li><div><a href={'/cronjobs/logs/'|ezurl}>{'Cronjobs logs'|i18n( 'extension/nlcronjobs' )}</a></div></li>
+ <li><div><a href={'/cronjobs/clear/'|ezurl}>{'Clear logs'|i18n( 'extension/nlcronjobs' )}</a></div></li>
</ul>
{* DESIGN: Content END *}</div></div></div></div></div></div>
@@ -0,0 +1,37 @@
+<div class="cronjobs-list">
+ <div class="context-block">
+ <div class="box-header"><div class="box-tc"><div class="box-ml"><div class="box-mr"><div class="box-tl"><div class="box-tr">
+ <h1 class="context-title">{'Clear logs'|i18n( 'extension/nlcronjobs' )}</h1>
+ <div class="header-mainline"></div>
+ </div></div></div></div></div></div>
+ </div>
+
+ <div class="context-block">
+
+ {if $outputs|count|gt(0)}
+ <div class="message-feedback">
+ <ul>
+ {foreach $outputs as $output}
+ <li>{$output}</li>
+ {/foreach}
+ </ul>
+ </div>
+ {/if}
+
+ <div class="box-ml"><div class="box-mr"><div class="box-content">
+ <form action={'/cronjobs/clear'|ezurl} method="post">
+ <div>
+ <input type="checkbox" value="1" name="log_output" id="log_output" />
+ <label for="log_output">Clear output file</label>
+ </div>
+ <div>
+ <input type="checkbox" value="1" name="log_error" id="log_error" />
+ <label for="log_error">Clear error file</label>
+ <div>
+ <input type="submit" value="{'Clear'|i18n( 'extension/nlcronjobs' )}" class="button" />
+ </form>
+ <div class="clear"></div>
+ </div></div></div>
+
+ </div>
+</div>
@@ -1,3 +1,4 @@
+{* scroll to bottom and reload page *}
{literal}
<script type="text/javascript">
if( !(typeof(jQuery) == 'undefined' || jQuery === null) ) {
@@ -13,14 +14,16 @@
</script>
{/literal}
+<a name="top"></a>
+
+{* menu *}
<a href="#end_output">Last output</a> -
<a href="#end_error">Last errors</a> -
-<a href="#" onclick="location.reload()">Reload</a>
-
+<a href="#end_output" onclick="location.reload()">Reload</a>
+<hr />
+
<div id="contents">
- <a name="top"></a>
<div class="output">Output: <br>
- <hr />
{$output|nl2br}
<a name="end_output"></a>
<br/>
@@ -33,5 +36,10 @@
{$errors|nl2br}
<a name="end_error"></a>
</div>
- <a href="#top">Top</a>
+
+ <hr />
+ <a href="#end_output">Last output</a> -
+ <a href="#top">Top</a> -
+ <a href="#end_output" onclick="location.reload()">Reload</a>
+
</div>
@@ -0,0 +1,34 @@
+<?php
+/**
+ * Clear logs
+ */
+
+$Module = $Params['Module'];
+
+$tpl = eZTemplate::factory();
+$tpl->setVariable( 'module', $Module );
+
+$http = eZHTTPTool::instance();
+$manager = ProcessManager::instance();
+$outputs = array();
+
+if( $http->hasVariable('log_output') ) {
+ $manager->cleanOutputFile();
+ $outputs[] = 'Output file cleared.';
+}
+if( $http->hasVariable('log_error') ) {
+ $manager->cleanErrorFile();
+ $outputs[] = 'Error file cleared.';
+}
+
+$tpl->setVariable( 'outputs', $outputs );
+
+$Result = array();
+$Result['content'] = $tpl->fetch( 'design:cronjobs/clear.tpl' );
+$Result['left_menu'] = "design:cronjobs/backoffice_left_menu.tpl";
+$Result['path'] = array( array( 'url' => '/cronjobs/clear/',
+ 'text' => ezpI18n::tr( 'ezcronjobs', 'Cronjobs' ) ),
+ array( 'url' => false,
+ 'text' => 'clear' ) );
+
+?>
@@ -1,6 +1,6 @@
<?php
/**
- *
+ * Display logs
*/
$Module = $Params['Module'];
@@ -1,10 +1,6 @@
<?php
/**
* File containing the module definition.
- *
- * @copyright Copyright (C) 1999-2011 eZ Systems AS. All rights reserved.
- * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
- *
*/
$Module = array( 'name' => 'NL Cronjobs' );
@@ -14,15 +10,21 @@
$ViewList['list'] = array(
'script' => 'list.php',
'default_navigation_part' => 'nlcronjobnavigationpart'
- );
+);
$ViewList['launch'] = array(
'script' => 'launch.php',
'default_navigation_part' => 'nlcronjobnavigationpart'
- );
+);
$ViewList['logs'] = array(
'script' => 'logs.php',
'default_navigation_part' => 'nlcronjobnavigationpart'
- );
+);
+
+$ViewList['clear'] = array(
+ 'script' => 'clear.php',
+ 'default_navigation_part' => 'nlcronjobnavigationpart'
+);
+
?>

0 comments on commit 0883a0f

Please sign in to comment.