Revision: 2011 Author: olavmrk Date: Mon Nov 30 01:25:58 2009 Log: cron: Translations & web display of output.
Patch by [email protected]. http://code.google.com/p/simplesamlphp/source/detail?r=2011 Added: /trunk/modules/cron/dictionaries/cron.php /trunk/modules/cron/templates/croninfo-result.php Modified: /trunk/modules/cron/templates/croninfo-tpl.php /trunk/modules/cron/www/cron.php /trunk/modules/cron/www/croninfo.php ======================================= --- /dev/null +++ /trunk/modules/cron/dictionaries/cron.php Mon Nov 30 01:25:58 2009 @@ -0,0 +1,56 @@ +<?php + +$lang = array( + + 'cron_header' => array ( + 'da' => 'Cron resultat side', + 'en' => 'Cron result page', + 'es' => 'Página de resultado del cron', + ), + + 'cron_result_title' => array ( + 'da' => 'Her er resultatet for opgaven udførelse:', + 'en' => 'Here are the result for the cron job execution:', + 'es' => 'Aqui están los resultados de las tareas en la ejecución del cron:', + ), + + 'cron_info' => array ( + 'da' => 'Cron er en måde at køre tingene regelmæssigt på UNIX-systemer.', + 'en' => 'Cron is a way to run things regularly on unix systems.', + 'es' => 'Cron es una forma de ejecutar tareas periodicas en los sistemas UNIX.', + ), + + 'cron_suggestion' => array ( + 'da' => 'Her er et forslag til en crontab fil:', + 'en' => 'Here is a suggestion for a crontab file:', + 'es' => 'He aquí una sugerencia de un archivo crontab:', + ), + + 'cron_execution' => array ( + 'da' => 'Klik her for at køre cron job:', + 'en' => 'Click here to run the cron jobs:', + 'es' => 'Haga clic aquí para ejecutar las tareas de cron:', + ), + + 'run_text' => array ( + 'da' => 'Run cron:', + 'en' => 'Run cron:', + 'es' => 'Ejecutar cron:', + ), + + 'ran_text' => array ( + 'da' => 'Cron løb på', + 'en' => 'Cron ran at', + 'es' => 'Cron ejecutado el', + ), + + 'cron_report_title' => array ( + 'da' => 'Cron rapport', + 'en' => 'Cron report', + 'es' => 'Informe del cron', + ), + +); + + +?> ======================================= --- /dev/null +++ /trunk/modules/cron/templates/croninfo-result.php Mon Nov 30 01:25:58 2009 @@ -0,0 +1,20 @@ +<?php + +$this->data['header'] = $this->t('cron_header'); +$this->includeAtTemplateBase('includes/header.php'); +?> + <p><?php echo $this->t('cron_result_title') ?></p> + <pre style="color: #444; padding: 1em; border: 1px solid #eee; margin: .4em "><code> + <?php + echo '<h1>' .$this->t('cron_report_title'). '</h1><p>' .$this->t('ran_text'). ' ' .$this->data['time'] . '</p>' . + '<p>URL: <tt>' . $this->data['url'] . '</tt></p>' . + '<p>Tag: ' . $this->data['tag'] . "</p>\n\n" . + '<ul><li>' . join('</li><li>', $this->data['summary']) . '</li></ul>'; + ?> + </code> + </pre> +</div> + +<?php +$this->includeAtTemplateBase('includes/footer.php'); +?> ======================================= --- /trunk/modules/cron/templates/croninfo-tpl.php Wed Apr 22 01:02:14 2009 +++ /trunk/modules/cron/templates/croninfo-tpl.php Mon Nov 30 01:25:58 2009 @@ -1,36 +1,36 @@ <?php -$this->data['header'] = 'Cron information page'; +$this->data['header'] = $this->t('cron_header'); $this->includeAtTemplateBase('includes/header.php'); +$run_text = $this->t('run_text'); ?> - <p>Cron is a way to run things regularly on unix systems.</p> - - <p>Here is a suggestion for a crontab file:</p> + <p><?php echo $this->t('cron_info') ?></p> + + <p><?php echo $this->t('cron_suggestion') ?></p> <pre style="font-size: x-small; color: #444; padding: 1em; border: 1px solid #eee; margin: .4em "><code><?php foreach ($this->data['urls'] AS $url ) { - echo "# " . $url['title'] . "\n"; + echo "# " . $run_text. ' [' .$url['tag']. ']' . "\n"; echo "" . $url['int'] . " curl --silent \"" . $url['href'] . "\" > /dev/null 2>&1\n"; } ?> </code></pre> - - <p>Click here to run the cron jobs: + + <br><p><?php echo $this->t('cron_execution') ?></p> <ul> <?php - + foreach ($this->data['urls'] AS $url ) { - echo '<li><a href="' . $url['href'] . '">' . $url['title'] . '</a></li>'; - } - + echo '<li><a href="' . $url['href'] . '&output=xhtml">' . $run_text. ' [' .$url['tag']. ']' . '</a></li>'; + } + ?> </ul> - </div> <?php ======================================= --- /trunk/modules/cron/www/cron.php Fri Aug 14 04:07:44 2009 +++ /trunk/modules/cron/www/cron.php Mon Nov 30 01:25:58 2009 @@ -9,15 +9,12 @@ exit; } } -#print_r($_REQUEST['tag']) ; exit; - if (!is_null($cronconfig->getValue('allowed_tags'))) { if (!in_array($_REQUEST['tag'], $cronconfig->getValue('allowed_tags'))) { SimpleSAML_Logger::error('Cron - Illegal tag [' . $_REQUEST['tag'] . '].'); exit; } } - $summary = array(); @@ -25,6 +22,9 @@ 'summary' => &$summary, 'tag' => $_REQUEST['tag'], ); +$url = SimpleSAML_Utilities::selfURL(); +$time = date(DATE_RFC822); + SimpleSAML_Module::callHooks('cron', $croninfo); foreach ($summary AS $s) { @@ -33,14 +33,13 @@ if ($cronconfig->getValue('sendemail', TRUE) && count($summary) > 0) { - $statustext = '<ul><li>' . join('</li><li>', $summary) . '</li></ul>'; - - $message = '<h1>Cron report</h1><p>Cron ran at ' . date(DATE_RFC822) . '</p>' . - '<p>URL: <tt>' . SimpleSAML_Utilities::selfURL() . '</tt></p>' . - '<p>Tag: ' . $_REQUEST['tag'] . "</p>\n\n" . $statustext; + $message = '<h1>Cron report</h1><p>Cron ran at ' . $time . '</p>' . + '<p>URL: <tt>' . $url . '</tt></p>' . + '<p>Tag: ' . $croninfo['tag'] . "</p>\n\n" . + '<ul><li>' . join('</li><li>', $summary) . '</li></ul>'; $toaddress = $config->getString('technicalcontact_email', '[email protected]'); - if($toaddress == '[email protected]') { + if($toaddress == '[email protected]') { SimpleSAML_Logger::error('Cron - Could not send email. [technicalcontact_email] not set in config.'); } else { $email = new SimpleSAML_XHTML_EMail($toaddress, 'simpleSAMLphp cron report', '[email protected]'); @@ -50,8 +49,13 @@ } -#$t = new SimpleSAML_XHTML_Template($config, 'modinfo:modlist.php'); -#$t->data['modules'] = $modinfo; -#$t->show(); +if (isset($_REQUEST['output']) && $_REQUEST['output'] == "xhtml") { + $t = new SimpleSAML_XHTML_Template($config, 'cron:croninfo-result.php','cron:cron'); + $t->data['tag'] = $croninfo['tag']; + $t->data['time'] = $time; + $t->data['url'] = $url; + $t->data['summary'] = $summary; + $t->show(); +} ?> ======================================= --- /trunk/modules/cron/www/croninfo.php Tue Apr 21 00:42:38 2009 +++ /trunk/modules/cron/www/croninfo.php Mon Nov 30 01:25:58 2009 @@ -29,14 +29,14 @@ foreach ($tags AS $tag) { $urls[] = array( 'href' => SimpleSAML_Module::getModuleURL('cron/cron.php?key=' . $key . '&tag=' . $tag), - 'title' => 'Run cron [' . $tag . ']', + 'tag' => $tag, 'int' => (array_key_exists($tag, $def) ? $def[$tag] : $def['default']), ); } -$t = new SimpleSAML_XHTML_Template($config, 'cron:croninfo-tpl.php'); +$t = new SimpleSAML_XHTML_Template($config, 'cron:croninfo-tpl.php', 'cron:cron'); $t->data['urls'] = $urls; $t->show(); -- You received this message because you are subscribed to the Google Groups "simpleSAMLphp commits" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/simplesamlphp-commits?hl=en.
