source: branches/1.2/content/plugins/cron/cron_settings.php @ 1315

Revision 1315, 4.8 KB checked in by shibuya246, 3 years ago (diff)

[branch] first version of auto cron job for hotaru (ported from wp)

Line 
1<?php
2/**
3 * File: plugins/cron/cron_settings.php
4 * Purpose: The functions for cron.
5 *
6 * LICENSE: Hotaru CMS is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, either version 3 of
9 * the License, or (at your option) any later version.
10 *
11 * Hotaru CMS is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with Hotaru CMS. If not, see http://www.gnu.org/licenses/.
17 *
18 * @category  Content Management System
19 * @package   HotaruCMS
20 * @author    shibuya246 <blog@shibuya246.com>
21 * @copyright Copyright (c) 2010
22 * @license   http://www.gnu.org/copyleft/gpl.html GNU General Public License
23 * @link      http://shibuya246.com
24 */
25class CronSettings extends Cron
26{
27        public function settings($h)
28        {
29            //Get the settings from the database and put them in an array
30            $cron_settings = $h->getSetting('cron_settings');
31            //$cron_settings = unserialize($sitemap_settings);
32            //$cron = $this->_get_cron_array($h);
33
34            $cron = $this->_get_cron_array($h);
35
36            $schedules = $this->cron_get_schedules($h);
37            $date_format =  'M j, Y @ G:i';
38            if ($cron) {
39               foreach ( $cron as $timestamp => $cronhooks ) {
40                    foreach ( (array) $cronhooks as $hook => $events ) {
41                        foreach ( (array) $events as $key => $event ) {                           
42                            if (!is_int($hook)) {
43                                $cron[ $timestamp ][ $hook ][ $key ][ 'date' ] = date( $date_format, (int) $timestamp );
44                            }
45                        }
46                    }
47                }
48            }
49
50//            echo "<pre>";
51//            print_r($cron);
52//            echo "</pre>";
53            $schedules = $this->cron_get_schedules($h);
54            $date_format =  'M j, Y @ G:i';
55            ?>
56
57            <div class="wrap" id="cron-gui">
58                <div id="icon-tools" class="icon32"><br /></div>
59                <h2>What's in Cron?</h2>
60
61                <h3>Available schedules</h3>
62                <ul>
63                    <?php foreach( $schedules as $schedule ) { ?>
64                            <li><strong><?php echo $schedule[ 'display' ]; ?></strong></li>
65                    <?php } ?>
66                </ul>
67
68                <h3>Events</h3>
69                <table class="widefat fixed">
70                    <thead>
71                        <tr>
72                            <th scope="col">Next due (GMT/UTC)</th>
73                            <th scope="col">Schedule</th>
74                            <th scope="col">Hook</th>
75                            <th scope="col">Arguments</th>
76                        </tr>
77                    </thead>
78                    <tbody>
79                        <?php
80                        if ($cron) {
81                            foreach ( $cron as $timestamp => $cronhooks ) {
82                                foreach ( (array) $cronhooks as $hook => $events ) {
83                                    foreach ( (array) $events as $event ) { ?>
84                                    <tr>
85                                        <th scope="row"><?php echo $event[ 'date' ]; ?> (<?php echo $timestamp; ?>)</th>
86                                        <td>
87                                            <?php
88                                                if ( $event[ 'schedule' ] ) {
89                                                    echo $schedules [ $event[ 'schedule' ] ][ 'display' ];
90                                                } else {
91                                                    ?><em>One-off event</em><?php
92                                                }
93                                            ?>
94                                        </td>
95                                        <td><?php echo $hook; ?></td>
96                                        <td><?php if ( count( $event[ 'args' ] ) ) { ?>
97                                            <ul>
98                                                <?php foreach( $event[ 'args' ] as $key => $value ) { ?>
99                                                    <strong>[<?php echo $key; ?>]:</strong> <?php echo $value; ?>
100                                                <?php } ?>
101                                            </ul>
102                                        <?php } ?></td>
103                                    </tr>
104                                <?php }
105                                }
106                            }
107                        } ?>
108                    </tbody>
109                </table>
110            </div>
111    <?php
112    }
113     
114}
115?>
116
117
118
Note: See TracBrowser for help on using the repository browser.